-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Undocked panels should remember their position/size #27695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocked panels should remember their position/size #27695
Conversation
f774cc9 to
d09ba06
Compare
src/framework/dockwindow/thirdparty/KDDockWidgets/src/DockWidgetBase.cpp
Outdated
Show resolved
Hide resolved
d09ba06 to
3afa55e
Compare
mathesoncalum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much @krasko78!
Ready for testing now @zacjansheski - need to make sure we don't reintroduce #26009 or similar.
|
In this PR, after factory reset, percussion panel and mixer panel can be stacked as opposed to tabs in same dock area video1283134326.mp4 |
|
Undo/Redo spans right side of window vertically after "restore default layout" video1103005246.mp4 |
|
Thanks, Zac. The undo/redo issue is reproducible without this PR too. As far as the other issue is concerned: restoring a dock at I tried a bunch of things and the only thing that seems to work well is in the new commit I just added. Simply the idea is to add all panels as visible so they can be positioned properly and then the hidden panels to be closed:
This PR also breaks new (unknown) panels for which the saved JSON layout does not know about: any unknown panels will still appear docked thanks to this PR but they won't be tabbed with the other panels they belong to if: a) all are hidden; and b) there exists a previoualy saved layout (i.e. this is not a clean start). I think this should not be a show-stopper for this PR though as the benefits are worth this inconvenience. |
961b8fa to
f188d34
Compare
|
@krasko78 Sorry, another rebase is needed... I've reviewed this, and have no objections, but I'm not confident enough to approve it, also considering the consequences for new unknown dock widgets, mentioned above. So @mathesoncalum it would be great if you could take a look as well. |
|
Fair enough, Casper. Docks are tricky. I'll rebase and review. Maybe now I'll be able to look at it with fresh eyes and figure something out. |
5d5ff9d to
3d9d4c6
Compare
|
@cbjeukendrup @mathesoncalum Next round! So the problem was in that the horizontal panels (Mixer, Piano keybord, etc.) are all hidden by default so in To me, this all means that we need a way to be able to tab a panel to a closed one and I have found a way to do it. The core change I have made is to
The only thing left for Another change worth mentioning is in In
In I have performed extensive testing of as many scenarios as occurred to me, including when no layout is present in the workspace (factory reset). I tested with an unknown panel both set to initially visible and hidden, reseting to the default layout, floating and docked horizontal panels. It looks good to me. QA: You can test with an unknown panel by hacking the layout. Unzip your workspace file, open |
390eb82 to
5e990fc
Compare
mathesoncalum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5e990fc to
8c3ed48
Compare
7e43e3d to
a55bfa5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, now that 4.6.4 is behind us we can return to this...
For context, behind the scenes we have been actively investigating the best approach to a dock system update. As you can probably imagine it's quite a big/tricky task with a lot of uncertainties but one thing we'd really like to aim for is a system that doesn't involve our own hacked/patched version of KDDockWidgets.
For this reason, and reasons stated previously in this PR thread, I think we can leave the lastPositions-related stuff for now, drop the original second commit, and simply do the forceClose -> close change for now.
This will solve one of, if not the, most frequently reported issues relating to dock positions and minimizes the risk of us having to do follow-up patches to KDDW.
Huge thanks for your work on this one @krasko78
cbjeukendrup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to approve this, although it's sad that this is all that remains after the long history of this PR. But the future is bright (hopefully 😅).
|
Did I write most of the above comments? Oh, boy, it is really time to stop the drugs or change the dealer. Hopefully this will earn me the next Nobel prize for Literature. Changing |
|
@krasko78 if you look at #18345 and #27570 (probably more), these issues relate to undocked panels only and the root cause is Quick video to demonstrate what this actually solves - sound on (voice reveal!): forceClose.mov |
|
Ah, I see. Looks like this is the case when all vertical or horizontal panels are either undocked or invisible. I am glad at least something is getting fixed. Thanks, @mathesoncalum! |
a55bfa5 to
52370d3
Compare
|
Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved |

Resolves partially: #11242 & #26678 (partially because docked panels are still a problem)
Resolves: #18345 (however the height is not retained because the Mixer auto-calculates it)
Resolves: #27570
NOTE: Below is the original comment for this PR, prior to various force-pushes and discussions.
I am proposing a couple of simple changes to fix the problem with the docks not remembering their position which is a big nuisance:
openmethod on the panel like we do with the non-panels, this will call theshowmethod on the widget. From there KDockWidgets has all the functionality to restore the widget to it position prior to it getting closed. So I am proposing that we call theopenmethod and bypass our destination-panel-search logic with the following two exceptions:show()method is not enough: it would not change the active tab although the contents of the widget would become visible. So I've added a check for this case and we just need to have the frame activate the tab with the widget. Otherwise we call theshow()method which will do its best to restore the widget and will also activate it in the frame.show()method in this case would show the widget undocked with some size which makes sense. However, in this case it is better to fallback to our destination-panel-search logic instead. To this end, I unfortunately had to add a small method toDockWidgetBasewhich is third-party code but I didn't find another way to do it - everything around the last position is private and there are no no virtual methods to hook into...forceClose()which turns on a flag calledm_isForceClosingin DockWidgetBase.cpp::873 and this later on prevents the code from capturing its current position (i.e. its last position) inDockWidgetBase::Private::close()around line 650. I am proposing that we callclose()instead offorceClose()so the current position is captured correctly before the widget is closed so it can be restored to it later on when shown.Most widgets have size constraints and others also have some auto-size logic built into them. For example, the vertical panels are restricted to 300px in width meaning that if you resize them more or less than this width when undocked, if you close and reopen them, they will return to this width. The horizontal panels, such as the Mixer, have a maximum height of 520px. Moreover, the Mixer panel and the Playback controls have additional size constraints. [Personally I am not a fan of these constraints (more freedom would be nice). There is an unfinished story to lift those constraints or bring them to less limiting values.] So when restoring a closed widget it may not have its pre-closure size, but at least the position should be retained.