HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
tt::abstract_container_widget Class Reference
Inheritance diagram for tt::abstract_container_widget:
tt::widget std::enable_shared_from_this< widget > tt::grid_layout_widget tt::overlay_view_widget tt::row_column_layout_widget< Arrangement > tt::scroll_view_widget< CanScrollHorizontally, CanScrollVertically, ControlsWindow > tt::selection_widget< T > tt::tab_view_widget< T > tt::toolbar_widget tt::window_widget

Public Types

using super = widget
 

Public Member Functions

 abstract_container_widget (gui_window &window, std::shared_ptr< abstract_container_widget > parent) noexcept
 
void clear () noexcept
 Remove and deallocate all child widgets.
 
std::shared_ptr< widgetadd_widget (std::shared_ptr< widget > widget) noexcept
 Add a widget directly to this widget.
 
widgetfront () noexcept
 
widget const & front () const noexcept
 
widgetback () noexcept
 
widget const & back () const noexcept
 
std::shared_ptr< abstract_container_widget const > shared_from_this () const noexcept
 
std::shared_ptr< abstract_container_widgetshared_from_this () noexcept
 
template<typename T , typename... Args>
std::shared_ptr< T > make_widget (Args &&...args)
 Add a widget directly to this widget.
 
virtual bool is_toolbar () const noexcept
 
bool update_constraints (hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept
 Update the constraints of the widget.
 
void update_layout (hires_utc_clock::time_point display_time_point, bool need_layout) noexcept
 Update the internal layout of the widget.
 
void draw (draw_context context, hires_utc_clock::time_point display_time_point) noexcept
 Draw the widget.
 
bool handle_command_recursive (command command, std::vector< std::shared_ptr< widget > > const &reject_list) noexcept override
 Handle command recursive.
 
hit_box hitbox_test (point2 position) const noexcept override
 Find the widget that is under the mouse cursor.
 
std::shared_ptr< widget const > find_first_widget (keyboard_focus_group group) const noexcept
 
std::shared_ptr< widget const > find_last_widget (keyboard_focus_group group) const noexcept
 
std::shared_ptr< widgetfind_next_widget (std::shared_ptr< widget > const &current_keyboard_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept
 Find the next widget that handles keyboard focus.
 
- Public Member Functions inherited from tt::widget
 widget (gui_window &window, std::shared_ptr< abstract_container_widget > parent) noexcept
 
 widget (const widget &)=delete
 
widgetoperator= (const widget &)=delete
 
 widget (widget &&)=delete
 
widgetoperator= (widget &&)=delete
 
virtual void init () noexcept
 Should be called right after allocating and constructing a widget.
 
float margin () const noexcept
 Get the margin around the Widget.
 
float draw_layer () const noexcept
 The first drawing layer of the widget.
 
int logical_layer () const noexcept
 The logical layer of the widget.
 
int semantic_layer () const noexcept
 The semantic layer of the widget.
 
ranged_int< 3 > width_resistance () const noexcept
 Get the resistance in width.
 
ranged_int< 3 > height_resistance () const noexcept
 Get the resistance in height.
 
interval_extent2 preferred_size () const noexcept
 Get the size-range of the widget.
 
void set_layout_parameters (geo::transformer auto const &local_to_parent, extent2 size, aarectangle const &clipping_rectangle) noexcept
 Set the location and size of the widget inside the window.
 
void set_layout_parameters_from_parent (aarectangle child_rectangle, aarectangle parent_clipping_rectangle, float draw_layer_delta) noexcept
 
void set_layout_parameters_from_parent (aarectangle child_rectangle) noexcept
 
matrix3 parent_to_local () const noexcept
 
matrix3 local_to_parent () const noexcept
 
matrix3 window_to_local () const noexcept
 
matrix3 local_to_window () const noexcept
 
extent2 size () const noexcept
 
float width () const noexcept
 
float height () const noexcept
 
aarectangle rectangle () const noexcept
 Get the rectangle in local coordinates.
 
virtual float base_line () const noexcept
 Return the base-line where the text should be located.
 
aarectangle clipping_rectangle () const noexcept
 
gui_devicedevice () const noexcept
 
virtual bool accepts_keyboard_focus (keyboard_focus_group group) const noexcept
 Check if the widget will accept keyboard focus.
 
virtual color background_color () const noexcept
 
virtual color foreground_color () const noexcept
 
virtual color focus_color () const noexcept
 
virtual color accent_color () const noexcept
 
virtual color label_color () const noexcept
 
virtual void request_redraw () const noexcept
 
virtual bool handle_event (command command) noexcept
 Handle command.
 
virtual bool handle_event (std::vector< command > const &commands) noexcept
 
virtual bool handle_event (mouse_event const &event) noexcept
 
virtual bool handle_event (keyboard_event const &event) noexcept
 Handle keyboard event.
 
std::shared_ptr< abstract_container_widget const > shared_parent () const noexcept
 Get a shared_ptr to the parent.
 
std::shared_ptr< abstract_container_widgetshared_parent () noexcept
 Get a shared_ptr to the parent.
 
abstract_container_widget const & parent () const noexcept
 Get a reference to the parent.
 
abstract_container_widgetparent () noexcept
 Get a reference to the parent.
 
bool is_first (keyboard_focus_group group) const noexcept
 Is this widget the first widget in the parent container.
 
bool is_last (keyboard_focus_group group) const noexcept
 Is this widget the last widget in the parent container.
 
- Public Member Functions inherited from std::enable_shared_from_this< widget >
enable_shared_from_this (T... args)
 
operator= (T... args)
 
shared_from_this (T... args)
 
~enable_shared_from_this (T... args)
 

Additional Inherited Members

- Static Public Member Functions inherited from tt::widget
static std::vector< std::shared_ptr< widget > > parent_chain (std::shared_ptr< tt::widget > const &child_widget) noexcept
 Get a list of parents of a given widget.
 
- Data Fields inherited from tt::widget
gui_windowwindow
 Convenient reference to the Window.
 
observable< bool > enabled = true
 The widget is enabled.
 

Member Function Documentation

◆ add_widget()

std::shared_ptr< widget > tt::abstract_container_widget::add_widget ( std::shared_ptr< widget > widget)
inlinenoexcept

Add a widget directly to this widget.

Thread safety: locks.

◆ clear()

void tt::abstract_container_widget::clear ( )
inlinenoexcept

Remove and deallocate all child widgets.

◆ draw()

void tt::abstract_container_widget::draw ( draw_context context,
hires_utc_clock::time_point display_time_point )
inlinevirtualnoexcept

Draw the widget.

This function is called by the window (optionally) on every frame. It should recursively call this function on every visible child. This function is only called when updateLayout() has returned true.

The overriding function should call the base class's draw(), the place where the call this function will determine the order of the vertices into each buffer. This is important when needing to do the painters algorithm for alpha-compositing. However the pipelines are always drawn in the same order.

Precondition
mutex must be locked by current thread.
Parameters
contextThe context to where the widget will draw.
display_time_pointThe time point when the widget will be shown on the screen.

Reimplemented from tt::widget.

Reimplemented in tt::toolbar_widget, tt::overlay_view_widget, tt::selection_widget< T >, and tt::tab_view_widget< T >.

◆ find_next_widget()

std::shared_ptr< widget > tt::abstract_container_widget::find_next_widget ( std::shared_ptr< widget > const & current_keyboard_widget,
keyboard_focus_group group,
keyboard_focus_direction direction ) const
inlinevirtualnoexcept

Find the next widget that handles keyboard focus.

This recursively looks for the current keyboard widget, then returns the next (or previous) widget that returns true from accepts_keyboard_focus().

Parameters
current_keyboard_widgetThe widget that currently has focus; or empty to get the first widget that accepts focus.
groupThe group to which the widget must belong.
directionThe direction in which to walk the widget tree.
Returns
A pointer to the next widget.
Return values
currentKeyboardWidgetwhen currentKeyboardWidget was found but no next widget was found.
emptywhen currentKeyboardWidget is not found in this Widget.

Reimplemented from tt::widget.

Reimplemented in tt::selection_widget< T >, and tt::tab_view_widget< T >.

◆ handle_command_recursive()

bool tt::abstract_container_widget::handle_command_recursive ( command command,
std::vector< std::shared_ptr< widget > > const & reject_list )
inlineoverridevirtualnoexcept

Handle command recursive.

Handle a command and pass it to each child.

Parameters
commandThe command to handle by this widget.
reject_listThe widgets that should ignore this command
Returns
True when the command was handled by this widget or recursed child.

Reimplemented from tt::widget.

◆ hitbox_test()

hit_box tt::abstract_container_widget::hitbox_test ( point2 position) const
inlineoverridevirtualnoexcept

Find the widget that is under the mouse cursor.

This function will recursively test with visual child widgets, when widgets overlap on the screen the hitbox object with the highest elevation is returned.

Parameters
positionThe coordinate of the mouse local to the widget.
Returns
A hit_box object with the cursor-type and a reference to the widget.

Reimplemented from tt::widget.

Reimplemented in tt::toolbar_widget, tt::scroll_view_widget< CanScrollHorizontally, CanScrollVertically, ControlsWindow >, tt::selection_widget< T >, tt::tab_view_widget< T >, and tt::window_widget.

◆ make_widget()

template<typename T , typename... Args>
std::shared_ptr< T > tt::abstract_container_widget::make_widget ( Args &&... args)
inline

Add a widget directly to this widget.

◆ update_constraints()

bool tt::abstract_container_widget::update_constraints ( hires_utc_clock::time_point display_time_point,
bool need_reconstrain )
inlinevirtualnoexcept

Update the constraints of the widget.

This function is called on each vertical sync, even if no drawing is to be done. It should recursively call updateConstraints() on each of the visible children, so they get a chance to update.

This function may be used for expensive calculations, such as text-shaping, which should only be done when the data changes. Because this function is called on every vertical sync it should cache these calculations.

Subclasses should call updateConstraints() on its base-class to check if the constraints where changed. Widget::update_constraints() will check if requestConstraints was set. Container::update_constraints() will check if any of the children changed constraints.

If the container, due to a change in constraints, wants the window to resize to the minimum size it should set window.requestResize to true.

This function will change what is returned by preferred_size() and preferred_base_line().

Precondition
mutex must be locked by current thread.
Parameters
display_time_pointThe time point when the widget will be shown on the screen.
need_reconstrainForce the widget to re-constrain.
Returns
True if its or any children's constraints has changed.

Reimplemented from tt::widget.

Reimplemented in tt::row_column_layout_widget< Arrangement >, tt::toolbar_widget, tt::grid_layout_widget, tt::overlay_view_widget, tt::scroll_view_widget< CanScrollHorizontally, CanScrollVertically, ControlsWindow >, tt::selection_widget< T >, tt::tab_view_widget< T >, and tt::window_widget.

◆ update_layout()

void tt::abstract_container_widget::update_layout ( hires_utc_clock::time_point display_time_point,
bool need_layout )
inlinevirtualnoexcept

Update the internal layout of the widget.

This function is called on each vertical sync, even if no drawing is to be done. It should recursively call updateLayout() on each of the visible children, so they get a chance to update.

This function may be used for expensive calculations, such as geometry calculations, which should only be done when the data or sizes change. Because this function is called on every vertical sync it should cache these calculations.

This function will likely call set_layout_parameters() on its children.

Subclasses should call updateLayout() on its children, call updateLayout() on its base class with forceLayout argument to the result of layoutRequest.exchange(false).

Precondition
mutex must be locked by current thread.
Parameters
display_time_pointThe time point when the widget will be shown on the screen.
need_layoutForce the widget to layout

Reimplemented from tt::widget.

Reimplemented in tt::row_column_layout_widget< Arrangement >, tt::toolbar_widget, tt::window_widget, tt::grid_layout_widget, tt::overlay_view_widget, tt::scroll_view_widget< CanScrollHorizontally, CanScrollVertically, ControlsWindow >, tt::selection_widget< T >, and tt::tab_view_widget< T >.


The documentation for this class was generated from the following file: