Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Okular
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joao Oliveira
Okular
Commits
3430081a
Commit
3430081a
authored
Jul 17, 2019
by
Albert Astals Cid
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/Applications/19.08'
parents
c510540c
8e1d9aa4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
40 deletions
+64
-40
ui/pageview.cpp
ui/pageview.cpp
+64
-40
No files found.
ui/pageview.cpp
View file @
3430081a
...
...
@@ -3500,55 +3500,24 @@ void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
else
backColor
=
viewport
()
->
palette
().
color
(
QPalette
::
Dark
);
// when checking if an Item is contained in contentsRect, instead of
// growing PageViewItems rects (for keeping outline into account), we
// grow the contentsRect
QRect
checkRect
=
contentsRect
;
checkRect
.
adjust
(
-
3
,
-
3
,
1
,
1
);
// create a region from which we'll subtract painted rects
QRegion
remainingArea
(
contentsRect
);
// This loop draws the actual pages
// iterate over all items painting the ones intersecting contentsRect
for
(
const
PageViewItem
*
item
:
qAsConst
(
d
->
items
)
)
{
// check if a piece of the page intersects the contents rect
if
(
!
item
->
isVisible
()
||
!
item
->
croppedGeometry
().
intersects
(
c
heck
Rect
)
)
if
(
!
item
->
isVisible
()
||
!
item
->
croppedGeometry
().
intersects
(
c
ontents
Rect
)
)
continue
;
// get item and item's outline geometries
QRect
itemGeometry
=
item
->
croppedGeometry
(),
outlineGeometry
=
itemGeometry
;
outlineGeometry
.
adjust
(
-
1
,
-
1
,
3
,
3
);
QRect
itemGeometry
=
item
->
croppedGeometry
();
// move the painter to the top-left corner of the real page
p
->
save
();
p
->
translate
(
itemGeometry
.
left
(),
itemGeometry
.
top
()
);
// draw the page outline (black border and 2px bottom-right shadow)
if
(
!
itemGeometry
.
contains
(
contentsRect
)
)
{
int
itemWidth
=
itemGeometry
.
width
(),
itemHeight
=
itemGeometry
.
height
();
// draw simple outline
p
->
setPen
(
Qt
::
black
);
p
->
drawRect
(
-
1
,
-
1
,
itemWidth
+
1
,
itemHeight
+
1
);
// draw bottom/right gradient
static
const
int
levels
=
2
;
int
r
=
backColor
.
red
()
/
(
levels
+
2
)
+
6
,
g
=
backColor
.
green
()
/
(
levels
+
2
)
+
6
,
b
=
backColor
.
blue
()
/
(
levels
+
2
)
+
6
;
for
(
int
i
=
0
;
i
<
levels
;
i
++
)
{
p
->
setPen
(
QColor
(
r
*
(
i
+
2
),
g
*
(
i
+
2
),
b
*
(
i
+
2
)
)
);
p
->
drawLine
(
i
,
i
+
itemHeight
+
1
,
i
+
itemWidth
+
1
,
i
+
itemHeight
+
1
);
p
->
drawLine
(
i
+
itemWidth
+
1
,
i
,
i
+
itemWidth
+
1
,
i
+
itemHeight
);
p
->
setPen
(
backColor
);
p
->
drawLine
(
-
1
,
i
+
itemHeight
+
1
,
i
-
1
,
i
+
itemHeight
+
1
);
p
->
drawLine
(
i
+
itemWidth
+
1
,
-
1
,
i
+
itemWidth
+
1
,
i
-
1
);
}
}
// draw the page using the PagePainter with all flags active
if
(
contentsRect
.
intersects
(
itemGeometry
)
)
{
...
...
@@ -3567,15 +3536,70 @@ void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
}
// remove painted area from 'remainingArea' and restore painter
remainingArea
-=
outlineGeometry
.
intersected
(
contentsRect
)
;
remainingArea
-=
itemGeometry
;
p
->
restore
();
}
// fill with background color the unpainted area
const
QVector
<
QRect
>
&
backRects
=
remainingArea
.
rects
();
int
backRectsNumber
=
backRects
.
count
();
for
(
int
jr
=
0
;
jr
<
backRectsNumber
;
jr
++
)
p
->
fillRect
(
backRects
[
jr
],
backColor
);
// fill the visible area around the page with the background color
for
(
const
QRect
&
backRect
:
remainingArea
)
p
->
fillRect
(
backRect
,
backColor
);
// take outline and shadow into account when testing whether a repaint is necessary
auto
dpr
=
devicePixelRatioF
();
QRect
checkRect
=
contentsRect
;
checkRect
.
adjust
(
-
3
,
-
3
,
1
,
1
);
// Method to linearly interpolate between black (=(0,0,0), omitted) and the background color
auto
interpolateColor
=
[
&
backColor
](
double
t
)
{
return
QColor
(
t
*
backColor
.
red
(),
t
*
backColor
.
green
(),
t
*
backColor
.
blue
()
);
};
// width of the shadow in device pixels
static
const
int
shadowWidth
=
2
*
dpr
;
// iterate over all items painting a black outline and a simple bottom/right gradient
for
(
const
PageViewItem
*
item
:
qAsConst
(
d
->
items
)
)
{
// check if a piece of the page intersects the contents rect
if
(
!
item
->
isVisible
()
||
!
item
->
croppedGeometry
().
intersects
(
checkRect
)
)
continue
;
// get item and item's outline geometries
QRect
itemGeometry
=
item
->
croppedGeometry
();
// move the painter to the top-left corner of the real page
p
->
save
();
p
->
translate
(
itemGeometry
.
left
(),
itemGeometry
.
top
()
);
// draw the page outline (black border and bottom-right shadow)
if
(
!
itemGeometry
.
contains
(
contentsRect
)
)
{
int
itemWidth
=
itemGeometry
.
width
();
int
itemHeight
=
itemGeometry
.
height
();
// draw simple outline
QPen
pen
(
Qt
::
black
);
pen
.
setWidth
(
0
);
p
->
setPen
(
pen
);
QRectF
outline
(
-
1.0
/
dpr
,
-
1.0
/
dpr
,
itemWidth
+
1.0
/
dpr
,
itemHeight
+
1.0
/
dpr
);
p
->
drawRect
(
outline
);
// draw bottom/right gradient
for
(
int
i
=
1
;
i
<=
shadowWidth
;
i
++
)
{
pen
.
setColor
(
interpolateColor
(
double
(
i
)
/
(
shadowWidth
+
1
)
)
);
p
->
setPen
(
pen
);
QPointF
left
(
(
i
-
1
)
/
dpr
,
itemHeight
+
i
/
dpr
);
QPointF
up
(
itemWidth
+
i
/
dpr
,
(
i
-
1
)
/
dpr
);
QPointF
corner
(
itemWidth
+
i
/
dpr
,
itemHeight
+
i
/
dpr
);
p
->
drawLine
(
left
,
corner
);
p
->
drawLine
(
up
,
corner
);
}
}
p
->
restore
();
}
}
void
PageView
::
updateItemSize
(
PageViewItem
*
item
,
int
colWidth
,
int
rowHeight
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment