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

Detailed Description

A ModalDialog selecting a RGBA color with a ColorPicker.

+ Inheritance diagram for ColorModalDialog:

Public Typedefs

using ColorCallback = std::function< void (const float4 &color)>
 Called with the color selected by the user. More...
 

Public Member Functions

 ColorModalDialog (const std::string &title, const std::vector< std::string > &buttons, const float4 &color, const ColorCallback &onSelect, float width=DEFAULT_WIDTH, float rowHeight=ColorPicker::DEFAULT_ROW_HEIGHT, float footerHeight=0.0f, const std::string &resource="")
 
const float4 & getColor () const
 
auto getColorPicker () const
 
void setPreviewTransform (const ColorPicker::Transform &transform)
 
void onAttach () override
 
- 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)
 
DialogBoxgetDialog () const
 
void setButtonSize (const float width, const float height)
 
- 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 (const bool modal)
 
StylegetStyle () const
 
void setStyle (const std::shared_ptr< Style > &style)
 
WidgetgetWidget () 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)
 
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 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
 
WindowManagergetWindowManager () const
 
void subscribe (const event_type &type, unique_id id, EventHandlerCallback callback)
 
void subscribe (const event_type &type, EventHandlerCallback callback)
 
void unsubscribe (unique_id id)
 

Static Public Member Functions

static float dialogHeight (float rowHeight, float footerHeight=0.0f)
 

Static Public Attributes

static constexpr int32 SELECT_BUTTON {0}
 Index of the button applying the selected color. More...
 
static constexpr int32 CANCEL_BUTTON {1}
 Index of the button closing the dialog without applying the color. More...
 
static constexpr float DEFAULT_WIDTH {170.0f}
 
static constexpr float DEFAULT_DECORATION_HEIGHT {110.0f}
 Height reserved above & below the selector for the title & the buttons. More...
 

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 ColorCallback = std::function<void(const float4& color)>

Called with the color selected by the user.

Constructor & Destructor Documentation

ColorModalDialog ( const std::string &  title,
const std::vector< std::string > &  buttons,
const float4 &  color,
const ColorCallback onSelect,
float  width = DEFAULT_WIDTH,
float  rowHeight = ColorPicker::DEFAULT_ROW_HEIGHT,
float  footerHeight = 0.0f,
const std::string &  resource = "" 
)

Creates a dialog selecting a color, displayed by show().

Parameters
titleText displayed at the top of the dialog.
buttonsLabels of the buttons, SELECT_BUTTON & CANCEL_BUTTON are their indexes.
colorColor selected when the dialog opens.
onSelectCalled when the user activates SELECT_BUTTON.
widthWidth of the dialog, in screen units.
rowHeightHeight of the row displaying the slider of one component.
footerHeightHeight reserved at the bottom of the picker for the application.
resourceResource string for the box drawn around the dialog, also used as the background of the selector.

Member Function Documentation

static float dialogHeight ( float  rowHeight,
float  footerHeight = 0.0f 
)
static
const float4& getColor ( ) const

Returns the color currently selected.

auto getColorPicker ( ) const
inline

Returns the selector displayed by the dialog or nullptr before it is displayed.

void onAttach ( )
overridevirtual

Event called after the Window have been attached to a WindowManager

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

void setPreviewTransform ( const ColorPicker::Transform transform)

Sets the conversion applied to the selected color before drawing the preview.

Member Data Documentation

constexpr int32 CANCEL_BUTTON {1}
staticconstexpr

Index of the button closing the dialog without applying the color.

constexpr float DEFAULT_DECORATION_HEIGHT {110.0f}
staticconstexpr

Height reserved above & below the selector for the title & the buttons.

constexpr float DEFAULT_WIDTH {170.0f}
staticconstexpr

Default width of the dialog, narrower than a message dialog : the picker is built around a square wheel & the sliders take the width they are given

constexpr int32 SELECT_BUTTON {0}
staticconstexpr

Index of the button applying the selected color.