|
Sparkle 0.0.1
|
Button widget displaying text with background visuals. More...
#include <spk_push_button.hpp>


Public Types | |
| enum class | State { Released , Pressed , Hovered , Both } |
| Visual state of the button. | |
| using | Contract = spk::TContractProvider<>::Contract |
| Contract type for click subscriptions. | |
| using | Job = spk::TContractProvider<>::Job |
| Job type invoked on clicks. | |
| Public Types inherited from spk::Widget | |
| enum class | FocusType { Keyboard = 0 , Mouse = 1 } |
| Types of focus a widget can own. | |
| Public Types inherited from spk::ActivableObject | |
| using | Contract = StatefulObject<ActivationStatus>::Contract |
| Subscription handle controlling callback lifetime. | |
| using | Job = StatefulObject<ActivationStatus>::Job |
| Callback signature executed on activation state changes. | |
| Public Types inherited from spk::StatefulObject< ActivationStatus > | |
| using | Contract |
| Handle allowing subscribers to manage callback lifetimes. | |
| using | Job |
| Callable invoked when the object transitions to a state. | |
Public Member Functions | |
| PushButton (const std::wstring &p_name, spk::Widget *p_parent) | |
| Builds a push button widget. | |
| void | setVisualState (const State &p_state) |
| Sets the current visual state. | |
| void | setForceHovered (bool p_force) |
| Forces hovered state visually. | |
| Contract | subscribe (const Job &p_job) |
| Subscribes to click events. | |
| void | setTexture (const spk::SpriteSheet *p_spriteSheet, State p_state=State::Both) |
| Sets the background texture for a state. | |
| void | setCornerSize (const spk::Vector2UInt &p_cornerSize, State p_state=State::Both) |
| Sets the background corner size for a state. | |
| void | setFont (spk::Font *p_font, State p_state=State::Both) |
| Sets the font for a state. | |
| void | setFontSize (const spk::Font::Size &p_size, State p_state=State::Both) |
| Sets the font size for a state. | |
| void | setColors (const spk::Color &p_glyphColor, const spk::Color &p_outlineColor, State p_state=State::Both) |
| Sets glyph and outline colors for a state. | |
| void | setText (const std::wstring &p_text, State p_state=State::Both) |
| Sets the text for a state. | |
| void | setAlignment (HorizontalAlignment p_horizontalAlignment, VerticalAlignment p_verticalAlignment, State p_state=State::Both) |
| Sets text alignment for a state. | |
| const spk::SpriteSheet * | texture (State p_state) const |
| Returns the background texture for a state. | |
| const spk::Vector2UInt & | cornerSize (State p_state) const |
| Returns the background corner size for a state. | |
| spk::Font * | font (State p_state) const |
| Returns the font for a state. | |
| const spk::Font::Size & | fontSize (State p_state) const |
| Returns the font size for a state. | |
| const spk::Color & | glyphColor (State p_state) const |
| Returns the glyph color for a state. | |
| const spk::Color & | outlineColor (State p_state) const |
| Returns the outline color for a state. | |
| const std::wstring & | text (State p_state) const |
| Returns the text for a state. | |
| HorizontalAlignment | horizontalAlignment (State p_state) const |
| Returns the horizontal alignment for a state. | |
| VerticalAlignment | verticalAlignment (State p_state) const |
| Returns the vertical alignment for a state. | |
| Public Member Functions inherited from spk::Widget | |
| void | takeFocus (FocusType p_focusType) |
| Grants this widget ownership of the requested focus type. | |
| void | releaseFocus (FocusType p_focusType) |
| Releases a previously acquired focus type. | |
| bool | hasFocus (FocusType p_focusType) const |
| Checks if this widget currently owns a focus type. | |
| void | takeAllFocus () |
| Acquires both keyboard and mouse focus. | |
| void | releaseAllFocus () |
| Releases both keyboard and mouse focus types. | |
| Widget (const std::wstring &p_name, Widget *p_parent) | |
| Builds a widget optionally attached to a parent. | |
| void | addChild (Widget *p_child) override |
| Adds a child widget and sorts the hierarchy by layer. | |
| const float & | layer () const |
| Current rendering layer of the widget. | |
| void | setLayer (const float &p_newLayer) |
| Updates the widget layer and propagates relative offsets to children. | |
| const std::wstring & | name () const |
| Retrieves the widget name. | |
| void | setName (const std::wstring &p_name) |
| Sets the widget name. | |
| void | setGeometry (const spk::Extend2D &p_geometry) override |
| Requests a specific viewport and scissor region for the widget. | |
| const spk::Extend2D & | geometry () const |
| Returns the current widget geometry. | |
| const spk::OpenGL::ViewRegion & | viewRegion () const |
| Accesses the computed view region. | |
| const spk::OpenGL::FrameBufferObject & | frameBufferObject () const |
| Returns the frame buffer object used for widget rendering. | |
| const spk::OpenGL::FrameBufferObject & | fbo () const |
| Alias for frameBufferObject(). | |
| void | requireGeometryChange () |
| Marks the widget view region as needing recomputation. | |
| Public Member Functions inherited from spk::InherenceObject< Widget > | |
| virtual void | removeChild (Widget *p_child) |
| Removes a child from this node. | |
| Widget * | parent () const |
| Returns the parent pointer. | |
| virtual std::vector< Widget * > & | children () |
| Returns the children vector. | |
| void | clearChildren () |
| Clears the children list and resets each child's parent pointer. | |
| Public Member Functions inherited from spk::ActivableObject | |
| ActivableObject () | |
| Builds a deactivated object. | |
| ActivableObject (ActivationStatus p_initial) | |
| Builds with a custom initial activation state. | |
| void | activate () |
| Sets the state to Activated. | |
| void | deactivate () |
| Sets the state to Deactivated. | |
| void | toggle () |
| Toggles between activated and deactivated states. | |
| bool | isActive () const |
| Checks whether the object is currently activated. | |
| Contract | addActivationCallback (const Job &p_callback) |
| Registers a callback executed when the object activates. | |
| Contract | addDeactivationCallback (const Job &p_callback) |
| Registers a callback executed when the object deactivates. | |
| Public Member Functions inherited from spk::StatefulObject< ActivationStatus > | |
| StatefulObject (const ActivationStatus &p_initialState) | |
| Builds with an initial state. | |
| StatefulObject & | operator= (const StatefulObject &p_other)=delete |
| void | setState (const ActivationStatus &p_newState) |
| Sets a new state and triggers callbacks registered for it. | |
| ActivationStatus | state () const |
| Returns the current state. | |
| Contract | addCallback (const ActivationStatus &p_state, const Job &p_callback) |
| Subscribes a callback for a specific state. | |
| Public Member Functions inherited from spk::ResizableElement | |
| SizeHint & | sizeHint () |
| Returns mutable size hint data. | |
| const SizeHint & | sizeHint () const |
| Returns const size hint data. | |
Protected Member Functions | |
| void | _onGeometryChange () override |
| Updates layout geometry when size changes. | |
| void | _onPaintEvent (spk::PaintEvent &p_event) override |
| Paints the button visuals. | |
| void | _onMousePressEvent (spk::MousePressEvent &p_event) override |
| Handles mouse press events. | |
| void | _onMouseReleaseEvent (spk::MouseReleaseEvent &p_event) override |
| Handles mouse release events. | |
| void | _onMouseDoubleClickEvent (spk::MouseDoubleClickEvent &p_event) override |
| Handles mouse double click events. | |
| void | _onMouseMotionEvent (spk::MouseMotionEvent &p_event) override |
| Handles mouse motion events. | |
| Protected Member Functions inherited from spk::Widget | |
| virtual void | _onKeyPressEvent (spk::KeyPressEvent &p_event) |
| Keyboard press handler for derived widgets. | |
| virtual void | _onKeyReleaseEvent (spk::KeyReleaseEvent &p_event) |
| Keyboard release handler for derived widgets. | |
| virtual void | _onGlyphEvent (spk::GlyphEvent &p_event) |
| Text glyph input handler for derived widgets. | |
| virtual void | _onMouseWheelEvent (spk::MouseWheelEvent &p_event) |
| Mouse wheel handler for derived widgets. | |
| virtual void | _onEnterResizeModeEvent (spk::EnterResizeModeEvent &p_event) |
| Callback for entering resize mode. | |
| virtual void | _onResizeEvent (spk::ResizeEvent &p_event) |
| Resize handling hook. | |
| virtual void | _onExitResizeModeEvent (spk::ExitResizeModeEvent &p_event) |
| Callback invoked when leaving resize mode. | |
| virtual void | _onQuitEvent (spk::QuitEvent &p_event) |
| Quit event handler hook. | |
| virtual void | _onMoveEvent (spk::MoveEvent &p_event) |
| Window move handler hook. | |
| virtual void | _onFullScreenModeEvent (spk::FullScreenModeEvent &p_event) |
| Full screen toggle handler hook. | |
| virtual void | _onMaximizedModeEvent (spk::MaximizedModeEvent &p_event) |
| Maximized mode change handler. | |
| virtual void | _onFocusEvent (spk::FocusEvent &p_event) |
| Focus change handler hook. | |
| virtual void | _onUpdateEvent (spk::UpdateEvent &p_event) |
| Frame update handler hook. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from spk::Widget | |
| static Widget * | focusedWidget (FocusType p_focusType) |
| Retrieves the widget currently owning a focus type. | |
| Static Public Attributes inherited from spk::Widget | |
| static const size_t | NbFocusType = 2 |
| Number of focus slots tracked at runtime. | |
Button widget displaying text with background visuals.
| spk::PushButton::PushButton | ( | const std::wstring & | p_name, |
| spk::Widget * | p_parent ) |
Builds a push button widget.
| p_name | Widget name. |
| p_parent | Parent widget. |

|
overrideprotectedvirtual |
Updates layout geometry when size changes.
Reimplemented from spk::Widget.
|
overrideprotectedvirtual |
Handles mouse double click events.
| p_event | Mouse double click event payload. |
Reimplemented from spk::Widget.

|
overrideprotectedvirtual |
Handles mouse motion events.
| p_event | Mouse motion event payload. |
Reimplemented from spk::Widget.

|
overrideprotectedvirtual |
Handles mouse press events.
| p_event | Mouse press event payload. |
Reimplemented from spk::Widget.

|
overrideprotectedvirtual |
Handles mouse release events.
| p_event | Mouse release event payload. |
Reimplemented from spk::Widget.

|
overrideprotectedvirtual |
| const spk::Vector2UInt & spk::PushButton::cornerSize | ( | State | p_state | ) | const |
Returns the background corner size for a state.
| p_state | State to query. |
| const spk::Font::Size & spk::PushButton::fontSize | ( | State | p_state | ) | const |
| const spk::Color & spk::PushButton::glyphColor | ( | State | p_state | ) | const |
| HorizontalAlignment spk::PushButton::horizontalAlignment | ( | State | p_state | ) | const |
Returns the horizontal alignment for a state.
| p_state | State to query. |
| const spk::Color & spk::PushButton::outlineColor | ( | State | p_state | ) | const |
| void spk::PushButton::setAlignment | ( | HorizontalAlignment | p_horizontalAlignment, |
| VerticalAlignment | p_verticalAlignment, | ||
| State | p_state = State::Both ) |
Sets text alignment for a state.
| p_horizontalAlignment | Horizontal alignment. |
| p_verticalAlignment | Vertical alignment. |
| p_state | State to update. |

| void spk::PushButton::setColors | ( | const spk::Color & | p_glyphColor, |
| const spk::Color & | p_outlineColor, | ||
| State | p_state = State::Both ) |
Sets glyph and outline colors for a state.
| p_glyphColor | Glyph color. |
| p_outlineColor | Outline color. |
| p_state | State to update. |
| void spk::PushButton::setCornerSize | ( | const spk::Vector2UInt & | p_cornerSize, |
| State | p_state = State::Both ) |
Sets the background corner size for a state.
| p_cornerSize | Corner size in pixels. |
| p_state | State to update. |


| void spk::PushButton::setFontSize | ( | const spk::Font::Size & | p_size, |
| State | p_state = State::Both ) |
| void spk::PushButton::setForceHovered | ( | bool | p_force | ) |
Forces hovered state visually.
| p_force | Whether to force hovered visuals. |
| void spk::PushButton::setText | ( | const std::wstring & | p_text, |
| State | p_state = State::Both ) |
Sets the text for a state.
| p_text | Button text. |
| p_state | State to update. |


| void spk::PushButton::setTexture | ( | const spk::SpriteSheet * | p_spriteSheet, |
| State | p_state = State::Both ) |
Sets the background texture for a state.
| p_spriteSheet | Sprite sheet pointer. |
| p_state | State to update. |

| void spk::PushButton::setVisualState | ( | const State & | p_state | ) |
Sets the current visual state.
| p_state | New state. |

| PushButton::Contract spk::PushButton::subscribe | ( | const Job & | p_job | ) |
Subscribes to click events.
| p_job | Callback invoked on click. |
| const std::wstring & spk::PushButton::text | ( | State | p_state | ) | const |
| const spk::SpriteSheet * spk::PushButton::texture | ( | State | p_state | ) | const |
Returns the background texture for a state.
| p_state | State to query. |
| VerticalAlignment spk::PushButton::verticalAlignment | ( | State | p_state | ) | const |
Returns the vertical alignment for a state.
| p_state | State to query. |