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

Detailed Description

An Icon displaying an SVG shape fitted into the widget rectangle.

+ Inheritance diagram for IconSVG:

Public Member Functions

 IconSVG ()
 
 IconSVG (const std::string &uri, float strokeWidth=SVG::DEFAULT_STROKE_WIDTH, float tolerance=SVG::DEFAULT_TOLERANCE, SVGBounds bounds=SVGBounds::CONTENT)
 
 IconSVG (const std::shared_ptr< SVG > &svg)
 
void setSVG (const std::string &uri, float strokeWidth=SVG::DEFAULT_STROKE_WIDTH, float tolerance=SVG::DEFAULT_TOLERANCE, SVGBounds bounds=SVGBounds::CONTENT)
 
void setSVG (const std::shared_ptr< SVG > &svg)
 
auto getSVG () const
 
float getSourceRatio () const override
 
- Public Member Functions inherited from Icon
void setColor (const float4 &color)
 
auto getColor () const
 
auto hasCustomColor () const
 
void resetColor ()
 
void setScale (float scale)
 
auto getScale () const
 
Rect getDrawingRect (float screenRatio) const
 
- 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 std::shared_ptr< SVG > load (const std::string &uri, float strokeWidth=SVG::DEFAULT_STROKE_WIDTH, float tolerance=SVG::DEFAULT_TOLERANCE, SVGBounds bounds=SVGBounds::CONTENT)
 
static void clearCache ()
 

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 Member Functions inherited from Icon
 Icon (Type type)
 
- 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}
 

Constructor & Destructor Documentation

IconSVG ( )

Constructs an empty icon.

IconSVG ( const std::string &  uri,
float  strokeWidth = SVG::DEFAULT_STROKE_WIDTH,
float  tolerance = SVG::DEFAULT_TOLERANCE,
SVGBounds  bounds = SVGBounds::CONTENT 
)
explicit

Constructs an icon displaying the SVG document loaded from the given URI.

Parameters
uriURI of the .svg document
strokeWidthWidth of the stroke of a stroked documen
tolerancePrecision of the flattening of the curves
boundsBox the drawing is fitted into, SVGBounds::CONTENT by default so that the drawing uses all the room the widget gives it
IconSVG ( const std::shared_ptr< SVG > &  svg)
explicit

Constructs an icon displaying an already loaded SVG document.

Member Function Documentation

static void clearCache ( )
static

Releases the SVG documents kept by load(). The icons still displaying one of them keep it alive.

float getSourceRatio ( ) const
overridevirtual

Returns the width/height ratio of the drawing.

Implements lysa::ui::Icon::getSourceRatio()

auto getSVG ( ) const
inline

Returns the displayed SVG document, nullptr when the icon is empty.

static std::shared_ptr<SVG> load ( const std::string &  uri,
float  strokeWidth = SVG::DEFAULT_STROKE_WIDTH,
float  tolerance = SVG::DEFAULT_TOLERANCE,
SVGBounds  bounds = SVGBounds::CONTENT 
)
static

Returns the SVG document of the given URI, parsing it on first use.

void setSVG ( const std::shared_ptr< SVG > &  svg)

Displays an already loaded SVG document.

void setSVG ( const std::string &  uri,
float  strokeWidth = SVG::DEFAULT_STROKE_WIDTH,
float  tolerance = SVG::DEFAULT_TOLERANCE,
SVGBounds  bounds = SVGBounds::CONTENT 
)

Loads and displays an SVG document.

Parameters
uriURI of the .svg document
strokeWidthWidth of the stroke of a stroked document
tolerancePrecision of the flattening of the curves
boundsBox the drawing is fitted into