wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.81k stars 1.71k forks source link

[macOS?] Sizers are not setting the size of windows correctly #24530

Open hwiesmann opened 2 weeks ago

hwiesmann commented 2 weeks ago

Description

When running the widgets sample the following window opens:

Bildschirmfoto 2024-05-14 um 22 12 44

The upper panel that should show the treebook is clearly not sized correctly. After changing the frame's size the panel is sized correctly.

I think that this is a regression related to some older patches as I have not seen this in (much) older version of wxWidgets.

Platform and version information

vadz commented 2 weeks ago

I can indeed see this, although I had to delete ~/Library/Preferences/widgets Preferences as with it, i.e. when the previously saved position is restored, everything works correctly.

It looks like there is a missing size event, and so layout, on startup, but calling Layout() explicitly doesn't help. I'm not sure what's going on here, more debugging is needed...

hwiesmann commented 3 days ago

The main reason for this issue seems to be that adding a page to the tree book does not trigger a request to resize the tree control (only the best size is invalidated). As the tree book has a defined size and the panel's sizer is happy with the tree book's size, the tree book also does not send a resize event (only a move event). Therefore, nothing is triggering a resize event for the tree control. This means that the size of the tree control is the size when the tree control is created. Whenever the size of the frame or panel changes, the tree book issue a size event and as a consequence of this event the tree control's size is newly determined.

I have no other idea how to solve this issue besides calling m_book->Layout() after InitBook().