-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix EditorProperty spacing #93089
Fix EditorProperty spacing #93089
Conversation
It would be good to check that it doesn't look weird after this PR. I guess it should be fine as they're used on different lines, and not as two changing states of the same button. |
@@ -291,7 +302,7 @@ void EditorProperty::_notification(int p_what) { | |||
} else { | |||
draw_texture(checkbox, check_rect.position, color2); | |||
} | |||
int check_ofs = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("CheckBox")); | |||
int check_ofs = checkbox->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree")); |
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.
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.
Just seems excessive in the context of EditorProperty because it's the only button in EditorProperty that you can independently control the "padding" of (i.e why only checkbox and not the revert button, key button, etc?), and also the way it was implemented is it was adding two constants together which I think makes theming less predictable
If we think that the flexibility of specifying the checkbox spacing independently from EditorProperty "global" horizontal spacing is important I'd say it would probably make more sense to only take the checkbox h_separation into the account there
@@ -88,17 +88,17 @@ Size2 EditorProperty::get_minimum_size() const { | |||
|
|||
if (keying) { | |||
Ref<Texture2D> key = get_editor_theme_icon(SNAME("Key")); | |||
ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); | |||
ms.width += key->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree")); |
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.
That would be for a future PR, but we should probably move these and other theme constants to a ThemeCache struct like we have in some other editor controls (e.g. EditorFileDialog
).
Thanks! |
EditorProperty was trying to use a wrong constant for horizontal separation resulting in broken spacing (most noticeably for the keying icon). This PR adds missing horizontal space and also centers the key icon vertically
Before/After:
Tested with all of the possible icons that may appear in EditorProperty and a custom theme:
Also tested RTL:
Note:
Key.svg
shape was not centered vertically in the svg file because there's also aKeyNext.svg
which includes an additional plus sign element below the key. It's likely best to makeKey.svg
centered regardless (which I did in this PR), otherwise it looks broken in the editor. Spent some time trying to figure out why it isn't centered before I realised it's the icon itself