Page 1 of 1

GUI: Allow different font color for checkbox & radio states

Posted: Sat Sep 17, 2016 2:12 am
by aubergine18
Unlike buttons, checkboxes and radiobuttons don't allow different colors for their different states: default, hover, clicked, disabled.

(They don't have a disabled state either, it would be nice if that could be added, along with way to disable GUI elements)

It would be nice if they had some extra prototype properties similar to those of button prototypes:

Code: Select all

default_font_color
hovered_font_color
clicked_font_color
disabled_font_color
If a modder wants to change colors when checkbox is checked or radio button is selected, it can simply listen to the associated GUI event and change the style of the GUI element to one which has alternate color scheme.

Re: GUI: Allow different font color for checkbox & radio states

Posted: Sat Sep 17, 2016 9:40 am
by ssilk
Isn't that already possible?

Re: GUI: Allow different font color for checkbox & radio states

Posted: Sat Sep 17, 2016 2:06 pm
by aubergine18
For buttons, yes = they have background image states and fort color states. But not for checkbox or radiobutton - they have background image states (the square or circle in case of checkbox/radiobutton), but not font color states. There's no events fired for the mouse states (eg. on hover) so no way to mimic the functionality via hacks either.

See __core__/prototypes/styles.lua for examples between 'button_style' and 'checkbox_style' or 'radiobutton_style' prototypes.

Note: I could be wrong - if someone has code showing it working, please post it! (Specifically: font color changing on hover and on click - via stylesheet not code hacks).

Re: GUI: Allow different font color for checkbox & radio states

Posted: Sat Sep 17, 2016 9:05 pm
by ssilk
Well, but the implementation you suggest is ... wrong (sorry :) ). You need to do that CSS like, create some definitions of
default, hovered, clicked, disabled and that includes also background images, border thickness and color, background color etc. etc. in a way, where the default can be inherited to the others, that overwrite only parts. Just like CSS.

Example: http://www.w3schools.com/CSSref/sel_hover.asp
http://www.w3schools.com/CSSref/tryit.a ... link_more1
http://www.w3schools.com/CSSref/tryit.a ... link_more2

Re: GUI: Allow different font color for checkbox & radio states

Posted: Sun Sep 18, 2016 5:52 am
by aubergine18
Yes, I'd love to do it CSS style (not sure how performant that's going to be in a game context - it works fine for browsers with decades of fine tuning, but might be too slow/cumbersome for a game to implement).

The way the game currently does it with buttons, while not ideal, is sufficient if it could be extended to checkboxes and radio buttons. It all depends on what the devs are planning to do with this planned GUI overhaul that was mentioned in the recent #FF. I'd very much like pseudo states :hover, :select, :active etc on all entities, but at the very least I'd like button-style capabilities on radio and check entities.

One other thing I'd very much like is just generally more consistency in the stylesheets and Lua API. I can see they're going for monomorphism in the approach currently taken, but I'm not sure it's an effective approach for GUI stuff. I've been chipping away at a consistent set of properties for my Style mod, like standardising top-left position of an image to a "pos" array, regardless of how the different types of images (composition, monolith, raw, animation, etc) all have different properties for defining top left (some are array, others are x,y, etc).