HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields
tt::abstract_button_widget< T > Class Template Reference

#include <ttauri/widgets/abstract_button_widget.hpp>

Inheritance diagram for tt::abstract_button_widget< T >:
tt::widget std::enable_shared_from_this< widget > tt::abstract_toggle_button_widget< bool > tt::menu_item_widget< value_type > tt::abstract_radio_button_widget< T > tt::abstract_toggle_button_widget< T > tt::button_widget< T > tt::menu_item_widget< T > tt::abstract_bool_toggle_button_widget tt::radio_button_widget< T > tt::toolbar_tab_button_widget< T > tt::checkbox_widget< bool > tt::checkbox_widget< T > tt::toggle_widget tt::boolean_checkbox_widget

Public Types

using super = widget
 
using value_type = T
 
using notifier_type = notifier<void()>
 
using callback_type = typename notifier_type::callback_type
 
using callback_ptr_type = typename notifier_type::callback_ptr_type
 

Public Member Functions

template<typename Value = observable<value_type>>
 abstract_button_widget (gui_window &window, std::shared_ptr< abstract_container_widget > parent, value_type true_value, Value &&value={})
 
color background_color () const noexcept override
 
bool accepts_keyboard_focus (keyboard_focus_group group) const noexcept
 Check if the widget will accept keyboard focus.
 
bool handle_event (command command) noexcept
 Handle command.
 
bool handle_event (mouse_event const &event) noexcept final
 
hit_box hitbox_test (point2 position) const noexcept final
 Find the widget that is under the mouse cursor.
 
template<typename Callback >
callback_ptr_type subscribe (Callback &&callback) noexcept
 Subscribe a callback to call when the button is activated.
 
void unsubscribe (callback_ptr_type &callback_ptr) noexcept
 Unsubscribe a callback.
 
- 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 update_constraints (hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept
 Update the constraints of the widget.
 
virtual void update_layout (hires_utc_clock::time_point display_time_point, bool need_layout) noexcept
 Update the internal layout of the widget.
 
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 draw (draw_context context, hires_utc_clock::time_point display_time_point) noexcept
 Draw the widget.
 
virtual void request_redraw () const noexcept
 
virtual bool handle_event (std::vector< command > const &commands) noexcept
 
virtual bool handle_command_recursive (command command, std::vector< std::shared_ptr< widget > > const &reject_list) noexcept
 Handle command recursive.
 
virtual bool handle_event (keyboard_event const &event) noexcept
 Handle keyboard event.
 
virtual 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.
 
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)
 

Data Fields

value_type const true_value
 
observable< value_type > value
 
- Data Fields inherited from tt::widget
gui_windowwindow
 Convenient reference to the Window.
 
observable< bool > enabled = true
 The widget is enabled.
 

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.
 

Detailed Description

template<typename T>
class tt::abstract_button_widget< T >

An abstract button widget.

This widgets implements the behavior for a widget where its whole area is clickable, accepts and responds to gui_activate commands.

Member Function Documentation

◆ accepts_keyboard_focus()

template<typename T >
bool tt::abstract_button_widget< T >::accepts_keyboard_focus ( keyboard_focus_group group) const
inlinevirtualnoexcept

Check if the widget will accept keyboard focus.

Precondition
mutex must be locked by current thread.

Reimplemented from tt::widget.

Reimplemented in tt::menu_item_widget< T >, tt::menu_item_widget< value_type >, and tt::toolbar_tab_button_widget< T >.

◆ background_color()

template<typename T >
color tt::abstract_button_widget< T >::background_color ( ) const
inlineoverridevirtualnoexcept

Reimplemented from tt::widget.

◆ handle_event() [1/2]

template<typename T >
bool tt::abstract_button_widget< T >::handle_event ( command command)
inlinevirtualnoexcept

Handle command.

If a widget does not fully handle a command it should pass the command to the super class' handle_event().

Reimplemented from tt::widget.

Reimplemented in tt::menu_item_widget< T >, tt::menu_item_widget< value_type >, and tt::toolbar_tab_button_widget< T >.

◆ handle_event() [2/2]

template<typename T >
bool tt::abstract_button_widget< T >::handle_event ( mouse_event const & event)
inlinefinalvirtualnoexcept

Handle mouse event. Called by the operating system to show the position and button state of the mouse. This is called very often so it must be made efficient. This function is also used to determine the mouse cursor.

In most cased overriding methods should call the super's handle_event() at the start of the function, to detect hover.

When this method does not handle the event the window will call handle_event() on the widget's parent.

Parameters
eventThe mouse event, positions are in window coordinates.
Returns
If this widget has handled the mouse event.

Reimplemented from tt::widget.

◆ hitbox_test()

template<typename T >
hit_box tt::abstract_button_widget< T >::hitbox_test ( point2 position) const
inlinefinalvirtualnoexcept

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.

◆ subscribe()

template<typename T >
template<typename Callback >
callback_ptr_type tt::abstract_button_widget< T >::subscribe ( Callback && callback)
inlinenoexcept

Subscribe a callback to call when the button is activated.

See also
notifier::subscribe()

◆ unsubscribe()

template<typename T >
void tt::abstract_button_widget< T >::unsubscribe ( callback_ptr_type & callback_ptr)
inlinenoexcept

Unsubscribe a callback.

See also
notifier::subscribe()

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