Theme

class 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 Strings).

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.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
inner class Rule(val selector: Selector)

A Rule is the combination of the Selector, which determines which Nodes will be affected by the rule, and the RuleSettings which contain the property values that will be set.

Properties

Link copied to clipboard
Link copied to clipboard

This font is used when converting from em to LogicalPixels.

Link copied to clipboard

Note, adding new rules will NOT affect a scene until applyToScene is called.

Functions

Link copied to clipboard
infix fun combineWith(other: Theme): Theme
Link copied to clipboard
Link copied to clipboard
fun dump()

For debugging only, prints the Theme to the console. I've tried to make the debugging information as close to the DSL as possible, but there are differences, so you can't take the output of dump and use it as actual Theme DSL code :-(

Link copied to clipboard
Link copied to clipboard