Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
StyleSpec Class Reference

#include <StyleSpec.h>

+ Collaboration diagram for StyleSpec:

Public Types

enum  Property {
  TEXTCOLOR , BGCOLOR , BGCOLOR_HOVERED , BGCOLOR_PRESSED ,
  NOCLIP , BORDER , BGIMG , BGIMG_HOVERED ,
  BGIMG_MIDDLE , BGIMG_PRESSED , FGIMG , FGIMG_HOVERED ,
  FGIMG_MIDDLE , FGIMG_PRESSED , ALPHA , CONTENT_OFFSET ,
  PADDING , FONT , FONT_SIZE , COLORS ,
  BORDERCOLORS , BORDERWIDTHS , SOUND , SPACING ,
  SIZE , NUM_PROPERTIES , NONE
}
 
enum  State : u8 {
  STATE_DEFAULT = 0 , STATE_FOCUSED = 1 << 0 , STATE_HOVERED = 1 << 1 , STATE_PRESSED = 1 << 2 ,
  NUM_STATES = 1 << 3 , STATE_INVALID = 1 << 4
}
 

Public Member Functions

std::string get (Property prop, std::string def) const
 
void set (Property prop, const std::string &value)
 
State getState () const
 Gets the state that this style is intended for.
 
void addState (State state)
 Set the given state on this style.
 
video::SColor getColor (Property prop, video::SColor def) const
 
video::SColor getColor (Property prop) const
 
std::array< video::SColor, 4 > getColorArray (Property prop, std::array< video::SColor, 4 > def) const
 
std::array< s32, 4 > getIntArray (Property prop, std::array< s32, 4 > def) const
 
irr::core::rect< s32 > getRect (Property prop, irr::core::rect< s32 > def) const
 
irr::core::rect< s32 > getRect (Property prop) const
 
v2f32 getVector2f (Property prop, v2f32 def) const
 
v2s32 getVector2i (Property prop, v2s32 def) const
 
v2s32 getVector2i (Property prop) const
 
gui::IGUIFont * getFont () const
 
video::ITexture * getTexture (Property prop, ISimpleTextureSource *tsrc, video::ITexture *def) const
 
video::ITexture * getTexture (Property prop, ISimpleTextureSource *tsrc) const
 
bool getBool (Property prop, bool def) const
 
bool isNotDefault (Property prop) const
 
bool hasProperty (Property prop) const
 
StyleSpecoperator|= (const StyleSpec &other)
 
StyleSpec operator| (const StyleSpec &other) const
 

Static Public Member Functions

static Property GetPropertyByName (const std::string &name)
 
static State getStateByName (const std::string &name)
 Parses a name and returns the corresponding state enum.
 
static StyleSpec getStyleFromStatePropagation (const std::array< StyleSpec, NUM_STATES > &styles, State state)
 Using a list of styles mapped to state values, calculate the final.
 

Private Member Functions

bool parseArray (const std::string &value, std::vector< std::string > &arr) const
 
bool parseRect (const std::string &value, irr::core::rect< s32 > *parsed_rect) const
 
bool parseVector2f (const std::string &value, v2f32 *parsed_vec) const
 

Private Attributes

std::array< bool, NUM_PROPERTIESproperty_set {}
 
std::array< std::string, NUM_PROPERTIESproperties
 
State state_map = STATE_DEFAULT
 

Member Enumeration Documentation

◆ Property

Enumerator
TEXTCOLOR 
BGCOLOR 
BGCOLOR_HOVERED 
BGCOLOR_PRESSED 
NOCLIP 
BORDER 
BGIMG 
BGIMG_HOVERED 
BGIMG_MIDDLE 
BGIMG_PRESSED 
FGIMG 
FGIMG_HOVERED 
FGIMG_MIDDLE 
FGIMG_PRESSED 
ALPHA 
CONTENT_OFFSET 
PADDING 
FONT 
FONT_SIZE 
COLORS 
BORDERCOLORS 
BORDERWIDTHS 
SOUND 
SPACING 
SIZE 
NUM_PROPERTIES 
NONE 

◆ State

enum StyleSpec::State : u8
Enumerator
STATE_DEFAULT 
STATE_FOCUSED 
STATE_HOVERED 
STATE_PRESSED 
NUM_STATES 
STATE_INVALID 

Member Function Documentation

◆ addState()

void StyleSpec::addState ( State state)
inline

Set the given state on this style.

References FATAL_ERROR_IF, NUM_STATES, and state_map.

Referenced by GUIFormSpecMenu::parseStyle().

+ Here is the caller graph for this function:

◆ get()

std::string StyleSpec::get ( Property prop,
std::string def ) const
inline

References properties.

Referenced by operator|=(), and GUIFormSpecMenu::parseStyle().

+ Here is the caller graph for this function:

◆ getBool()

bool StyleSpec::getBool ( Property prop,
bool def ) const
inline

References is_yes(), and properties.

Referenced by GUIButton::setFromStyle(), and GUIScene::setStyles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColor() [1/2]

video::SColor StyleSpec::getColor ( Property prop) const
inline

References FATAL_ERROR_IF, parseColorString(), and properties.

+ Here is the call graph for this function:

◆ getColor() [2/2]

video::SColor StyleSpec::getColor ( Property prop,
video::SColor def ) const
inline

References parseColorString(), and properties.

Referenced by GUIButton::setFromStyle(), and GUIScene::setStyles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColorArray()

std::array< video::SColor, 4 > StyleSpec::getColorArray ( Property prop,
std::array< video::SColor, 4 > def ) const
inline

References parseArray(), parseColorString(), and properties.

+ Here is the call graph for this function:

◆ getFont()

gui::IGUIFont * StyleSpec::getFont ( ) const
inline

References FontSpec::bold, FM_Mono, FM_Standard, FONT, FONT_SIZE, FONT_SIZE_UNSPECIFIED, g_fontengine, FontEngine::getFont(), FontEngine::getFontSize(), FontSpec::italic, FontSpec::mode, properties, FontSpec::size, split(), stof, and stoi.

Referenced by GUIButton::setFromStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIntArray()

std::array< s32, 4 > StyleSpec::getIntArray ( Property prop,
std::array< s32, 4 > def ) const
inline

References parseArray(), properties, and stoi.

+ Here is the call graph for this function:

◆ GetPropertyByName()

static Property StyleSpec::GetPropertyByName ( const std::string & name)
inlinestatic

References ALPHA, BGCOLOR, BGCOLOR_HOVERED, BGCOLOR_PRESSED, BGIMG, BGIMG_HOVERED, BGIMG_MIDDLE, BGIMG_PRESSED, BORDER, BORDERCOLORS, BORDERWIDTHS, COLORS, CONTENT_OFFSET, FGIMG, FGIMG_HOVERED, FGIMG_MIDDLE, FGIMG_PRESSED, FONT, FONT_SIZE, NOCLIP, NONE, PADDING, SIZE, SOUND, SPACING, and TEXTCOLOR.

Referenced by GUIFormSpecMenu::parseStyle().

+ Here is the caller graph for this function:

◆ getRect() [1/2]

irr::core::rect< s32 > StyleSpec::getRect ( Property prop) const
inline

References FATAL_ERROR_IF, parseRect(), and properties.

+ Here is the call graph for this function:

◆ getRect() [2/2]

irr::core::rect< s32 > StyleSpec::getRect ( Property prop,
irr::core::rect< s32 > def ) const
inline

References parseRect(), and properties.

Referenced by GUIButton::setFromStyle(), and GUIButtonImage::setFromStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getState()

State StyleSpec::getState ( ) const
inline

Gets the state that this style is intended for.

References state_map.

Referenced by GUIButton::setFromStyle().

+ Here is the caller graph for this function:

◆ getStateByName()

static State StyleSpec::getStateByName ( const std::string & name)
inlinestatic

Parses a name and returns the corresponding state enum.

References STATE_DEFAULT, STATE_FOCUSED, STATE_HOVERED, STATE_INVALID, and STATE_PRESSED.

Referenced by GUIFormSpecMenu::parseStyle().

+ Here is the caller graph for this function:

◆ getStyleFromStatePropagation()

static StyleSpec StyleSpec::getStyleFromStatePropagation ( const std::array< StyleSpec, NUM_STATES > & styles,
State state )
inlinestatic

Using a list of styles mapped to state values, calculate the final.

References STATE_DEFAULT, and state_map.

Referenced by GUIButton::setFromState(), and GUIScene::setStyles().

+ Here is the caller graph for this function:

◆ getTexture() [1/2]

video::ITexture * StyleSpec::getTexture ( Property prop,
ISimpleTextureSource * tsrc ) const
inline

References FATAL_ERROR_IF, ISimpleTextureSource::getTexture(), and properties.

+ Here is the call graph for this function:

◆ getTexture() [2/2]

video::ITexture * StyleSpec::getTexture ( Property prop,
ISimpleTextureSource * tsrc,
video::ITexture * def ) const
inline

References ISimpleTextureSource::getTexture(), and properties.

Referenced by GUIButton::setFromStyle(), and GUIButtonImage::setFromStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVector2f()

v2f32 StyleSpec::getVector2f ( Property prop,
v2f32 def ) const
inline

References parseVector2f(), and properties.

+ Here is the call graph for this function:

◆ getVector2i() [1/2]

v2s32 StyleSpec::getVector2i ( Property prop) const
inline

References FATAL_ERROR_IF, parseVector2f(), and properties.

+ Here is the call graph for this function:

◆ getVector2i() [2/2]

v2s32 StyleSpec::getVector2i ( Property prop,
v2s32 def ) const
inline

References parseVector2f(), and properties.

Referenced by GUIButton::setFromStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasProperty()

bool StyleSpec::hasProperty ( Property prop) const
inline

References property_set.

Referenced by operator|=(), and GUIFormSpecMenu::parseStyle().

+ Here is the caller graph for this function:

◆ isNotDefault()

bool StyleSpec::isNotDefault ( Property prop) const
inline

References properties.

Referenced by GUIButton::setFromStyle(), and GUIButtonImage::setFromStyle().

+ Here is the caller graph for this function:

◆ operator|()

StyleSpec StyleSpec::operator| ( const StyleSpec & other) const
inline

◆ operator|=()

StyleSpec & StyleSpec::operator|= ( const StyleSpec & other)
inline

References get(), hasProperty(), NUM_PROPERTIES, and set().

+ Here is the call graph for this function:

◆ parseArray()

bool StyleSpec::parseArray ( const std::string & value,
std::vector< std::string > & arr ) const
inlineprivate

References split(), and warningstream.

Referenced by getColorArray(), and getIntArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseRect()

bool StyleSpec::parseRect ( const std::string & value,
irr::core::rect< s32 > * parsed_rect ) const
inlineprivate

References split(), stoi, and warningstream.

Referenced by getRect(), and getRect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseVector2f()

bool StyleSpec::parseVector2f ( const std::string & value,
v2f32 * parsed_vec ) const
inlineprivate

References split(), stof, and warningstream.

Referenced by getVector2f(), getVector2i(), and getVector2i().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

void StyleSpec::set ( Property prop,
const std::string & value )
inline

References properties, and property_set.

Referenced by operator|=(), and GUIFormSpecMenu::parseStyle().

+ Here is the caller graph for this function:

Member Data Documentation

◆ properties

◆ property_set

std::array<bool, NUM_PROPERTIES> StyleSpec::property_set {}
private

Referenced by hasProperty(), and set().

◆ state_map

State StyleSpec::state_map = STATE_DEFAULT
private

The documentation for this class was generated from the following file: