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

Detailed Description

A container displaying one widget at a time selected with a TabBar.

+ Inheritance diagram for TabContainer:

Public Member Functions

 TabContainer (TabPlacement placement=TabPlacement::TOP)
 
std::shared_ptr< WidgetaddTab (const std::string &label, const std::shared_ptr< Widget > &content, const std::string &resource="", const std::shared_ptr< Widget > &leading=nullptr, const std::shared_ptr< Widget > &trailing=nullptr)
 
std::shared_ptr< WidgetaddTab (const std::shared_ptr< Widget > &label, const std::shared_ptr< Widget > &content, const std::string &resource="", const std::shared_ptr< Widget > &leading=nullptr, const std::shared_ptr< Widget > &trailing=nullptr)
 
template<typename T , typename... Args>
std::shared_ptr< T > createTab (const std::string &label, Args &&...args)
 
void removeTab (int32 index)
 
void removeAllTabs ()
 
int32 getCount () const
 
std::shared_ptr< WidgetgetContent (int32 index) const
 
std::shared_ptr< WidgetgetSelectedContent () const
 
int32 getIndexOf (const std::shared_ptr< Widget > &content) const
 
template<typename T = Text>
std::shared_ptr< T > getTab (int32 index) const
 
void select (int32 index)
 
int32 getSelected () const
 
auto getTabBar () const
 
auto getContentArea () const
 
void setTabBarHeight (float height)
 
auto getTabBarHeight () const
 
void setPlacement (TabPlacement placement)
 
auto getPlacement () const
 
void setResources (const std::string &resTabBar)
 
- Public Member Functions inherited from Panel
 Panel ()
 
- 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 Attributes

static constexpr int32 NO_TAB {TabBar::NO_TAB}
 No tab is selected or no tab displays a given widget. 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 Member Functions inherited from Panel
 Panel (const 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

TabContainer ( TabPlacement  placement = TabPlacement::TOP)

Creates an empty tab container.

Parameters
placementPosition of the bar of tabs relatively to the displayed widgets.

Member Function Documentation

std::shared_ptr<Widget> addTab ( const std::shared_ptr< Widget > &  label,
const std::shared_ptr< Widget > &  content,
const std::string &  resource = "",
const std::shared_ptr< Widget > &  leading = nullptr,
const std::shared_ptr< Widget > &  trailing = nullptr 
)

Adds a widget displayed by a new tab, added at the right of the last tab.

The widget of the first tab added is displayed without emitting UIEvent::OnSelectItem.

Parameters
labelLabel of the tab.
contentWidget displayed when the tab is selected.
resourceResource string for the text of the tab.
leadingOptional widget displayed at the left of the text, like an icon.
trailingOptional widget displayed at the right of the text, like a closing cross.
Returns
The added widget.
std::shared_ptr<Widget> addTab ( const std::string &  label,
const std::shared_ptr< Widget > &  content,
const std::string &  resource = "",
const std::shared_ptr< Widget > &  leading = nullptr,
const std::shared_ptr< Widget > &  trailing = nullptr 
)

Adds a widget displayed by a new tab, added at the right of the last tab.

The widget of the first tab added is displayed without emitting UIEvent::OnSelectItem.

Parameters
labelText of the tab.
contentWidget displayed when the tab is selected.
resourceResource string for the text of the tab.
leadingOptional widget displayed at the left of the text, like an icon.
trailingOptional widget displayed at the right of the text, like a closing cross.
Returns
The added widget.
std::shared_ptr<T> createTab ( const std::string &  label,
Args &&...  args 
)
inline

Creates a widget displayed by a new tab, added at the right of the last tab.

Template Parameters
TThe type of the widget to create.
ArgsThe types of the arguments to pass to the widget constructor.
Parameters
labelText of the tab.
argsThe arguments to pass to the widget constructor.
Returns
The created widget.
std::shared_ptr<Widget> getContent ( int32  index) const

Returns the widget displayed by a tab or nullptr for an invalid index.

auto getContentArea ( ) const
inline

Returns the widget holding the widgets displayed by the tabs.

int32 getCount ( ) const
inline

Returns the number of tabs.

int32 getIndexOf ( const std::shared_ptr< Widget > &  content) const

Returns the index of the tab displaying a given widget or NO_TAB.

auto getPlacement ( ) const
inline

Returns the position of the bar of tabs relatively to the displayed widgets.

int32 getSelected ( ) const

Returns the index of the selected tab or NO_TAB.

std::shared_ptr<Widget> getSelectedContent ( ) const

Returns the widget displayed by the selected tab or nullptr.

std::shared_ptr< T > getTab ( int32  index) const

Returns the text widget of a tab, or nullptr for an invalid index.

auto getTabBar ( ) const
inline

Returns the bar displaying the tabs.

auto getTabBarHeight ( ) const
inline

Returns the requested height of the bar of tabs or zero if adjusted to the content.

void removeAllTabs ( )

Removes all the tabs & the widgets they display.

void removeTab ( int32  index)

Removes a tab & the widget it displays.

Removing the selected tab selects the next one, or the previous one for the last tab.

void select ( int32  index)

Selects a tab & displays the widget it displays.

void setPlacement ( TabPlacement  placement)

Sets the position of the bar of tabs relatively to the displayed widgets.

void setResources ( const std::string &  resTabBar)

Sets the UI resources of the widgets created by the container.

void setTabBarHeight ( float  height)

Sets the height of the bar of tabs, zero to adjust it to the content of the tabs.

Member Data Documentation

constexpr int32 NO_TAB {TabBar::NO_TAB}
staticconstexpr

No tab is selected or no tab displays a given widget.