1.8
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
Widget Class Reference

Base Widget class. More...

Inheritance diagram for Widget:
Inheritance graph
[legend]

Public Types

enum class  Flag : uint32_t {
  plane_window = detail::bit(0) , window = detail::bit(1) , frame = detail::bit(2) , disabled = detail::bit(3) ,
  readonly = detail::bit(4) , active = detail::bit(5) , invisible = detail::bit(6) , grab_mouse = detail::bit(7) ,
  no_clip = detail::bit(8) , no_layout = detail::bit(9) , no_autoresize = detail::bit(10) , checked = detail::bit(11) ,
  component = detail::bit(12)
}
 Common flags used for various widget properties. More...
 
using Flags = egt::Flags< Widget::Flag >
 Widget flags. More...
 
using WalkCallback = std::function< bool(Widget *widget, int level)>
 Callback definition used by walk(). More...
 
using WidgetId = uint64_t
 Type used to identify a unique Widget ID. More...
 
- Public Types inherited from Object
using EventCallback = std::function< void(Event &event)>
 Event handler callback function. More...
 
using FilterFlags = FlagsBase< EventId >
 Event handler EventId filter. More...
 
using RegisterHandle = uint64_t
 Handle type. More...
 

Public Member Functions

 Widget (const Rect &rect={}, const Widget::Flags &flags={}) noexcept
 
 Widget (const Widget &)=delete
 
 Widget (Frame &parent, const Rect &rect={}, const Widget::Flags &flags={}) noexcept
 
 Widget (Serializer::Properties &props) noexcept
 
 Widget (Widget &&) noexcept=default
 
 ~Widget () noexcept override
 
EGT_NODISCARD bool active () const
 Get the active state. More...
 
void active (bool value)
 Set the active state. More...
 
AlignFlagsalign ()
 Get the alignment. More...
 
EGT_NODISCARD const AlignFlagsalign () const
 Get the alignment. More...
 
void align (const AlignFlags &a)
 Align the widget. More...
 
EGT_NODISCARD float alpha () const
 Get the alpha property. More...
 
void alpha (float alpha)
 Set the alpha property. More...
 
EGT_NODISCARD bool autoresize () const
 Return the autoresize state of the widget. More...
 
void autoresize (bool value)
 Set the autoresize state. More...
 
EGT_NODISCARD DefaultDim border () const
 Get the border width. More...
 
void border (DefaultDim border)
 Set the border width. More...
 
EGT_NODISCARD Theme::BorderFlags border_flags () const
 Get the border flags. More...
 
void border_flags (const Theme::BorderFlags &flags)
 Set the border flags. More...
 
EGT_NODISCARD float border_radius () const
 Get the border radius. More...
 
void border_radius (float radius)
 Set the border radius. More...
 
EGT_NODISCARD const Rectbox () const
 Bounding box for the Widget. More...
 
void box (const Rect &rect)
 Change the bounding box of the widget. More...
 
bool can_handle_event () const
 Returns true if the widget is capable of handling an event. More...
 
EGT_NODISCARD Point center () const
 Get the center point of the widget's box(). More...
 
EGT_NODISCARD bool checked () const
 Get the boolean checked state of the a widget. More...
 
virtual void checked (bool value)
 Set the checked state of the widget. More...
 
EGT_NODISCARD bool clip () const
 Return the clip state of the widget. More...
 
EGT_NODISCARD const Patterncolor (Palette::ColorId id) const
 Get a Widget color. More...
 
void color (Palette::ColorId id, const Pattern &color, Palette::GroupId group=Palette::GroupId::normal)
 Add a color to the widget's instance palette. More...
 
EGT_NODISCARD const Patterncolor (Palette::ColorId id, Palette::GroupId group) const
 Get a Widget color. More...
 
virtual EGT_NODISCARD Rect content_area () const
 Return the area that content is allowed to be positioned into. More...
 
virtual void damage ()
 Damage the box() of the widget and cause a redraw. More...
 
virtual void damage (const Rect &rect)
 Mark the specified rect as a damaged area of the widget. More...
 
virtual void deserialize_children (const Deserializer &deserializer)
 Deserialize the children of this widget. More...
 
void detach ()
 Detach this widget from its parent. More...
 
void disable ()
 Set the disabled state to true. More...
 
void disable_toggle ()
 Toggle the disabled state. More...
 
EGT_NODISCARD bool disabled () const
 Return the disabled state of the widget. More...
 
void disabled (bool value)
 Set the disabled state. More...
 
DisplayPoint display_origin ()
 Get the display origin of the Widget. More...
 
virtual Point display_to_local (const DisplayPoint &p)
 Convert a display point to a local point. More...
 
virtual void draw (Painter &painter, const Rect &rect)
 Draw the widget. More...
 
void draw_box (Painter &painter, Palette::ColorId bg, Palette::ColorId border) const
 Helper function to draw this widget's box using the appropriate theme. More...
 
void draw_circle (Painter &painter, Palette::ColorId bg, Palette::ColorId border) const
 Helper function to draw this widget's circle using the appropriate theme. More...
 
void enable ()
 Set the disabled state to false. More...
 
Theme::FillFlagsfill_flags ()
 Get a modifiable fill flags reference. More...
 
EGT_NODISCARD const Theme::FillFlagsfill_flags () const
 Get the fill flags. More...
 
void fill_flags (const Theme::FillFlags &flags)
 Set the fill flags. More...
 
EGT_NODISCARD bool focus () const
 Get the current focus state. More...
 
void focus (bool value)
 Set the focus state. More...
 
EGT_NODISCARD const Fontfont () const
 Get the widget Font. More...
 
void font (const Font &font)
 Set the widget Font. More...
 
EGT_NODISCARD bool frame () const
 Return the frame state of the widget. More...
 
EGT_NODISCARD bool grab_mouse () const
 Return the grab_mouse state of the widget. More...
 
void grab_mouse (bool value)
 Set the grab_mouse state. More...
 
virtual void handle (Event &event)
 Handle an event. More...
 
bool has_font () const
 Check whether the widget has a custom Font. More...
 
EGT_NODISCARD bool has_palette () const
 Check whether the widget has a custom palette. More...
 
EGT_NODISCARD DefaultDim height () const
 Height of the widget's box(). More...
 
void height (DefaultDim h)
 Change the height. More...
 
virtual void hide ()
 Hide the Widget. More...
 
EGT_NODISCARD DefaultDim horizontal_ratio () const
 Get the horizontal ratio relative to parent. More...
 
void horizontal_ratio (DefaultDim horizontal)
 Set the horizontal ratio relative to parent. More...
 
EGT_NODISCARD bool in_layout () const
 Indicate if the Widget is computing the layout or not. More...
 
virtual void layout ()
 Perform layout of the Widget. More...
 
DisplayPoint local_to_display (const Point &p)
 Convert a local point to a display point. More...
 
EGT_NODISCARD DefaultDim margin () const
 Get the margin width. More...
 
void margin (DefaultDim margin)
 Set the margin width. More...
 
virtual EGT_NODISCARD Size min_size_hint () const
 Get a minimum size hint for the Widget. More...
 
void min_size_hint (const Size &size)
 Set the minimum size hint for the Widget. More...
 
EGT_NODISCARD size_t moat () const
 Get the sum of the margin(), padding(), and border() around the content of the widget. More...
 
virtual void move (const Point &point)
 Move the Widget to a new position. More...
 
void move_to_center ()
 Move the widget to the center of its parent. More...
 
void move_to_center (const Point &point)
 Move the widget to the specified center point. More...
 
EGT_NODISCARD bool no_layout () const
 Return the no_layout state of the widget. More...
 
void no_layout (bool value)
 Set the no_layout state. More...
 
virtual void on_screen_resized ()
 Called from ComposerScreen::resize(). More...
 
Widgetoperator= (const Widget &)=delete
 
Widgetoperator= (Widget &&) noexcept=default
 
EGT_NODISCARD DefaultDim padding () const
 Return the padding width. More...
 
void padding (DefaultDim padding)
 Set the padding width. More...
 
virtual void paint (Painter &painter)
 Paint the Widget using a Painter. More...
 
virtual void paint_to_file (const std::string &filename={})
 Draw the widget to a file. More...
 
EGT_NODISCARD const Palettepalette () const
 Get the widget palette. More...
 
void palette (const Palette &palette)
 Set the widget instance Palette. More...
 
Widgetparent ()
 Get a pointer to the parent Widget, or nullptr if none exists. More...
 
EGT_NODISCARD const Widgetparent () const
 Get a pointer to the parent Widget, or nullptr if none exists. More...
 
EGT_NODISCARD bool plane_window () const
 Return the plane_window state of the widget. More...
 
EGT_NODISCARD const Pointpoint () const
 Get the origin of the widget's box(). More...
 
virtual void post_deserialize (Serializer::Properties &props)
 Resume deserializing of the widget after its children have been deserialized. More...
 
void ratio (DefaultDim horizontal, DefaultDim vertical)
 Set the size ratio relative to parent. More...
 
void ratio (DefaultDim ratio)
 Set the size ratio relative to parent. More...
 
EGT_NODISCARD bool readonly () const
 Get the readonly state of the widget. More...
 
void readonly (bool value)
 Set the readonly state of the widget. More...
 
void readonly_toggle ()
 Toggle the readonly state. More...
 
void reset_font ()
 Reset the widget's Font. More...
 
void reset_palette ()
 Clear the widget instance palette. More...
 
virtual void resize (const Size &size)
 Resize the widget. More...
 
void resize_by_ratio (DefaultDim hratio, DefaultDim vratio)
 Scale the current size of the Widget given the ratio. More...
 
void resize_by_ratio (DefaultDim ratio)
 Scale the current size of the Widget given the ratio. More...
 
virtual void scale (float hscale, float vscale)
 Set the scale of the widget. More...
 
void scale (float scale)
 Set the scale of the widget. More...
 
virtual EGT_NODISCARD Screenscreen () const
 Get a pointer to the Screen instance, using using a parent as necessary. More...
 
virtual void serialize (Serializer &serializer) const
 Serialize the widget to the specified serializer. More...
 
virtual void serialize_children (Serializer &serializer) const
 Serialize the widget's children to the specified serializer. More...
 
virtual void show ()
 Show the Widget. More...
 
EGT_NODISCARD const Sizesize () const
 Get the size of the widget's box(). More...
 
EGT_NODISCARD const Themetheme () const
 Get the Widget Theme. More...
 
EGT_NODISCARD Point to_parent (const Point &r) const
 Convert a point with a local origin to a parent origin. More...
 
EGT_NODISCARD Rect to_parent (const Rect &r) const
 Convert a point in a rect a local origin to a parent origin. More...
 
virtual EGT_NODISCARD std::string type () const
 Returns a string representation of the type of this widget. More...
 
EGT_NODISCARD const Rectuser_requested_box () const
 Get the box corresponding to the user requested one, not the actual one. More...
 
EGT_NODISCARD DefaultDim vertical_ratio () const
 Get the vertical ratio relative to parent. More...
 
void vertical_ratio (DefaultDim vertical)
 Set the vertical ratio relative to parent. More...
 
EGT_NODISCARD bool visible () const
 Get the visible state of the widget. More...
 
void visible (bool value)
 Set the visible state. More...
 
void visible_toggle ()
 Toggle the visibility state. More...
 
virtual void walk (const WalkCallback &callback, int level=0)
 Walk the Widget tree and call callback with each Widget. More...
 
EGT_NODISCARD WidgetId widgetid () const
 Get the unique id of the widget. More...
 
EGT_NODISCARD DefaultDim width () const
 Width of the widget's box(). More...
 
void width (DefaultDim w)
 Change the width. More...
 
EGT_NODISCARD DefaultDim x () const
 X coordinate of the widget's box(). More...
 
void x (DefaultDim x)
 Set the X coordinate of the box. More...
 
EGT_NODISCARD DefaultDim xratio () const
 Get the X position ratio relative to parent. More...
 
void xratio (DefaultDim xratio)
 Set the X position ratio relative to parent. More...
 
EGT_NODISCARD DefaultDim y () const
 Y coordinate of the widget's box(). More...
 
void y (DefaultDim y)
 Set the Y coordinate of the box. More...
 
EGT_NODISCARD DefaultDim yratio () const
 Get the Y position ratio relative to parent. More...
 
void yratio (DefaultDim yratio)
 Set the Y position ratio relative to parent. More...
 
virtual EGT_NODISCARD size_t zorder () const
 Get the zorder of the widget. More...
 
virtual void zorder (size_t rank)
 Set the zorder of the widget. More...
 
virtual void zorder_bottom ()
 Move the widget to the bottom. More...
 
virtual void zorder_down ()
 Move this widgets zorder down relative to other widgets with the same parent. More...
 
virtual void zorder_top ()
 Move the widget to the top. More...
 
virtual void zorder_up ()
 Move this widgets zorder up relative to other widgets with the same parent. More...
 
- Public Member Functions inherited from Object
 Object () noexcept=default
 
 Object (const Object &)=delete
 
 Object (Object &&)=default
 
virtual ~Object () noexcept=default
 
void clear_handlers ()
 Clear all registered event handlers. More...
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event. More...
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId. More...
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object. More...
 
void name (const std::string &name)
 Set the name of the Object. More...
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event. More...
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler. More...
 

Public Attributes

Signal on_checked_changed
 Event signal. More...
 
Signal on_gain_focus
 Invoked when the widget gains focus. More...
 
Signal on_lost_focus
 Invoked when the widget loses focus. More...
 
Signal on_show
 Invoked when a widget is shown. More...
 
Signal on_hide
 Invoked when a widget is hidden. More...
 

Protected Types

using ChildDrawCallback = std::function< void(Painter &painter, Widget *widget)>
 Helper type that defines the special draw child callback. More...
 
using SubordinatesArray = std::list< std::shared_ptr< Widget > >
 Helper type for an array of subordinate widgets. More...
 
- Protected Types inherited from Object
using CallbackArray = std::vector< CallbackMeta >
 Helper type for an array of callbacks. More...
 

Protected Member Functions

 Widget (Serializer::Properties &props, bool is_derived) noexcept
 
void add_component (Widget &widget)
 Add a component. More...
 
void add_damage (const Rect &rect)
 Add damage to the damage array. More...
 
virtual void begin_draw ()
 Cause the widget to draw itself and all of its children. More...
 
void begin_draw (Widget *parent)
 Call the begin_draw() method of the parent. More...
 
EGT_NODISCARD detail::Range< SubordinatesArray > & children ()
 Return the array of child widgets. More...
 
EGT_NODISCARD const detail::Range< SubordinatesArraychildren () const
 Return the array of child widgets. More...
 
EGT_NODISCARD bool component () const
 Get the component status. More...
 
void component (bool value)
 Set the component flag. More...
 
virtual void damage_from_subordinate (const Rect &rect)
 Special variation of damage() that is to be called explicitly by subordinate widgets. More...
 
void deserialize_leaf (Serializer::Properties &props)
 Deserialize widget properties that require to call overridden methods. More...
 
Widgetfind_screen ()
 Starting from this Widget, find the Widget that has a Screen. More...
 
EGT_NODISCARD const Widgetfind_screen () const
 Starting from this Widget, find the Widget that has a Screen. More...
 
Widget::Flagsflags ()
 Get a modifiable ref of the flags. More...
 
EGT_NODISCARD const Widget::Flagsflags () const
 Get a const ref of the flags. More...
 
virtual EGT_NODISCARD bool has_screen () const
 Does this Widget have a screen? More...
 
EGT_NODISCARD Rect local_box () const
 Get the local box which is the same size as box(), but with the origin zeroed. More...
 
EGT_NODISCARD bool parent_in_layout ()
 Indicate if our parent is computing the layout. More...
 
void parent_layout ()
 Call our parent to do a layout. More...
 
void remove_component (Widget *widget)
 Remove a component. More...
 
virtual void set_parent (Widget *parent)
 Set this widget's parent. More...
 
void special_child_draw (Painter &painter, Widget *widget)
 Special draw function that can be invoked when drawing each child. More...
 
EGT_NODISCARD ChildDrawCallback special_child_draw_callback () const
 Get the special child draw callback. More...
 
void special_child_draw_callback (ChildDrawCallback func)
 Set the special child draw callback. More...
 
EGT_NODISCARD ChildDrawCallback special_child_draw_callback (Widget *parent) const
 Get the child draw callback of the parent. More...
 
virtual Point to_panel (const Point &p)
 Convert a local point to the coordinate system of the current panel. More...
 
virtual EGT_NODISCARD Point to_subordinate (const Point &p) const
 Convert a point with an origin of the current widget to subordinate origin. More...
 
EGT_NODISCARD Rect to_subordinate (Rect rect) const
 
virtual EGT_NODISCARD bool top_level () const
 Is this widget a top level widget? More...
 
size_t zorder (const Widget *widget) const
 Get the zorder of the widget. More...
 
void zorder (const Widget *widget, size_t rank)
 Set the zorder of the widget. More...
 
void zorder_bottom (const Widget *widget)
 Move the specified widget zorder to the bottom of the current list of widgets with the same parent. More...
 
void zorder_down (const Widget *widget)
 Move the specified widget zorder down relative to other widgets with the same parent. More...
 
void zorder_top (const Widget *widget)
 Move the specified widget zorder to the top of the current list of widgets with the same parent. More...
 
void zorder_up (const Widget *widget)
 Move the specified widget zorder up relative to other widgets with the same parent. More...
 

Protected Attributes

Rect m_box
 Bounding box. More...
 
detail::Range< SubordinatesArraym_children
 Array of child widgets in the order they were added. More...
 
SubordinatesArray::iterator m_components_begin
 Iterator for the beginning of components which are positionned after children in the subordinates array. More...
 
Screen::DamageArray m_damage
 The damage array for this widget. More...
 
bool m_in_draw {false}
 Status for whether this widget is currently drawing. More...
 
bool m_in_layout {false}
 Status for whether this widget is currently performing layout. More...
 
Size m_min_size
 Minimum size of the widget when not an empty value. More...
 
Widgetm_parent {nullptr}
 Pointer to this widget's parent. More...
 
ChildDrawCallback m_special_child_draw_callback
 Used internally for calling the special child draw function. More...
 
SubordinatesArray m_subordinates
 Array of subordinates widgets split in child widgets and component widgets. More...
 
Rect m_user_requested_box
 Keep track of the box requested by the user. More...
 
WidgetId m_widgetid {0}
 Unique ID of this widget. More...
 
- Protected Attributes inherited from Object
detail::CopyOnWriteAllocate< CallbackArraym_callbacks
 Array of callbacks. More...
 
RegisterHandle m_handle_counter {0}
 Counter used to generate unique handles for each callback registration. More...
 
std::string m_name
 A user defined name for the Object. More...
 

Friends

class Frame
 

Detailed Description

Base Widget class.

This is the base class for all widgets. A Widget is a thing, a UI component, with a basic set of properties. In this case, it has a bounding rectangle, some flags, and some states - and these properties can be manipulated. A Widget can handle events, draw itself, and more. However, the specifics of what it means to handle an event or draw the Widget is implemented in classes that are derived from this one, like a Button or a Label.

Member Typedef Documentation

◆ ChildDrawCallback

using ChildDrawCallback = std::function<void(Painter& painter, Widget* widget)>
protected

Helper type that defines the special draw child callback.

◆ Flags

Widget flags.

◆ SubordinatesArray

using SubordinatesArray = std::list<std::shared_ptr<Widget> >
protected

Helper type for an array of subordinate widgets.

◆ WalkCallback

using WalkCallback = std::function<bool(Widget* widget, int level)>

Callback definition used by walk().

In the callback, return true to continue or false to stop.

◆ WidgetId

using WidgetId = uint64_t

Type used to identify a unique Widget ID.

Member Enumeration Documentation

◆ Flag

enum Flag : uint32_t
strong

Common flags used for various widget properties.

Enumerator
plane_window 

This is an overlay plane window.

window 

This is a window widget.

frame 

This is a frame.

disabled 

When set, the widget is disabled.

Typically, when a widget is disabled it will not accept input.

This may change how the widget behaves or is drawn.

readonly 

When set, the widget will not receive input events.

active 

When true, the widget is active.

The active state of a widget is usually a momentary state, unlike focus, which exists until focus is changed. For example, when a button is currently being held down, it its implementation may consider this the active state and choose to draw the button differently.

This may change how the widget behaves or is draw.

invisible 

When set, the widget is not visible.

grab_mouse 

Grab related mouse events.

For example, if a button receives the EventId::raw_pointer_down event, make sure the button also gets subsequent mouse events, including the EventId::raw_pointer_up event.

no_clip 

Don't clip the child to drawing only in its box.

Use this with caution, it's probably not what you want.

no_layout 

Tell any parent not to perform layout on this widget.

no_autoresize 

Do not automatically resize a widget to meet the minimal size hint.

checked 

Is the widget in a checked state.

component 

Is the widget a component.

Constructor & Destructor Documentation

◆ Widget() [1/6]

Widget ( const Rect rect = {},
const Widget::Flags flags = {} 
)
explicitnoexcept
Parameters
[in]rectInitial rectangle of the Widget.
[in]flagsWidget flags.

◆ Widget() [2/6]

Widget ( Frame parent,
const Rect rect = {},
const Widget::Flags flags = {} 
)
explicitnoexcept
Parameters
[in]parentParent Frame of the Widget.
[in]rectInitial rectangle of the Widget.
[in]flagsWidget flags.

◆ Widget() [3/6]

Widget ( Serializer::Properties props)
inlineexplicitnoexcept
Parameters
[in]propslist of widget argument and its properties.

◆ Widget() [4/6]

Widget ( Serializer::Properties props,
bool  is_derived 
)
explicitprotectednoexcept

◆ Widget() [5/6]

Widget ( const Widget )
delete

◆ Widget() [6/6]

Widget ( Widget &&  )
defaultnoexcept

◆ ~Widget()

~Widget ( )
overridenoexcept

Member Function Documentation

◆ active() [1/2]

EGT_NODISCARD bool active ( ) const

Get the active state.

The meaning of active is largely up to the derived implementation.

◆ active() [2/2]

void active ( bool  value)

Set the active state.

The meaning of active is largely up to the derived implementation.

◆ add_component()

void add_component ( Widget widget)
protected

Add a component.

◆ add_damage()

void add_damage ( const Rect rect)
protected

Add damage to the damage array.

Damage rects added here must have origin at point() of this widget. This is done for several reasons, including if this widget is moved, all of the damage rects are still valid.

◆ align() [1/3]

AlignFlags& align ( )
inline

Get the alignment.

◆ align() [2/3]

EGT_NODISCARD const AlignFlags& align ( ) const
inline

Get the alignment.

◆ align() [3/3]

void align ( const AlignFlags a)

Align the widget.

This will align the widget relative to the box of its parent widget.

Parameters
[in]aThe AlignFlags.

◆ alpha() [1/2]

EGT_NODISCARD float alpha ( ) const
inline

Get the alpha property.

Returns
Alpha property in the range 0.0 to 1.0.

◆ alpha() [2/2]

void alpha ( float  alpha)

Set the alpha property.

This controls the alpha property of the entire widget and all of its children.

Parameters
[in]alphaWidget alpha component in range 0.0 - 1.0.

◆ autoresize() [1/2]

EGT_NODISCARD bool autoresize ( ) const

Return the autoresize state of the widget.

◆ autoresize() [2/2]

void autoresize ( bool  value)

Set the autoresize state.

Parameters
[in]valueWhen true, the widget can be automatically resized.

By default, this state is true;

◆ begin_draw() [1/2]

virtual void begin_draw ( )
inlineprotectedvirtual

Cause the widget to draw itself and all of its children.

Warning
Normally this should not be called directly and instead the event loop will call this function.

Reimplemented in Window.

◆ begin_draw() [2/2]

void begin_draw ( Widget parent)
inlineprotected

Call the begin_draw() method of the parent.

As begin_draw() is protected, a subclass of widget is not allowed to call m_parent->begin_draw(), so use this method.

◆ border() [1/2]

EGT_NODISCARD DefaultDim border ( ) const
inline

Get the border width.

See also
The Widget Box Model

◆ border() [2/2]

void border ( DefaultDim  border)
inline

Set the border width.

See also
The Widget Box Model

◆ border_flags() [1/2]

EGT_NODISCARD Theme::BorderFlags border_flags ( ) const
inline

Get the border flags.

See also
Theme::BorderFlag

◆ border_flags() [2/2]

void border_flags ( const Theme::BorderFlags flags)
inline

Set the border flags.

See also
Theme::BorderFlag

◆ border_radius() [1/2]

EGT_NODISCARD float border_radius ( ) const
inline

Get the border radius.

◆ border_radius() [2/2]

void border_radius ( float  radius)
inline

Set the border radius.

◆ box() [1/2]

EGT_NODISCARD const Rect& box ( ) const
inline

Bounding box for the Widget.

This is the rectangle that defines where this widget is positioned relative to its parent and also the size of the widget.

See also
The Widget Box Model

◆ box() [2/2]

void box ( const Rect rect)

Change the bounding box of the widget.

This is the same as calling move() and resize() at the same time.

See also
The Widget Box Model

◆ can_handle_event()

bool can_handle_event ( ) const
inline

Returns true if the widget is capable of handling an event.

◆ center()

EGT_NODISCARD Point center ( ) const
inline

Get the center point of the widget's box().

◆ checked() [1/2]

EGT_NODISCARD bool checked ( ) const
inline

Get the boolean checked state of the a widget.

Returns
true if checked.

◆ checked() [2/2]

virtual void checked ( bool  value)
virtual

Set the checked state of the widget.

Reimplemented in Button.

◆ children() [1/2]

EGT_NODISCARD detail::Range<SubordinatesArray>& children ( )
inlineprotected

Return the array of child widgets.

◆ children() [2/2]

EGT_NODISCARD const detail::Range<SubordinatesArray> children ( ) const
inlineprotected

Return the array of child widgets.

◆ clip()

EGT_NODISCARD bool clip ( ) const

Return the clip state of the widget.

◆ color() [1/3]

EGT_NODISCARD const Pattern& color ( Palette::ColorId  id) const

Get a Widget color.

This will return a color for the Palette::GroupId reflecting the current state of the Widget when the call is made. To get a specific Palette::GroupId color, use the overloaded function.

If the id and group exist in the widget instance palette, that will be used. Otherwise, the default_palette() will be used.

Parameters
idPalette::ColorId to get.

◆ color() [2/3]

void color ( Palette::ColorId  id,
const Pattern color,
Palette::GroupId  group = Palette::GroupId::normal 
)

Add a color to the widget's instance palette.

This will add the specified id, color, and group to the widget's instance palette.

Parameters
idPalette::ColorId to set.
colorColor to set.
groupPalette::GroupId to set.

◆ color() [3/3]

EGT_NODISCARD const Pattern& color ( Palette::ColorId  id,
Palette::GroupId  group 
) const

Get a Widget color.

If the id and group exist in the widget instance palette, that will be used. Otherwise, the default_palette() will be used.

Parameters
idPalette::ColorId to get.
groupPalette::GroupId to get.

◆ component() [1/2]

EGT_NODISCARD bool component ( ) const
protected

Get the component status.

◆ component() [2/2]

void component ( bool  value)
protected

Set the component flag.

◆ content_area()

virtual EGT_NODISCARD Rect content_area ( ) const
virtual

Return the area that content is allowed to be positioned into.

In most cases, the normal box() area needs to be shrunk by the margin + padding + border. However, some widgets reserve more for themselves, and only allow their children to be positioned in the rest.

See also
The Widget Box Model

◆ damage() [1/2]

virtual void damage ( )
virtual

Damage the box() of the widget and cause a redraw.

This is the same as calling damage(box()) in most cases.

Warning
damage() cannot be called while in or below a Widget::draw() method.

◆ damage() [2/2]

virtual void damage ( const Rect rect)
virtual

Mark the specified rect as a damaged area of the widget.

Note
This call will propagate to a top level parent widget that owns a Screen.
Warning
damage() cannot be called while in or below a Widget::draw() method.
Parameters
rectThe rectangle to save for damage. This will merge the damaged area with any already existing damaged area that it overlaps with into a super rectangle. Then, the whole array has to be checked again to make sure the new rectangle doesn't conflict with another existing rectangle.

Reimplemented in Window, and ScrolledView.

◆ damage_from_subordinate()

virtual void damage_from_subordinate ( const Rect rect)
inlineprotectedvirtual

Special variation of damage() that is to be called explicitly by subordinate widgets.

Reimplemented in ScrolledView.

◆ deserialize_children()

virtual void deserialize_children ( const Deserializer deserializer)
inlinevirtual

Deserialize the children of this widget.

Reimplemented in StaticGrid, and Frame.

◆ deserialize_leaf()

void deserialize_leaf ( Serializer::Properties props)
protected

Deserialize widget properties that require to call overridden methods.

Should be called at the end of all T::T(Serializer::Properties& props, bool is_derived) constructors, if and only if 'is_derived' is 'false'.

Indeed, we wait for an object to be entirely constructed so the expected virtual/overridden methods are executed.

◆ detach()

void detach ( )

Detach this widget from its parent.

Warning
This can result in immediately deleting the instance of the widget if its lifetime is managed by a smart pointer and there are no more references.

◆ disable()

void disable ( )

Set the disabled state to true.

◆ disable_toggle()

void disable_toggle ( )
inline

Toggle the disabled state.

See also
disable() and enable()

◆ disabled() [1/2]

EGT_NODISCARD bool disabled ( ) const
inline

Return the disabled state of the widget.

When a widget is disabled, it does not receive events. Depending on the widget, the color scheme may change.

◆ disabled() [2/2]

void disabled ( bool  value)
inline

Set the disabled state.

Parameters
[in]valueWhen true, the Widget is disabled.
See also
enable() and disable()

◆ display_origin()

DisplayPoint display_origin ( )

Get the display origin of the Widget.

◆ display_to_local()

virtual Point display_to_local ( const DisplayPoint p)
virtual

Convert a display point to a local point.

A display point has origin in the top left of the display. A local point has its origin at the top left of the position of this widget.

See also
Coordinate System

◆ draw()

virtual void draw ( Painter painter,
const Rect rect 
)
virtual

Draw the widget.

To change how a widget is drawn, this function can be overloaded and changed in a derived class, or it can be changed dynamically with the Theme.

To optimize drawing, a Widget may use the Rect parameter to limit what needs to be redrawn, which may be smaller than the widget's box(), but will never be outside the widget's box().

Painter will always be supplied in a default state to this function, so there is no need to do any cleanup or state saving inside this draw() function.

Warning
Normally this should not be called directly and instead the EventLoop will call this function with an already established Painter when the Widget needs to be drawn.
See also
Color, Palette, and Theme and Drawing
Parameters
[in]painterInstance of the Painter for the Screen.
[in]rectThe rectangle to draw.

Reimplemented in ScrolledView, VideoWindow, TextBox, Sprite, SliderType< T >, SliderType< float >, SliderType< int >, SliderType< float >, SliderType< int >, RectangleWidget, RadioBox, RadialType< T >, AnalogMeterType< T >, AnalogMeterType< float >, AnalogMeterType< int >, AnalogMeterType< float >, AnalogMeterType< int >, LevelMeterType< T >, LevelMeterType< float >, LevelMeterType< int >, LevelMeterType< float >, LevelMeterType< int >, SpinProgressType< T >, SpinProgressType< float >, SpinProgressType< int >, SpinProgressType< float >, SpinProgressType< int >, ProgressBarType< T >, ProgressBarType< float >, ProgressBarType< int >, ProgressBarType< float >, ProgressBarType< int >, Label, ImageHolder< Label, Palette::ColorId::label_bg, Palette::ColorId::border, Palette::ColorId::label_text >, ImageHolder< Button, Palette::ColorId::button_bg, Palette::ColorId::border, Palette::ColorId::button_text >, ImageHolder< Label, Palette::ColorId::label_bg, Palette::ColorId::border, Palette::ColorId::label_text >, ImageHolder< Button, Palette::ColorId::button_bg, Palette::ColorId::border, Palette::ColorId::button_text >, SelectableGrid, NeedleLayer, GaugeLayer, ComboBox, ToggleBox, CheckBox, PieChart, ChartBase, CameraWindow, Button, LineWidget, and CircleWidget.

◆ draw_box()

void draw_box ( Painter painter,
Palette::ColorId  bg,
Palette::ColorId  border 
) const

Helper function to draw this widget's box using the appropriate theme.

◆ draw_circle()

void draw_circle ( Painter painter,
Palette::ColorId  bg,
Palette::ColorId  border 
) const

Helper function to draw this widget's circle using the appropriate theme.

◆ enable()

void enable ( )

Set the disabled state to false.

◆ fill_flags() [1/3]

Theme::FillFlags& fill_flags ( )
inline

Get a modifiable fill flags reference.

See also
Theme::FillFlag

◆ fill_flags() [2/3]

EGT_NODISCARD const Theme::FillFlags& fill_flags ( ) const
inline

Get the fill flags.

See also
Theme::FillFlag

◆ fill_flags() [3/3]

void fill_flags ( const Theme::FillFlags flags)
inline

Set the fill flags.

The fill flags of a widget are used to set predefined draw operators for a widget. This provides a level of customization that is primarily for performance optimizations.

Setting a fill type of empty means that no background will be drawn no matter what the background color of the widget is.

See also
Theme::FillFlag

◆ find_screen() [1/2]

Widget* find_screen ( )
inlineprotected

Starting from this Widget, find the Widget that has a Screen.

This searches up the widget hierarchy from here.

◆ find_screen() [2/2]

EGT_NODISCARD const Widget* find_screen ( ) const
inlineprotected

Starting from this Widget, find the Widget that has a Screen.

This searches up the widget hierarchy from here.

◆ flags() [1/2]

Widget::Flags& flags ( void  )
inlineprotected

Get a modifiable ref of the flags.

Warning
Directly modifying flags may result in inconsistent state of the widget. Always use the appropriate member functions (i.e. readonly(), checked()).

◆ flags() [2/2]

EGT_NODISCARD const Widget::Flags& flags ( void  ) const
inlineprotected

Get a const ref of the flags.

◆ focus() [1/2]

EGT_NODISCARD bool focus ( ) const
inline

Get the current focus state.

Returns
true if in focus.

◆ focus() [2/2]

void focus ( bool  value)

Set the focus state.

Parameters
valueState of the focus.

◆ font() [1/2]

EGT_NODISCARD const Font& font ( ) const

Get the widget Font.

This will return any font set on the widget instance, or default to the widget Theme font.

◆ font() [2/2]

void font ( const Font font)
inline

Set the widget Font.

Sets the widget font which means the widget instance will no longer use its Theme font.

◆ frame()

EGT_NODISCARD bool frame ( ) const

Return the frame state of the widget.

◆ grab_mouse() [1/2]

EGT_NODISCARD bool grab_mouse ( ) const

Return the grab_mouse state of the widget.

◆ grab_mouse() [2/2]

void grab_mouse ( bool  value)

Set the grab_mouse state.

Parameters
[in]valueWhen true, grab mouse events.

By default, this state is false.

◆ handle()

virtual void handle ( Event event)
virtual

Handle an event.

This handles global events that usually do not originate at the widget. For example, a pointer event. All events are defined by egt::EventId.

The default implementation in the Widget class, will dispatch the event to any third party handlers that have been registered with on_event(). What this means is if you expect other handlers to receive the events then this must be called from derived classes. Or, manually call invoke_handlers().

Override this function in a derived class to handle events.

See also
Events
Parameters
eventThe Event that occurred.

Reimplemented in ScrolledView, TextBox, SliderType< T >, SliderType< float >, SliderType< int >, SliderType< float >, SliderType< int >, SideBoard, RadioBox, RadialType< T >, ListBox, SelectableGrid, ComboBox, CheckBox, and Button.

◆ has_font()

bool has_font ( ) const
inline

Check whether the widget has a custom Font.

◆ has_palette()

EGT_NODISCARD bool has_palette ( ) const
inline

Check whether the widget has a custom palette.

◆ has_screen()

virtual EGT_NODISCARD bool has_screen ( ) const
inlineprotectedvirtual

Does this Widget have a screen?

Reimplemented in Window.

◆ height() [1/2]

EGT_NODISCARD DefaultDim height ( ) const
inline

Height of the widget's box().

◆ height() [2/2]

void height ( DefaultDim  h)
inline

Change the height.

Parameters
[in]hThe new height of the Widget.

◆ hide()

virtual void hide ( )
virtual

Hide the Widget.

A widget that is not visible will receive no draw() calls.

This changes the visible() state of the Widget.

Reimplemented in Window.

◆ horizontal_ratio() [1/2]

EGT_NODISCARD DefaultDim horizontal_ratio ( ) const
inline

Get the horizontal ratio relative to parent.

◆ horizontal_ratio() [2/2]

void horizontal_ratio ( DefaultDim  horizontal)
inline

Set the horizontal ratio relative to parent.

Parameters
[in]horizontalHorizontal ratio of parent width, with 100 being 100%.

◆ in_layout()

EGT_NODISCARD bool in_layout ( ) const
inline

Indicate if the Widget is computing the layout or not.

◆ layout()

virtual void layout ( )
virtual

Perform layout of the Widget.

This will cause the widget to layout itself and any of its children. This can mean, for example, the widget will resize() itself to respect its min_size_hint().

Note
Remember that when overriding this function as a Frame, you must call layout on each child Frame to propagate the layout.

Reimplemented in ScrolledView, BoxSizer, and StaticGrid.

◆ local_box()

EGT_NODISCARD Rect local_box ( ) const
inlineprotected

Get the local box which is the same size as box(), but with the origin zeroed.

◆ local_to_display()

DisplayPoint local_to_display ( const Point p)

Convert a local point to a display point.

A display point has origin in the top left of the display. A local point has its origin at the top left of the position of this widget.

See also
Coordinate System

◆ margin() [1/2]

EGT_NODISCARD DefaultDim margin ( ) const
inline

Get the margin width.

See also
The Widget Box Model

◆ margin() [2/2]

void margin ( DefaultDim  margin)
inline

Set the margin width.

See also
The Widget Box Model

◆ min_size_hint() [1/2]

virtual EGT_NODISCARD Size min_size_hint ( ) const
virtual

◆ min_size_hint() [2/2]

void min_size_hint ( const Size size)
inline

Set the minimum size hint for the Widget.

This is used by sizers to pick minimum and default dimensions when no other force is used. When this is set to a non-zero value, this will override any computation done by min_size_hint().

Parameters
sizeThe minimum size.

◆ moat()

EGT_NODISCARD size_t moat ( ) const

Get the sum of the margin(), padding(), and border() around the content of the widget.

◆ move()

virtual void move ( const Point point)
virtual

Move the Widget to a new position.

Changes the X and Y position of the Widget.

Parameters
[in]pointThe new origin point for the widget relative to its parent.
Note
This will cause a redraw of the Widget.

Reimplemented in Window, and ComboBox.

◆ move_to_center() [1/2]

void move_to_center ( )

Move the widget to the center of its parent.

Changes the X and Y position of the widget relative to the center point of its parent.

Note
This will cause a redraw of the widget.

◆ move_to_center() [2/2]

void move_to_center ( const Point point)

Move the widget to the specified center point.

Changes the X and Y position of the widget relative to the center point.

Note
This will cause a redraw of the widget.

◆ no_layout() [1/2]

EGT_NODISCARD bool no_layout ( ) const

Return the no_layout state of the widget.

◆ no_layout() [2/2]

void no_layout ( bool  value)

Set the no_layout state.

Parameters
[in]valueWhen true, parent won't perform layout for the widget.

By default, this state is false.

◆ on_screen_resized()

virtual void on_screen_resized ( )
virtual

Called from ComposerScreen::resize().

Note
Widgets can be copied, moved or destroyed. Therefore their life cycle is more complex than static data (default font size, default widget sizes). If the ComposerScreen::on_screen_resized signal had been used to manage widgets when the screen is resized, then we would have to register a hook from any constructor, forcing us to explicitly define copy and move constructors instead of using default implementation of those constructors. We would also have to register that hook from the copy and move assignment operators and finally unregister it from the widget destructor.

This would have required too many changes to accurately handle all widget life cycles, so instead we call this virtual method on the main window from ComposerScreen::resize() to recursively scan and progress the whole widget tree.

Reimplemented in Frame.

◆ operator=() [1/2]

Widget& operator= ( const Widget )
delete

◆ operator=() [2/2]

Widget& operator= ( Widget &&  )
defaultnoexcept

◆ padding() [1/2]

EGT_NODISCARD DefaultDim padding ( ) const
inline

Return the padding width.

See also
The Widget Box Model

◆ padding() [2/2]

void padding ( DefaultDim  padding)
inline

Set the padding width.

See also
The Widget Box Model

◆ paint()

virtual void paint ( Painter painter)
virtual

Paint the Widget using a Painter.

paint() is not part of the normal draw path. This is a utility function to get the widget to draw its contents to another surface provided with a Painter.

Reimplemented in Window, and Sprite.

◆ paint_to_file()

virtual void paint_to_file ( const std::string &  filename = {})
virtual

Draw the widget to a file.

Parameters
[in]filenameOptional filename to save to.

Reimplemented in Frame.

◆ palette() [1/2]

EGT_NODISCARD const Palette& palette ( ) const

Get the widget palette.

This will return any palette set on the widget instance, or default to the global palette.

◆ palette() [2/2]

void palette ( const Palette palette)

Set the widget instance Palette.

This will replace any Palette instance currently owned by the Widget. This does not have to be a complete Palette, in which case the widget will default to the Theme palette if a Color is not found in this palette.

Parameters
paletteThe new palette to assign to the widget.
Note
This will overwrite the entire widget Palette.

◆ parent() [1/2]

Widget* parent ( )

Get a pointer to the parent Widget, or nullptr if none exists.

◆ parent() [2/2]

EGT_NODISCARD const Widget* parent ( ) const

Get a pointer to the parent Widget, or nullptr if none exists.

◆ parent_in_layout()

EGT_NODISCARD bool parent_in_layout ( )
protected

Indicate if our parent is computing the layout.

◆ parent_layout()

void parent_layout ( )
protected

Call our parent to do a layout.

◆ plane_window()

EGT_NODISCARD bool plane_window ( ) const

Return the plane_window state of the widget.

◆ point()

EGT_NODISCARD const Point& point ( ) const
inline

Get the origin of the widget's box().

◆ post_deserialize()

virtual void post_deserialize ( Serializer::Properties props)
inlinevirtual

Resume deserializing of the widget after its children have been deserialized.

Reimplemented in ScrolledView, and Notebook.

◆ ratio() [1/2]

void ratio ( DefaultDim  horizontal,
DefaultDim  vertical 
)
inline

Set the size ratio relative to parent.

Parameters
[in]horizontalHorizontal ratio of parent width, with 100 being 100%.
[in]verticalVertical ratio of parent height, with 100 being 100%.

◆ ratio() [2/2]

void ratio ( DefaultDim  ratio)
inline

Set the size ratio relative to parent.

Parameters
[in]ratioHorizontal and vertical ratio parent size, with 100 being 100%.
Note
This is the same as calling ratio(ratio, ratio).

◆ readonly() [1/2]

EGT_NODISCARD bool readonly ( ) const
inline

Get the readonly state of the widget.

Returns
true if the widget is readonly.

◆ readonly() [2/2]

void readonly ( bool  value)

Set the readonly state of the widget.

When a widget is readonly, it typically works as normal, except it does not accept any user input. Depending on the widget, the color scheme may change.

Parameters
valueReadonly when true.

◆ readonly_toggle()

void readonly_toggle ( )
inline

Toggle the readonly state.

See also
readonly()

◆ remove_component()

void remove_component ( Widget widget)
protected

Remove a component.

◆ reset_font()

void reset_font ( )
inline

Reset the widget's Font.

This is the inverse of setting a custom font for this widget instance with font().

◆ reset_palette()

void reset_palette ( )

Clear the widget instance palette.

This will clear the widget instance's palette. Meaning, for all colors the widget will now use default_palette().

◆ resize()

virtual void resize ( const Size size)
virtual

Resize the widget.

Changes the width and height of the Widget.

Parameters
[in]sizeThe new size of the Widget.
Note
This will cause a redraw of the Widget.

Reimplemented in Window, ScrolledView, TextBox, CircleWidget, PieChart, ChartBase, VirtualKeyboard, VideoWindow, ListBox, and ComboBox.

◆ resize_by_ratio() [1/2]

void resize_by_ratio ( DefaultDim  hratio,
DefaultDim  vratio 
)

Scale the current size of the Widget given the ratio.

There is no automatic undo for this operation. Each call to this function uses the current size of the Widget.

Parameters
[in]hratioHorizontal ratio of width(), with 100 being 100%.
[in]vratioVertical ratio of height(), with 100 being 100%.
See also
resize()

◆ resize_by_ratio() [2/2]

void resize_by_ratio ( DefaultDim  ratio)
inline

Scale the current size of the Widget given the ratio.

Parameters
[in]ratioHorizontal and vertical ratio of size(), with 100 being 100%.
See also
resize()

◆ scale() [1/2]

virtual void scale ( float  hscale,
float  vscale 
)
inlinevirtual

Set the scale of the widget.

Parameters
[in]hscaleHorizontal scale, with 1.0 being 100%.
[in]vscaleVertical scale, with 1.0 being 100%.
Warning
This is experimental.

Reimplemented in Window, VideoWindow, and CameraWindow.

◆ scale() [2/2]

void scale ( float  scale)
inline

Set the scale of the widget.

Parameters
[in]scaleVertical and horizontal scale, with 1.0 being 100%.
Warning
This is experimental.

◆ screen()

virtual EGT_NODISCARD Screen* screen ( ) const
virtual

Get a pointer to the Screen instance, using using a parent as necessary.

Returns
An Screen if available, or nullptr.

Reimplemented in Window.

◆ serialize()

virtual void serialize ( Serializer serializer) const
virtual

◆ serialize_children()

virtual void serialize_children ( Serializer serializer) const
inlinevirtual

Serialize the widget's children to the specified serializer.

Reimplemented in StaticGrid, and Frame.

◆ set_parent()

virtual void set_parent ( Widget parent)
protectedvirtual

Set this widget's parent.

Reimplemented in Label, ComboBox, and Button.

◆ show()

virtual void show ( )
virtual

Show the Widget.

This changes the visible() state of the Widget.

Reimplemented in Window, and Frame.

◆ size()

EGT_NODISCARD const Size& size ( ) const
inline

Get the size of the widget's box().

◆ special_child_draw()

void special_child_draw ( Painter painter,
Widget widget 
)
inlineprotected

Special draw function that can be invoked when drawing each child.

This is useful, for example, to draw a custom bounding box around children or to modify how a child draws by overwriting it.

Parameters
painterAn instance of the Painter to use.
widgetThe widget.

◆ special_child_draw_callback() [1/3]

EGT_NODISCARD ChildDrawCallback special_child_draw_callback ( ) const
inlineprotected

Get the special child draw callback.

◆ special_child_draw_callback() [2/3]

void special_child_draw_callback ( ChildDrawCallback  func)
inlineprotected

Set the special child draw callback.

◆ special_child_draw_callback() [3/3]

EGT_NODISCARD ChildDrawCallback special_child_draw_callback ( Widget parent) const
inlineprotected

Get the child draw callback of the parent.

As special_child_draw_callback() is protected, a subclass of widget is not allowed to call m_parent->special_child_draw_callback(), so use this method.

◆ theme()

EGT_NODISCARD const Theme& theme ( ) const

Get the Widget Theme.

A global_theme() will be returned.

See also
Theme

◆ to_panel()

virtual Point to_panel ( const Point p)
protectedvirtual

Convert a local point to the coordinate system of the current panel.

In other words, work towards a parent that has the panel so we can get this point relative to the origin of the panel we are drawing to.

◆ to_parent() [1/2]

EGT_NODISCARD Point to_parent ( const Point r) const

Convert a point with a local origin to a parent origin.

◆ to_parent() [2/2]

EGT_NODISCARD Rect to_parent ( const Rect r) const
inline

Convert a point in a rect a local origin to a parent origin.

See also
to_parent().

◆ to_subordinate() [1/2]

virtual EGT_NODISCARD Point to_subordinate ( const Point p) const
inlineprotectedvirtual

Convert a point with an origin of the current widget to subordinate origin.

◆ to_subordinate() [2/2]

EGT_NODISCARD Rect to_subordinate ( Rect  rect) const
inlineprotected

◆ top_level()

virtual EGT_NODISCARD bool top_level ( ) const
inlineprotectedvirtual

Is this widget a top level widget?

Reimplemented in Frame.

◆ type()

virtual EGT_NODISCARD std::string type ( ) const
virtual

◆ user_requested_box()

EGT_NODISCARD const Rect& user_requested_box ( ) const
inline

Get the box corresponding to the user requested one, not the actual one.

◆ vertical_ratio() [1/2]

EGT_NODISCARD DefaultDim vertical_ratio ( ) const
inline

Get the vertical ratio relative to parent.

◆ vertical_ratio() [2/2]

void vertical_ratio ( DefaultDim  vertical)
inline

Set the vertical ratio relative to parent.

Parameters
[in]verticalVertical ratio of parent height, with 100 being 100%.

◆ visible() [1/2]

EGT_NODISCARD bool visible ( ) const
inline

Get the visible state of the widget.

Returns
true if the widget is visible.

◆ visible() [2/2]

void visible ( bool  value)

Set the visible state.

◆ visible_toggle()

void visible_toggle ( )
inline

Toggle the visibility state.

See also
show() and hide() and visible()

◆ walk()

virtual void walk ( const WalkCallback callback,
int  level = 0 
)
virtual

Walk the Widget tree and call callback with each Widget.

Parameters
callbackFunction to call for each widget.
levelThe current level of the widget hierarchy starting with the level originally passed in.
widget->walk([](Widget* widget, int level) {
// do something
});
Widget(const Rect &rect={}, const Widget::Flags &flags={}) noexcept

Reimplemented in Frame.

◆ widgetid()

EGT_NODISCARD WidgetId widgetid ( ) const
inline

Get the unique id of the widget.

Every widget allocated is given a unique id. This is used internally to create a default name() of the widget, but can also be used to uniquely identify widgets for other purposes.

◆ width() [1/2]

EGT_NODISCARD DefaultDim width ( ) const
inline

Width of the widget's box().

◆ width() [2/2]

void width ( DefaultDim  w)
inline

Change the width.

Parameters
[in]wThe new width of the Widget.

◆ x() [1/2]

EGT_NODISCARD DefaultDim x ( ) const
inline

X coordinate of the widget's box().

◆ x() [2/2]

void x ( DefaultDim  x)
inline

Set the X coordinate of the box.

Parameters
[in]xThe new origin X value for the widget relative to its parent.

◆ xratio() [1/2]

EGT_NODISCARD DefaultDim xratio ( ) const
inline

Get the X position ratio relative to parent.

◆ xratio() [2/2]

void xratio ( DefaultDim  xratio)
inline

Set the X position ratio relative to parent.

Parameters
[in]xratioX ratio of parent width, with 100 being 100%.

◆ y() [1/2]

EGT_NODISCARD DefaultDim y ( ) const
inline

Y coordinate of the widget's box().

◆ y() [2/2]

void y ( DefaultDim  y)
inline

Set the Y coordinate of the box.

Parameters
[in]yThe new origin Y value for the widget relative to its parent.

◆ yratio() [1/2]

EGT_NODISCARD DefaultDim yratio ( ) const
inline

Get the Y position ratio relative to parent.

◆ yratio() [2/2]

void yratio ( DefaultDim  yratio)
inline

Set the Y position ratio relative to parent.

Parameters
[in]yratioY ratio of parent height, with 100 being 100%.

◆ zorder() [1/4]

virtual EGT_NODISCARD size_t zorder ( ) const
virtual

Get the zorder of the widget.

See also
Z-order

◆ zorder() [2/4]

size_t zorder ( const Widget widget) const
protected

Get the zorder of the widget.

Parameters
widgetThe widget.

◆ zorder() [3/4]

void zorder ( const Widget widget,
size_t  rank 
)
protected

Set the zorder of the widget.

Parameters
widgetThe widget.
rankThe rank in the zorder.

◆ zorder() [4/4]

virtual void zorder ( size_t  rank)
virtual

Set the zorder of the widget.

Parameters
rankThe rank in the zorder.
See also
Z-order

◆ zorder_bottom() [1/2]

virtual void zorder_bottom ( )
virtual

Move the widget to the bottom.

See also
Z-order

Reimplemented in Frame, and Frame.

◆ zorder_bottom() [2/2]

void zorder_bottom ( const Widget widget)
protected

Move the specified widget zorder to the bottom of the current list of widgets with the same parent.

Parameters
widgetThe widget.

◆ zorder_down() [1/2]

virtual void zorder_down ( )
virtual

Move this widgets zorder down relative to other widgets with the same parent.

See also
Z-order

Reimplemented in Frame, and Frame.

◆ zorder_down() [2/2]

void zorder_down ( const Widget widget)
protected

Move the specified widget zorder down relative to other widgets with the same parent.

Parameters
widgetThe widget.

◆ zorder_top() [1/2]

virtual void zorder_top ( )
virtual

Move the widget to the top.

See also
Z-order

Reimplemented in Frame, and Frame.

◆ zorder_top() [2/2]

void zorder_top ( const Widget widget)
protected

Move the specified widget zorder to the top of the current list of widgets with the same parent.

Parameters
widgetThe widget.

◆ zorder_up() [1/2]

virtual void zorder_up ( )
virtual

Move this widgets zorder up relative to other widgets with the same parent.

See also
Z-order

Reimplemented in Frame, and Frame.

◆ zorder_up() [2/2]

void zorder_up ( const Widget widget)
protected

Move the specified widget zorder up relative to other widgets with the same parent.

Parameters
widgetThe widget.

Friends And Related Function Documentation

◆ Frame

friend class Frame
friend

Member Data Documentation

◆ m_box

Rect m_box
protected

Bounding box.

◆ m_children

detail::Range<SubordinatesArray> m_children
protected

Array of child widgets in the order they were added.

◆ m_components_begin

SubordinatesArray::iterator m_components_begin
protected

Iterator for the beginning of components which are positionned after children in the subordinates array.

Components are child widget as well, but not added through the Frame interface. Components are composition widgets and users must not be able to add extra ones or to remove them.

◆ m_damage

Screen::DamageArray m_damage
protected

The damage array for this widget.

◆ m_in_draw

bool m_in_draw {false}
protected

Status for whether this widget is currently drawing.

◆ m_in_layout

bool m_in_layout {false}
protected

Status for whether this widget is currently performing layout.

◆ m_min_size

Size m_min_size
protected

Minimum size of the widget when not an empty value.

◆ m_parent

Widget* m_parent {nullptr}
protected

Pointer to this widget's parent.

The parent is a Widget, which is capable of managing children.

◆ m_special_child_draw_callback

ChildDrawCallback m_special_child_draw_callback
protected

Used internally for calling the special child draw function.

◆ m_subordinates

SubordinatesArray m_subordinates
protected

Array of subordinates widgets split in child widgets and component widgets.

◆ m_user_requested_box

Rect m_user_requested_box
protected

Keep track of the box requested by the user.

◆ m_widgetid

WidgetId m_widgetid {0}
protected

Unique ID of this widget.

◆ on_checked_changed

Signal on_checked_changed

Event signal.

Invoked when the checked state of the widget changes.

◆ on_gain_focus

Signal on_gain_focus

Invoked when the widget gains focus.

◆ on_hide

Signal on_hide

Invoked when a widget is hidden.

◆ on_lost_focus

Signal on_lost_focus

Invoked when the widget loses focus.

◆ on_show

Signal on_show

Invoked when a widget is shown.