Skip to content
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

Improve dock layout for lower resolution #1840

Merged
merged 15 commits into from
Aug 4, 2024

Conversation

MrStevns
Copy link
Member

@MrStevns MrStevns commented Apr 30, 2024

A follow up PR from #1824

I've adjusted the margin as well as the min width for all the dock widgets so they are aligned.
In addition the font has also been adjusted from 13 pt to 11 pt.

The result looks like this:
image
Front: new layout
Back: old layout

The widgets that had the greatest impact adjusting this was the tool options widget as well as the onion skin widget.

Side by side:

Old New
image image

Adjusting the font also helped quite a bit.

11 point font size 13 point font size
image image
142 px 162 px

I've also added extra QLayout around certain elements, which is not a mistake. Doing so fixes some problems where Qt added extra margins around checkboxes and labels.

@MrStevns MrStevns changed the title Compact dock layout Improve dock layout for lower resolution Apr 30, 2024
@chchwy chchwy force-pushed the compact-dock-layout branch from b7a3d9f to 915c29a Compare April 30, 2024 17:55
@chchwy
Copy link
Member

chchwy commented May 1, 2024

Would you be able to change the margins of the flowlayout in the toolbox as well?
It should be at toolbox.cpp line141 something like:

FlowLayout* flowlayout = new FlowLayout(0, 3, 3);

@MrStevns MrStevns force-pushed the compact-dock-layout branch from 915c29a to 8e12fc4 Compare May 1, 2024 17:10
@MrStevns
Copy link
Member Author

MrStevns commented May 1, 2024

I played around with that too, though it causes the widget to never go into one vertical line, at least on mac.

3 px margin 0 px margin
image image

It bothers me a bit but I can't figure out how to force the layout into submission. For some reason it won't get smaller than 60 px or so... even though I believe i've tweaked all possible values. I must be missing something.

edit: Aha! it's the title widget that enforces the min width.

@chchwy
Copy link
Member

chchwy commented May 2, 2024

It bothers me a bit but I can't figure out how to force the layout into submission. For some reason it won't get smaller than 60 px or so... even though I believe i've tweaked all possible values. I must be missing something.

edit: Aha! it's the title widget that enforces the min width.

yea, title bar is to blame.

@chchwy chchwy self-requested a review May 4, 2024 11:27
@J5lx J5lx self-requested a review May 4, 2024 12:21
@MrStevns MrStevns force-pushed the compact-dock-layout branch from 83c7a60 to f8edeff Compare May 5, 2024 12:23
@chchwy chchwy force-pushed the compact-dock-layout branch from f8edeff to d336801 Compare May 7, 2024 15:58
@MrStevns
Copy link
Member Author

MrStevns commented May 9, 2024

Small improvement. The toolbox can now also be shrunk down when laid out horizontally.
dock-widget-layout2

@MrStevns
Copy link
Member Author

Hmm not sure what's up but the font looks larger on some of the widgets on my windows machine.
it looks like setting the font point size specifically almost has the opposite effect on windows... sigh 😩

https://forum.qt.io/topic/125993/font-point-size-weird-behaviour-on-windows I found this and some other threads mentioning similar problems... what a can of worms.

image

Sure we could just go back to the old font but seriously... Qt, you had one job.

@MrStevns
Copy link
Member Author

Fixed. The "solution" is to use qstylesheet instead. In this case i'm setting the font-size of all widgets that are children of BaseDockWidget.

image

@MrStevns
Copy link
Member Author

MrStevns commented May 14, 2024

I have also tested these changes on a linux distro now.
image

@J5lx
Copy link
Member

J5lx commented May 16, 2024

The overall direction of this PR looks fine to me, but there’s something weird going on with the font size. On Windows, it looks practically unchanged except for the title bars, whereas on Linux the text is painfully tiny for me, much smaller than the default font size (note the status bar for comparison):
image
My theory is that this is because of the way you’re hard-coding the font size. I experimented around a little and found that setting the font size to 86% (first screenshot) of the global default gave me a result that (subjectively) seemed much closer to the effect seen in your original screenshots, while 85% (second screenshot), which is closer to your original 11/13 ratio, still looked a little too small for my liking but still better than the original hard-coded 11px.
image
image
For reference, I’m using setStyleSheet(QString("QWidget { font-size: %1pt }").arg(.86 * QFont().pointSizeF())); (pixelSize() does not work). Note that I haven’t tried this on Windows yet.

Also, on Qt 6, I now get a new warning in the console:

Init Dock widget: "TimeLine"
Init Dock widget: "ColorWheel"
Init Dock widget: "Color Inspector"
Init Dock widget: "ColorPalette"
Init Dock widget: "Onion Skin"
Init Dock widget: "ToolOption"
QWidget::setMinimumSize: (scrollArea/QScrollArea) Negative sizes (0,-1) are not possible
Init Dock widget: "ToolBox"

And lastly, your most recent commit seems to have broken the colour inspector preview somehow, it now defaults to the standard widget background on startup. Not sure what exactly is going on there…

@J5lx J5lx added Enhancement UI Related to the visual appearance of the program labels May 16, 2024
@MrStevns
Copy link
Member Author

Thanks for testing it out. 👍

On Windows, it looks practically unchanged except for the title bars, whereas on Linux the text is painfully tiny for me, much smaller than the default font size (note the status bar for comparison):

I've reverted the font change again.
This seems to be one of the those things that require a greater understanding of Qt in order to change properly, so we'll keep the same font for now. I don't like the idea of scaling the font with some arbitrary number. It must be possible to use proper px or pt values and then it's a matter of figuring out how those work in Qt compared to web, if it's css they're basing their logic of.

Also, on Qt 6, I now get a new warning in the console:

I'll fix that.

@J5lx
Copy link
Member

J5lx commented May 18, 2024

I don't like the idea of scaling the font with some arbitrary number. It must be possible to use proper px or pt values and then it's a matter of figuring out how those work in Qt compared to web, if it's css they're basing their logic of.

“Scaling the font with some arbitrary number” is pretty standard on the web and generally recommended for accessibility, I’m not sure what’s the problem with it. E.g. the main font size on our forum is 0.938em, and I haven’t changed it. If you have something else in mind, sure. But please consider taking the system default as a base in one way or another since we mainly use native styling.

@chchwy chchwy added this to the 0.8.0 milestone May 21, 2024
chchwy and others added 8 commits June 7, 2024 08:34
- Font size: 11
- Minimum width: 140 px or less
- Padding adjusted to be 3 px.

The size has to be set specifically, otherwise the designer will adjust to what it thinks is best.
The reason is that we add the margins to the outer layout instead of inside the scroll area.
instead use qstylesheet and it might work better.
@chchwy chchwy force-pushed the compact-dock-layout branch from c8b51ab to 30df82d Compare June 7, 2024 00:34
@MrStevns
Copy link
Member Author

“Scaling the font with some arbitrary number” is pretty standard on the web and generally recommended for accessibility, I’m not sure what’s the problem with it. E.g. the main font size on our forum is 0.938em, and I haven’t changed it. If you have something else in mind, sure. But please consider taking the system default as a base in one way or another since we mainly use native styling.

Alright fair enough, I'm used to mobile development where it's not like this but if that's how it's done, then we'll do it like that.
I've reverted the font changes now though, instead I think it would be wiser to create a font size preference, so the user can control this themselves. That's out of scope for this PR though.

And lastly, your most recent commit seems to have broken the colour inspector preview somehow, it now defaults to the standard widget background on startup. Not sure what exactly is going on there…

This was caused by a style override which has been reverted.

Would you mind reviewing again @J5lx

@J5lx J5lx self-assigned this Jul 27, 2024
Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still get the warning that I mentioned above. Other than that it looks good to me though.

@MrStevns
Copy link
Member Author

Hmm strange, it's not something i'm seeing in my build anymore.
I'm using Qt 6.7.0, what version are you on?

Also, is this with the default layout or have you moved the docks around?

@J5lx
Copy link
Member

J5lx commented Jul 29, 2024

I’m on 6.7.2 and seeing that warning with the default layout although, upon closer inspection, only some of the time. I did some debugging and I found there’s at least two issues at play here. The first one is only indirectly related to the warning, but could very well be the reason why you’re not seeing it. That’s because at its very end, initUI calls getMinHeightForWidth which reads mDockArea. However, mDockArea is only written in the dockLocationChanged signal handler which was only connected earlier in initUI. Therefore the mDockArea value is uninitialized at that time and reading it in getMinHeightForWidth results in undefined behaviour – sometimes the if branch executes, other times the “else branch”.

Only in the latter case does the second issue occur which is what actually causes the warning. That’s because at this point in time, BaseDockWidget::getMinHeightForWidth always returns -1, which is then directly passed directly into setMinimumHeight in initUI, resulting in the warning “QWidget::setMinimumSize: (scrollArea/QScrollArea) Negative sizes (0,-1) are not possible”.

Initially we'll also set a default dock value but as soon as the dock is added, it will be updated with the new dock location.
@MrStevns
Copy link
Member Author

MrStevns commented Jul 31, 2024

Ah... good point regarding mDockArea being uninitialized, I forget that it was an enum 😅

I've made a few changes, though i'm unsure about whether we should simply change -1 to 1 in BaseDockWidget rather than me simply not calling the base class at all, if it always gives a warning. What do you think?

@MrStevns MrStevns requested a review from J5lx July 31, 2024 17:13
@J5lx
Copy link
Member

J5lx commented Aug 3, 2024

Since you brought up BaseDockWidget, I had a closer look at it and realised that the entire min height handling in there is actually entirely Toolbox-specific and it can be simplified a bit by consolidating that in Toolbox itself. Please take a look: MrStevns#23

Consolidate BaseDockWidget/Toolbox minimum size handling
Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that taken care of, everything looks good to me now. Feel free to merge if you’re happy with it as well.

@MrStevns MrStevns merged commit 6a9a383 into pencil2d:master Aug 4, 2024
10 checks passed
@MrStevns
Copy link
Member Author

MrStevns commented Aug 4, 2024

Thanks Jakob! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement UI Related to the visual appearance of the program
Projects
Development

Successfully merging this pull request may close these issues.

3 participants