mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[layouts] Fix incorrectly rendered item background and frame when item is
non-opaque Fixes #20909
This commit is contained in:
parent
4da0796180
commit
0de94dd1fe
@ -325,11 +325,16 @@ void QgsLayoutItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *it
|
||||
// painter is already scaled to dots
|
||||
// need to translate so that item origin is at 0,0 in painter coordinates (not bounding rect origin)
|
||||
p.translate( -boundingRect().x() * context.scaleFactor(), -boundingRect().y() * context.scaleFactor() );
|
||||
// scale to layout units for background and frame rendering
|
||||
p.scale( context.scaleFactor(), context.scaleFactor() );
|
||||
drawBackground( context );
|
||||
p.scale( 1 / context.scaleFactor(), 1 / context.scaleFactor() );
|
||||
double viewScale = QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle );
|
||||
QgsLayoutItemRenderContext itemRenderContext( context, viewScale );
|
||||
draw( itemRenderContext );
|
||||
p.scale( context.scaleFactor(), context.scaleFactor() );
|
||||
drawFrame( context );
|
||||
p.scale( 1 / context.scaleFactor(), 1 / context.scaleFactor() );
|
||||
p.end();
|
||||
|
||||
QgsImageOperation::multiplyOpacity( image, mEvaluatedOpacity );
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "qgsreadwritecontext.h"
|
||||
#include "qgslayoutitemundocommand.h"
|
||||
#include "qgslayoutitemmap.h"
|
||||
#include "qgslayoutitemlabel.h"
|
||||
#include "qgslayoutitemshape.h"
|
||||
#include "qgslayouteffect.h"
|
||||
#include "qgsfillsymbollayer.h"
|
||||
@ -1979,6 +1980,21 @@ void TestQgsLayoutItem::opacity()
|
||||
checker.setControlPathPrefix( QStringLiteral( "composer_effects" ) );
|
||||
QVERIFY( checker.testLayout( mReport ) );
|
||||
|
||||
// with background and frame
|
||||
l.removeLayoutItem( item );
|
||||
|
||||
QgsLayoutItemLabel *labelItem = new QgsLayoutItemLabel( &l );
|
||||
l.addLayoutItem( labelItem );
|
||||
labelItem->attemptSetSceneRect( QRectF( 50, 50, 150, 100 ) );
|
||||
labelItem->setBackgroundEnabled( true );
|
||||
labelItem->setBackgroundColor( QColor( 40, 140, 240 ) );
|
||||
labelItem->setFrameEnabled( true );
|
||||
labelItem->setFrameStrokeColor( QColor( 40, 30, 20 ) );
|
||||
labelItem->setItemOpacity( 0.5 );
|
||||
checker = QgsLayoutChecker( QStringLiteral( "composereffects_transparency_bgframe" ), &l );
|
||||
checker.setControlPathPrefix( QStringLiteral( "composer_effects" ) );
|
||||
QVERIFY( checker.testLayout( mReport ) );
|
||||
|
||||
QgsLayout l2( QgsProject::instance() );
|
||||
l2.initializeDefaults();
|
||||
QgsLayoutItemShape *mComposerRect1 = new QgsLayoutItemShape( &l2 );
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Loading…
x
Reference in New Issue
Block a user