-
Notifications
You must be signed in to change notification settings - Fork 286
UI Feature: Improve toolbox flow layout #1916
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
Merged
MrStevns
merged 7 commits into
pencil2d:master
from
MrStevns:feat/toolbox-flow-layout-improvements
Jun 3, 2025
Merged
UI Feature: Improve toolbox flow layout #1916
MrStevns
merged 7 commits into
pencil2d:master
from
MrStevns:feat/toolbox-flow-layout-improvements
Jun 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Because I would like to change the alignment of the items on the last line Also fixed a bunch of layout spacing inconsistencies
This happens because they will appear next to each other initially but then hidden away. The consequence of that is the dockwidget sizes itself based on that, even if it they are removed right after.
chchwy
approved these changes
Jun 3, 2025
Looks good to me! |
chchwy
pushed a commit
to chchwy/pencil2d
that referenced
this pull request
Jun 5, 2025
* FlowLayout: rewrite for maintainability sake * Introduce customised flow layout for toolbox Because I would like to change the alignment of the items on the last line Also fixed a bunch of layout spacing inconsistencies * Fix center alignment issue being off by one item * Move Toolbox into own widget for more control of sizing * Fix dock widget expansion caused by bucket and camera tools being layout This happens because they will appear next to each other initially but then hidden away. The consequence of that is the dockwidget sizes itself based on that, even if it they are removed right after. * Add missing license header * Cleanup # Conflicts: # app/src/toolbox.cpp # app/src/toolbox.h # app/ui/toolboxwidget.ui # core_lib/core_lib.pro
chchwy
pushed a commit
that referenced
this pull request
Jun 5, 2025
* FlowLayout: rewrite for maintainability sake * Introduce customised flow layout for toolbox Because I would like to change the alignment of the items on the last line Also fixed a bunch of layout spacing inconsistencies * Fix center alignment issue being off by one item * Move Toolbox into own widget for more control of sizing * Fix dock widget expansion caused by bucket and camera tools being layout This happens because they will appear next to each other initially but then hidden away. The consequence of that is the dockwidget sizes itself based on that, even if it they are removed right after. * Add missing license header * Cleanup # Conflicts: # app/src/toolbox.cpp # app/src/toolbox.h # app/ui/toolboxwidget.ui # core_lib/core_lib.pro
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've given our FlowLayout class an overhaul.
Pure row height calculation has been moved into its own separate function, rather than mixing everything with the "testOnly" flag. The justified logic has been updated such that it will always try to cram as many items on a line as possible, but still be constrained to a minimum spacing.
The result of that looks like this:
The sizing logic for the Tools widget has been updated as well. If there's only one row, then the items will be aligned centered and otherwise the alignment will change to justified, until all items has been layout. When all items has been layout horizontally, the flow layout will default to centered placement again.
I've also introduced a new ToolBoxLayout class in order to change the alignment of the last line, as it will otherwise align justified with no concern of aligning to lines above.
With this PR, combined with #1913, we will be able to shrink to the following.

Note that due to how QDockWidget sizing works, in order to get more control of how the toolbox is layout, I had to move everything into a container widget.