Add Click Margin Theme Constant for BaseButton - #116763
Conversation
078a1a2 to
a7636d4
Compare
|
Is there any chance we could bring this into 4.8? |
|
Could you rebase this to retrigger the artifact generation? |
a7636d4 to
e1e3707
Compare
|
I would like to get feedback if the implementation to override the method |
e1e3707 to
ac1f708
Compare
|
Sorry, I will need you to rebase one more time to include a CI fix that was just merged. |
ac1f708 to
bb88582
Compare
|
Two issues:
|
Not sure if this is needed. Overriding |
But the margin also affects the hover and oder stuff so I'm not a fan of |
You're right, maybe it's too much.
|
There was a problem hiding this comment.
Tested locally, it works as expected. Code looks good to me.
Some feedback:
-
It's possible to use negative hit margins, which makes the button harder to hit with the mouse (clicking on the button's edges won't press it).
- With large negative values, the rect size can become negative, causing this error to be spammed:
ERROR: Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size.
at: has_point (./core/math/rect2.h:185)
I would clamp the final rect size to 0 to avoid this.
-
To improve usability, the editor could use a default hit margin of
Math::round(2 * EDSCALE)pixels on desktop platforms, andMath::round(4 * EDSCALE)pixels on the Android editor (for touchscreens).- The slight margin on desktop platforms is designed to help when moving the mouse quickly and clicking on various buttons, so you don't need to be as precise. It's subtle, but should help a lot already.
bb88582 to
3ef0cdf
Compare
I think it's better to use the I also added the |
BaseButtonBaseButton
There was a problem hiding this comment.
Works great now 🙂
The click margin in the editor is subtle, but it should help avoid a lot of missed clicks in the long run, particularly between aligned buttons (like the filter category icons in the Output panel).
While testing this, I noticed it's not possible to override theme items on an entire abstract class in the Theme editor with either of the ways to add new theme items:
click_margin doesn't appear in search results and can't be overriden at all using the Manage Items... dialog. It can be overridden using the sidebar still (the first method), but only on BaseButton subclasses (Button, LinkButton, TextureButton).
In the long term, we should base the Android click margin based on the input method used to perform the input, but this can be implemented in a future PR (likely by introducing click_margin_touch and keeping the current constant for mouse usage only). This depends on #110893 being implemented first, so that it can distinguish touch inputs from mouse inputs.
This constant could also be implemented in LineEdit and TextEdit in future PRs, as it would also help improve usability for those controls.
3ef0cdf to
81007a8
Compare
The linked PR is already merged?
A lot of Control Nodes would benefit from it. |
|
Thanks! |
…rgin Add Click Margin Theme Constant for `BaseButton`
Closes godotengine/godot-proposals#4338
This adds a Hit Margin Theme Constant for BaseButton.
The only way I found to implement this was by overriding the has_point for the BaseButton. This is needed since the BaseButton uses gui_input for detecting input and gui_input is only be called when has_point is true.
base_button_hit_margin.mp4