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

#include <hikogui/widgets/selection_delegate.hpp>

Inheritance diagram for hi::v1::default_selection_delegate< T >:
hi::v1::selection_delegate

Public Types

using value_type = T
 
using option_type = std::pair<value_type, label>
 
using options_type = std::vector<option_type>
 

Public Member Functions

template<forward_of< observer< value_type > > Value, forward_of< observer< options_type > > Options>
 default_selection_delegate (Value &&value, Options &&options) noexcept
 Construct a default selection delegate.
 
size_t size (widget_intf const &sender) const noexcept override
 The number of options in the pull-down menu.
 
std::optional< label > selected_label (widget_intf const &sender) const noexcept override
 Get the label of the selected option.
 
std::optional< widget_id > keyboard_focus_id (widget_intf const &sender) const noexcept override
 The id of the widget that will need to get keyboard focus when the pull-down menu is opened.
 
std::unique_ptr< widgetmake_option_widget (widget_intf const &sender, widget_intf const &parent, size_t index) noexcept override
 Create a new widget that represents the button in the selection menu.
 
- Public Member Functions inherited from hi::v1::selection_delegate
virtual void init (widget_intf const &sender)
 
virtual void deinit (widget_intf const &sender)
 
bool empty (widget_intf const &sender) const noexcept
 
template<forward_of< void()> Func>
callback< void()> subscribe_on_value (Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
 Subscribe a callback for notifying the widget of a change in the value.
 
template<forward_of< void()> Func>
callback< void()> subscribe_on_options (Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
 Subscribe a callback for notifying the widget of a change in the options.
 

Data Fields

observer< value_type > value
 
observer< options_typeoptions
 

Detailed Description

template<typename T>
class hi::v1::default_selection_delegate< T >

A delegate that control the state of a selection_widget.

Template Parameters
Tthe type used as the key for which option is selected.

Constructor & Destructor Documentation

◆ default_selection_delegate()

template<typename T >
template<forward_of< observer< value_type > > Value, forward_of< observer< options_type > > Options>
hi::v1::default_selection_delegate< T >::default_selection_delegate ( Value && value,
Options && options )
inlinenoexcept

Construct a default selection delegate.

Parameters
valueThe observer value which represents the selected option.
optionsAn observer std::vector<std::pair<value_type,label>> of all possible options.

Member Function Documentation

◆ keyboard_focus_id()

template<typename T >
std::optional< widget_id > hi::v1::default_selection_delegate< T >::keyboard_focus_id ( widget_intf const & sender) const
inlineoverridevirtualnoexcept

The id of the widget that will need to get keyboard focus when the pull-down menu is opened.

Returns
The id of the widget that needs keyboard focus.
Return values
std::nulloptThere are no options.

Reimplemented from hi::v1::selection_delegate.

◆ make_option_widget()

template<typename T >
std::unique_ptr< widget > hi::v1::default_selection_delegate< T >::make_option_widget ( widget_intf const & sender,
widget_intf const & parent,
size_t index )
inlineoverridevirtualnoexcept

Create a new widget that represents the button in the selection menu.

Parameters
senderThe selection widget that uses this delegate.
parentThe parent widget of the new widget being created.
indexThe index of the option.
Returns
A new widget that represents the option at index.

Implements hi::v1::selection_delegate.

◆ selected_label()

template<typename T >
std::optional< label > hi::v1::default_selection_delegate< T >::selected_label ( widget_intf const & sender) const
inlineoverridevirtualnoexcept

Get the label of the selected option.

Returns
The label of the selected option.
Return values
std::nulloptNone of the options has been selected.

Reimplemented from hi::v1::selection_delegate.

◆ size()

template<typename T >
size_t hi::v1::default_selection_delegate< T >::size ( widget_intf const & sender) const
inlineoverridevirtualnoexcept

The number of options in the pull-down menu.

Reimplemented from hi::v1::selection_delegate.


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