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

Detailed Description

A ModalDialog displaying a message to ask the user to confirm an action.

+ Inheritance diagram for ConfirmDialog:

Public Typedefs

using Callback = std::function< void (int32 button)>
 Receives the index of the button pressed by the user. More...
 

Public Member Functions

 ConfirmDialog (const std::string &title, const std::string &message, const std::vector< std::string > &buttons, const Callback &onClose=nullptr, float width=DialogBox::DEFAULT_WIDTH, float height=DialogBox::DEFAULT_HEIGHT, const std::string &resource="")
 
void setMessage (const std::string &message)
 
const auto & getMessage () const
 
void setOnClose (const Callback &callback)
 
auto getSelectedButton () const
 
const auto & getLines () const
 
- Public Member Functions inherited from ModalDialog
 ModalDialog (const std::string &title, const std::vector< std::string > &buttons={}, float width=DialogBox::DEFAULT_WIDTH, float height=DialogBox::DEFAULT_HEIGHT, const std::string &resource="")
 
void add (const Window &parent)
 
void add (const Widget &parent)
 
DialogBox & getDialog () const
 
void setButtonSize (const float width, const float height)
 
void setCloseButtonVisible (bool visible)
 
bool isCloseButtonVisible () const
 
- Public Member Functions inherited from Window
 Window (const Rect &rect)
 
 ~Window () override = default
 
bool isAttached () const
 
void setResizeableBorders (const uint32 borders)
 
auto getResizeableBorders () const
 
auto isModal () const
 
void setModal (bool modal)
 
Style & getStyle () const
 
void setStyle (const std::shared_ptr< Style > &style)
 
void inheritStyle (const Window &other)
 
Widget & getWidget () const
 
void setWidget (std::shared_ptr< Widget > child=nullptr, const std::string &resources="", float padding=0)
 
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 (const std::shared_ptr< T > &child, const Alignment alignment, const std::string &resource="", const bool overlap=false) const
 
void remove (const std::shared_ptr< Widget > &child) const
 
void setFocusedWidget (const std::shared_ptr< Widget > &widget)
 
void clearFocusedWidget ()
 
const auto & getFocusedWidget () const
 
bool focusNextWidget ()
 
bool focusPreviousWidget ()
 
auto getWidth () const
 
auto getHeight () const
 
void setRect (const Rect &newRect)
 
void setWidth (float width)
 
void setHeight (float height)
 
void setPos (float x, float y)
 
void setPos (const float2 &pos)
 
float getX () const
 
float getY () const
 
void setX (float x)
 
void setY (float y)
 
const auto & getRect () const
 
float getAspectRatio () const
 
auto isVisible () const
 
void setVisible (bool isVisible)
 
void hide ()
 
void show ()
 
void setTransparency (float alpha)
 
virtual void onAttach ()
 
virtual void onDetach ()
 
virtual void onShow ()
 
virtual void onHide ()
 
virtual void onResize ()
 
virtual void onMove ()
 
virtual bool onKeyDown (Key key)
 
virtual bool onTextInput (const std::string &text)
 
virtual bool onKeyUp (Key key)
 
virtual bool onMouseDown (MouseButton button, float x, float y)
 
virtual bool onMouseUp (MouseButton button, float x, float y)
 
virtual bool onMouseMove (uint32 buttonsState, float x, float y)
 
virtual void onGotFocus ()
 
virtual void onLostFocus ()
 
void setMinimumSize (float width, float height)
 
void setMaximumSize (float width, float height)
 
auto getMinimumWidth () const
 
auto getMinimumHeight () const
 
auto getMaximumWidth () const
 
auto getMaximumHeight () const
 
std::shared_ptr< Font > getFont () const
 
void setFont (const std::shared_ptr< Font > &font)
 
float getFontScale () const
 
void setFontScale (float fontScale)
 
void refresh () const
 
void attach (WindowManager *windowManager)
 
void close ()
 
Vector2DRenderer & getRenderer () const
 
RenderingWindow & getRenderingWindow () const
 
WindowManager & getWindowManager () 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)
 

Static Public Attributes

static constexpr int32 BUTTON_CONFIRM {0}
 Index of the first button. More...
 
- Static Public Attributes inherited from Window
static constexpr uint32 MODAL_LAYER {2}
 

Additional Inherited Members

- Public Types inherited from Window
enum  ResizeableBorder {
  RESIZEABLE_NONE = 0b0000, RESIZEABLE_LEFT = 0b0001, RESIZEABLE_RIGHT = 0b0010, RESIZEABLE_TOP = 0b0100,
  RESIZEABLE_BOTTOM = 0b1000
}
 

Member Typedef Documentation

using Callback = std::function<void(int32 button)>

Receives the index of the button pressed by the user.

Constructor & Destructor Documentation

ConfirmDialog ( const std::string &  title,
const std::string &  message,
const std::vector< std::string > &  buttons,
const Callback &  onClose = nullptr,
float  width = DialogBox::DEFAULT_WIDTH,
float  height = DialogBox::DEFAULT_HEIGHT,
const std::string &  resource = "" 
)

Creates a confirmation dialog

Parameters
titleText displayed at the top of the dialog.
messageMessage displayed above the buttons
buttonsLabels of the buttons
onCloseCalled with the index of the pressed button once the dialog is hidden.
widthWidth of the dialog
heightHeight of the dialog
resourceResource string for the box

Member Function Documentation

const auto& getLines ( ) const
inline

Returns the widgets displaying the lines of the message.

const auto& getMessage ( ) const
inline

Returns the message.

auto getSelectedButton ( ) const
inline

Returns the index of the button that closed the dialog.

void setMessage ( const std::string &  message)

Changes the message.

void setOnClose ( const Callback &  callback)
inline

Sets the function called with the index of the pressed button.

Member Data Documentation

constexpr int32 BUTTON_CONFIRM {0}
staticconstexpr

Index of the first button.