R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
UI::IButton Class Referenceabstract

Abstract interface for UI buttons. More...

#include <IButton.hpp>

Inheritance diagram for UI::IButton:
Inheritance graph
Collaboration diagram for UI::IButton:
Collaboration graph

Public Member Functions

virtual ~IButton ()=default
 Virtual destructor.
 
virtual void Update ()=0
 Update the button internal state (hover/pressed) and trigger callbacks.
 
virtual void Render ()=0
 Render the button.
 
virtual void SetCallback (std::function< void()> callback)=0
 Set callback invoked on click.
 
virtual void SetPosition (float x, float y)=0
 Set the top-left position of the button.
 
virtual void GetPosition (float &x, float &y) const =0
 Get the current top-left position of the button.
 
virtual void SetSize (float width, float height)=0
 Set the button size.
 
virtual void GetSize (float &width, float &height) const =0
 Get the current size of the button.
 
virtual void SetBackgroundColor (unsigned int color)=0
 Set button background color.
 
virtual void SetHoverColor (unsigned int color)=0
 Set button hover color.
 
virtual ButtonState GetState () const =0
 Get current button state.
 
virtual bool IsEnabled () const =0
 Check if button is enabled.
 
virtual void SetEnabled (bool enabled)=0
 Enable/disable the button.
 
virtual void SetText (const std::string &text)=0
 Set button label text.
 
virtual const std::string & GetText () const =0
 Get button label text.
 
virtual void SetTextSize (int size)=0
 Set label font size in pixels.
 
virtual int GetTextSize () const =0
 Get label font size.
 
virtual void SetTextColor (unsigned int color)=0
 Set label color.
 
virtual unsigned int GetTextColor () const =0
 Get label color.
 
virtual void SetFont (int fontHandle)=0
 Set font handle to use for button text.
 
virtual int GetFont () const =0
 Get current font handle used by this button.
 
virtual void SetAlign (Align align)=0
 Set alignment mode relative to the current window.
 
virtual Align GetAlign () const =0
 Get current alignment mode.
 
virtual void ApplyAlignment ()=0
 Apply alignment (recomputes position based on window size).
 
virtual void SetFocused (bool focused)=0
 Set the keyboard focus state of the button.
 
virtual bool IsFocused () const =0
 Check if this button currently has keyboard focus.
 
virtual void TriggerClick ()=0
 Programmatically trigger the button's click callback.
 

Detailed Description

Abstract interface for UI buttons.

This interface defines a minimal, backend-agnostic contract for interactive buttons:

  • input update (hover/pressed/click)
  • rendering
  • visuals (size, position, colors)
  • label text (font, color, size)
  • optional alignment helpers relative to the window

Definition at line 50 of file IButton.hpp.

Constructor & Destructor Documentation

◆ ~IButton()

virtual UI::IButton::~IButton ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ ApplyAlignment()

virtual void UI::IButton::ApplyAlignment ( )
pure virtual

Apply alignment (recomputes position based on window size).

Note
Call this after SetSize(), or when the window is resized.

Implemented in UI::RaylibButton.

◆ GetAlign()

virtual Align UI::IButton::GetAlign ( ) const
pure virtual

Get current alignment mode.

Returns
Align.

Implemented in UI::RaylibButton.

◆ GetFont()

virtual int UI::IButton::GetFont ( ) const
pure virtual

Get current font handle used by this button.

Returns
Font handle (or -1 for default font).

Implemented in UI::RaylibButton.

◆ GetPosition()

virtual void UI::IButton::GetPosition ( float &  x,
float &  y 
) const
pure virtual

Get the current top-left position of the button.

Parameters
xOutput X position in pixels.
yOutput Y position in pixels.

Implemented in UI::RaylibButton.

◆ GetSize()

virtual void UI::IButton::GetSize ( float &  width,
float &  height 
) const
pure virtual

Get the current size of the button.

Parameters
widthOutput width in pixels.
heightOutput height in pixels.

Implemented in UI::RaylibButton.

◆ GetState()

virtual ButtonState UI::IButton::GetState ( ) const
pure virtual

Get current button state.

Returns
ButtonState.

Implemented in UI::RaylibButton.

◆ GetText()

virtual const std::string & UI::IButton::GetText ( ) const
pure virtual

Get button label text.

Returns
Reference to internal string.

Implemented in UI::RaylibButton.

◆ GetTextColor()

virtual unsigned int UI::IButton::GetTextColor ( ) const
pure virtual

Get label color.

Returns
Color in 0xAARRGGBB format.

Implemented in UI::RaylibButton.

◆ GetTextSize()

virtual int UI::IButton::GetTextSize ( ) const
pure virtual

Get label font size.

Returns
Font size in pixels.

Implemented in UI::RaylibButton.

◆ IsEnabled()

virtual bool UI::IButton::IsEnabled ( ) const
pure virtual

Check if button is enabled.

Returns
true if enabled.

Implemented in UI::RaylibButton.

◆ IsFocused()

virtual bool UI::IButton::IsFocused ( ) const
pure virtual

Check if this button currently has keyboard focus.

Returns
true if focused.

Implemented in UI::RaylibButton.

◆ Render()

virtual void UI::IButton::Render ( )
pure virtual

Render the button.

Note
Must be called between the backend BeginDrawing/EndDrawing calls.

Implemented in UI::RaylibButton.

◆ SetAlign()

virtual void UI::IButton::SetAlign ( Align  align)
pure virtual

Set alignment mode relative to the current window.

Parameters
alignDesired alignment.
Note
Implementations may call ApplyAlignment() immediately.

Implemented in UI::RaylibButton.

◆ SetBackgroundColor()

virtual void UI::IButton::SetBackgroundColor ( unsigned int  color)
pure virtual

Set button background color.

Parameters
colorColor in 0xAARRGGBB format.

Implemented in UI::RaylibButton.

◆ SetCallback()

virtual void UI::IButton::SetCallback ( std::function< void()>  callback)
pure virtual

Set callback invoked on click.

Parameters
callbackFunction called when the button is clicked.

Implemented in UI::RaylibButton.

◆ SetEnabled()

virtual void UI::IButton::SetEnabled ( bool  enabled)
pure virtual

Enable/disable the button.

Parameters
enabledtrue to enable.

Implemented in UI::RaylibButton.

◆ SetFocused()

virtual void UI::IButton::SetFocused ( bool  focused)
pure virtual

Set the keyboard focus state of the button.

Parameters
focusedtrue if this button should be focused.

Implemented in UI::RaylibButton.

◆ SetFont()

virtual void UI::IButton::SetFont ( int  fontHandle)
pure virtual

Set font handle to use for button text.

Parameters
fontHandleFont handle returned by Graphics::IGraphics::LoadFont(). Use -1 for default font.

Implemented in UI::RaylibButton.

◆ SetHoverColor()

virtual void UI::IButton::SetHoverColor ( unsigned int  color)
pure virtual

Set button hover color.

Parameters
colorColor in 0xAARRGGBB format.

Implemented in UI::RaylibButton.

◆ SetPosition()

virtual void UI::IButton::SetPosition ( float  x,
float  y 
)
pure virtual

Set the top-left position of the button.

Parameters
xX position in pixels.
yY position in pixels.

Implemented in UI::RaylibButton.

◆ SetSize()

virtual void UI::IButton::SetSize ( float  width,
float  height 
)
pure virtual

Set the button size.

Parameters
widthWidth in pixels.
heightHeight in pixels.

Implemented in UI::RaylibButton.

◆ SetText()

virtual void UI::IButton::SetText ( const std::string &  text)
pure virtual

Set button label text.

Parameters
textUTF-8 text.

Implemented in UI::RaylibButton.

◆ SetTextColor()

virtual void UI::IButton::SetTextColor ( unsigned int  color)
pure virtual

Set label color.

Parameters
colorColor in 0xAARRGGBB format.

Implemented in UI::RaylibButton.

◆ SetTextSize()

virtual void UI::IButton::SetTextSize ( int  size)
pure virtual

Set label font size in pixels.

Parameters
sizeFont size.

Implemented in UI::RaylibButton.

◆ TriggerClick()

virtual void UI::IButton::TriggerClick ( )
pure virtual

Programmatically trigger the button's click callback.

Note
Used by keyboard navigation to simulate a click on Enter key.

Implemented in UI::RaylibButton.

◆ Update()

virtual void UI::IButton::Update ( )
pure virtual

Update the button internal state (hover/pressed) and trigger callbacks.

Note
Should be called once per frame.

Implemented in UI::RaylibButton.


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