Lysa UI  0.0
Lysa UI —UI components for the Lysa Engine
RadialPieMenu Class Reference

Detailed Description

A modal radial selector of 2 to 8 widgets

+ Inheritance diagram for RadialPieMenu:

Classes

struct  Entry
 

Public Member Functions

 RadialPieMenu (const Rect &area, float2 center, std::vector< Entry > entries, std::optional< Key > triggerKey=std::nullopt)
 
const auto & getEntries () const
 
auto getHoveredIndex () const
 
auto getSelectedIndex () const
 
void setSelectedIndex (std::optional< std::size_t > index)
 
void setCenterSVG (const std::shared_ptr< SVG > &svg)
 
void onAttach () override
 
void onLostFocus () override
 
bool onMouseMove (uint32, float x, float y) override
 
bool onMouseDown (MouseButton, float x, float y) override
 
bool onKeyDown (Key) override
 
bool onKeyUp (Key) override
 
void draw (UIResource &, Vector2DRenderer &, bool before) const override
 
- Public Member Functions inherited from Popup
 Popup (const float x, const float y, const Type type=POPUP)
 
float getX () const
 
float getY () const
 
void hangFromAnchor (const float width, const float height)
 
void eventAttach () override
 
- Public Member Functions inherited from Widget
 Widget (Type type=WIDGET)
 
 ~Widget () override
 
Type getType () const
 
bool isVisible () const
 
void setVisible (bool show=true)
 
bool isEnabled () const
 
void setEnabled (bool isEnabled=true)
 
virtual void setPos (float x, float y)
 
float getWidth () const
 
float getHeight () const
 
float getRequestedWidth () const
 
float getRequestedHeight () const
 
virtual void setSize (float width, float height)
 
void setWidth (const float width)
 
void setHeight (const float height)
 
const Rect & getRect () const
 
Rect getScreenRect () const
 
void setRect (float x, float y, float width, float height)
 
void setRect (const Rect &rect)
 
float getAspectRatio () const
 
Alignment getAlignment () const
 
void setAlignment (Alignment alignment)
 
void setLayoutDirection (TextDirection direction)
 
TextDirection getLayoutDirection () const
 
TextDirection getEffectiveLayoutDirection () const
 
std::shared_ptr< Font > getFont () const
 
void setFont (const std::shared_ptr< Font > &font)
 
float getFontScale () const
 
virtual void setFontScale (float fontScale)
 
bool isFocused () const
 
bool isFocusable () const
 
bool isTabStop () const
 
void setTabStop (const bool tabStop)
 
Widget * getParent () const
 
void setOverlap (const bool overlap)
 
template<typename T , typename... Args>
std::shared_ptr< T > create (const std::string &resource, const Alignment alignment, Args &&...args)
 
template<typename T , typename... Args>
std::shared_ptr< T > create (const Alignment alignment, Args &&...args)
 
template<typename T >
std::shared_ptr< T > add (std::shared_ptr< T > child, const Alignment alignment=Alignment::NONE, const std::string &resource="", const bool overlap=false)
 
template<typename T >
std::shared_ptr< T > addPopup (std::shared_ptr< T > child, const std::string &resource="")
 
template<typename T >
std::shared_ptr< T > addAfter (std::shared_ptr< T > child, const std::shared_ptr< Widget > &after, const Alignment alignment, const std::string &resource="", const bool overlap=false)
 
virtual void remove (const std::shared_ptr< Widget > &child)
 
virtual void removeAll ()
 
void setPadding (float padding)
 
float getPadding () const
 
float getVBorder () const
 
float getHBorder () const
 
void setVBorder (float size)
 
void setHBorder (float size)
 
bool isDrawBackground () const
 
void setDrawBackground (bool drawBackground)
 
bool isPushed () const
 
bool isPointed () const
 
bool isFreezed () const
 
bool isRedrawOnMouseEvent () const
 
bool isOverlapping () const
 
Rect getChildrenRect () const
 
void setFreezed (const bool f)
 
void setPushed (const bool p)
 
void refresh ()
 
void setResource (std::shared_ptr< UIResource > res)
 
uint32 getGroupIndex () const
 
void setGroupIndex (int32 index)
 
template<typename T >
T getUserData () const
 
template<typename T >
std::shared_ptr< T > getPointerUserData () const
 
const std::any & getUserData () const
 
void setUserData (const std::any &data)
 
float getTransparency () const
 
void setTransparency (float alpha)
 
void resizeChildren ()
 
float getChildrenOffsetX () const
 
float getChildrenOffsetY () const
 
void setChildrenOffset (float x, float y)
 
std::shared_ptr< Widget > setFocus (bool focus=true)
 
virtual void onDetach ()
 
virtual void onShow ()
 
virtual void onHide ()
 
virtual void onResize ()
 
virtual void onMove ()
 
virtual bool onTextInput (const std::string &text)
 
virtual bool onMouseUp (MouseButton button, float x, float y)
 
virtual void onMouseLeave ()
 
virtual void onDisable ()
 
virtual void onEnable ()
 
virtual void onGotFocus ()
 
bool getConsumeMouseEvent () const
 
void setConsumeMouseEvent (const bool consumeMouseEvent)
 
const std::list< std::shared_ptr< Widget > > & getChildren () const
 
bool hasChildren () const
 
void subscribe (const event_type &type, unique_id id, EventHandlerCallback callback)
 
void subscribe (const event_type &type, EventHandlerCallback callback)
 
void subscribe (const event_type &type, SignalHandlerCallback callback)
 
void unsubscribe (unique_id id)
 
virtual void eventDetach ()
 
virtual void eventShow ()
 
virtual void eventAspectRatioChanged ()
 
virtual void eventHide ()
 
virtual void eventEnable ()
 
virtual void eventDisable ()
 
virtual void eventMove (float x, float y)
 
virtual void eventResize ()
 
virtual bool eventTextInput (const std::string &text)
 
virtual bool eventKeyDown (Key key)
 
virtual bool eventKeyUp (Key key)
 
virtual void eventMouseLeave ()
 
virtual void eventGotFocus ()
 
virtual void eventLostFocus ()
 
bool isAttached () const
 
Window & getWindow () const
 
Style & getStyle () const
 
Vector2DRenderer & getRenderer () const
 
RenderingWindow & getRenderingWindow () const
 
WindowManager & getWindowManager () const
 
bool isCustomDraw () const
 
void skipInvisibleChildren (const bool s)
 

Static Public Member Functions

static float2 direction (std::size_t index, std::size_t count)
 
static std::optional< std::size_t > indexAt (float2 offset, std::size_t count)
 

Static Public Attributes

static constexpr std::size_t MIN_ENTRIES {2}
 
static constexpr std::size_t MAX_ENTRIES {8}
 
static constexpr float DEAD_ZONE {24.0f}
 

Protected Member Functions

bool eventMouseMove (uint32 buttons, float x, float y) override
 
bool eventMouseDown (MouseButton button, float x, float y) override
 
bool eventMouseUp (MouseButton, float, float) override
 

Additional Inherited Members

- Public Types inherited from Widget
enum  Type {
  WIDGET, PANEL, BOX, LINE,
  FRAME, BUTTON, TOGGLEBUTTON, RADIOBUTTON,
  CHECKBOX, CHECKMARK, CROSSMARK, ARROW,
  TEXT, TEXTEDIT, RICHTEXTAREA, SCROLLBAR,
  SLIDER, RULER, COLORSLIDER, COLORWHEEL,
  KNOB, TREEVIEW, IMAGE, POPUP,
  LIST, LISTBOX, SELECTION, PROGRESSBAR,
  SCROLLCONTAINER, MENU, MENUPANEL, MENUBOX,
  TABBAR, TABCONTAINER, DIALOG, FOLDABLECONTAINER,
  COLORPICKER, COLORPICKERBUTTON, SPINBOX, SPINBUTTONS,
  ICONIMAGE, ICONSVG, DROPDOWNLIST, TOOLTIP,
  GRIDCELL, GRID, TABLE, RADIALPIEMENU,
  NUMBEREDIT
}
 
- Protected Attributes inherited from Widget
const Type type
 
Rect rect
 
float requestedWidth {0}
 
float requestedHeight {0}
 
float hborder {0}
 
float vborder {0}
 
float padding {0}
 
bool consumeMouseEvent {false}
 
bool overlap {false}
 
bool focused {false}
 
bool allowFocus {false}
 
bool tabStop {true}
 
bool allowChildren {true}
 
bool drawBackground {true}
 
bool moveChildrenOnPush {false}
 
bool scrollChildren {false}
 
bool skipInvisibleChildrenEnabled {false}
 
bool redrawOnMouseEvent {false}
 
bool redrawOnMouseMove {false}
 
bool customDraw {false}
 
float transparency {1.0f}
 
Widget * parent {nullptr}
 
Alignment alignment {Alignment::NONE}
 
TextDirection layoutDirection {TextDirection::AUTO}
 
std::shared_ptr< UIResource > resource
 
std::list< std::shared_ptr< Widget > > children
 
bool mouseMoveOnFocus {false}
 
float childrenOffsetX {0}
 
float childrenOffsetY {0}
 

Constructor & Destructor Documentation

RadialPieMenu ( const Rect &  area,
float2  center,
std::vector< Entry >  entries,
std::optional< Key >  triggerKey = std::nullopt 
)

Member Function Documentation

static float2 direction ( std::size_t  index,
std::size_t  count 
)
static
void draw ( UIResource &  ,
Vector2DRenderer &  ,
bool  before 
) const
overridevirtual

Reimplemented from lysa::ui::Widget::draw()

bool eventMouseDown ( MouseButton  button,
float  x,
float  y 
)
inlineoverrideprotectedvirtual

Raw mouse down event, see onMouseDown

Reimplemented from lysa::ui::Widget::eventMouseDown()

bool eventMouseMove ( uint32  buttonsState,
float  x,
float  y 
)
inlineoverrideprotectedvirtual

Raw mouse move event, see onMouseMove

Reimplemented from lysa::ui::Widget::eventMouseMove()

bool eventMouseUp ( MouseButton  button,
float  x,
float  y 
)
inlineoverrideprotectedvirtual

Raw mouse up event, see onMouseUp

Reimplemented from lysa::ui::Widget::eventMouseUp()

const auto& getEntries ( ) const
inline
auto getHoveredIndex ( ) const
inline
auto getSelectedIndex ( ) const
inline
static std::optional<std::size_t> indexAt ( float2  offset,
std::size_t  count 
)
static
void onAttach ( )
overridevirtual

Event called after Widget have been added to another widget or a window

Reimplemented from lysa::ui::Widget::onAttach()

bool onKeyDown ( Key  key)
overridevirtual

Event called when a key was pressed.

Parameters
keyThe key pressed.
Returns
True if event was handled.

Reimplemented from lysa::ui::Widget::onKeyDown()

bool onKeyUp ( Key  key)
overridevirtual

Event called when a key was released.

Parameters
keyThe key released.
Returns
True if event was handled.

Reimplemented from lysa::ui::Widget::onKeyUp()

void onLostFocus ( )
inlineoverridevirtual

Event called when the Window lost the keyboard focus.

Reimplemented from lysa::ui::Widget::onLostFocus()

bool onMouseDown ( MouseButton  button,
float  x,
float  y 
)
overridevirtual

Event called when a mouse button was pressed inside the Window.

Parameters
buttonThe mouse button.
xMouse X coordinate.
yMouse Y coordinate.
Returns
True if event was handled.

Reimplemented from lysa::ui::Widget::onMouseDown()

bool onMouseMove ( uint32  buttonsState,
float  x,
float  y 
)
overridevirtual

Event called when the mouse is moved above the Window client area.

Parameters
buttonsStateState of mouse buttons.
xMouse X coordinate.
yMouse Y coordinate.
Returns
True if event was handled.

Reimplemented from lysa::ui::Widget::onMouseMove()

void setCenterSVG ( const std::shared_ptr< SVG > &  svg)
void setSelectedIndex ( std::optional< std::size_t >  index)

Member Data Documentation

constexpr float DEAD_ZONE {24.0f}
staticconstexpr
constexpr std::size_t MAX_ENTRIES {8}
staticconstexpr
constexpr std::size_t MIN_ENTRIES {2}
staticconstexpr