|
HikoGUI
A low latency retained GUI
|
#include <ttauri/widgets/menu_item_widget.hpp>
Public Types | |
| using | super = abstract_button_widget<T> |
| using | value_type = typename super::value_type |
Public Types inherited from tt::abstract_button_widget< T > | |
| 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>> | |
| menu_item_widget (gui_window &window, std::shared_ptr< abstract_container_widget > parent, value_type true_value, Value &&value={}) noexcept | |
| void | init () noexcept override |
| Should be called right after allocating and constructing a widget. | |
| void | set_show_check_mark (bool flag) noexcept |
Set the show_check_mark() flag. | |
| bool | show_check_mark () const noexcept |
| Whether the label aligns to an optional check-mark. | |
| void | set_show_icon (bool flag) noexcept |
Set the show_icon() flag. | |
| bool | show_icon () const noexcept |
| Whether the text in the label will align to an optional icon in the label. | |
| void | set_show_short_cut (bool flag) noexcept |
Set the show_short_cut() flag. | |
| bool | show_short_cut () const noexcept |
| Whether the menu item should make space for an optional short-cut. | |
| bool | accepts_keyboard_focus (keyboard_focus_group group) const noexcept override |
| Check if the widget will accept keyboard focus. | |
| bool | handle_event (tt::command command) noexcept override |
| Handle command. | |
| bool | update_constraints (hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override |
| 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 override |
| Draw the widget. | |
| color | focus_color () const noexcept override |
Public Member Functions inherited from tt::abstract_button_widget< T > | |
| 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 | 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 | |
| widget & | operator= (const widget &)=delete |
| widget (widget &&)=delete | |
| widget & | operator= (widget &&)=delete |
| 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_device * | device () const noexcept |
| virtual color | foreground_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 (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< widget > | find_next_widget (std::shared_ptr< widget > const ¤t_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_widget > | shared_parent () noexcept |
| Get a shared_ptr to the parent. | |
| abstract_container_widget const & | parent () const noexcept |
| Get a reference to the parent. | |
| abstract_container_widget & | parent () 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 > | |
| T | enable_shared_from_this (T... args) |
| T | operator= (T... args) |
| T | shared_from_this (T... args) |
| T | ~enable_shared_from_this (T... args) |
Data Fields | |
| observable< label > | label |
Data Fields inherited from tt::abstract_button_widget< T > | |
| value_type const | true_value |
| observable< value_type > | value |
Data Fields inherited from tt::widget | |
| gui_window & | window |
| 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. | |
Menu item widget.
Visual:
Control:
|
inlineoverridevirtualnoexcept |
Check if the widget will accept keyboard focus.
mutex must be locked by current thread. Reimplemented from tt::abstract_button_widget< T >.
|
inlineoverridevirtualnoexcept |
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.
mutex must be locked by current thread. | context | The context to where the widget will draw. |
| display_time_point | The time point when the widget will be shown on the screen. |
Reimplemented from tt::widget.
|
inlineoverridevirtualnoexcept |
Reimplemented from tt::widget.
|
inlineoverridevirtualnoexcept |
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::abstract_button_widget< T >.
|
inlineoverridevirtualnoexcept |
Should be called right after allocating and constructing a widget.
Reimplemented from tt::widget.
|
inlinenoexcept |
Set the show_check_mark() flag.
|
inlinenoexcept |
Set the show_icon() flag.
|
inlinenoexcept |
Set the show_short_cut() flag.
|
inlinenoexcept |
Whether the label aligns to an optional check-mark.
The check-mark denotes that value == true_value.
Most menu items, except for the menu items in the toolbar, will want to show a check-mark.
| true | The label is placed after an optional check mark. |
| false | The label is flushed with the edge of the menu item. |
|
inlinenoexcept |
Whether the text in the label will align to an optional icon in the label.
Make space for, and optionally display, an icon in front of the text. This option should be used when any of the labels in a menu has an icon.
This should not be used when a menu is displayed in the same direction as the icon label. For example a left or right aligned menu item in a row menu; such as the tool-bar.
| true | The text of the label will be aligned after an optional icon of the label. |
| false | The text of the label will be not be aligned to an optional icon of the label. |
|
inlinenoexcept |
Whether the menu item should make space for an optional short-cut.
An optional short-cut may be displayed after the label on the edge of the menu-item.
If any of the menu-items in a menu has a short-cut this should be set to true for all of them. This should be set to false for menu items in the tool-bar or for items in a selection widget.
| true | Make room for a short-cut after a label |
| false | Don't make extra room for a short-cut after a label. |
|
inlineoverridevirtualnoexcept |
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().
mutex must be locked by current thread. | display_time_point | The time point when the widget will be shown on the screen. |
| need_reconstrain | Force the widget to re-constrain. |
Reimplemented from tt::widget.
|
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).
mutex must be locked by current thread. | display_time_point | The time point when the widget will be shown on the screen. |
| need_layout | Force the widget to layout |
Reimplemented from tt::widget.