mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[legend] insure multi-line labels are vertically centered with tall symbols
This commit is contained in:
parent
4bcd97066f
commit
455874258c
@ -108,9 +108,9 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings& set
|
||||
|
||||
// Vertical alignment of label with symbol
|
||||
if ( labelSize.height() < symbolSize.height() )
|
||||
labelY += symbolSize.height() / 2 + textHeight / 2; // label centered with symbol
|
||||
else
|
||||
labelY += textHeight; // label starts at top and runs under symbol
|
||||
labelY += symbolSize.height() / 2 - labelSize.height() / 2; // label centered with symbol
|
||||
|
||||
labelY += textHeight;
|
||||
}
|
||||
|
||||
for ( QStringList::Iterator itemPart = lines.begin(); itemPart != lines.end(); ++itemPart )
|
||||
|
@ -114,6 +114,7 @@ class TestQgsLegendRenderer : public QObject
|
||||
void testBasic();
|
||||
void testBigMarker();
|
||||
void testMapUnits();
|
||||
void testTallSymbol();
|
||||
void testLongSymbolText();
|
||||
void testThreeColumns();
|
||||
void testFilterByMap();
|
||||
@ -338,6 +339,28 @@ void TestQgsLegendRenderer::testMapUnits()
|
||||
QVERIFY( _verifyImage( testName, mReport ) );
|
||||
}
|
||||
|
||||
void TestQgsLegendRenderer::testTallSymbol()
|
||||
{
|
||||
QString testName = "legend_tall_symbol";
|
||||
|
||||
QgsCategorizedSymbolRenderer* catRenderer = dynamic_cast<QgsCategorizedSymbolRenderer*>( mVL3->renderer() );
|
||||
QVERIFY( catRenderer );
|
||||
catRenderer->updateCategoryLabel( 1, "This is\nthree lines\nlong label" );
|
||||
|
||||
mVL2->setName( "This is a two lines\nlong label" );
|
||||
|
||||
QgsLayerTreeModel legendModel( mRoot );
|
||||
|
||||
QgsLegendSettings settings;
|
||||
settings.setWrapChar( "\n" );
|
||||
settings.setSymbolSize( QSizeF( 10.0, 10.0 ) );
|
||||
_setStandardTestFont( settings );
|
||||
_renderLegend( testName, &legendModel, settings );
|
||||
QVERIFY( _verifyImage( testName, mReport ) );
|
||||
|
||||
mVL2->setName( "Polygon Layer" );
|
||||
}
|
||||
|
||||
void TestQgsLegendRenderer::testLongSymbolText()
|
||||
{
|
||||
QString testName = "legend_long_symbol_text";
|
||||
|
BIN
tests/testdata/control_images/legend/expected_legend_tall_symbol/expected_legend_tall_symbol.png
vendored
Normal file
BIN
tests/testdata/control_images/legend/expected_legend_tall_symbol/expected_legend_tall_symbol.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Loading…
x
Reference in New Issue
Block a user