Bug: For forms where size or minimum_size properties are expressed by the user, the function SetSizerAndFit() must be avoided
Description:
wxUIEditor: Latest daily build
For forms where the size is expressed like this
the code in ::Create() function is:
The result on final application is shown below.
It is wrong
I think in case the user expresses the form size by using size or minimum_size another approach should be used to generate the code.
Instead of SetSizerAndFit(bSizer1); should be used SetSizer(bSizer1);
This approach should be used for all forms
I can't reproduce the problem when minimum_size is set (just that property, not the size property). What I'm getting is:
SetSizer(box_sizer);
SetMinSize(wxSize(200, 200));
Fit();
Same for maximum_size. Currently, the size property gets set in the header file but doesn't change source code generation -- as you note, it should not call Fit() in this case. Not calling Fit() when min or max size is set seems odd since neither of those settings would normally be used to set the initial size of the dialog. I'd be more inclined to make that a property if you really don't want Fit() called. I know that changing the current behavior would break some of the dialogs in wxUiEditor itself, forcing me to call Fit() in the OnInit() event to work around the omission of Fit in the dialog's creation.
I understand your point, but indeed it is necessary to find a way in case a user sets a specific size, thst case means he/she wants that dimension not other. The property you mentioned could be a good compromise, you should create it TRUE by default, and in case the user doesn't need such a behaviour, cimply it will be necessary to remove the tick. I like it, it is the way DilogBLock uses since its beginning ...
If minimum size is set, and the layout of controls fits within that minimum size, then Fit() will not change the dialog size. The only time Fit() will change the size from mimimum size if if controls would be clipped -- which can happen if minimum size did not use dialog units, and the dialog is displayed on a high-resolution screen with scaling set over 100%. Removing the call to Fit() will force everyone who uses minimum size to also add an event handler to call Fit() if they want the dialog to be DPI-aware.
The size property is different -- in this case you are requesting an exact size and you don't want wxWidgets to change it. In that scenario, it is a mistake to call Fit() which can change the size of the form (dialog, frame, etc.).
There is an additional bug for wxDialog where if size is set to dialog units, no code is generated to convert those dialog units to pixels. While that is still the default for wxFormBuilder, both XRC and more modern RAD designers support dialog units so that the dialog takes into account scaling on a high DPI screen.
Removing from milestone since the PR changes the call to SetSizerAndFit to SetSizer if prop_size is set.