Theme
A theme defines all the visual aspects of glok controls, as well as some non-visual aspects (e.g. which controls accept input focus).
It does this by changing values of StylableProperties based on rules, similar to CSS. Note, properties which are not StylableProperty will be ignored.
The syntax is very different from CSS, but the premise is the same, there are Selectors, which govern which Nodes will be affected, and a set of property values. Together these form a Rule.
The Tantalum can be viewed on-line here : Default Theme.kt
There are two basic Selectors : StyleSelector and PseudoStyleSelector. These match against Nodes using Node.styles and Node.pseudoStyles. (which are sets of String
s).
More complex Selectors can be created using logical operators and
and or
, as well as the child
and ancestor
functions.
If two Rules both match against the same Node, and define the same property, then the value from the last Rule will win (i.e. lower down the theme definition).
By convention only, PseudoStyles
start with a colon. e.g. ":focused", ":selected", ":armed" etc. Regular Styles
are either the name of the control (e.g. "text_area" or "button") or the role they play within a control, with a period as the prefix. (e.g. ".container", ".editor", ".divider" etc. ) However, for each Style
and PseudoStyle
used by Glok, there is a const String
. e.g. TEXT_AREA = "text_area", CONTAINER = ".container" and FOCUSED = ":focuses". I prefer to use these, because then there no room for typos.
Oops, I didn't mention that Glok's themes are compiled, not interpreted like CSS. I like compilers ;-)
Themes can be merged, so you could take the default theme, and merge it with a (small) theme of your own making. See combineWith.
See Scene for a Class Diagram.
Types
Properties
This font is used when converting from em
to LogicalPixels.
Note, adding new rules will NOT affect a scene until applyToScene is called.