mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
Fix overlapping text when narrow range is close to top
This commit is contained in:
parent
a91f5bf7c2
commit
f306e558c6
@ -224,6 +224,7 @@ void QgsElevationControllerLabels::paintEvent( QPaintEvent * )
|
|||||||
|
|
||||||
const bool lowerIsCloseToLimit = lowerY + fm.height() > rect().bottom() - fm.descent();
|
const bool lowerIsCloseToLimit = lowerY + fm.height() > rect().bottom() - fm.descent();
|
||||||
const bool upperIsCloseToLimit = upperY - fm.height() < rect().top() + fm.ascent();
|
const bool upperIsCloseToLimit = upperY - fm.height() < rect().top() + fm.ascent();
|
||||||
|
const bool lowerIsCloseToUpperLimit = lowerY - fm.height() < rect().top() + fm.ascent();
|
||||||
|
|
||||||
QLocale locale;
|
QLocale locale;
|
||||||
|
|
||||||
@ -246,17 +247,28 @@ void QgsElevationControllerLabels::paintEvent( QPaintEvent * )
|
|||||||
|
|
||||||
if ( mLimits.upper() < std::numeric_limits< double >::max() )
|
if ( mLimits.upper() < std::numeric_limits< double >::max() )
|
||||||
{
|
{
|
||||||
if ( upperIsCloseToLimit )
|
if ( qgsDoubleNear( mRange.upper(), mRange.lower() ) )
|
||||||
{
|
{
|
||||||
f.setBold( true );
|
if ( !lowerIsCloseToUpperLimit )
|
||||||
path.addText( left, upperY, f, locale.toString( mRange.upper() ) );
|
{
|
||||||
|
f.setBold( false );
|
||||||
|
path.addText( left, rect().top() + fm.ascent(), f, locale.toString( mLimits.upper() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f.setBold( true );
|
if ( upperIsCloseToLimit )
|
||||||
path.addText( left, upperY, f, locale.toString( mRange.upper() ) );
|
{
|
||||||
f.setBold( false );
|
f.setBold( true );
|
||||||
path.addText( left, rect().top() + fm.ascent(), f, locale.toString( mLimits.upper() ) );
|
path.addText( left, upperY, f, locale.toString( mRange.upper() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f.setBold( true );
|
||||||
|
path.addText( left, upperY, f, locale.toString( mRange.upper() ) );
|
||||||
|
f.setBold( false );
|
||||||
|
path.addText( left, rect().top() + fm.ascent(), f, locale.toString( mLimits.upper() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user