Skip to content

Commit 0ae2b1a

Browse files
committedJan 6, 2014
[composer] Tweak appearance of compositions so that it's still possible to see page edges when using a transparent paper style
1 parent d1a3508 commit 0ae2b1a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎src/core/composer/qgscomposition.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ QgsComposition::QgsComposition( QgsMapRenderer* mapRenderer )
7878
, mAtlasPreviewEnabled( false )
7979
, mPreventCursorChange( false )
8080
{
81-
setBackgroundBrush( Qt::gray );
81+
setBackgroundBrush( QColor( 215, 215, 215 ) );
8282
createDefaultPageStyleSymbol();
8383
addPaperItem();
8484

@@ -2248,7 +2248,7 @@ void QgsComposition::renderPage( QPainter* p, int page )
22482248
setBackgroundBrush( Qt::NoBrush );
22492249
render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
22502250
//show background after rendering
2251-
setBackgroundBrush( Qt::gray );
2251+
setBackgroundBrush( QColor( 215, 215, 215 ) );
22522252
setSnapLinesVisible( true );
22532253

22542254
mPlotStyle = savedPlotStyle;

‎src/core/composer/qgspaperitem.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,24 @@ void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* ite
166166
}
167167

168168
painter->save();
169+
170+
if ( mComposition->plotStyle() == QgsComposition::Preview )
171+
{
172+
//if in preview mode, draw page border and shadow so that it's
173+
//still possible to tell where pages with a transparent style begin and end
174+
painter->setRenderHint( QPainter::Antialiasing, false );
175+
176+
//shadow
177+
painter->setBrush( QBrush( QColor( 150, 150, 150 ) ) );
178+
painter->setPen( Qt::NoPen );
179+
painter->drawRect( QRectF( 1, 1, rect().width() + 1, rect().height() + 1 ) );
180+
181+
//page area
182+
painter->setBrush( QColor( 215, 215, 215 ) );
183+
painter->setPen( QPen( QColor( 100, 100, 100 ) ) );
184+
painter->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
185+
}
186+
169187
painter->setRenderHint( QPainter::Antialiasing );
170188
mComposition->pageStyleSymbol()->startRender( context );
171189

@@ -217,6 +235,11 @@ void QgsPaperItem::initialize()
217235
setFlag( QGraphicsItem::ItemIsMovable, false );
218236
setZValue( 0 );
219237

238+
//even though we aren't going to use it to draw the page, set the pen width as 4
239+
//so that the page border and shadow is fully rendered within its scene rect
240+
//(QGraphicsRectItem considers the pen width when calculating an item's scene rect)
241+
setPen( QPen( QBrush( Qt::NoBrush ), 4 ) );
242+
220243
//create a new QgsPaperGrid for this page, and add it to the composition
221244
mPageGrid = new QgsPaperGrid( pos().x(), pos().y(), rect().width(), rect().height(), mComposition );
222245
mComposition->addItem( mPageGrid );

0 commit comments

Comments
 (0)
Please sign in to comment.