Skip to content

Switch buttons #6099

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

Absotively
Copy link

@Absotively Absotively commented Jul 23, 2025

This adds SwitchButton, a switch button control. This is intended mainly for power buttons in things like the APC UI and gas manipulation device UIs.

space-wizards/space-station-14#39161 adds styles for this control to space-station-14 and changes the APC UI to use it.

Description and technical details

I've added some screenshots that show how the control's layout works. These use the styles from space-wizards/space-station-14#39161. That PR will not actually implement all of the UI changes shown in these screenshots. It only changes the APC menu. I plan to change the gas pump status button in a later PR, and I currently do not plan to actually change the intercom menu at all, but it makes a useful layout example.

The control has three visible components. From left to right, they are:

  • an optional main label describing what the switch controls;
  • a toggle switch icon;
  • and a label describing the current state.
image

Clicking any of these toggles the button state.

The control has localizable default state labels of "Off" and "On"; I think having state labels improves usability in most of the cases where this control would be used. Microsoft uses default "Off" and "On" labels and encourages developers to use them; it seems likely they'd provide different guidance if these default labels caused many localization issues.

The default state labels can be overwritten by setting OffStateText and OnStateText.

The state label portion of the switch reserves overlapping space for both labels, so the button's size and layout don't change when the button is clicked.

If there is a main label, and the button is expanded horizontally, the excess space is put at the end of the main label. This means that if multiple switch buttons with the same labels and width are stacked, for instance in a vertical BoxContainer, they will all line up nicely.
image

If the main label is empty, the icon and state label are aligned left.
image

It is my understanding that RobustToolbox doesn't support right-to-left text; if I am wrong about that then SwitchButton will need some additional work to handle rtl layouts.

CheckButton

The CheckButton class appears to have originally been intended to be this type of control. It inherits from Button and I do not believe it has ever had any actual differences from Button.

It is currently used in three places, all of which are have layouts based around it being regular button. As such, removing it or turning it into the actual switch button implementation would cause problems for old game versions.

I have added [Obsolete] to CheckButton. In space-wizards/space-station-14#39161, all uses of CheckButton are replaced with Button.

@ArtisticRoomba
Copy link
Member

Mmmmm, good cooking.

@Absotively Absotively marked this pull request as ready for review July 23, 2025 03:54
@sowelipililimute
Copy link
Member

first impression, it's nice that the switch is always bundled with the label

but, the design of the switch itself is a bit ambiguous & relies too much on something that's not colourblind accessible

detailed thoughts for the specifics of that texture will be left on that PR when i get the time

@PJB3005
Copy link
Member

PJB3005 commented Jul 23, 2025

Bikeshedding the texture for accessibility: we could put an "I" and "O" symbol on the sides. Admittedly it may be a bit abstract in some cases but it's pretty standard iconography.

@Absotively
Copy link
Author

I appreciate the feedback on the texture. I'm going to respond in space-wizards/space-station-14#39161 since that's where the texture is.

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

Successfully merging this pull request may close these issues.

4 participants