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

CheckButton checked/unchecked icon can be on both sides #104463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pafuent
Copy link
Contributor

@pafuent pafuent commented Mar 22, 2025

CheckButtonRightLeft

If inverted is set to true on CheckButton the checked/unchecked icon will be drawn in the right for for right-to-left layouts or in the left for left-to-right layouts.

Naming is hard, so I'm open to name changes.

Inspiration: https://youtu.be/cJ5Rkk5fnGg?list=PLeG_dAglpVo6TS0q858NajyeglRuvb7hs&t=923

@pafuent pafuent requested review from a team as code owners March 22, 2025 00:55
@pafuent
Copy link
Contributor Author

pafuent commented Mar 22, 2025

FYI @njamster

@Calinou Calinou added this to the 4.x milestone Mar 22, 2025
@Calinou
Copy link
Member

Calinou commented Mar 22, 2025

From an UX perspective, is there a good reason to invert the CheckButton position while staying on a given typesetting configuration (LTR or RTL)? I can understand the aesthetics aspect, but I wonder if this can decrease usability if not used carefully.

@pafuent pafuent force-pushed the check_button_checked_unchecked_icon_can_be_on_left_or_right_sides branch from f53c758 to 610c51d Compare March 22, 2025 01:05
If `inverted` is set to true on `CheckButton` the checked/unchecked icon
will be drawn in the right for for right-to-left layouts
or in the left for left-to-right layouts.
@pafuent pafuent force-pushed the check_button_checked_unchecked_icon_can_be_on_left_or_right_sides branch from 610c51d to 23f72c3 Compare March 22, 2025 01:12
@pafuent
Copy link
Contributor Author

pafuent commented Mar 22, 2025

if this can decrease usability if not used carefully

If you are worried if this wont work when you switch from LTR or RTL (or vice-versa) the code takes that in consideration and invert works as expected in both cases:

  • inverted on LTR means checked/unchecked icon on the left
  • inverted on RTL means checked/unchecked mirrored icon on the right

@AThousandShips
Copy link
Member

I think "invert" is too generic, at first glance I'd assume it meant the checked state was inverted so it was visible as checked when unpressed and vice versa

@Mickeon
Copy link
Contributor

Mickeon commented Mar 22, 2025

I may suggest inverted_side or mirrored but there may be no real winner here. As of writing this I cannot check, but there may be some Controls that have similar behavior to take inspiration from.

Either way, me too. I'm unsure what purpose this serves UX-wise. Even if it was talked about, I'm not sure it's useful.

@pafuent
Copy link
Contributor Author

pafuent commented Mar 28, 2025

mirrored is being used as a suffix for theme items related to right-to-left layouts, so could be confusing to use it because in this case it will affect right-to-left and left-to-right layouts.

@njamster
Copy link

Personally, I think a checkbox_position enum with two options, "Beginning" and "End", would work best?

As to the purpose of this: I'll openly admit it's mostly motivated by aesthetics and personal preference. As mentioned in my talk, it can be worked around relatively easily – so personally I don't care if this is added or not. That being said, the workaround is quite verbose (involving three nodes and a script) for how little it achieves (moving the checkbox).

@KoBeWi
Copy link
Member

KoBeWi commented Mar 31, 2025

You can work it around by swapping CheckBox icons with CheckButton's. You don't even need a script.

godot.windows.editor.dev.x86_64_4qbZvu0Xnv.mp4

@njamster
Copy link

Nice catch, thanks! :) Still, I'd argue that using another node with a different texture isn't exactly an obvious solution to the problem, while the documentation recommends choosing between CheckButton and CheckBox based on whether toggling it has an immediate effect or not. So while this simplifies the workaround, I'd still consider it an improvement if no workaround would be needed in the first place, and one could pick the position of the toggle button manually.

@KoBeWi
Copy link
Member

KoBeWi commented Mar 31, 2025

tbh we could merge CheckBox and CheckButton into a single class with 3 modes (checkbox, checkbutton, radio button), with option to display the icon on either side. But that's Godot 5 material.

@MarianoGnu
Copy link
Contributor

MarianoGnu commented Mar 31, 2025

I believe this toggle should be part of the theme settings that could be overridden by the node, but usually if you set it in one Button, you want it to all of them, so changing it in the default theme sounds like the best place to do it.
I also agree the name invert is too generic and is confusing because user may not understand the context

@pafuent
Copy link
Contributor Author

pafuent commented Apr 1, 2025

I'll try to come up with an updated version that address most of the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants