If I modify the perspective and save it as default (Code::Blocks default) it is not loaded on start; the toolbars always appear in the same position, but it is not the saved one.
If then I select View -> Perspectives -> Code::Blocks default (it already has a check mark) then the toolbars move where I want them.
In short, the perspective was saved correctly but it is not loaded on start.
This happens with the 16/08/2020 nightly and with my own compiled versions, with wx3.1.3 and wx3.1.4 in 32 and 64 bits, on Windows 7 and Windows 10.
I can reproduce on Linux wx3.0.4
Attached patch fixes is.
Can you also test it please?
@danselmi: Can you write an explanation what is the problem and why the fix works?
After applying the patch on MSW 7 I tested the executable in devel31. It works as it should, but the behaviour is strange; Without calling update31 I started the executable under output31 and it works fine also. Then removed the patch, and both executables (devel31 and output31) work fine.
In this context "fine" means "changes to the layout are preserved when restarting". I have disabled the "Layout has changed, save?" dialog so it saves automatically.
It looks like some part of the conf has been "unlocked". I'll test tomorrow more thoroughly on another computer, this one has been "fixed".
@fuscated: You are right, this patch is crap! I just deleted it.
I will look further into it.
I have tested this in another computer, in this case moving a wide toolbar (Code Completion) from the second line to the right of the first line (it fits nicely on a maximized window).
When reopening C::B (maximized by default) the perspective does load, but if the moved toolbar does not fit in the non-maximized window then the toolbars are rearranged and the toolbar ends in the second line where it was before the change.
If now I load the perspective manually with C::B already maximized the toolbar appears in the right side of the first line, where I put it before closing.
I think the problem is fitting the toolbars before the main window is maximized.
Please show screen shots with before/after. Sometimes the sizes of the toolbars are incorrect and the fit function may not be able to use all available space.
I guess one problem is that after a persp load we don't call the fit function. In this case it would be more clear where the problem is :)
I have attached two images:
SavedPerspective.png is what I have just before closing C::B, this perspective is automatically saved
AfterReopen.png is what I get when reopening C::B
C::B was maximized at closing, and the width of the non-maximized window wasn't enough to show the full Code Completion toolbar.
If I iadjust C::B non-maximized width so the toolbar is completely shown and then maximize C::B before closing I get SavedPerspective.png before closing and after reopening (expected behaviour).
Last edit: Miguel Gimenez 2020-11-05
Hm, this is confusing.
For me maximizing happens at MainFrame::LoadWindowSize and it happens before fitting the toolbars. I guess we must probably FitToolbars on some kind of idle event after the size of the window is fully known.
@Miguel Gimenez Could you verify that the calls to MainFrame::LoadWindowSize and FitToolbars happen in the correct order?
If the order is correct probably the next step is to check if the value
int maxWidth = mainFrame->GetSize().x;
is correct. Probably it isn't...For me the maxWidth value for maximized window on 1920x1200 monitor is 1820. Linux GTK2, wx-master-something.
Order is correct, there is only one call to FitToolbars and maxWidth for me is also 1820. This value should be 1920 for a maximized window, if I understand documentation for GetSize() correctly:
What is the size when the fit works correctly? Does it work correctly actually (lay the toolbars as you like them and use view -> toolbars -> fit)?
If the window is maximized, selecting View -> Toolbars -> Fit do nothing but View -> Perspective -> LoadDefault do restore the toolbars as they were saved, even if the window is not maximized. In the last case FitToolbars is not called at all. I presume FitToolbars shouldn't be called at all when starting.
Fitting toolbars executes FitToolbars and I see maxWidth = 1936, a bit strange for a 1920 screen (although borders are not visible and they may account for the difference), wouldn't it be better using GetClientSize() in FitToolbars()? The border can't host toolbars...
BTW, 1936 is not the 1820 value we get on starting, the latter looks an incorrect default value
FitToolbars is called at startup for a reason - dpi changes require fitting toolbars. I suppose we'll have to call FitToolbars after loading the perspective. What would be the behaviour if you add this call?
I still don't understand why the maximized state matters? Unfortunately I don't have time to do windows testing at the moment. Is it possible to reproduce this issue on linux?
Danselmi reproduced it on Linux.
The maximized state matters only because it is the widest state. The toolbars that fit in the maximized state, but won't fit in the restored state, are moved to the next line even if the window is maximized on start, so the shown perspective is different from the one seen when closing C::B.
Worse enough, this new layout is what is saved when closing C::B a second time (of course, only if you have selected automatic saving).
The workarounds I have found are making the restored window as wider as possible or don't putting toolbars in the rightmost quarter of the window.
If I call FitToolbars after LoadPerspective nothing changes
Last edit: Miguel Gimenez 2020-11-07
The problem happens because of these lines: https://github.com/obfuscated/codeblocks_sf/blob/master/src/src/main.cpp#L1604-L1605
Does it work for you if you just comment them out?
I'm actually not sure why I've added them in the first place. Maybe to prevent clipping if the size of the window isn't returned correctly...
Yes, it works
Does it still work if you put the window's taskbar on the left/right (if this is still possible of course)?
Try to setup the toolbars in a way that they just fit when the taskbar is at the bottom, but doesn't fit when the taskbar is on the side.
The last toolbar moves to the left of the second line. The same happens if I reduce the size of C::B before closing, leaving the last toolbar partially hidden.