Rose
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
rose::Widget Class Reference

An element of the application user interface. More...

#include <Visual.h>

Inheritance diagram for rose::Widget:
Inheritance graph
[legend]
Collaboration diagram for rose::Widget:
Collaboration graph
[legend]

Public Member Functions

 Widget (const Widget &)=delete
 
 Widget (Widget &&)=delete
 
Widgetoperator= (const Widget &)=delete
 
Widgetoperator= (Widget &&)=delete
 
std::string_view nodeId () const noexcept override
 
std::shared_ptr< WidgetpointerWidget (const Position< int > &position, const Position< int > &containerPosition)
 Search for the Widget within which the position lies. More...
 
Position< int > computeScreenPosition ()
 Recursively compute the Widget Position on the Screen. More...
 
bool contains (const Position< int > &position)
 Determine if a given Screen Position is within the Widget Rectangle. More...
 
ApplicationgetApplication ()
 Get a reference to the Application object. More...
 
ApplicationgetApplication () const
 const version of getApplication()
 
std::shared_ptr< WindowgetWindow ()
 Get the Window ancestor of a Widget. More...
 
std::shared_ptr< WindowgetWindow () const
 const version of getWindow().
 
bool enterEvent ()
 Notify Widget of mouse pointer enter event. More...
 
void setEnterLeaveEventCallback (EventCallback eventCallback)
 Set the enter callback.
 
bool leaveEvent ()
 Notify Widget of mouse pointer leave event. More...
 
void setLeaveEventCallback (EventCallback eventCallback)
 Set the leave callback.
 
bool buttonEvent (bool pressed, uint button, uint clicks, bool passed)
 Notify Widget of mouse button events. More...
 
void setButtonEventCallback (ButtonCallback buttonCallback)
 Set the button callback.
 
bool mouseMotionEvent (bool pressed, uint button, const Position< int > &mousePos, const Position< int > &relativePos, bool passed)
 Notify Widget of mouse motion events. More...
 
void setMouseMotionEventCallback (MouseMotionCallback mouseMotionCallback)
 Set the mouse motion callback.
 
bool mouseScrollEvent (const Position< int > &deltaPos, bool passed)
 Notify Widget of mouse scroll wheel events. More...
 
void setMouseScrollEventCallback (ScrollCallback scrollCallback)
 Set the mouse scroll callback.
 
bool keyboardShortcutEvent (uint32_t shortcutCode, bool state, uint repeat)
 Notify the Widget of a keyboard shortcut invocation. More...
 
void setKeyboardShortcutCallback (KeyboardShortcutCallback keyboardShortcutCallback)
 Set the keyboard shortcut callback.
 
bool keyTextInputEvent (const std::string &text)
 Notify the Widget of text input. More...
 
void setTextInputCallback (TextInputCallback textInputCallback)
 Set the text input callback.
 
bool supportsKeyboardFocus () const
 
bool keyboardFocusEvent (bool hasFocus)
 Notify the Widget when it gains or looses keyboard focus. More...
 
void setKeyboardFocusCallback (KeyboardFocusCallback keyboardFocusCallback)
 Set the keyboard focus callback.
 
bool keyboardEvent (const SDL_KeyboardEvent &keyboardEvent)
 
void setKeyboardEvent (KeyboardEventCallback keyboardEventCallback)
 
- Public Member Functions inherited from rose::Visual
void setScreenRectangle (const Position< int > &containerPosition)
 Compute the screen rectangle from the Container screen Position. More...
 
Rectangle getScreenRectangle (const Position< int > &containerPosition) const
 Get the rectangle occupied by the Visual. More...
 
virtual void draw (gm::Context &context, const Position< int > &containerPosition)=0
 Draw the visual.
 
virtual Rectangle layout (rose::gm::Context &context, const Rectangle &screenRect)=0
 Layout the visual.
 
Position< int > drawPadding (const Position< int > &containerPosition)
 Pad the drawing location.
 
Rectangle layoutPadding (const Rectangle &screenRect)
 Pad the layout.
 
void setSize (const Size &size)
 Set preferred Size.
 
Size getSize () const
 Get the preferred size.
 
void setPosition (const Position< int > &position)
 Set preferred Position.
 
Position< int > getPosition () const
 Get the preferred Position.
 
void setPadding (const Padding &padding)
 Set Padding.
 
void setScreenRectangle (const Rectangle &screenRect)
 Set Screen Rectangle.
 
constexpr bool isVisible () const noexcept
 Check visibility.
 
void setVisible (bool visible) noexcept
 Set visibility.
 
void setLayoutHint (const LayoutHint &hint)
 Add a LayoutHint.
 
std::optional< int > getAttachmentHint (LayoutHint::Attachment attachment)
 Get an AttachmentHint value given a LayoutHint::Attachment. More...
 
std::optional< int > getGridHint (LayoutHint::GridLayoutHint gridLayoutHint)
 Get a GridLayoutHint value given a LayoutHint::GridLayoutHint. More...
 
template<size_t HintClass>
std::optional< const ValueMapgetHintMap () const
 
SemanticGesture supportedSemanticGestures () const
 Get supported SemanticGestures.
 
- Public Member Functions inherited from rose::Container
virtual void add (const std::shared_ptr< Node > &node)
 
void remove (const std::shared_ptr< Node > &node)
 
- Public Member Functions inherited from rose::Node
 Node (const std::shared_ptr< Container > &container)
 Create a node and add it to a Container. More...
 
void setId (const Id &nodeId) noexcept
 Set Id.
 
std::string_view getId () const
 Get Id.
 
IdPath getIdPath () const
 Get the Id Path.
 
virtual void addedToContainer ()
 Called when a Node is added to a Container. More...
 
std::shared_ptr< Containercontainer ()
 
std::shared_ptr< Containercontainer () const
 
template<typename C >
std::shared_ptr< C > containerAs ()
 
template<typename C >
std::shared_ptr< C > containerAs () const
 
std::shared_ptr< const NodegetNode () const
 Get a const std::shared_ptr to this node. More...
 
std::shared_ptr< NodegetNode ()
 Get a std::shared_ptr to this node. More...
 
template<typename NodeType >
std::shared_ptr< const NodegetNode () const
 Get a std::shared_ptr<const NodeType> to this node. More...
 
template<typename NodeType >
std::shared_ptr< NodeType > getNode ()
 Get a std::shared_ptr<NodeType> to this node. More...
 
std::shared_ptr< Noderemove ()
 

Static Public Attributes

static constexpr std::string_view id = "Widget"
 
- Static Public Attributes inherited from rose::Container
static constexpr std::string_view id = "Container"
 
- Static Public Attributes inherited from rose::Node
static constexpr std::string_view id = "Node"
 

Protected Attributes

EventCallback mEnterEventCallback {}
 The pointer has entered the Widget.
 
EventCallback mLeaveEventCallback {}
 The pointer has left the Widget.
 
ButtonCallback mButtonEventCallback {}
 The pointer button has been pressed with the pointer inside the Widget.
 
MouseMotionCallback mMouseMotionCallback {}
 The pointer is in motion, inside the Widget with a button pressed.
 
ScrollCallback mMouseScrollCallback {}
 The mouse scroll wheel has moved with the pointer inside the Widget.
 
KeyboardShortcutCallback mKeyboardShortcutCallback {}
 A keyboard button event while the Widget has keyboard focus.
 
TextInputCallback mTextInputCallback {}
 A text input event while the Widget has keyboard focus.
 
KeyboardFocusCallback mKeyboardFocusCallback {}
 Notification that this Widget has gained or lost keyboard focus.
 
KeyboardEventCallback mKeyboardEventCallback {}
 Notification that this Widget has received a keyboard event.
 
- Protected Attributes inherited from rose::Visual
SemanticGesture mSemanticGesture {}
 
Position< int > mPos {}
 Position relative to the container, arrived at by layout.
 
Size mSize {}
 The size on screen, arrived at by layout.
 
Position< int > mPreferredPos {}
 The preferred position.
 
Size mPreferredSize {}
 The preferred size.
 
Rectangle mScreenRect {}
 The screen Rectangle computed at drawing time.
 
Padding mPadding {}
 Immediately around the Visual, used for separation and alignment.
 
State mState {}
 The object state Id string.
 
bool mVisible {true}
 If true the object is visible.
 
- Protected Attributes inherited from rose::Node
std::weak_ptr< ContainermContainer {}
 The Container that holds the Node. More...
 
Id mId {}
 

Additional Inherited Members

- Public Types inherited from rose::Visual
using ValueMap = std::map< int, int >
 The std::map type for each hint class.
 
- Public Types inherited from rose::Node
using NodePtr = std::shared_ptr< Node >
 
- Static Public Member Functions inherited from rose::Node
template<typename NodeType >
static std::shared_ptr< NodeType > create ()
 Create a Node with no arguments. More...
 
template<typename NodeType , typename ... Args>
static std::shared_ptr< NodeType > create (Args ... args)
 Create a Node with arguments. More...
 
template<typename NodeType , typename ContainerType , typename ... Args>
static std::shared_ptr< NodeType > add (ContainerType container, Args ... args)
 Create a Node with arguments and add to a Container. More...
 
- Public Attributes inherited from rose::Visual
std::map< size_t, ValueMapmHintsMap {}
 The std::map of hint class to ValueMap.
 

Detailed Description

An element of the application user interface.

Member Function Documentation

◆ buttonEvent()

bool rose::Widget::buttonEvent ( bool  pressed,
uint  button,
uint  clicks,
bool  passed 
)

Notify Widget of mouse button events.

Parameters
pressedTrue if a button is pressed.
buttonThe button that changed state.
clicksThe number of clicks.
Returns
True if the event is consumed.

◆ computeScreenPosition()

Position< int > rose::Widget::computeScreenPosition ( )

Recursively compute the Widget Position on the Screen.

Returns
The computed Position.

◆ contains()

bool rose::Widget::contains ( const Position< int > &  position)

Determine if a given Screen Position is within the Widget Rectangle.

Parameters
positionThe Screen Position.
Returns
True if the Position is within the Rectangle.

◆ enterEvent()

bool rose::Widget::enterEvent ( )
inline

Notify Widget of mouse pointer enter event.

Returns
True if event is consumed.

◆ getApplication()

Application& rose::Widget::getApplication ( )
inline

Get a reference to the Application object.

Returns
The reference.

◆ getWindow()

std::shared_ptr<Window> rose::Widget::getWindow ( )
inline

Get the Window ancestor of a Widget.

Returns
The Window.

◆ keyboardFocusEvent()

bool rose::Widget::keyboardFocusEvent ( bool  hasFocus)

Notify the Widget when it gains or looses keyboard focus.

Parameters
hasFocusTrue when the Widget has gained focus.
Returns
True if the event is consumed.

◆ keyboardShortcutEvent()

bool rose::Widget::keyboardShortcutEvent ( uint32_t  shortcutCode,
bool  state,
uint  repeat 
)

Notify the Widget of a keyboard shortcut invocation.

Parameters
shortcutCodeThe keycode registered to the Widget.

◆ keyTextInputEvent()

bool rose::Widget::keyTextInputEvent ( const std::string &  text)

Notify the Widget of text input.

Parameters
textThe text input
Returns
True if the event is consumed.

◆ leaveEvent()

bool rose::Widget::leaveEvent ( )
inline

Notify Widget of mouse pointer leave event.

Returns
True if event is consumed.

◆ mouseMotionEvent()

bool rose::Widget::mouseMotionEvent ( bool  pressed,
uint  button,
const Position< int > &  mousePos,
const Position< int > &  relativePos,
bool  passed 
)

Notify Widget of mouse motion events.

If this Widget does not consume the event, and any button is pressed, it is passed up the tree. This allows a Manager above the pointer focused Widget to receive drag events.

Parameters
pressedTrue if a button is pressed.
buttonA bitwise or of pressed buttons.
mousePosThe screen position of the mouse.
relativePosThe relative motion of the mouse.
Returns
True if the event is consumed.

◆ mouseScrollEvent()

bool rose::Widget::mouseScrollEvent ( const Position< int > &  deltaPos,
bool  passed 
)

Notify Widget of mouse scroll wheel events.

If this Widget does not consume the event it is passed up the tree.

Parameters
deltaPosThe delta position of the scroll wheel motion.
Returns
True if the event is consumed.

◆ pointerWidget()

std::shared_ptr< Widget > rose::Widget::pointerWidget ( const Position< int > &  position,
const Position< int > &  containerPosition 
)

Search for the Widget within which the position lies.

Parameters
positionThe position.
containerPositionThe position of the container holding the Widget.
Returns
The Widget if found, otherwise a null pointer.

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