mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-30 00:04:58 -05:00
[feature][labeling] Expose Justify text alignment option for use
in multiline point/polygon labels Allows multiline labels to be "justify" aligned
This commit is contained in:
parent
3e5155993d
commit
cfd9afed71
@ -167,7 +167,8 @@ class QgsPalLayerSettings
|
||||
MultiLeft,
|
||||
MultiCenter,
|
||||
MultiRight,
|
||||
MultiFollowPlacement
|
||||
MultiFollowPlacement,
|
||||
MultiJustify,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -203,6 +203,9 @@ void QgsLabelPropertyDialog::init( const QString &layerId, const QString &provid
|
||||
case QgsPalLayerSettings::MultiRight:
|
||||
defaultMultilineAlign = QStringLiteral( "right" );
|
||||
break;
|
||||
case QgsPalLayerSettings::MultiJustify:
|
||||
defaultMultilineAlign = QStringLiteral( "justify" );
|
||||
break;
|
||||
case QgsPalLayerSettings::MultiFollowPlacement:
|
||||
defaultMultilineAlign = QStringLiteral( "follow label placement" );
|
||||
break;
|
||||
@ -592,6 +595,7 @@ void QgsLabelPropertyDialog::fillMultiLineAlignComboBox()
|
||||
mMultiLineAlignComboBox->addItem( tr( "Left" ), "Left" );
|
||||
mMultiLineAlignComboBox->addItem( tr( "Center" ), "Center" );
|
||||
mMultiLineAlignComboBox->addItem( tr( "Right" ), "Right" );
|
||||
mMultiLineAlignComboBox->addItem( tr( "Justify" ), "Justify" );
|
||||
}
|
||||
|
||||
void QgsLabelPropertyDialog::fillHaliComboBox()
|
||||
|
||||
@ -3188,6 +3188,10 @@ void QgsPalLayerSettings::parseTextFormatting( QgsRenderContext &context )
|
||||
{
|
||||
aligntype = QgsPalLayerSettings::MultiFollowPlacement;
|
||||
}
|
||||
else if ( str.compare( QLatin1String( "Justify" ), Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
aligntype = QgsPalLayerSettings::MultiJustify;
|
||||
}
|
||||
dataDefinedValues.insert( QgsPalLayerSettings::MultiLineAlignment, QVariant( static_cast< int >( aligntype ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,8 +311,9 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
MultiLeft = 0,
|
||||
MultiCenter,
|
||||
MultiRight,
|
||||
MultiFollowPlacement /*!< Alignment follows placement of label, e.g., labels to the left of a feature
|
||||
MultiFollowPlacement, /*!< Alignment follows placement of label, e.g., labels to the left of a feature
|
||||
will be drawn with right alignment*/
|
||||
MultiJustify, //!< Justified
|
||||
};
|
||||
|
||||
//TODO QGIS 4.0 - Remove -- moved to QgsLabelEngineObstacleSettings
|
||||
|
||||
@ -618,6 +618,8 @@ void QgsVectorLayerLabelProvider::drawLabelPrivate( pal::LabelPosition *label, Q
|
||||
hAlign = QgsTextRenderer::AlignCenter;
|
||||
else if ( tmpLyr.multilineAlign == QgsPalLayerSettings::MultiRight )
|
||||
hAlign = QgsTextRenderer::AlignRight;
|
||||
else if ( tmpLyr.multilineAlign == QgsPalLayerSettings::MultiJustify )
|
||||
hAlign = QgsTextRenderer::AlignJustify;
|
||||
|
||||
QgsTextRenderer::Component component;
|
||||
component.origin = outPt;
|
||||
|
||||
@ -192,6 +192,7 @@ QgsLabelingGui::QgsLabelingGui( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas,
|
||||
mFontMultiLineAlignComboBox->addItem( tr( "Left" ), QgsPalLayerSettings::MultiLeft );
|
||||
mFontMultiLineAlignComboBox->addItem( tr( "Center" ), QgsPalLayerSettings::MultiCenter );
|
||||
mFontMultiLineAlignComboBox->addItem( tr( "Right" ), QgsPalLayerSettings::MultiRight );
|
||||
mFontMultiLineAlignComboBox->addItem( tr( "Justify" ), QgsPalLayerSettings::MultiJustify );
|
||||
|
||||
// connections for groupboxes with separate activation checkboxes (that need to honor data defined setting)
|
||||
connect( mBufferDrawChkBx, &QAbstractButton::toggled, this, &QgsLabelingGui::updateUi );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user