Lysa UI  0.0
Lysa UI —UI components for the Lysa Engine
Style Class Referenceabstract

Detailed Description

UI Widget drawing style base class.

+ Inheritance diagram for Style:

Public Member Functions

virtual ~Style () = default
 
virtual void addResource (Widget &widget, const std::string &resources) = 0
 
virtual void setOption (const std::string &name, const std::string &value)
 
std::string getOption (const std::string &name) const
 
virtual void draw (const Widget &widget, UIResource &resources, Vector2DRenderer &render, bool when) const = 0
 
virtual void resize (Widget &widget, Rect &rect, UIResource &resources) = 0
 
const float4 & getTextColor () const
 

Static Public Member Functions

static std::shared_ptr< Style > create (const std::string &name="3D")
 

Static Public Attributes

static constexpr float DEFAULT_SCROLL_BAR_SIZE {18.0f}
 Default size of the scroll bars. More...
 
static constexpr float DEFAULT_RADIO_BUTTON_SIZE {16.0f}
 Default size of the radio buttons. More...
 
static constexpr float DEFAULT_CHECK_BOX_SIZE {16.0f}
 Default size of the check boxes. More...
 
static constexpr float DEFAULT_TREE_INDENT_SIZE {12.0f}
 Default width of a tree view indentation level. More...
 
static constexpr float DEFAULT_SORT_ARROW_SIZE {8.0f}
 Default width of a table sort direction indicator. More...
 
static constexpr float DEFAULT_KNOB_SIZE {48.0f}
 Default size of the knobs. More...
 

Protected Member Functions

virtual void init ()
 
virtual void updateOptions ()
 
virtual void updateColorOptions ()
 
void updateSizeOptions ()
 
float4 extractColor (const std::string &option, float r, float g, float b, float a=1.0f) const
 
float4 extractColor (const std::string &option, const float4 &defaultColor) const
 
float extractSize (const std::string &option, float defaultSize) const
 

Static Protected Member Functions

static float squareWidth (const Widget &widget, float size)
 

Protected Attributes

float4 focus {}
 
float4 selected {}
 
float4 highlight {}
 
float4 cursor {}
 
float4 shadowDark {}
 
float4 shadowBright {}
 
float4 fgUp {}
 
float4 fgDown {}
 
float4 button {}
 
float4 treeLines {}
 
float4 gridLines {}
 
float4 textColor {1.0f, 1.0f, 1.0f, 1.0f}
 
float scrollBarSize {DEFAULT_SCROLL_BAR_SIZE}
 
float radioButtonSize {DEFAULT_RADIO_BUTTON_SIZE}
 
float checkBoxSize {DEFAULT_CHECK_BOX_SIZE}
 
float treeIndentSize {DEFAULT_TREE_INDENT_SIZE}
 
float sortArrowSize {DEFAULT_SORT_ARROW_SIZE}
 
float knobSize {DEFAULT_KNOB_SIZE}
 

Constructor & Destructor Documentation

virtual ~Style ( )
virtualdefault

Member Function Documentation

virtual void addResource ( Widget widget,
const std::string &  resources 
)
pure virtual

Create a resource from a resources description string.

Parameters
widgetWidget to associate resources with.
resourcesString describing the resources.

Implemented in lysa::ui::StyleBase::addResource()

static std::shared_ptr<Style> create ( const std::string &  name = "3D")
static

Creates one of the built-in styles.

Parameters
nameName of the style : 3D for the classic 3D look (StyleClassic), material for the Material Design look (StyleMaterial).
virtual void draw ( const Widget widget,
UIResource resources,
Vector2DRenderer &  render,
bool  when 
) const
pure virtual

Draws a widget.

Parameters
widgetWidget to draw.
resourcesResources used for drawing this widget.
renderThe 2D renderer.
whenTrue = before drawing children, False = after.

Implemented in lysa::ui::StyleBase::draw()

float4 extractColor ( const std::string &  option,
const float4 &  defaultColor 
) const
protected
float4 extractColor ( const std::string &  option,
float  r,
float  g,
float  b,
float  a = 1.0f 
) const
protected
float extractSize ( const std::string &  option,
float  defaultSize 
) const
protected
std::string getOption ( const std::string &  name) const

Returns a style-specific option value.

const float4& getTextColor ( ) const
inline

Returns the default color of the texts.

virtual void init ( )
inlineprotectedvirtual
virtual void resize ( Widget widget,
Rect &  rect,
UIResource resources 
)
pure virtual

Adjusts a widget size to style specific constraints.

Parameters
widgetThe widget being resized.
rectThe rectangle to adjust.
resourcesThe widget's UI resources.

Implemented in lysa::ui::StyleBase::resize()

virtual void setOption ( const std::string &  name,
const std::string &  value 
)
virtual

Sets a style-specific option.

static float squareWidth ( const Widget widget,
float  size 
)
staticprotected
virtual void updateColorOptions ( )
protectedvirtual
virtual void updateOptions ( )
protectedvirtual
void updateSizeOptions ( )
protected

Member Data Documentation

float4 button {}
protected
float checkBoxSize {DEFAULT_CHECK_BOX_SIZE}
protected
float4 cursor {}
protected
constexpr float DEFAULT_CHECK_BOX_SIZE {16.0f}
staticconstexpr

Default size of the check boxes.

constexpr float DEFAULT_KNOB_SIZE {48.0f}
staticconstexpr

Default size of the knobs.

constexpr float DEFAULT_RADIO_BUTTON_SIZE {16.0f}
staticconstexpr

Default size of the radio buttons.

constexpr float DEFAULT_SCROLL_BAR_SIZE {18.0f}
staticconstexpr

Default size of the scroll bars.

constexpr float DEFAULT_SORT_ARROW_SIZE {8.0f}
staticconstexpr

Default width of a table sort direction indicator.

constexpr float DEFAULT_TREE_INDENT_SIZE {12.0f}
staticconstexpr

Default width of a tree view indentation level.

float4 fgDown {}
protected
float4 fgUp {}
protected
float4 focus {}
protected
float4 gridLines {}
protected
float4 highlight {}
protected
float knobSize {DEFAULT_KNOB_SIZE}
protected
float radioButtonSize {DEFAULT_RADIO_BUTTON_SIZE}
protected
float scrollBarSize {DEFAULT_SCROLL_BAR_SIZE}
protected
float4 selected {}
protected
float4 shadowBright {}
protected
float4 shadowDark {}
protected
float sortArrowSize {DEFAULT_SORT_ARROW_SIZE}
protected
float4 textColor {1.0f, 1.0f, 1.0f, 1.0f}
protected
float treeIndentSize {DEFAULT_TREE_INDENT_SIZE}
protected
float4 treeLines {}
protected