lxgui
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
lxgui::gui::animated_texture Class Reference

A layered_region that can draw animated sequences. More...

#include <gui_animated_texture.hpp>

Inheritance diagram for lxgui::gui::animated_texture:
lxgui::gui::layered_region lxgui::gui::region

Public Types

using base = layered_region
 

Public Member Functions

 animated_texture (utils::control_block &block, manager &mgr, const region_core_attributes &attr)
 Constructor. More...
 
std::string serialize (const std::string &tab) const override
 Prints all relevant information about this region in a string. More...
 
void render () const override
 Renders this region on the current render target. More...
 
void update (float delta) override
 Updates this region's logic. More...
 
void copy_from (const region &obj) override
 Copies a region's parameters into this texture (inheritance). More...
 
float get_speed () const
 Returns this animated_texture's animation speed (frame per second). More...
 
float get_state () const
 Returns this animated_texture's state (0: begin, 1: end). More...
 
float is_paused () const
 Check if this animated_texture is paused. More...
 
const std::string & get_texture_file () const
 Returns this texture's texture file. More...
 
color get_vertex_color (std::size_t index) const
 Returns this texture's vertex color. More...
 
void set_speed (float speed)
 Set this animated_texture's animation speed (frame per second). More...
 
void set_state (float state)
 Returns this animated_texture's state (0: begin, 1: end). More...
 
void set_paused (bool is_paused)
 Play or pause this animated_texture. More...
 
void play ()
 Play this animated_texture. More...
 
void pause ()
 Pause this animated_texture. More...
 
void stop ()
 Stop this animated_texture (stop playing and reset to start). More...
 
void set_texture (const std::string &file_name)
 Sets this texture's texture file. More...
 
void set_vertex_color (const color &c, std::size_t index=std::numeric_limits< std::size_t >::max())
 Sets this texture's vertex color. More...
 
void parse_layout (const layout_node &node) override
 Parses data from a layout_node. More...
 
utils::owner_ptr< regionrelease_from_parent () override
 Removes this region from its parent and return an owning pointer. More...
 
layer get_draw_layer () const
 Returns this layered_region's draw layer. More...
 
void set_draw_layer (layer layer_id)
 Sets this layered_region's draw layer. More...
 
int get_region_level () const
 Sets the region level. More...
 
void set_region_level (int region_level)
 Sets this layered_region's region level. More...
 
void notify_renderer_need_redraw () override
 Notifies the renderer of this region that it needs to be redrawn. More...
 
virtual void notify_borders_need_update ()
 Tells this region that its borders need updating. More...
 
virtual void notify_scaling_factor_updated ()
 Tells this region that the global interface scaling factor has changed. More...
 
const std::string & get_name () const
 Returns this region's name. More...
 
const std::string & get_raw_name () const
 Returns this region's raw name. More...
 
utils::observer_ptr< const frameget_parent () const
 Returns this region's parent. More...
 
const utils::observer_ptr< frame > & get_parent ()
 Returns this region's parent. More...
 
void destroy ()
 Forcefully removes this region from the GUI. More...
 
void set_alpha (float alpha)
 Changes this region's alpha (opacity). More...
 
float get_alpha () const
 Returns this region's alpha (opacity). More...
 
float get_effective_alpha () const
 Returns this region's effective alpha (opacity). More...
 
void show ()
 shows this region. More...
 
void hide ()
 hides this region. More...
 
void set_shown (bool is_shown)
 shows/hides this region. More...
 
bool is_shown () const
 Checks if this region is shown. More...
 
bool is_visible () const
 Checks if this region can be seen on the screen. More...
 
bool is_valid () const
 Checks if this region has all its borders correctly defined. More...
 
virtual void set_dimensions (const vector2f &dimensions)
 Changes this region's absolute dimensions (in pixels). More...
 
virtual void set_width (float abs_width)
 Changes this region's absolute width (in pixels). More...
 
virtual void set_height (float abs_height)
 Changes this region's absolute height (in pixels). More...
 
void set_relative_dimensions (const vector2f &dimensions)
 Changes this region's dimensions (relative to its parent). More...
 
void set_relative_width (float rel_width)
 Changes this region's width (relative to its parent). More...
 
void set_relative_height (float rel_height)
 Changes this region's height (relative to its parent). More...
 
const vector2fget_dimensions () const
 Returns this region's explicitly-defined width and height (in pixels). More...
 
vector2f get_apparent_dimensions () const
 Returns this region's apparent width and height (in pixels). More...
 
bool is_apparent_width_defined () const
 Checks if this region's apparent width is defined. More...
 
bool is_apparent_height_defined () const
 Checks if this region's apparent height is defined. More...
 
virtual bool is_in_region (const vector2f &position) const
 Checks if the provided coordinates are inside this region. More...
 
const std::string & get_region_type () const
 Returns the type of this region. More...
 
bool is_region_type (const std::string &type_name) const
 Checks if this region is of the provided type. More...
 
template<typename ObjectType >
bool is_region_type () const
 Checks if this region is of the provided type. More...
 
bool is_region_type (const region &obj) const
 Checks if this region is of a type equal or derived from the supplied region. More...
 
float get_bottom () const
 Returns the vertical position of this region's bottom border. More...
 
vector2f get_center () const
 Returns the position of this region's center. More...
 
float get_left () const
 Returns the horizontal position of this region's left border. More...
 
float get_right () const
 Returns the horizontal position of this region's right border. More...
 
float get_top () const
 Returns the vertical position of this region's top border. More...
 
const bounds2fget_borders () const
 Returns this region's borders. More...
 
void clear_all_anchors ()
 Removes all anchors. More...
 
void set_all_anchors (const utils::observer_ptr< region > &obj)
 Adjusts this regions anchors to fit the provided region. More...
 
void set_all_anchors (const std::string &obj_name)
 Adjusts this regions anchors to fit the provided region. More...
 
void set_anchor (const anchor_data &a)
 Adds/replaces an anchor. More...
 
template<typename... Args>
void set_anchor (Args &&... args)
 Adds/replaces an anchor. More...
 
bool depends_on (const region &obj) const
 Checks if this region depends on another. More...
 
std::size_t get_anchor_count () const
 Returns the number of defined anchors. More...
 
anchormodify_anchor (point p)
 Returns one of this region's anchor to modify it. More...
 
const anchorget_anchor (point p) const
 Returns one of this region's anchor. More...
 
const std::array< std::optional< anchor >, 9 > & get_anchors () const
 Returns all of this region's anchors. More...
 
float round_to_pixel (float value, utils::rounding_method method=utils::rounding_method::nearest) const
 Round an absolute position on screen to the nearest physical pixel. More...
 
vector2f round_to_pixel (const vector2f &position, utils::rounding_method method=utils::rounding_method::nearest) const
 Round an absolute position on screen to the nearest physical pixel. More...
 
void add_anchored_object (region &obj)
 Notifies this region that another one is anchored to it. More...
 
void remove_anchored_object (region &obj)
 Notifies this region that another one is no longer anchored to it. More...
 
bool is_virtual () const
 Checks if this region is virtual. More...
 
void set_manually_inherited (bool manually_inherited)
 Flags this region as manually inherited or not. More...
 
bool is_manually_inherited () const
 Checks if this object is manually inherited. More...
 
virtual utils::observer_ptr< const frame_rendererget_effective_frame_renderer () const
 Returns the renderer of this object or its parents. More...
 
utils::observer_ptr< frame_rendererget_effective_frame_renderer ()
 Returns the renderer of this object or its parents, nullptr if none. More...
 
const std::vector< utils::observer_ptr< region > > & get_anchored_objects () const
 Returns the list of all objects that are anchored to this one. More...
 
virtual void notify_loaded ()
 Notifies this region that it has been fully loaded. More...
 
bool is_loaded () const
 Checks if this region has been fully loaded. More...
 
virtual void notify_visible ()
 Notifies this region that it is now visible on screen. More...
 
virtual void notify_invisible ()
 Notifies this region that it is no longer visible on screen. More...
 
void set_addon (const addon *a)
 Sets the addon this frame belongs to. More...
 
const addonget_addon () const
 Returns this frame's addon. More...
 
std::string parse_file_name (const std::string &file_name) const
 Convert an addon-relative file path to a application-relative path. More...
 
managerget_manager ()
 Returns this region's manager. More...
 
const managerget_manager () const
 Returns this region's manager. More...
 
registryget_registry ()
 Returns the UI object registry, which keeps track of all objects in the UI. More...
 
const registryget_registry () const
 Returns the UI object registry, which keeps track of all objects in the UI. More...
 
void remove_glue ()
 Removes the Lua glue. More...
 

Static Public Member Functions

static void register_on_lua (sol::state &lua)
 Registers this region class to the provided Lua state. More...
 

Static Public Attributes

static constexpr const char * class_name = "AnimatedTexture"
 

Protected Member Functions

virtual void parse_size_node_ (const layout_node &node)
 
virtual void parse_anchor_node_ (const layout_node &node)
 
color parse_color_node_ (const layout_node &node)
 
vector2< std::optional< float > > parse_offset_node_ (const layout_node &node)
 
vector2< float > parse_offset_node_or_ (const layout_node &node, float fallback)
 
std::pair< anchor_type, vector2< std::optional< float > > > parse_dimension_node_ (const layout_node &node)
 
void read_anchors_ (float &left, float &right, float &top, float &bottom, float &x_center, float &y_center) const
 
bool make_borders_ (float &min, float &max, float center, float size) const
 
sol::state & get_lua_ ()
 
const sol::state & get_lua_ () const
 
template<typename T >
void create_glue_ (T &self)
 
void set_lua_member_ (std::string key, sol::stack_object value)
 
sol::object get_lua_member_ (const std::string &key) const
 
void set_virtual_ ()
 Makes this region virtual. More...
 
void set_name_ (const std::string &name)
 Sets this region's name. More...
 
virtual void set_parent_ (utils::observer_ptr< frame > parent)
 Changes this region's parent. More...
 
template<typename T >
void initialize_ (T &self, const region_core_attributes &attr)
 Set up function to call in all derived class constructors. More...
 

Static Protected Member Functions

template<typename T >
static const std::vector< std::string > & get_type_list_impl_ ()
 

Protected Attributes

layer layer_ = layer::artwork
 
int region_level_ = 0
 
managermanager_
 
const addonaddon_ = nullptr
 
std::string name_
 
std::string raw_name_
 
utils::observer_ptr< frameparent_ = nullptr
 
bool is_manually_inherited_ = false
 
bool is_virtual_ = false
 
bool is_loaded_ = false
 
bool is_valid_ = true
 
std::array< std::optional< anchor >, 9 > anchor_list_
 
bounds2< bool > defined_borders_
 
bounds2f borders_
 
float alpha_ = 1.0f
 
bool is_shown_ = true
 
bool is_visible_ = true
 
vector2f dimensions_
 
std::vector< utils::observer_ptr< region > > anchored_object_list_
 

Detailed Description

A layered_region that can draw animated sequences.

This object contains an animated texture taken from a file.

Definition at line 17 of file gui_animated_texture.hpp.

Member Typedef Documentation

◆ base

Definition at line 19 of file gui_animated_texture.hpp.

Constructor & Destructor Documentation

◆ animated_texture()

lxgui::gui::animated_texture::animated_texture ( utils::control_block &  block,
manager mgr,
const region_core_attributes attr 
)
explicit

Constructor.

Definition at line 15 of file gui_animated_texture.cpp.

Member Function Documentation

◆ add_anchored_object()

void lxgui::gui::region::add_anchored_object ( region obj)
inherited

Notifies this region that another one is anchored to it.

Parameters
objThe anchored region
Note
Anchored objects get their borders automatically updated whenever this object's borders are updated.

Definition at line 561 of file gui_region.cpp.

◆ clear_all_anchors()

void lxgui::gui::region::clear_all_anchors ( )
inherited

Removes all anchors.

Note
This region and its children won't be visible until you define at least one anchor.

Definition at line 365 of file gui_region.cpp.

◆ copy_from()

void lxgui::gui::animated_texture::copy_from ( const region obj)
overridevirtual

Copies a region's parameters into this texture (inheritance).

Parameters
objThe region to copy

Reimplemented from lxgui::gui::region.

Definition at line 74 of file gui_animated_texture.cpp.

◆ create_glue_()

template<typename T >
void lxgui::gui::region::create_glue_ ( T &  self)
protectedinherited

Definition at line 136 of file gui_region_tpl.hpp.

◆ depends_on()

bool lxgui::gui::region::depends_on ( const region obj) const
inherited

Checks if this region depends on another.

Parameters
objThe region to test
Note
Useful to detect circular references.

Definition at line 503 of file gui_region.cpp.

◆ destroy()

void lxgui::gui::region::destroy ( )
inherited

Forcefully removes this region from the GUI.

Warning
After calling this function, any pointer to the object is invalidated! Only call this function if you need the object to be destroyed early, before its parent (if any) would itself be destroyed.

Definition at line 333 of file gui_region.cpp.

◆ get_addon()

const addon * lxgui::gui::region::get_addon ( ) const
inherited

Returns this frame's addon.

Returns
This frame's addon
Note
Returns "nullptr" if the frame has been created by Lua code and wasn't assigned a parent.

Definition at line 843 of file gui_region.cpp.

◆ get_alpha()

float lxgui::gui::region::get_alpha ( ) const
inherited

Returns this region's alpha (opacity).

Returns
This region's alpha (opacity).

Definition at line 157 of file gui_region.cpp.

◆ get_anchor()

const anchor & lxgui::gui::region::get_anchor ( point  p) const
inherited

Returns one of this region's anchor.

Parameters
pThe anchor point
Returns
A pointer to the anchor, nullptr if none

Definition at line 539 of file gui_region.cpp.

◆ get_anchor_count()

std::size_t lxgui::gui::region::get_anchor_count ( ) const
inherited

Returns the number of defined anchors.

Returns
The number of defined anchors

Definition at line 519 of file gui_region.cpp.

◆ get_anchored_objects()

const std::vector< utils::observer_ptr< region > > & lxgui::gui::region::get_anchored_objects ( ) const
inherited

Returns the list of all objects that are anchored to this one.

Returns
The list of all objects that are anchored to this one

Definition at line 790 of file gui_region.cpp.

◆ get_anchors()

const std::array< std::optional< anchor >, 9 > & lxgui::gui::region::get_anchors ( ) const
inherited

Returns all of this region's anchors.

Returns
All of this region's anchors

Definition at line 549 of file gui_region.cpp.

◆ get_apparent_dimensions()

vector2f lxgui::gui::region::get_apparent_dimensions ( ) const
inherited

Returns this region's apparent width and height (in pixels).

Returns
This region's apparent width and height (in pixels)
Note
If you need to get the actual size of a region on the screen, use this function instead of get_dimensions(), as some regions may not have their dimensions explicitly defined, and instead get their extents from anchors.

Definition at line 276 of file gui_region.cpp.

◆ get_borders()

const bounds2f & lxgui::gui::region::get_borders ( ) const
inherited

Returns this region's borders.

Returns
This region's borders

Definition at line 361 of file gui_region.cpp.

◆ get_bottom()

float lxgui::gui::region::get_bottom ( ) const
inherited

Returns the vertical position of this region's bottom border.

Returns
The vertical position of this region's bottom border

Definition at line 357 of file gui_region.cpp.

◆ get_center()

vector2f lxgui::gui::region::get_center ( ) const
inherited

Returns the position of this region's center.

Returns
The position of this region's center

Definition at line 341 of file gui_region.cpp.

◆ get_dimensions()

const vector2f & lxgui::gui::region::get_dimensions ( ) const
inherited

Returns this region's explicitly-defined width and height (in pixels).

Returns
This region's explicitly-defined width and height (in pixels)
Note
If you need to get the actual size of a region on the screen, use get_apparent_dimensions(), as some regions may not have their dimensions explicitly defined, and instead get their extents from anchors. If a dimension is not explicitly defined, it will be returned as zero.

Definition at line 272 of file gui_region.cpp.

◆ get_draw_layer()

layer lxgui::gui::layered_region::get_draw_layer ( ) const
inherited

Returns this layered_region's draw layer.

Returns
this layered_region's draw layer

Definition at line 35 of file gui_layered_region.cpp.

◆ get_effective_alpha()

float lxgui::gui::region::get_effective_alpha ( ) const
inherited

Returns this region's effective alpha (opacity).

Returns
This region's effective alpha (opacity).
Note
This includes the region's parent alpha.

Definition at line 161 of file gui_region.cpp.

◆ get_effective_frame_renderer() [1/2]

utils::observer_ptr<frame_renderer> lxgui::gui::region::get_effective_frame_renderer ( )
inlineinherited

Returns the renderer of this object or its parents, nullptr if none.

Returns
The renderer of this object or its parents, nullptr if none
Note
For more information, see frame::set_frame_renderer().

Definition at line 615 of file gui_region.hpp.

◆ get_effective_frame_renderer() [2/2]

utils::observer_ptr< const frame_renderer > lxgui::gui::region::get_effective_frame_renderer ( ) const
virtualinherited

Returns the renderer of this object or its parents.

Returns
The renderer of this object or its parents
Note
For more information, see frame::set_frame_renderer().

Reimplemented in lxgui::gui::frame.

Definition at line 802 of file gui_region.cpp.

◆ get_left()

float lxgui::gui::region::get_left ( ) const
inherited

Returns the horizontal position of this region's left border.

Returns
The horizontal position of this region's left border

Definition at line 345 of file gui_region.cpp.

◆ get_lua_() [1/2]

sol::state & lxgui::gui::region::get_lua_ ( )
protectedinherited

Definition at line 767 of file gui_region.cpp.

◆ get_lua_() [2/2]

const sol::state & lxgui::gui::region::get_lua_ ( ) const
protectedinherited

Definition at line 771 of file gui_region.cpp.

◆ get_lua_member_()

sol::object lxgui::gui::region::get_lua_member_ ( const std::string &  key) const
protectedinherited

◆ get_manager() [1/2]

manager& lxgui::gui::region::get_manager ( )
inlineinherited

Returns this region's manager.

Returns
This region's manager

Definition at line 693 of file gui_region.hpp.

◆ get_manager() [2/2]

const manager& lxgui::gui::region::get_manager ( ) const
inlineinherited

Returns this region's manager.

Returns
This region's manager

Definition at line 701 of file gui_region.hpp.

◆ get_name()

const std::string & lxgui::gui::region::get_name ( ) const
inherited

Returns this region's name.

Returns
This region's name

Definition at line 140 of file gui_region.cpp.

◆ get_parent() [1/2]

const utils::observer_ptr<frame>& lxgui::gui::region::get_parent ( )
inlineinherited

Returns this region's parent.

Returns
This region's parent

Definition at line 237 of file gui_region.hpp.

◆ get_parent() [2/2]

utils::observer_ptr<const frame> lxgui::gui::region::get_parent ( ) const
inlineinherited

Returns this region's parent.

Returns
This region's parent

Definition at line 229 of file gui_region.hpp.

◆ get_raw_name()

const std::string & lxgui::gui::region::get_raw_name ( ) const
inherited

Returns this region's raw name.

Returns
This region's raw name
Note
This is the name of the region before "$parent" has been replaced by its parent's name.

Definition at line 144 of file gui_region.cpp.

◆ get_region_level()

int lxgui::gui::layered_region::get_region_level ( ) const
inherited

Sets the region level.

Returns
The region level

Definition at line 48 of file gui_layered_region.cpp.

◆ get_region_type()

const std::string & lxgui::gui::region::get_region_type ( ) const
inherited

Returns the type of this region.

Returns
The type of this region

Definition at line 148 of file gui_region.cpp.

◆ get_registry() [1/2]

registry & lxgui::gui::region::get_registry ( )
inherited

Returns the UI object registry, which keeps track of all objects in the UI.

Returns
The registry object

Definition at line 850 of file gui_region.cpp.

◆ get_registry() [2/2]

const registry & lxgui::gui::region::get_registry ( ) const
inherited

Returns the UI object registry, which keeps track of all objects in the UI.

Returns
The registry object

Definition at line 855 of file gui_region.cpp.

◆ get_right()

float lxgui::gui::region::get_right ( ) const
inherited

Returns the horizontal position of this region's right border.

Returns
The horizontal position of this region's right border

Definition at line 349 of file gui_region.cpp.

◆ get_speed()

float lxgui::gui::animated_texture::get_speed ( ) const

Returns this animated_texture's animation speed (frame per second).

Returns
This animated_texture's animation speed

Definition at line 87 of file gui_animated_texture.cpp.

◆ get_state()

float lxgui::gui::animated_texture::get_state ( ) const

Returns this animated_texture's state (0: begin, 1: end).

Returns
This animated_texture's state

Definition at line 91 of file gui_animated_texture.cpp.

◆ get_texture_file()

const std::string & lxgui::gui::animated_texture::get_texture_file ( ) const

Returns this texture's texture file.

Returns
This texture's texture file (empty string if none).

Definition at line 99 of file gui_animated_texture.cpp.

◆ get_top()

float lxgui::gui::region::get_top ( ) const
inherited

Returns the vertical position of this region's top border.

Returns
The vertical position of this region's top border

Definition at line 353 of file gui_region.cpp.

◆ get_type_list_impl_()

template<typename T >
const std::vector< std::string > & lxgui::gui::region::get_type_list_impl_
staticprotectedinherited

Definition at line 147 of file gui_region_tpl.hpp.

◆ get_vertex_color()

color lxgui::gui::animated_texture::get_vertex_color ( std::size_t  index) const

Returns this texture's vertex color.

Parameters
indexThe vertex index (0 to 3 included)
Returns
This texture's vertex color
Note
This color is used to filter the texture's colors: for each pixel, the original color is multiplied by this vertex color.

Definition at line 103 of file gui_animated_texture.cpp.

◆ hide()

void lxgui::gui::region::hide ( )
inherited

hides this region.

Note
All its children won't be visible on the screen anymore, even if they are still marked as shown.

Definition at line 186 of file gui_region.cpp.

◆ initialize_()

template<typename T >
void lxgui::gui::region::initialize_ ( T &  self,
const region_core_attributes attr 
)
protectedinherited

Set up function to call in all derived class constructors.

Parameters
selfA pointer to the derived this
attrThe region attributes provided to the constructor

Definition at line 141 of file gui_region_tpl.hpp.

◆ is_apparent_height_defined()

bool lxgui::gui::region::is_apparent_height_defined ( ) const
inherited

Checks if this region's apparent height is defined.

Returns
'true' if defined, 'false' otherwise
Note
The apparent height is defined if either the region's absolute or relative height is explicitly specified (from set_height(), set_relative_height(), set_dimensions(), or set_relative_dimensions()), or if its left and right borders are anchored. A region with an undefined apparent height will not be rendered on the screen until its height is defined.

Definition at line 284 of file gui_region.cpp.

◆ is_apparent_width_defined()

bool lxgui::gui::region::is_apparent_width_defined ( ) const
inherited

Checks if this region's apparent width is defined.

Returns
'true' if defined, 'false' otherwise
Note
The apparent width is defined if either the region's absolute or relative width is explicitly specified (from set_width(), set_relative_width(), set_dimensions(), or set_relative_dimensions()), or if its left and right borders are anchored. A region with an undefined apparent width will not be rendered on the screen until its width is defined.

Definition at line 280 of file gui_region.cpp.

◆ is_in_region()

bool lxgui::gui::region::is_in_region ( const vector2f position) const
virtualinherited

Checks if the provided coordinates are inside this region.

Parameters
positionThe coordinates to test
Returns
'true' if the provided coordinates are inside this region

Reimplemented in lxgui::gui::slider, and lxgui::gui::frame.

Definition at line 288 of file gui_region.cpp.

◆ is_loaded()

bool lxgui::gui::region::is_loaded ( ) const
inherited

Checks if this region has been fully loaded.

Note
A region that is not fully loaded still has all its core attributes set, hence can be considered as "fully constructed" from a C++ point of view. However, semantically, the object may need further steps to be complete, as designed by the UI designer. Therefore, form the UI's point of view, a region is considered "complete" only if is_loaded() returns 'true' (see notifu_loaded()). Only then can the region, e.g., react to or generate events.

Definition at line 798 of file gui_region.cpp.

◆ is_manually_inherited()

bool lxgui::gui::region::is_manually_inherited ( ) const
inherited

Checks if this object is manually inherited.

Returns
'true' if this object is manually inherited
Note
For more information, see set_manually_inherited().

Definition at line 784 of file gui_region.cpp.

◆ is_paused()

float lxgui::gui::animated_texture::is_paused ( ) const

Check if this animated_texture is paused.

Returns
'true' if paused, 'false' otherwise

Definition at line 95 of file gui_animated_texture.cpp.

◆ is_region_type() [1/3]

template<typename ObjectType >
bool lxgui::gui::region::is_region_type ( ) const
inlineinherited

Checks if this region is of the provided type.

Returns
'true' if this region is of the provided type

Definition at line 423 of file gui_region.hpp.

◆ is_region_type() [2/3]

bool lxgui::gui::region::is_region_type ( const region obj) const
inlineinherited

Checks if this region is of a type equal or derived from the supplied region.

Returns
'true' if this region is of a type equal or derived from the supplied region

Definition at line 431 of file gui_region.hpp.

◆ is_region_type() [3/3]

bool lxgui::gui::region::is_region_type ( const std::string &  type_name) const
inherited

Checks if this region is of the provided type.

Parameters
type_nameThe type to test
Returns
'true' if this region is of the provided type

Definition at line 152 of file gui_region.cpp.

◆ is_shown()

bool lxgui::gui::region::is_shown ( ) const
inherited

Checks if this region is shown.

Returns
'true' if this region is shown

Definition at line 203 of file gui_region.cpp.

◆ is_valid()

bool lxgui::gui::region::is_valid ( ) const
inherited

Checks if this region has all its borders correctly defined.

Returns
'true' if this region has all its borders correctly defined
Note
To be valid, a region needs to have a defined position and size along both the X and Y dimensions. This means either one anchor and a set size, or two opposite anchors. For example, any anchor plus a call to set_dimensions(). Or a top_left plus a bottom_right anchors. Or a left plus a right anchors plus a call to set_height().

Definition at line 211 of file gui_region.cpp.

◆ is_virtual()

bool lxgui::gui::region::is_virtual ( ) const
inherited

Checks if this region is virtual.

Returns
'true' if this region is virtual
Note
A virtual region will not be displayed on the screen, but can serve as a template to create new GUI elements (it is then "inherited", although note that this has no connection to C++ inheritance).

Definition at line 553 of file gui_region.cpp.

◆ is_visible()

bool lxgui::gui::region::is_visible ( ) const
inherited

Checks if this region can be seen on the screen.

Returns
'true' if this region can be seen on the screen

Definition at line 207 of file gui_region.cpp.

◆ make_borders_()

bool lxgui::gui::region::make_borders_ ( float &  min,
float &  max,
float  center,
float  size 
) const
protectedinherited

Definition at line 585 of file gui_region.cpp.

◆ modify_anchor()

anchor & lxgui::gui::region::modify_anchor ( point  p)
inherited

Returns one of this region's anchor to modify it.

Parameters
pThe anchor point
Returns
A reference to the anchor, will throw if this point has no anchor.
Note
After you have modified the anchor, you must call notify_borders_need_update() to ensure that the object's borders are properly updated.

Definition at line 529 of file gui_region.cpp.

◆ notify_borders_need_update()

void lxgui::gui::region::notify_borders_need_update ( )
virtualinherited

Tells this region that its borders need updating.

Reimplemented in lxgui::gui::slider.

Definition at line 744 of file gui_region.cpp.

◆ notify_invisible()

void lxgui::gui::region::notify_invisible ( )
virtualinherited

Notifies this region that it is no longer visible on screen.

Note
Automatically called by show()/hide().

Reimplemented in lxgui::gui::frame.

Definition at line 813 of file gui_region.cpp.

◆ notify_loaded()

void lxgui::gui::region::notify_loaded ( )
virtualinherited

Notifies this region that it has been fully loaded.

See also
is_loaded()

Reimplemented in lxgui::gui::frame.

Definition at line 794 of file gui_region.cpp.

◆ notify_renderer_need_redraw()

void lxgui::gui::layered_region::notify_renderer_need_redraw ( )
overridevirtualinherited

Notifies the renderer of this region that it needs to be redrawn.

Note
Automatically called by any shape changing function.

Reimplemented from lxgui::gui::region.

Definition at line 61 of file gui_layered_region.cpp.

◆ notify_scaling_factor_updated()

void lxgui::gui::region::notify_scaling_factor_updated ( )
virtualinherited

Tells this region that the global interface scaling factor has changed.

Reimplemented in lxgui::gui::scroll_frame, lxgui::gui::frame, lxgui::gui::font_string, and lxgui::gui::edit_box.

Definition at line 759 of file gui_region.cpp.

◆ notify_visible()

void lxgui::gui::region::notify_visible ( )
virtualinherited

Notifies this region that it is now visible on screen.

Note
Automatically called by show()/hide().

Reimplemented in lxgui::gui::frame.

Definition at line 808 of file gui_region.cpp.

◆ parse_anchor_node_()

void lxgui::gui::region::parse_anchor_node_ ( const layout_node node)
protectedvirtualinherited

Definition at line 89 of file gui_region_parser.cpp.

◆ parse_color_node_()

color lxgui::gui::region::parse_color_node_ ( const layout_node node)
protectedinherited

Definition at line 10 of file gui_region_parser.cpp.

◆ parse_dimension_node_()

std::pair< anchor_type, vector2< std::optional< float > > > lxgui::gui::region::parse_dimension_node_ ( const layout_node node)
protectedinherited

Definition at line 35 of file gui_region_parser.cpp.

◆ parse_file_name()

std::string lxgui::gui::region::parse_file_name ( const std::string &  file_name) const
inherited

Convert an addon-relative file path to a application-relative path.

Parameters
file_nameThe raw file name
Returns
The modified file name
Note
All file names must be relative to the current working directory (typically, the application's executable path), but sometimes it is more convenient and maintainable to specify a path that is relative to the addon directory. This can be achieved by simply putting "|" in front of a file name, which will then be interpreted as relative to the addon directory. This function takes care of this transformation.

Definition at line 818 of file gui_region.cpp.

◆ parse_layout()

void lxgui::gui::animated_texture::parse_layout ( const layout_node node)
overridevirtual

Parses data from a layout_node.

Parameters
nodeThe layout node

Reimplemented from lxgui::gui::region.

Definition at line 8 of file gui_animated_texture_parser.cpp.

◆ parse_offset_node_()

vector2< std::optional< float > > lxgui::gui::region::parse_offset_node_ ( const layout_node node)
protectedinherited

Definition at line 24 of file gui_region_parser.cpp.

◆ parse_offset_node_or_()

vector2< float > lxgui::gui::region::parse_offset_node_or_ ( const layout_node node,
float  fallback 
)
protectedinherited

Definition at line 28 of file gui_region_parser.cpp.

◆ parse_size_node_()

void lxgui::gui::region::parse_size_node_ ( const layout_node node)
protectedvirtualinherited

Definition at line 65 of file gui_region_parser.cpp.

◆ pause()

void lxgui::gui::animated_texture::pause ( )
inline

Pause this animated_texture.

Note
Has no effect if already paused

Definition at line 110 of file gui_animated_texture.hpp.

◆ play()

void lxgui::gui::animated_texture::play ( )
inline

Play this animated_texture.

Note
Has no effect if already playing

Definition at line 102 of file gui_animated_texture.hpp.

◆ read_anchors_()

void lxgui::gui::region::read_anchors_ ( float &  left,
float &  right,
float &  top,
float &  bottom,
float &  x_center,
float &  y_center 
) const
protectedinherited

Definition at line 614 of file gui_region.cpp.

◆ register_on_lua()

static void lxgui::gui::animated_texture::register_on_lua ( sol::state &  lua)
static

Registers this region class to the provided Lua state.

◆ release_from_parent()

utils::owner_ptr< region > lxgui::gui::layered_region::release_from_parent ( )
overridevirtualinherited

Removes this region from its parent and return an owning pointer.

Returns
An owning pointer to this region

Reimplemented from lxgui::gui::region.

Definition at line 28 of file gui_layered_region.cpp.

◆ remove_anchored_object()

void lxgui::gui::region::remove_anchored_object ( region obj)
inherited

Notifies this region that another one is no longer anchored to it.

Parameters
objThe region no longer anchored
See also
add_anchored_object()

Definition at line 565 of file gui_region.cpp.

◆ remove_glue()

void lxgui::gui::region::remove_glue ( )
inherited

Removes the Lua glue.

Definition at line 775 of file gui_region.cpp.

◆ render()

void lxgui::gui::animated_texture::render ( ) const
overridevirtual

Renders this region on the current render target.

Reimplemented from lxgui::gui::region.

Definition at line 32 of file gui_animated_texture.cpp.

◆ round_to_pixel() [1/2]

vector2f lxgui::gui::region::round_to_pixel ( const vector2f position,
utils::rounding_method  method = utils::rounding_method::nearest 
) const
inherited

Round an absolute position on screen to the nearest physical pixel.

Parameters
positionThe input absolute position (can be fractional)
methodThe rounding method
Returns
The position of the nearest physical pixel

Definition at line 578 of file gui_region.cpp.

◆ round_to_pixel() [2/2]

float lxgui::gui::region::round_to_pixel ( float  value,
utils::rounding_method  method = utils::rounding_method::nearest 
) const
inherited

Round an absolute position on screen to the nearest physical pixel.

Parameters
valueThe input absolute position (can be fractional)
methodThe rounding method
Returns
The position of the nearest physical pixel

Definition at line 573 of file gui_region.cpp.

◆ serialize()

std::string lxgui::gui::animated_texture::serialize ( const std::string &  tab) const
overridevirtual

Prints all relevant information about this region in a string.

Parameters
tabThe offset to give to all lines
Returns
All relevant information about this region

Reimplemented from lxgui::gui::region.

Definition at line 22 of file gui_animated_texture.cpp.

◆ set_addon()

void lxgui::gui::region::set_addon ( const addon a)
inherited

Sets the addon this frame belongs to.

Parameters
aThe addon this frame belongs to

Definition at line 833 of file gui_region.cpp.

◆ set_all_anchors() [1/2]

void lxgui::gui::region::set_all_anchors ( const std::string &  obj_name)
inherited

Adjusts this regions anchors to fit the provided region.

Parameters
obj_nameThe name of the object to fit to
Note
Removes all anchors and defines two new ones.

Definition at line 404 of file gui_region.cpp.

◆ set_all_anchors() [2/2]

void lxgui::gui::region::set_all_anchors ( const utils::observer_ptr< region > &  obj)
inherited

Adjusts this regions anchors to fit the provided region.

Parameters
objA pointer to the object you want to wrap
Note
Removes all anchors and defines two new ones.

Definition at line 437 of file gui_region.cpp.

◆ set_alpha()

void lxgui::gui::region::set_alpha ( float  alpha)
inherited

Changes this region's alpha (opacity).

Parameters
alphaThe new alpha value
Note
Default is 1.0f.

Definition at line 169 of file gui_region.cpp.

◆ set_anchor() [1/2]

template<typename... Args>
void lxgui::gui::region::set_anchor ( Args &&...  args)
inlineinherited

Adds/replaces an anchor.

Parameters
argsArgument to construct a new anchor_data

Definition at line 503 of file gui_region.hpp.

◆ set_anchor() [2/2]

void lxgui::gui::region::set_anchor ( const anchor_data a)
inherited

Adds/replaces an anchor.

Parameters
aThe anchor to add

Definition at line 473 of file gui_region.cpp.

◆ set_dimensions()

void lxgui::gui::region::set_dimensions ( const vector2f dimensions)
virtualinherited

Changes this region's absolute dimensions (in pixels).

Parameters
dimensionsThe new dimensions

Reimplemented in lxgui::gui::frame.

Definition at line 215 of file gui_region.cpp.

◆ set_draw_layer()

void lxgui::gui::layered_region::set_draw_layer ( layer  layer_id)
inherited

Sets this layered_region's draw layer.

Parameters
layer_idThe new layer

Definition at line 39 of file gui_layered_region.cpp.

◆ set_height()

void lxgui::gui::region::set_height ( float  abs_height)
virtualinherited

Changes this region's absolute height (in pixels).

Parameters
abs_heightThe new height

Reimplemented in lxgui::gui::frame.

Definition at line 239 of file gui_region.cpp.

◆ set_lua_member_()

void lxgui::gui::region::set_lua_member_ ( std::string  key,
sol::stack_object  value 
)
protectedinherited

◆ set_manually_inherited()

void lxgui::gui::region::set_manually_inherited ( bool  manually_inherited)
inherited

Flags this region as manually inherited or not.

Note
By default, all regions are automatically inherited. This is generally the desired behavior for regions defined by the user, but it is less desirable for "special" or "internal" regions necessary for the proper operation of some region types (e.g., the texture used by a button), which need special treatment or registration.

Definition at line 780 of file gui_region.cpp.

◆ set_name_()

void lxgui::gui::region::set_name_ ( const std::string &  name)
protectedinherited

Sets this region's name.

Parameters
nameThis region's name
Note
Can only be called once. If you need to set both the name and the parent at the same time (typically, at creation), use set_name_and_parent_().

Definition at line 294 of file gui_region.cpp.

◆ set_parent_()

void lxgui::gui::region::set_parent_ ( utils::observer_ptr< frame parent)
protectedvirtualinherited

Changes this region's parent.

Parameters
parentThe new parent
Note
Default is nullptr.

Reimplemented in lxgui::gui::frame.

Definition at line 312 of file gui_region.cpp.

◆ set_paused()

void lxgui::gui::animated_texture::set_paused ( bool  is_paused)

Play or pause this animated_texture.

Parameters
is_paused'true' to pause, 'false' to play

Definition at line 125 of file gui_animated_texture.cpp.

◆ set_region_level()

void lxgui::gui::layered_region::set_region_level ( int  region_level)
inherited

Sets this layered_region's region level.

Parameters
region_levelThe new level

Definition at line 52 of file gui_layered_region.cpp.

◆ set_relative_dimensions()

void lxgui::gui::region::set_relative_dimensions ( const vector2f dimensions)
inherited

Changes this region's dimensions (relative to its parent).

Parameters
dimensionsThe new dimensions (relative)

Definition at line 251 of file gui_region.cpp.

◆ set_relative_height()

void lxgui::gui::region::set_relative_height ( float  rel_height)
inherited

Changes this region's height (relative to its parent).

Parameters
rel_heightThe new height

Definition at line 265 of file gui_region.cpp.

◆ set_relative_width()

void lxgui::gui::region::set_relative_width ( float  rel_width)
inherited

Changes this region's width (relative to its parent).

Parameters
rel_widthThe new width

Definition at line 258 of file gui_region.cpp.

◆ set_shown()

void lxgui::gui::region::set_shown ( bool  is_shown)
inherited

shows/hides this region.

Parameters
is_shown'true' if you want to show this region
Note
See show() and hide() for more information.

Definition at line 196 of file gui_region.cpp.

◆ set_speed()

void lxgui::gui::animated_texture::set_speed ( float  speed)

Set this animated_texture's animation speed (frame per second).

Parameters
speedThe new animation speed

Definition at line 113 of file gui_animated_texture.cpp.

◆ set_state()

void lxgui::gui::animated_texture::set_state ( float  state)

Returns this animated_texture's state (0: begin, 1: end).

Parameters
stateThe new state

Definition at line 117 of file gui_animated_texture.cpp.

◆ set_texture()

void lxgui::gui::animated_texture::set_texture ( const std::string &  file_name)

Sets this texture's texture file.

Parameters
file_nameThe file from which to read data
Note
This function takes care of checking that the file can be opened.
This function will replace the solid color set by set_solid_color(). If you need to blend the texture with a color, use set_vertex_color() instead.

Definition at line 129 of file gui_animated_texture.cpp.

◆ set_vertex_color()

void lxgui::gui::animated_texture::set_vertex_color ( const color c,
std::size_t  index = std::numeric_limits<std::size_t>::max() 
)

Sets this texture's vertex color.

Parameters
cThis texture's new vertex color
indexThe vertex index (-1: all vertices)
Note
This color is used to filter the texture's colors: for each pixel, the original color is multiplied by this vertex color.

Definition at line 164 of file gui_animated_texture.cpp.

◆ set_virtual_()

void lxgui::gui::region::set_virtual_ ( )
protectedinherited

Makes this region virtual.

Note
See is_virtual().

Definition at line 557 of file gui_region.cpp.

◆ set_width()

void lxgui::gui::region::set_width ( float  abs_width)
virtualinherited

Changes this region's absolute width (in pixels).

Parameters
abs_widthThe new width

Reimplemented in lxgui::gui::frame.

Definition at line 227 of file gui_region.cpp.

◆ show()

void lxgui::gui::region::show ( )
inherited

shows this region.

Note
Its parent must be shown for it to appear on the screen.

Definition at line 176 of file gui_region.cpp.

◆ stop()

void lxgui::gui::animated_texture::stop ( )
inline

Stop this animated_texture (stop playing and reset to start).

Definition at line 117 of file gui_animated_texture.hpp.

◆ update()

void lxgui::gui::animated_texture::update ( float  delta)
overridevirtual

Updates this region's logic.

Parameters
deltaTime spent since last update

Reimplemented from lxgui::gui::region.

Definition at line 51 of file gui_animated_texture.cpp.

Member Data Documentation

◆ addon_

const addon* lxgui::gui::region::addon_ = nullptr
protectedinherited

Definition at line 802 of file gui_region.hpp.

◆ alpha_

float lxgui::gui::region::alpha_ = 1.0f
protectedinherited

Definition at line 818 of file gui_region.hpp.

◆ anchor_list_

std::array<std::optional<anchor>, 9> lxgui::gui::region::anchor_list_
protectedinherited

Definition at line 814 of file gui_region.hpp.

◆ anchored_object_list_

std::vector<utils::observer_ptr<region> > lxgui::gui::region::anchored_object_list_
protectedinherited

Definition at line 824 of file gui_region.hpp.

◆ borders_

bounds2f lxgui::gui::region::borders_
protectedinherited

Definition at line 816 of file gui_region.hpp.

◆ class_name

constexpr const char* lxgui::gui::animated_texture::class_name = "AnimatedTexture"
staticconstexpr

Definition at line 151 of file gui_animated_texture.hpp.

◆ defined_borders_

bounds2<bool> lxgui::gui::region::defined_borders_
protectedinherited

Definition at line 815 of file gui_region.hpp.

◆ dimensions_

vector2f lxgui::gui::region::dimensions_
protectedinherited

Definition at line 822 of file gui_region.hpp.

◆ is_loaded_

bool lxgui::gui::region::is_loaded_ = false
protectedinherited

Definition at line 811 of file gui_region.hpp.

◆ is_manually_inherited_

bool lxgui::gui::region::is_manually_inherited_ = false
protectedinherited

Definition at line 809 of file gui_region.hpp.

◆ is_shown_

bool lxgui::gui::region::is_shown_ = true
protectedinherited

Definition at line 819 of file gui_region.hpp.

◆ is_valid_

bool lxgui::gui::region::is_valid_ = true
protectedinherited

Definition at line 812 of file gui_region.hpp.

◆ is_virtual_

bool lxgui::gui::region::is_virtual_ = false
protectedinherited

Definition at line 810 of file gui_region.hpp.

◆ is_visible_

bool lxgui::gui::region::is_visible_ = true
protectedinherited

Definition at line 820 of file gui_region.hpp.

◆ layer_

layer lxgui::gui::layered_region::layer_ = layer::artwork
protectedinherited

Definition at line 92 of file gui_layered_region.hpp.

◆ manager_

manager& lxgui::gui::region::manager_
protectedinherited

Definition at line 800 of file gui_region.hpp.

◆ name_

std::string lxgui::gui::region::name_
protectedinherited

Definition at line 804 of file gui_region.hpp.

◆ parent_

utils::observer_ptr<frame> lxgui::gui::region::parent_ = nullptr
protectedinherited

Definition at line 807 of file gui_region.hpp.

◆ raw_name_

std::string lxgui::gui::region::raw_name_
protectedinherited

Definition at line 805 of file gui_region.hpp.

◆ region_level_

int lxgui::gui::layered_region::region_level_ = 0
protectedinherited

Definition at line 93 of file gui_layered_region.hpp.


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