Widget.OverrideStyle

This mixin overrides the useStyleProperties method to direct it toward your own style class. The basic usage is simple:

static class Style : YourParentClass.Style { /* YourParentClass is frequently Widget, of course, but not always */
	// override style hints as-needed here
}
OverrideStyle!Style; // add the method
While the class is not forced to be static, for best results, it should be. A non-static class can not be inherited by other objects whereas the static one can. A property on the base class, called widget, is available for you to access its properties.

This exists just because useStyleProperties has a somewhat convoluted signature and its overrides must repeat them. Moreover, its implementation uses a stack class to optimize GC pressure from small fetches and that's a little tedious to repeat in your child classes too when you only care about changing the type.

More...
class Widget
protected static
mixin template OverrideStyle (
S...
) {}

Detailed Description

It also has a further facility to pick a wholly differnet class based on the DynamicState of the Widget. You may also just override variesWithState when you use this flag.

mixin OverrideStyle!(
	DynamicState.focus, YourFocusedStyle,
	DynamicState.hover, YourHoverStyle,
	YourDefaultStyle
)

It checks if dynamicState matches the state and if so, returns the object given.

If there is no state mask given, the next one matches everything. The first match given is used.

However, since in most cases you'll want check state inside your individual methods, you probably won't find much use for this whole-class swap out.

Meta

History

Added May 16, 2021