TGUI  0.8.9

Class used by bindings to implement custom widgets withing these bindings (e.g. a custom C# widget in TGUI.Net) More...

#include <TGUI/CustomWidgetForBindings.hpp>

Inheritance diagram for tgui::CustomWidgetForBindings:
tgui::Widget tgui::SignalWidgetBase

Public Types

typedef std::shared_ptr< CustomWidgetForBindingsPtr
 Shared widget pointer.
 
typedef std::shared_ptr< const CustomWidgetForBindingsConstPtr
 Shared constant widget pointer.
 
- Public Types inherited from tgui::Widget
typedef std::shared_ptr< WidgetPtr
 Shared widget pointer.
 
typedef std::shared_ptr< const WidgetConstPtr
 Shared constant widget pointer.
 

Public Member Functions

void setPosition (const Layout2d &position) override
 sets the position of the widget More...
 
void setSize (const Layout2d &size) override
 Changes the size of the widget. More...
 
Vector2f getFullSize () const override
 Returns the entire size that the widget is using. More...
 
Vector2f getAbsolutePosition () const override
 Get the absolute position of the widget instead of the relative position to its parent. More...
 
Vector2f getWidgetOffset () const override
 Returns the distance between the position where the widget is drawn and where the widget is placed. More...
 
void setVisible (bool visible) override
 Shows or hides a widget. More...
 
void setEnabled (bool enabled) override
 Enables or disables the widget. More...
 
void setFocused (bool focused) override
 Focus or unfocus the widget. More...
 
bool canGainFocus () const override
 Returns whether the widget can gain focus. More...
 
bool mouseOnWidget (Vector2f pos) const override
 Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget. More...
 
void draw (sf::RenderTarget &target, sf::RenderStates states) const override
 Draw the widget to a render target. More...
 
Widget::Ptr clone () const override
 Makes a copy of the widget if you don't know its exact type. More...
 
- Public Member Functions inherited from tgui::Widget
 Widget ()
 Default constructor.
 
 Widget (const Widget &)
 Copy constructor.
 
 Widget (Widget &&)
 Move constructor.
 
 ~Widget ()
 Destructor.
 
Widgetoperator= (const Widget &)
 Overload of copy assignment operator.
 
Widgetoperator= (Widget &&)
 Move assignment.
 
void setRenderer (std::shared_ptr< RendererData > rendererData)
 Sets a new renderer for the widget. The renderer determines how the widget looks. More...
 
WidgetRenderergetSharedRenderer ()
 Returns the renderer, which gives access to functions that determine how the widget is displayed. More...
 
WidgetRenderergetRenderer ()
 Returns the renderer, which gives access to functions that determine how the widget is displayed. More...
 
void setPosition (Layout x, Layout y)
 Sets the position of the widget. More...
 
Vector2f getPosition () const
 Gets the position of the widget. More...
 
void setSize (Layout width, Layout height)
 Changes the size of the widget. More...
 
Vector2f getSize () const
 Returns the size of the widget. More...
 
virtual void showWithEffect (ShowAnimationType type, sf::Time duration)
 Shows the widget by introducing it with an animation. More...
 
virtual void hideWithEffect (ShowAnimationType type, sf::Time duration)
 Hides the widget by making it leave with an animation. More...
 
bool isVisible () const
 Returns true when the widget is visible. More...
 
bool isEnabled () const
 Returns true when the widget is enabled. More...
 
bool isFocused () const
 Returns true when the widget is focused and false otherwise. More...
 
const std::string & getWidgetType () const
 Returns the type of the widget. More...
 
ContainergetParent () const
 Returns a pointer to the parent widget. More...
 
bool isAnimationPlaying () const
 Returns whether there is an active animation (started with showWithEffect or hideWithEffect) More...
 
virtual void moveToFront ()
 Places the widget before all other widgets. More...
 
virtual void moveToBack ()
 Places the widget behind all other widgets. More...
 
void setUserData (std::any userData)
 Stores some data into the widget. More...
 
template<typename T >
getUserData () const
 Returns data stored in the widget. More...
 
void setInheritedFont (const Font &font)
 Sets the font of the widget that is used when no font is set in the renderer. More...
 
const FontgetInheritedFont () const
 Returns the font of the widget that is used when no font is set in the renderer. More...
 
void setInheritedOpacity (float opacity)
 Sets the opacity of the widget that will be multiplied with the opacity set in the renderer. More...
 
float getInheritedOpacity () const
 Returns the opacity of the widget that is multiplied with the opacity set in the renderer. More...
 
virtual void setTextSize (unsigned int size)
 Changes the character size of text in this widget if it uses text. More...
 
virtual unsigned int getTextSize () const
 Returns the character size of text in this widget. More...
 
void setToolTip (Widget::Ptr toolTip)
 Sets the tool tip that should be displayed when hovering over the widget. More...
 
Widget::Ptr getToolTip () const
 Returns the tool tip that is displayed when hovering over the widget. More...
 
void setWidgetName (const sf::String &name)
 Changes the name of a widget. More...
 
sf::String getWidgetName () const
 Returns the name of a widget. More...
 
void setFocusable (bool focusable)
 Changes whether a widget could be focused. More...
 
bool isFocusable () const
 Returns whether a widget could be focused. More...
 
bool isContainer () const
 Returns whether the widget is a container widget or not. More...
 
SignalgetSignal (std::string signalName) override
 Retrieves a signal based on its name. More...
 
template<typename WidgetType >
std::shared_ptr< const WidgetType > cast () const
 Downcast const widget.
 
template<typename WidgetType >
std::shared_ptr< WidgetType > cast ()
 Downcast widget.
 
- Public Member Functions inherited from tgui::SignalWidgetBase
template<typename Func , typename... Args, typename std::enable_if< std::is_convertible< Func, std::function< void(const Args &...)> >::value >::type * = nullptr>
unsigned int connect (std::string signalName, Func &&handler, const Args &... args)
 Connects a signal handler that will be called when this signal is emitted. More...
 
template<typename Func , typename... BoundArgs, typename std::enable_if<!std::is_convertible< Func, std::function< void(const BoundArgs &...)> >::value &&std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const std::string &)> >::value , ::type * = nullptr>
unsigned int connect (std::string signalName, Func &&handler, BoundArgs &&... args)
 Connects a signal handler that will be called when this signal is emitted. More...
 
template<typename Func , typename... BoundArgs, typename std::enable_if<!std::is_convertible< Func, std::function< void(const BoundArgs &...)> >::value &&!std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const std::string &)> >::value , ::type * = nullptr>
unsigned int connect (std::string signalName, Func &&handler, BoundArgs &&... args)
 Connects a signal handler that will be called when this signal is emitted. More...
 
template<typename Func , typename... BoundArgs>
unsigned int connect (std::initializer_list< std::string > signalNames, Func &&handler, BoundArgs &&... args)
 Connect a signal handler to multiple signals. More...
 
bool disconnect (unsigned int id)
 Disconnects a signal handler. More...
 
void disconnectAll (std::string signalName)
 Disconnects all signal handler from a certain signal. More...
 
void disconnectAll ()
 Disconnects all signal handlers from signals.
 

Static Public Member Functions

static CustomWidgetForBindings::Ptr create ()
 Creates a new widget. More...
 

Protected Member Functions

void rendererChanged (const std::string &property) override
 Function called when one of the properties of the renderer is changed. More...
 
void mouseEnteredWidget () override
 This function is called when the mouse enters the widget.
 
void mouseLeftWidget () override
 This function is called when the mouse leaves the widget.
 
- Protected Member Functions inherited from tgui::Widget
virtual std::unique_ptr< DataIO::Node > save (SavingRenderersMap &renderers) const
 Saves the widget as a tree node in order to save it to a file.
 
virtual void load (const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers)
 Loads the widget from a tree of nodes.
 

Additional Inherited Members

- Public Attributes inherited from tgui::Widget
SignalVector2f onPositionChange = {"PositionChanged"}
 The position of the widget changed. Optional parameter: new position.
 
SignalVector2f onSizeChange = {"SizeChanged"}
 The size of the widget changed. Optional parameter: new size.
 
Signal onFocus = {"Focused"}
 The widget was focused.
 
Signal onUnfocus = {"Unfocused"}
 The widget was unfocused.
 
Signal onMouseEnter = {"MouseEntered"}
 The mouse entered the widget.
 
Signal onMouseLeave = {"MouseLeft"}
 The mouse left the widget.
 
SignalAnimation onAnimationFinished = {"AnimationFinished"}
 A show or hide animation finished. Optional parameters: animation type, new widget visibility or both.
 

Detailed Description

Class used by bindings to implement custom widgets withing these bindings (e.g. a custom C# widget in TGUI.Net)

Member Function Documentation

◆ canGainFocus()

bool tgui::CustomWidgetForBindings::canGainFocus ( ) const
overridevirtual

Returns whether the widget can gain focus.

Returns
Can the widget be focused?

Reimplemented from tgui::Widget.

◆ clone()

Widget::Ptr tgui::CustomWidgetForBindings::clone ( ) const
inlineoverridevirtual

Makes a copy of the widget if you don't know its exact type.

This function should only be used when you don't know the type of the widget. If you know what kind of widget you are copying, you should use the copy function.

Returns
Copy of the widget
Warning
This function should not be used as it won't function correctly because the binding object isn't changed.

Implements tgui::Widget.

◆ create()

static CustomWidgetForBindings::Ptr tgui::CustomWidgetForBindings::create ( )
static

Creates a new widget.

Returns
The new widget

◆ draw()

void tgui::CustomWidgetForBindings::draw ( sf::RenderTarget &  target,
sf::RenderStates  states 
) const
overridevirtual

Draw the widget to a render target.

Parameters
targetRender target to draw to
statesCurrent render states

Implements tgui::Widget.

◆ getAbsolutePosition()

Vector2f tgui::CustomWidgetForBindings::getAbsolutePosition ( ) const
overridevirtual

Get the absolute position of the widget instead of the relative position to its parent.

Returns
Absolute position of the widget

Reimplemented from tgui::Widget.

◆ getFullSize()

Vector2f tgui::CustomWidgetForBindings::getFullSize ( ) const
overridevirtual

Returns the entire size that the widget is using.

This function will return a value equal or greater than what getSize returns. If the widget would e.g. have borders around it then this function will return the size, including these borders.

Returns
Full size of the widget

Reimplemented from tgui::Widget.

◆ getWidgetOffset()

Vector2f tgui::CustomWidgetForBindings::getWidgetOffset ( ) const
overridevirtual

Returns the distance between the position where the widget is drawn and where the widget is placed.

The offset is (0,0) for almost all widgets.

Returns
Offset of the widget

Reimplemented from tgui::Widget.

◆ mouseOnWidget()

bool tgui::CustomWidgetForBindings::mouseOnWidget ( Vector2f  pos) const
overridevirtual

Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget.

Returns
Is the mouse on top of the widget?

Implements tgui::Widget.

◆ rendererChanged()

void tgui::CustomWidgetForBindings::rendererChanged ( const std::string &  property)
overrideprotectedvirtual

Function called when one of the properties of the renderer is changed.

Parameters
propertyLowercase name of the property that was changed

Reimplemented from tgui::Widget.

◆ setEnabled()

void tgui::CustomWidgetForBindings::setEnabled ( bool  enabled)
overridevirtual

Enables or disables the widget.

Parameters
enabledIs the widget enabled?

The disabled widget will no longer receive events and thus no longer send callbacks. All widgets are enabled by default.

Reimplemented from tgui::Widget.

◆ setFocused()

void tgui::CustomWidgetForBindings::setFocused ( bool  focused)
overridevirtual

Focus or unfocus the widget.

Parameters
focusedIs the widget focused?

When a widget is focused, the previously focused widget will be unfocused.

Warning
This function only works properly when the widget was already added to its parent (e.g. the Gui).

Reimplemented from tgui::Widget.

◆ setPosition()

void tgui::CustomWidgetForBindings::setPosition ( const Layout2d position)
overridevirtual

sets the position of the widget

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable widget is (0, 0).

Parameters
positionNew position
See also
move, getPosition

Usage examples:

// Place the widget on an exact position
widget->setPosition({40, 30});
// Place the widget relative to the size of its parent
widget->setPosition({"5%", "10%"});
// Place the widget 50 pixels below another widget and automatically move it when the other widget moves
widget->setPosition({tgui::bindLeft(otherWidget), tgui::bindBottom(otherWidget) + 50});
TGUI_API Layout bindBottom(std::shared_ptr< Widget > widget)
Bind to the bottom of the widget.
TGUI_API Layout bindLeft(std::shared_ptr< Widget > widget)
Bind to the x position of the widget.

Reimplemented from tgui::Widget.

◆ setSize()

void tgui::CustomWidgetForBindings::setSize ( const Layout2d size)
overridevirtual

Changes the size of the widget.

Parameters
sizeSize of the widget

Usage examples:

// Give the widget an exact size
widget->setSize({40, 30});
// Give the widget a size relative to the size of its parent
widget->setSize({"20%", "5%"});
// Make the widget 50 pixels higher than some other widget and automatically resize it when the other widget resizes
widget->setSize({200, tgui::bindHeight(otherWidget) + 50});
TGUI_API Layout bindHeight(std::shared_ptr< Widget > widget)
Bind to the height of the widget.

Reimplemented from tgui::Widget.

◆ setVisible()

void tgui::CustomWidgetForBindings::setVisible ( bool  visible)
overridevirtual

Shows or hides a widget.

Parameters
visibleIs the widget visible?

The widget won't receive events (and thus won't send callbacks) nor will it be drawn when hidden. The widget is visible by default.

Reimplemented from tgui::Widget.


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