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

Detailed Description

A disc selecting the hue & the saturation of a color

+ Inheritance diagram for ColorWheel:

Public Typedefs

using Transform = std::function< float4 (const float4 &)>
 

Public Member Functions

 ColorWheel (float hue=0.0f, float saturation=0.0f, float brightness=1.0f)
 
auto getHue () const
 
auto getSaturation () const
 
auto getBrightness () const
 
auto getAlpha () const
 
void setHueSaturation (float hue, float saturation)
 
void setBrightness (float brightness)
 
void setAlpha (float alpha)
 
float4 getColor () const
 
void setColor (const float4 &color)
 
float4 displayedColorAt (float hue, float saturation) const
 
void setPreviewTransform (const Transform &transform)
 
float2 getCenter () const
 
float getRadius () const
 
auto getSegments () const
 
void setSegments (uint32 segments)
 
auto getRings () const
 
void setRings (uint32 rings)
 
auto getCursorRadius () const
 
void setCursorRadius (float radius)
 
auto getCursorBorder () const
 
void setCursorBorder (float width)
 
- 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
 
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)
 
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
 
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 >
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 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 onMouseLeave ()
 
virtual void onDisable ()
 
virtual void onEnable ()
 
virtual void onGotFocus ()
 
virtual void onLostFocus ()
 
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 unsubscribe (unique_id id)
 
bool isAttached () const
 
WindowgetWindow () const
 
StylegetStyle () const
 
Vector2DRenderer & getRenderer () const
 
RenderingWindow & getRenderingWindow () const
 
WindowManagergetWindowManager () const
 

Static Public Member Functions

static float4 fromHSV (float hue, float saturation, float brightness, float alpha=1.0f)
 
static float3 toHSV (const float4 &color)
 

Static Public Attributes

static constexpr uint32 DEFAULT_SEGMENTS {360}
 Number of angular subdivisions the disc is drawn with. More...
 
static constexpr uint32 DEFAULT_RINGS {48}
 
static constexpr float DEFAULT_CURSOR_RADIUS {4.0f}
 Default radius of the circle displaying the selected hue & saturation. More...
 
static constexpr float DEFAULT_CURSOR_BORDER {1.5f}
 Default width of the border of the circle displaying the selection. More...
 

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, 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
}
 
- 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 allowChildren {true}
 
bool drawBackground {true}
 
bool moveChildrenOnPush {false}
 
bool scrollChildren {false}
 
bool skipInvisibleChildren {false}
 
bool redrawOnMouseEvent {false}
 
bool redrawOnMouseMove {false}
 
float transparency {1.0f}
 
Widget * parent {nullptr}
 
Alignment alignment {Alignment::NONE}
 
std::shared_ptr< UIResourceresource
 
std::list< std::shared_ptr< Widget > > children
 
bool mouseMoveOnFocus {false}
 
float childrenOffsetX {0}
 
float childrenOffsetY {0}
 

Member Typedef Documentation

using Transform = std::function<float4(const float4&)>

Converts the selected color into the color the disc is drawn with, used when the colors of the UI are not in the same space as the selected color.

Constructor & Destructor Documentation

ColorWheel ( float  hue = 0.0f,
float  saturation = 0.0f,
float  brightness = 1.0f 
)

Creates a color wheel.

Parameters
hueInitial hue, in [0.0, 1.0].
saturationInitial saturation, in [0.0, 1.0].
brightnessBrightness the disc is drawn with, in [0.0, 1.0].

Member Function Documentation

float4 displayedColorAt ( float  hue,
float  saturation 
) const

Returns the color the disc is drawn with at a given hue & saturation with the preview transform applied

static float4 fromHSV ( float  hue,
float  saturation,
float  brightness,
float  alpha = 1.0f 
)
static

Converts a HSV color to RGBA

auto getAlpha ( ) const
inline

Returns the alpha of the selected color in [0.0, 1.0]

auto getBrightness ( ) const
inline

Returns the brightness the disc is drawn with in [0.0, 1.0]

float2 getCenter ( ) const

Returns the center of the disc, in screen units

float4 getColor ( ) const

Returns the selected color

auto getCursorBorder ( ) const
inline

Returns the width of the border of the circle displaying the selection

auto getCursorRadius ( ) const
inline

Returns the radius of the circle displaying the selected hue & saturation

auto getHue ( ) const
inline

Returns the selected hue in [0.0, 1.0]

float getRadius ( ) const

Returns the radius of the disc, in vertical units

auto getRings ( ) const
inline

Returns the number of concentric rings the disc is drawn with

auto getSaturation ( ) const
inline

Returns the selected saturation in [0.0, 1.0]

auto getSegments ( ) const
inline

Returns the number of angular subdivisions the disc is drawn with

void setAlpha ( float  alpha)

Changes the alpha of the selected color

void setBrightness ( float  brightness)

Changes the brightness the disc is drawn with

void setColor ( const float4 &  color)

Moves the cursor & changes the brightness to display a color

void setCursorBorder ( float  width)

Changes the width of the border of the circle displaying the selection

void setCursorRadius ( float  radius)

Changes the radius of the circle displaying the selected hue & saturation

void setHueSaturation ( float  hue,
float  saturation 
)

Moves the cursor, pushing an UIEvent::OnColorChange event if the color changes

void setPreviewTransform ( const Transform transform)

Sets the conversion applied to the colors before drawing the disc

void setRings ( uint32  rings)

Changes the number of concentric rings the disc is drawn with

void setSegments ( uint32  segments)

Changes the number of angular subdivisions the disc is drawn with

static float3 toHSV ( const float4 &  color)
static

Converts a RGBA color to HSV, the alpha is dropped

Member Data Documentation

constexpr float DEFAULT_CURSOR_BORDER {1.5f}
staticconstexpr

Default width of the border of the circle displaying the selection.

constexpr float DEFAULT_CURSOR_RADIUS {4.0f}
staticconstexpr

Default radius of the circle displaying the selected hue & saturation.

constexpr uint32 DEFAULT_RINGS {48}
staticconstexpr

Number of concentric rings the disc is drawn with : narrow rings keep the round caps of the arcs small, which is what makes them tile the disc cleanly

constexpr uint32 DEFAULT_SEGMENTS {360}
staticconstexpr

Number of angular subdivisions the disc is drawn with.