class

Egui::StyleSheet

Inherits Reference < Object

Constructors

Instance methods

[](path : String) : StyleClass

The class for path, created on first touch (defining a child never requires defining its ancestors first).

Source
[]?(path : String) : StyleClass | Nil
Source
classes

Introspection: every defined class path, tree order.

Source
dump(io : IO) : Nil

Introspection: print the whole tree (classes → states → keys with values) — puts ctx.stylesheet or log it to see every key.

Source
resolve(path : String, state : String | Nil = nil) : StyleVars

The class+state vars, merged in two cascade layers and cached: the returned bag is the same object frame after frame until a rule changes something — read it, do not mutate it.

  1. class layer (defaults): ancestor vars root→leaf — the more specific class wins per key;
  2. state layer: every matching state overlay root→leaf, merged on top — states ALWAYS override class defaults, and the leaf state wins among states (CSS: classes are defaults, pseudo-class rules beat them).
Source
rule(selector : String, vars : Hash(String, StyleValue)) : self

Define/extend a rule CSS-style: rule("sidebar.tab:selected", …) splits into class "sidebar.tab" + state "selected". Merges into whatever the selector already holds (per-key override) and drops the resolve cache.

Source
selectors

Introspection: every defined selector — "class" and "class:state".

Source
state_vars(path : String, state : String) : StyleVars | Nil

The raw (unmerged) state overlay defined for one class+state — the state layer of the cascade, applied on top of the class layer but under widget #style overrides.

Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source
touch

Drop the cached merges manually (after mutating a StyleClass directly through []; rule does this itself).

Source
unset(selector : String, key : String) : self

Remove one key from a class/state rule (the inspector's "reset"): the slot goes back to inheriting the theme. Unset keys and unknown selectors are no-ops.

Source