Bug report #9498

legend item vertical spacing (once again) broken for layers set to hidden

Added by Mathieu Pellerin - nIRV almost 11 years ago. Updated almost 11 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Radim Blazek
Category:Map Composer/Printing
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:18089

Description

A regression slipped into QGIS master with regards to composer legend item's vertical spacing of layers set to hidden. Prior to 2.0 launch, work was done to allow for proper vertical spacing of layers for a simple scenario: for the vertical spacing between a multi-item layer (i.e. categorized layer) and a single-item layer (i.e. single symbol layer) to be equal. It's now broken again under QGIS master.

I've attached a screenshot showing the problem as well as a simple project to test this out.

Assigning to Radim who did a great job fixing this before 2.0, apologies if the assignment is wrong :)

legend_broken_hidden_spaces.png (30.5 KB) Mathieu Pellerin - nIRV, 2014-02-05 07:22 PM

legend_broken.zip (382 KB) Mathieu Pellerin - nIRV, 2014-02-05 07:22 PM

spacing-ok-selection-not.png (85.6 KB) Mathieu Pellerin - nIRV, 2014-02-15 12:32 AM

proper_spacing_hidden_layer.patch Magnifier (1.27 KB) Mathieu Pellerin - nIRV, 2014-02-15 01:27 AM

Associated revisions

Revision d102a79a
Added by Mathieu Pellerin - nIRV almost 11 years ago

[composer] fix vertical spacing of hidden layer title in legend items (fix #9498)

Revision ef5ede16
Added by Nathan Woodrow almost 11 years ago

Merge pull request #1180 from nirvn/legend_spacing_fix2

[composer] fix vertical spacing of hidden layer title in legend items (fix #9498)

Revision 7822abdc
Added by Radim Blazek almost 11 years ago

composer legend items space, better fixes #9498

History

#1 Updated by Mathieu Pellerin - nIRV almost 11 years ago

The fix here appears to be simple: when a layer title type is set to hidden, the vertical spacing value above the (first/unique) item symbol of that layer should only be symbol spacing.

#2 Updated by Mathieu Pellerin - nIRV almost 11 years ago

  • Priority changed from Normal to Severe/Regression

Marking as blocker since it's a regression.

In 2.0, the user could do this:
- Empty layer title string, which would remove the layer title row within the legend item.
- Set the layer title type to group or subgroup, and have the group or subgroup spacing set to 0

In the latest QGIS master, it's now impossible to have an empty layer title string, preventing users from relying on the above-mentioned workaround.

#3 Updated by Mathieu Pellerin - nIRV almost 11 years ago

Radim, I think the problem might be located around line 837 of qgscomposerlegend.cpp and the commented out line 830:
//if ( currentLegendItem->style() != QgsComposerLegendStyle::Hidden )

Thoughts?

#4 Updated by Mathieu Pellerin - nIRV almost 11 years ago

If I re-enable the if ( currentLegendItem->style() != QgsComposerLegendStyle::Hidden ) condition, the legend's vertical spacing of hidden layer title acts as (IMO) one would expect (see attached screenshot).

The zebra selection outline is however broken (as shown in same screenshot).

#5 Updated by Mathieu Pellerin - nIRV almost 11 years ago

Radim, I got something that seems to work OK, attaching the diff patch.

I've tested it using a bunch of layer item (group, subgroup, hidden) combinations, as well as multi-column, and all worked ok over here.

#6 Updated by Nathan Woodrow almost 11 years ago

  • Status changed from Open to Closed

#7 Updated by Radim Blazek almost 11 years ago

I am not sure the fix is OK. Basically each row in legend is a nucleon, group of nucleons is atom. Layer item is a nucleon and it should really be added only if it is not hidden. The fix adds the title as nucleon but does not render it. I believe that it should not be added at all. I'll look at it once more.

#8 Updated by Radim Blazek almost 11 years ago

I have done better fix (fixing the real problem) in 7822abd.
Please test.

#9 Updated by Mathieu Pellerin - nIRV almost 11 years ago

  • Resolution set to fixed/implemented
  • % Done changed from 0 to 100

Radim, I've just compiled qgis with your commit in, and legend is acting like a charm, excellent. I think we can call this one fixed for good now :)

Also available in: Atom PDF