-
Notifications
You must be signed in to change notification settings - Fork 60
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
Widget sizeHint, button/box sizePolicy fixes #130
Conversation
I don't think Time Slice has this option anymore. |
71c7508
to
8ab8f1d
Compare
orangewidget/gui.py
Outdated
else: | ||
separator(widget) | ||
warnings.warn("'addSpace' has been deprecated. Use gui.separator instead.", | ||
DeprecationWarning, stacklevel=3) |
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.
Better deprecate (someone test this pls I might be doing it wrong)
3408551
to
b328515
Compare
While I do agree that this branch combined with the PR in Orange3 makes Orange look nicer, I can not merge this. For me, there is too much new additional magic in miscellanea (allowing Mac-specific changes also bother me somewhat, but if that is really needed to fix strange alignments, well, then fine. These I could actually merge... @ales-erjavec, do you have any time to review this? If you say these code patterns are fine, then I'll accept them. |
I can merge this PR if:
|
orangewidget/gui.py
Outdated
if button.style().metaObject().className() == 'QMacStyle': | ||
btnpaddingbox = vBox(widget, margin=0, spacing=0) | ||
separator(btnpaddingbox, 0, 4) # lines up with a WA_LayoutUsesWidgetRect checkbox | ||
button.outer_box = btnpaddingbox |
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.
Why would you assume anything related to checkbox here?
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.
Autocommit is a button next to a checkbox. Generally you want all buttons in a row (QHBoxLayout) at the same height, so it's set globally.
Without this, still keeping Qt.WA_LayoutUsesWidgetRect
will misalign the checkbox and button.
I don't like it. I already cannot reason about what the existing code does. This would make it even worse. If you do remove I would keep some changes that fix layouts locally, I.e. the one that removes near global |
orangewidget/gui.py
Outdated
if box and parent and box is not parent and parent.layout() and parent.layout().spacing() == -1: | ||
parent.layout().setSpacing(8) |
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.
Remove this. If you keep it add addToLayout
to the if
condition. But really remove this.
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.
MacStyle is weird. It doesn't use constant spacing, it uses this weird matrix to calculate spacing between two controls, depending on which one precedes the other. https://doc.qt.io/archives/qq/qq23-layouts.html
This works great if you only use control elements. But as soon as you nest controls in boxes (e.g., label + combo), the margins and spacing get really big. Our solution for this is to set the spacing on the box (if no spacing has yet been set), if you add a nested control. For this to work right, Qt.WA_LayoutUsesWidgetRect
should be set on all the controls in the parent box.
... That was our rationale, but I've removed it, and I think we'll live without it.
orangewidget/gui.py
Outdated
if widget and widget.layout() and \ | ||
isinstance(widget.layout(), QtWidgets.QVBoxLayout) and \ | ||
not widget.layout().isEmpty(): | ||
misc.setdefault('addSpaceBefore', True) |
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.
Do not add back another automagic to replace the addSpace
one.
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.
addSpaceBefore
replaced addSpace
, it's there to put separators between boxes, but not before the first box. I could make it private to the gui package, then you could disable it with addToLayout=False
.
Initially this helped align checkboxes with checkboxes in their nested boxes (e.g. with a spinbox). But, this messes with MacStyle spacing, and makes everything a bit too spaced out. If this is necessary, put all controls in their own box, or set the attribute manually.
Also fixup some spacing/margins
b328515
to
f10329c
Compare
f10329c
to
f01b90b
Compare
Issue
Widgets aren't visually consistent. It'll take a little bit of work in Orange3 and add-ons, but once we're there, everything will be nice. Most of the changes I made in the Orange3 PR simplify the code, I hope that's the case for addons too.
Description of changes
See commit history.
This was written on macOS 10.15.7, working with both QMacStyle and Plastic. Hoping Windows and Linux look ok.
Includes