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

Detailed Description

A scrollable list of widgets with a selection highlight.

+ Inheritance diagram for ListBox:

Public Member Functions

 ListBox ()
 
int32 addItem (const std::shared_ptr< Widget > &item, Alignment alignment=Alignment::LEFT, const std::string &resource="") override
 
void removeItem (int32 index) override
 
void setResources (const std::string &resBox, const std::string &resScroll, const std::string &resSel)
 
auto getSelectionWidget () const
 
- Public Member Functions inherited from List
 List (Type type)
 
virtual void removeAllItems ()
 
std::shared_ptr< WidgetgetItem (int32 index) const
 
int32 getCount () const
 
int32 getSelectedIndex () const
 
std::shared_ptr< WidgetgetSelectedItem () const
 
void select (int32 index)
 
const std::list< std::shared_ptr< Widget > > & getItems () const
 
- Public Member Functions inherited from Widget
 Widget (Type type=WIDGET)
 
 ~Widget () override = default
 
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
 
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)
 
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
 
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, 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)
 
void * getUserData () const
 
void setUserData (void *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 eventCreate ()
 
virtual void eventDestroy (Vector2DRenderer &renderer)
 
virtual void eventShow ()
 
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 eventKeyUp (Key key)
 
virtual bool eventMouseDown (MouseButton button, float x, float y)
 
virtual bool eventMouseUp (MouseButton button, float x, float y)
 
virtual bool eventMouseMove (uint32 buttonsState, float x, float y)
 
virtual void eventGotFocus ()
 
virtual void eventLostFocus ()
 
bool getConsumeMouseEvent () const
 
void setConsumeMouseEvent (const bool consumeMouseEvent)
 
const std::list< std::shared_ptr< Widget > > & getChildren () const
 

Additional Inherited Members

- Public Types inherited from Widget
enum  Type {
  WIDGET, PANEL, BOX, LINE,
  FRAME, BUTTON, TOGGLEBUTTON, TEXT,
  TEXTEDIT, SCROLLBAR, TREEVIEW, IMAGE,
  POPUP, LIST, LISTBOX, SELECTION,
  PROGRESSBAR, SCROLLBOX
}
 
- Static Public Attributes inherited from List
static constexpr int32 NO_SELECTION {-1}
 Value returned by getSelectedIndex() when nothing is selected. More...
 
- Protected Attributes inherited from List
int32 prevSelected {NO_SELECTION}
 
std::list< std::shared_ptr< Widget > > items
 
- Protected Attributes inherited from Widget
const Type type
 
Rect rect
 
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 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
 
void * window {nullptr}
 
void * style {nullptr}
 
bool mouseMoveOnFocus {false}
 
float fontScale {0.0f}
 
float childrenOffsetX {0}
 
float childrenOffsetY {0}
 

Constructor & Destructor Documentation

ListBox ( )

Creates a default ListBox widget.

Member Function Documentation

int32 addItem ( const std::shared_ptr< Widget > &  item,
Alignment  alignment = Alignment::LEFT,
const std::string &  resource = "" 
)
overridevirtual

Adds a widget at the end of the list.

Parameters
itemWidget to add.
alignmentPlacement alignment.
resourceResource string.
Returns
The index (0-based) of the inserted item.

Reimplemented from lysa::ui::List::addItem()

auto getSelectionWidget ( ) const
inline

Returns the internal selection highlight widget.

void removeItem ( int32  index)
overridevirtual

Removes the item at the given index and updates the scroll range.

Parameters
indexIndex (0-based) of the item to remove.

Reimplemented from lysa::ui::List::removeItem()

void setResources ( const std::string &  resBox,
const std::string &  resScroll,
const std::string &  resSel 
)

Sets the UI resources for the list box.

Parameters
resBoxResource for the inner background box.
resScrollResource for the vertical scroll bar.
resSelResource for the selection highlight.