Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::MenuBar::Menu Class Reference

Menu entry that can host actions and submenus. More...

#include <spk_menu_bar.hpp>

Inheritance diagram for spk::MenuBar::Menu:
Inheritance graph
Collaboration diagram for spk::MenuBar::Menu:
Collaboration graph

Classes

class  Action
 Menu action entry wrapped around a push button. More...
struct  Bounds
 Bounding box for expanded menu popup geometry. More...
class  Separator
 Menu separator element. More...

Public Types

enum class  PopupPlacement { Below , Right }
 Placement for menu popups relative to the menu button.
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

 Menu (const std::wstring &p_name, spk::Widget *p_parent, spk::Widget *p_popupParent, PopupPlacement p_popupPlacement, MenuBar *p_menuBar, Menu *p_parentMenu)
 Builds a menu widget.
void setTitle (const std::wstring &p_title)
 Sets the menu title text.
ActionaddAction (const std::wstring &p_actionName)
 Adds an action to this menu.
MenuaddMenu (const std::wstring &p_menuName)
 Adds a submenu to this menu.
SeparatoraddSeparator ()
 Adds a separator to the menu.
void openPopup ()
 Opens the menu popup.
void closePopup ()
 Closes the menu popup.
bool isPopupOpen () const
 Returns whether the popup is open.
void closeSubmenus ()
 Closes all submenus.
void closeSubmenusExcept (Menu *p_menu)
 Closes all submenus except one.
void setMainMenuOffset (const spk::Vector2Int &p_offset)
 Sets the offset for main menu popup placement.
void setSubMenuOffset (const spk::Vector2Int &p_offset)
 Sets the offset for submenu popup placement.
spk::Vector2UInt popupMinimalSize () const
 Returns the minimal popup size.
spk::Vector2UInt popupBackgroundPadding () const
 Returns the popup background padding.
spk::Vector2UInt popupLayoutPadding () const
 Returns the popup layout padding.
const spk::Vector2IntmainMenuOffset () const
 Returns the main menu popup offset.
const spk::Vector2IntsubMenuOffset () const
 Returns the submenu popup offset.
Bounds expandedBounds (const spk::Vector2Int &p_menuAnchor) const
 Returns expanded bounds for popup placement.
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::Extend2Dgeometry () const
 Returns the current widget geometry.
const spk::OpenGL::ViewRegionviewRegion () const
 Accesses the computed view region.
const spk::OpenGL::FrameBufferObjectframeBufferObject () const
 Returns the frame buffer object used for widget rendering.
const spk::OpenGL::FrameBufferObjectfbo () 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.
Widgetparent () 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.
StatefulObjectoperator= (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
SizeHintsizeHint ()
 Returns mutable size hint data.
const SizeHintsizeHint () const
 Returns const size hint data.

Additional Inherited Members

Static Public Member Functions inherited from spk::Widget
static WidgetfocusedWidget (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.
Protected Member Functions inherited from spk::Widget
virtual void _onPaintEvent (spk::PaintEvent &p_event)
 Paint event hook for derived widgets.
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 _onMousePressEvent (spk::MousePressEvent &p_event)
 Mouse button press handler for derived widgets.
virtual void _onMouseReleaseEvent (spk::MouseReleaseEvent &p_event)
 Mouse button release handler for derived widgets.
virtual void _onMouseDoubleClickEvent (spk::MouseDoubleClickEvent &p_event)
 Mouse double click handler for derived widgets.
virtual void _onMouseMotionEvent (spk::MouseMotionEvent &p_event)
 Mouse motion 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.

Detailed Description

Menu entry that can host actions and submenus.

Constructor & Destructor Documentation

◆ Menu()

spk::MenuBar::Menu::Menu ( const std::wstring & p_name,
spk::Widget * p_parent,
spk::Widget * p_popupParent,
PopupPlacement p_popupPlacement,
MenuBar * p_menuBar,
Menu * p_parentMenu )

Builds a menu widget.

Parameters
p_nameMenu name.
p_parentParent widget.
p_popupParentParent widget for the popup.
p_popupPlacementPopup placement direction.
p_menuBarOwning menu bar.
p_parentMenuParent menu when this is a submenu.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ addAction()

MenuBar::Menu::Action & spk::MenuBar::Menu::addAction ( const std::wstring & p_actionName)

Adds an action to this menu.

Parameters
p_actionNameAction name.
Returns
Reference to the created action.
Here is the call graph for this function:

◆ addMenu()

MenuBar::Menu & spk::MenuBar::Menu::addMenu ( const std::wstring & p_menuName)

Adds a submenu to this menu.

Parameters
p_menuNameSubmenu name.
Returns
Reference to the created submenu.
Here is the call graph for this function:

◆ addSeparator()

MenuBar::Menu::Separator & spk::MenuBar::Menu::addSeparator ( )

Adds a separator to the menu.

Returns
Reference to the created separator.
Here is the call graph for this function:

◆ closeSubmenusExcept()

void spk::MenuBar::Menu::closeSubmenusExcept ( Menu * p_menu)

Closes all submenus except one.

Parameters
p_menuSubmenu to keep open.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expandedBounds()

MenuBar::Menu::Bounds spk::MenuBar::Menu::expandedBounds ( const spk::Vector2Int & p_menuAnchor) const

Returns expanded bounds for popup placement.

Parameters
p_menuAnchorMenu anchor position.
Returns
Expanded bounds.
Here is the call graph for this function:

◆ isPopupOpen()

bool spk::MenuBar::Menu::isPopupOpen ( ) const

Returns whether the popup is open.

Returns
true when popup is open.

◆ mainMenuOffset()

const spk::Vector2Int & spk::MenuBar::Menu::mainMenuOffset ( ) const

Returns the main menu popup offset.

Returns
Main menu offset.

◆ popupBackgroundPadding()

spk::Vector2UInt spk::MenuBar::Menu::popupBackgroundPadding ( ) const

Returns the popup background padding.

Returns
Background padding.

◆ popupLayoutPadding()

spk::Vector2UInt spk::MenuBar::Menu::popupLayoutPadding ( ) const

Returns the popup layout padding.

Returns
Layout padding.

◆ popupMinimalSize()

spk::Vector2UInt spk::MenuBar::Menu::popupMinimalSize ( ) const

Returns the minimal popup size.

Returns
Popup minimal size.

◆ setMainMenuOffset()

void spk::MenuBar::Menu::setMainMenuOffset ( const spk::Vector2Int & p_offset)

Sets the offset for main menu popup placement.

Parameters
p_offsetOffset from menu anchor.
Here is the caller graph for this function:

◆ setSubMenuOffset()

void spk::MenuBar::Menu::setSubMenuOffset ( const spk::Vector2Int & p_offset)

Sets the offset for submenu popup placement.

Parameters
p_offsetOffset from menu anchor.
Here is the caller graph for this function:

◆ setTitle()

void spk::MenuBar::Menu::setTitle ( const std::wstring & p_title)

Sets the menu title text.

Parameters
p_titleTitle text.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subMenuOffset()

const spk::Vector2Int & spk::MenuBar::Menu::subMenuOffset ( ) const

Returns the submenu popup offset.

Returns
Submenu offset.

The documentation for this class was generated from the following files:
  • includes/structure/widget/spk_menu_bar.hpp
  • srcs/structure/widget/spk_menu_bar.cpp