TGUI  0.10-beta
tgui::WidgetRenderer Class Reference

Base class for all renderer classes. More...

#include <TGUI/Renderers/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::ListViewRenderer tgui::MenuBarRenderer tgui::PictureRenderer tgui::ProgressBarRenderer tgui::RadioButtonRenderer tgui::ScrollbarRenderer tgui::SeparatorLineRenderer tgui::SliderRenderer tgui::SpinButtonRenderer tgui::TabsRenderer tgui::TextAreaRenderer tgui::TreeViewRenderer

Public Member Functions

 WidgetRenderer ()=default
 Default constructor.
 
 WidgetRenderer (const std::shared_ptr< RendererData > &data)
 Construct the renderer from renderer data. More...
 
virtual ~WidgetRenderer ()=default
 Virtual destructor.
 
void setOpacity (float opacity)
 Changes the opacity of the widget. More...
 
float getOpacity () const
 Returns the opacity of the widget. More...
 
void setOpacityDisabled (float opacity)
 Changes the opacity of the widget when it is disabled. More...
 
float getOpacityDisabled () const
 Returns the opacity of the widget when it is disabled. 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 setTextSize (unsigned int size)
 Changes the text size of the widget that is specified by the renderer. More...
 
unsigned int getTextSize () const
 Returns text size of the widget that is specified by the renderer. More...
 
void setTransparentTexture (bool ignoreTransparentParts)
 Sets whether mouse events should be ignored on transparent parts of the texture of the widget in normal state. More...
 
bool getTransparentTexture () const
 Returns whether mouse events should be ignored on transparent parts of the texture of the widget. More...
 
void setProperty (const String &property, ObjectConverter &&value)
 Changes a property of the renderer. More...
 
ObjectConverter getProperty (const String &property) const
 Retrieves the value of a certain property. More...
 
const std::map< String, ObjectConverter > & getPropertyValuePairs () const
 Gets a map with all properties and their values. More...
 
void subscribe (const void *id, const std::function< void(const String &property)> &function)
 Subscribes a callback function to changes in the renderer. More...
 
void unsubscribe (const void *id)
 Subscribes a callback function to changes in the renderer. More...
 
void setData (const std::shared_ptr< RendererData > &data)
 
std::shared_ptr< RendererDatagetData () const
 Returns the renderer data. More...
 
std::shared_ptr< RendererDataclone () const
 Gets a clone of the renderer data. More...
 

Protected Attributes

std::shared_ptr< RendererDatam_data = RendererData::create()
 

Detailed Description

Base class for all renderer classes.

Constructor & Destructor Documentation

◆ WidgetRenderer()

tgui::WidgetRenderer::WidgetRenderer ( const 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

◆ getOpacityDisabled()

float tgui::WidgetRenderer::getOpacityDisabled ( ) const

Returns the opacity of the widget when it is disabled.

Returns
The opacity of the widget in disabled state, or -1 when using the not using a different opacity when the widget is enabled or disabled.

◆ getProperty()

ObjectConverter tgui::WidgetRenderer::getProperty ( const 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< String, ObjectConverter > & tgui::WidgetRenderer::getPropertyValuePairs ( ) const

Gets a map with all properties and their values.

Returns
Property-value pairs of the renderer

◆ getTextSize()

unsigned int tgui::WidgetRenderer::getTextSize ( ) const

Returns text size of the widget that is specified by the renderer.

By default, this function will return 0 which means the renderer isn't overwriting the text size of the widget. Use the getTextSize() function of the widget itself (instead of the one from the renderer) to get the actual size.

Returns
Text size of the widget or 0 if the renderer doesn't specify a text size

◆ getTransparentTexture()

bool tgui::WidgetRenderer::getTransparentTexture ( ) const

Returns whether mouse events should be ignored on transparent parts of the texture of the widget.

Returns
Whether mouse events on transparent texture parts are ignored
See also
setTransparentTexture

◆ 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

◆ setOpacityDisabled()

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

Changes the opacity of the widget when it is disabled.

Parameters
opacityThe opacity of the widget in disabled state. 0 means completely transparent, while 1 (default) means fully opaque. Set to -1 (default) to use the normal opacity value even when the widget is disabled.

◆ setProperty()

void tgui::WidgetRenderer::setProperty ( const 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

◆ setTextSize()

void tgui::WidgetRenderer::setTextSize ( unsigned int  size)

Changes the text size of the widget that is specified by the renderer.

Parameters
sizeThe new text size to use

If the text size is 0 (default) then the renderer won't overwrite the text size of the widget.

◆ setTransparentTexture()

void tgui::WidgetRenderer::setTransparentTexture ( bool  ignoreTransparentParts)

Sets whether mouse events should be ignored on transparent parts of the texture of the widget in normal state.

ignoreTransparentParts Should mouse events on transparent texture parts be ignored?

When mouse events are ignored, they are passed to a widget behind the widget. By default, mouse events are NOT ignored and the widget will receive mouse events even on transparent texture parts.

This property does nothing if the widget doesn't use textures.

◆ subscribe()

void tgui::WidgetRenderer::subscribe ( const void *  id,
const std::function< void(const 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 ( const 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: