Opened 2 years ago

Last modified 2 years ago

#18139 confirmed defect

GridBagSizer initial spacing is incorrect

Reported by: Kocsonya Owned by:
Priority: normal Milestone:
Component: GUI-all Version: dev-latest
Keywords: wxGridBagSizer growable Cc:
Blocked By: Blocking:
Patch: no


When the GBSizer has a tall item spanning several rows in one column and small items (one row each) in an other column, the extra height forced by the tall multi-row item is not distributed between the rows according to the ratios set by the SetGrowableRaw() calls. Instead, all rows are their minimum required height except that last (highest index) one, which then gets all the extra space.

If the resulting layout is then later resized by the mouse, giving even more space to the rows, that new space is distributed according to the ratios set up by the SetGrowableRow() calls. But the original height discrepancy is preserved.

I believe that behaviour is incorrect: the sizer should distribute the space according to the same policy regardless of whether the extra space is coming from a resize or from constraints set by sizes of objects managed by the sizer.

I found this problem on Linux, but on the discussion forum I got feedback that the issue manifests on Windows as well.

A very small C++ file is attached to demonstrate the bug.

Attachments (1)

gbsizer_bug.cpp download (2.0 KB) - added by Kocsonya 2 years ago.
A small program demonstrating the bug

Download all attachments as: .zip

Change History (2)

Changed 2 years ago by Kocsonya

A small program demonstrating the bug

comment:1 Changed 2 years ago by vadz

  • Component changed from base to GUI-all
  • Keywords wxGridBagSizer added; GridBagSizer removed
  • Status changed from new to confirmed
  • Version changed from 3.0.4 to dev-latest

I'm actually not sure what's the correct behaviour supposed to be here, but the current one definitely doesn't seem very useful, so we do have a bug here.

Unfortunately I'm not at all familiar with wxGridBagSizer code and can't really dive into it right now. If you can make a patch fixing the bug in it (presumably in RecalcSizes()?), it would be, of course, very welcome. It would also be great to add some unit tests for it in (not existing yet) tests/sizers/gbsizer.cpp, similarly to the tests for the other sizer types we have there.

Note: See TracTickets for help on using tickets.