Feature request #2868
Label alignment in composer
Status: | Closed | ||
---|---|---|---|
Priority: | Low | ||
Assignee: | Marco Hugentobler | ||
Category: | - | ||
Pull Request or Patch supplied: | Resolution: | fixed | |
Easy fix?: | No | Copied to github as #: | 12928 |
Description
One new feature that would be good is the support of label alignment in the composer.
When you have created a label, you can't align it to the right or to the middle of the "label bloc". By default it is only aligned on the left side.
Furthermore, the upper and lower alignment could also be implemented (perhaps on a second time).
History
#1 Updated by Médéric RIBREUX over 14 years ago
I tried to code this enhancement. The attachement is a png file which shows what could be a centered (horizontally) label in the composer.
After looking into the code, the source files that need to be modified are in src/core/composer:
- qgscomposerlabel.cpp (alignment attributes)
- qgscomposeritem.cpp (effective printing)
For the moment here is how I implement it:
- the QPainter->drawText (QT native) already deals with vertical and horizontal alignment.
- all we have to do is to pass the good args
- I have add a halign and a valign attributes in QgsComposerLabel class in order to deals with horizontal and vertical alignements
- those attributes are "text" formatted as I think that it is important to specify rather "center", "left or "right" (human readable in the qpt file) instead of the OR value from the mix of QT::AlignHCenter, QT::AlignLeft or QT::AlignRight values. This is only my point of view and it can be changed to the constant values OR number (easier to implement in the code cause you don't have to convert Strings to QT::Alignxxxx values).
- I have add a new QgsComposerItem::drawText function which uses alignements args
My next operation is a GUI implementation of this...
I will post a patch as soon as possible !
#2 Updated by Médéric RIBREUX over 14 years ago
Here is a patch with my implementation.
What has been done:- You can verticaly and horizontaly align labels text.
- GUI controls are implemented too (needs to be translated).
- Alignment attributes can be written/read in/from qpt files.
- A composer guru should evaluate the patch
- the translation files need to be regenerated (with update_ts_files.sh script)
- commit... or more fixes !
#3 Updated by Marco Hugentobler over 14 years ago
- Resolution set to fixed
- Status changed from Open to Closed
Applied in f05eefd2 (SVN r13939) with modifications. Thanks, medspx!