Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F631969
FileDiffSliderWidget.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
FileDiffSliderWidget.cpp
View Options
#include
"FileDiffSliderWidget.h"
#include
<QPainter>
#include
<QMouseEvent>
FileDiffSliderWidget
::
FileDiffSliderWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
}
void
FileDiffSliderWidget
::
updatePixmap
()
{
left_pixmap
=
fdw
->
makePixmap
(
FileDiffWidget
::
Side
::
Left
,
8
,
height
());
right_pixmap
=
fdw
->
makePixmap
(
FileDiffWidget
::
Side
::
Right
,
8
,
height
());
}
void
FileDiffSliderWidget
::
paintEvent
(
QPaintEvent
*
)
{
if
(
!
visible
)
return
;
if
(
scroll_total
<
1
)
return
;
if
(
left_pixmap
.
isNull
()
||
right_pixmap
.
isNull
())
{
updatePixmap
();
}
int
w
;
w
=
left_pixmap
.
width
();
QPainter
pr
(
this
);
pr
.
fillRect
(
w
,
0
,
4
,
height
(),
QColor
(
240
,
240
,
240
));
pr
.
drawPixmap
(
0
,
0
,
left_pixmap
);
pr
.
drawPixmap
(
w
+
4
,
0
,
right_pixmap
);
int
y
=
scroll_value
*
height
()
/
scroll_total
;
int
h
=
(
scroll_value
+
scroll_visible_size
)
*
height
()
/
scroll_total
;
h
-=
y
;
if
(
h
<
1
)
h
=
1
;
pr
.
fillRect
(
w
+
1
,
y
,
2
,
h
,
Qt
::
black
);
}
void
FileDiffSliderWidget
::
resizeEvent
(
QResizeEvent
*
)
{
clear
(
visible
);
}
void
FileDiffSliderWidget
::
scroll
(
int
pos
)
{
int
v
=
pos
;
v
=
v
*
scroll_total
/
height
()
-
scroll_visible_size
/
2
;
if
(
v
<
0
)
v
=
0
;
emit
valueChanged
(
v
);
}
void
FileDiffSliderWidget
::
mousePressEvent
(
QMouseEvent
*
e
)
{
if
(
visible
&&
e
->
button
()
==
Qt
::
LeftButton
)
{
scroll
(
e
->
pos
().
y
());
}
}
void
FileDiffSliderWidget
::
mouseMoveEvent
(
QMouseEvent
*
e
)
{
if
(
visible
&&
(
e
->
buttons
()
&
Qt
::
LeftButton
))
{
scroll
(
e
->
pos
().
y
());
}
}
void
FileDiffSliderWidget
::
clear
(
bool
v
)
{
left_pixmap
=
QPixmap
();
right_pixmap
=
QPixmap
();
visible
=
v
;
update
();
}
void
FileDiffSliderWidget
::
setScrollPos
(
int
total
,
int
value
,
int
size
)
{
scroll_total
=
total
;
scroll_value
=
value
;
scroll_visible_size
=
size
;
visible
=
(
scroll_total
>
0
)
&&
(
scroll_visible_size
>
0
);
update
();
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Nov 15, 1:14 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
148823
Default Alt Text
FileDiffSliderWidget.cpp (1 KB)
Attached To
Mode
R77 Guitar
Attached
Detach File
Event Timeline