Opened 14 years ago

Closed 14 years ago

#2868 closed patch (fixed)

Label alignment in composer

Reported by: medspx Owned by: mhugent
Priority: minor: annoyance Milestone: Version 1.6.0
Component: Printing Version: Trunk
Keywords: labels, alignment, composer Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

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).

Attachments (3)

QGIS_centered.png (47.2 KB ) - added by medspx 14 years ago.
Composer Label placement
bug2868fix.diff (11.8 KB ) - added by medspx 14 years ago.
Patch for alignment implentation
QGIS_2868.png (53.5 KB ) - added by medspx 14 years ago.
image of composer GUI with label alignment implementation

Download all attachments as: .zip

Change History (7)

by medspx, 14 years ago

Attachment: QGIS_centered.png added

Composer Label placement

comment:1 by medspx, 14 years ago

Component: Build/InstallPrinting

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 !

by medspx, 14 years ago

Attachment: bug2868fix.diff added

Patch for alignment implentation

by medspx, 14 years ago

Attachment: QGIS_2868.png added

image of composer GUI with label alignment implementation

comment:2 by medspx, 14 years ago

Keywords: labels alignment composer added
Version: Trunk

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.

What needs to be done:

  • A composer guru should evaluate the patch
  • the translation files need to be regenerated (with update_ts_files.sh script)
  • commit... or more fixes !

comment:3 by mhugent, 14 years ago

Owner: changed from nobody to mhugent
Type: enhancementpatch

comment:4 by mhugent, 14 years ago

Resolution: fixed
Status: newclosed

Applied in r13938 with modifications. Thanks, medspx!

Note: See TracTickets for help on using tickets.