TGUI  0.8-dev
tgui::WidgetRenderer Class Reference

Base class for all renderer classes. More...

#include <WidgetRenderer.hpp>

Inheritance diagram for tgui::WidgetRenderer:
tgui::ButtonRenderer tgui::ChatBoxRenderer tgui::ChildWindowRenderer tgui::ComboBoxRenderer tgui::EditBoxRenderer tgui::GroupRenderer tgui::KnobRenderer tgui::LabelRenderer tgui::ListBoxRenderer tgui::MenuBarRenderer tgui::ProgressBarRenderer tgui::RadioButtonRenderer tgui::ScrollbarRenderer tgui::SliderRenderer tgui::SpinButtonRenderer tgui::TabsRenderer tgui::TextBoxRenderer

Public Member Functions

 WidgetRenderer ()=default
 Default constructor.
 
 WidgetRenderer (std::shared_ptr< RendererData > data)
 Construct the renderer from renderer data. More...
 
virtual ~WidgetRenderer ()
 Virtual destructor.
 
void setOpacity (float opacity)
 Changes the opacity of the widget. More...
 
float getOpacity () const
 Returns the opacity of the widget. More...
 
void setFont (Font font)
 Changes the font used for the text in the widget. More...
 
Font getFont () const
 Returns the font associated with the widget (if any) More...
 
void setProperty (const std::string &property, const std::string &value)
 Changes a property of the renderer. More...
 
void setProperty (const std::string &property, ObjectConverter &&value)
 Changes a property of the renderer. More...
 
ObjectConverter getProperty (const std::string &property) const
 Retrieves the value of a certain property. More...
 
const std::map< std::string, ObjectConverter > & getPropertyValuePairs () const
 Gets a map with all properties and their values. More...
 
void subscribe (void *id, const std::function< void(const std::string &property)> &function)
 Subscribes a callback function to changes in the renderer. More...
 
void unsubscribe (void *id)
 Subscribes a callback function to changes in the renderer. More...
 
std::shared_ptr< RendererDatagetData () const
 Returns the renderer data. More...
 
std::shared_ptr< RendererDataclone () const
 Gets a clone of the renderer data. More...
 

Detailed Description

Base class for all renderer classes.

Constructor & Destructor Documentation

§ WidgetRenderer()

tgui::WidgetRenderer::WidgetRenderer ( std::shared_ptr< RendererData data)
inline

Construct the renderer from renderer data.

Parameters
dataRenderer data to initialize the renderer with

Member Function Documentation

§ clone()

std::shared_ptr<RendererData> tgui::WidgetRenderer::clone ( ) const

Gets a clone of the renderer data.

You can pass this to a widget with the setRenderer function to have a separate non-shared copy of this renderer.

§ getData()

std::shared_ptr<RendererData> tgui::WidgetRenderer::getData ( ) const

Returns the renderer data.

Returns
Data that is shared between the renderers
Warning
You should not make changed to this data directly. Instead, use the function from the renderer classes

§ getFont()

Font tgui::WidgetRenderer::getFont ( ) const

Returns the font associated with the widget (if any)

Returns
Font used by widget

§ getOpacity()

float tgui::WidgetRenderer::getOpacity ( ) const

Returns the opacity of the widget.

Returns
The opacity of the widget. 0 means completely transparent, while 1 (default) means fully opaque

§ getProperty()

ObjectConverter tgui::WidgetRenderer::getProperty ( const std::string &  property) const

Retrieves the value of a certain property.

Parameters
propertyThe property that you would like to retrieve
Returns
The value inside a ObjectConverter object which you can extract with the correct get function or an ObjectConverter object with type ObjectConverter::Type::None when the property did not exist.

§ getPropertyValuePairs()

const std::map<std::string, ObjectConverter>& tgui::WidgetRenderer::getPropertyValuePairs ( ) const

Gets a map with all properties and their values.

Returns
Property-value pairs of the renderer

§ setFont()

void tgui::WidgetRenderer::setFont ( Font  font)

Changes the font used for the text in the widget.

Parameters
fontThe new font

When you don't call this function then the font from the parent widget will be used.

§ setOpacity()

void tgui::WidgetRenderer::setOpacity ( float  opacity)

Changes the opacity of the widget.

Parameters
opacityThe opacity of the widget. 0 means completely transparent, while 1 (default) means fully opaque

§ setProperty() [1/2]

void tgui::WidgetRenderer::setProperty ( const std::string &  property,
const std::string &  value 
)

Changes a property of the renderer.

Parameters
propertyThe property that you would like to change
valueThe new value that you like to assign to the property. The value can either be a string value or a serialized string
Exceptions
Exceptionfor unknown properties or when value was of a wrong type

§ setProperty() [2/2]

void tgui::WidgetRenderer::setProperty ( const std::string &  property,
ObjectConverter &&  value 
)

Changes a property of the renderer.

Parameters
propertyThe property that you would like to change
valueThe new value that you like to assign to the property. The ObjectConverter is implicitly constructed from the possible value types
Exceptions
Exceptionfor unknown properties or when value was of a wrong type

§ subscribe()

void tgui::WidgetRenderer::subscribe ( void *  id,
const std::function< void(const std::string &property)> &  function 
)

Subscribes a callback function to changes in the renderer.

Parameters
idUnique identifier for this callback function so that you can unsubscribe it later
functionCallback function to call when the renderer changes

§ unsubscribe()

void tgui::WidgetRenderer::unsubscribe ( void *  id)

Subscribes a callback function to changes in the renderer.

Parameters
idUnique identifier used when subscribing the callback function

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