14#include "../text/semantic_text_style.hpp"
15#include "../text/text_selection.hpp"
16#include "../text/text_shaper.hpp"
17#include "../observer.hpp"
19#include "../i18n/translate.hpp"
20#include "../undo_stack.hpp"
21#include "../scoped_task.hpp"
30namespace hi {
inline namespace v1 {
32template<
typename Context>
70 observer<alignment>
alignment = hi::alignment::middle_center();
74 observer<semantic_text_style>
text_style = semantic_text_style::label;
110 void set_layout(
widget_layout const& context)
noexcept override;
111 void draw(draw_context
const& context)
noexcept override;
112 bool handle_event(
gui_event const& event)
noexcept override;
113 hitbox hitbox_test(point3 position)
const noexcept override;
114 [[nodiscard]]
bool accepts_keyboard_focus(keyboard_focus_group group)
const noexcept override;
117 enum class add_type { append, insert, dead };
121 text_selection selection;
124 enum class cursor_state_type {
off,
on, busy, none };
126 gstring _cached_text;
127 text_shaper _shaped_text;
130 delegate_type::callback_token _delegate_cbt;
132 decltype(
text_style)::callback_token _text_style_cbt;
134 text_selection _selection;
136 scoped_task<> _blink_cursor;
138 observer<cursor_state_type> _cursor_state = cursor_state_type::none;
139 decltype(_cursor_state)::callback_token _cursor_state_cbt;
143 bool _request_scroll =
false;
151 gui_event _last_drag_mouse_event = {};
155 utc_nanoseconds _last_drag_mouse_event_next_repeat = {};
161 bool _overwrite_mode =
false;
168 grapheme _has_dead_character =
nullptr;
170 undo_stack<undo_type> _undo_stack = {1000};
172 void set_attributes() noexcept {}
173 void set_attributes(text_widget_attribute
auto&& first, text_widget_attribute
auto&&...rest)
noexcept
175 if constexpr (forward_of<
decltype(first), observer<hi::alignment>>) {
177 }
else if constexpr (forward_of<
decltype(first), observer<hi::semantic_text_style>>) {
188 void scroll_to_show_selection() noexcept;
190 void request_scroll() noexcept;
201 void reset_state(
char const *states) noexcept;
203 [[nodiscard]] gstring_view selected_text() const noexcept;
204 void undo_push() noexcept;
205 void undo() noexcept;
206 void redo() noexcept;
208 scoped_task<> blink_cursor() noexcept;
212 void fix_cursor_position() noexcept;
216 void replace_selection(gstring const& replacement) noexcept;
224 void delete_dead_character() noexcept;
225 void delete_character_next() noexcept;
226 void delete_character_prev() noexcept;
227 void delete_word_next() noexcept;
228 void delete_word_prev() noexcept;
#define hi_static_no_default()
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:172
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
Defines delegate_delegate and some default text delegates.
Definition of GUI event types.
@ grapheme
The gui_event has grapheme data.
std::shared_ptr< text_delegate > make_default_text_delegate(auto &&value) noexcept
Create a shared pointer to a default text delegate.
Definition text_delegate.hpp:224
@ off
The 'off' state of a button.
DOXYGEN BUG.
Definition algorithm.hpp:15
@ on
The border is drawn on the edge of a quad.
The HikoGUI namespace.
Definition ascii.hpp:19
A user interface event.
Definition gui_event.hpp:76
Definition set_constraints_context.hpp:15
A delegate that controls the state of a text_widget.
Definition text_delegate.hpp:25
A text widget.
Definition text_widget.hpp:61
observer< semantic_text_style > text_style
The style of the text.
Definition text_widget.hpp:74
text_widget(widget *parent, std::shared_ptr< delegate_type > delegate) noexcept
Construct a text widget.
text_widget(widget *parent, different_from< std::shared_ptr< delegate_type > > auto &&text, text_widget_attribute auto &&...attributes) noexcept
Construct a text widget.
Definition text_widget.hpp:100
observer< alignment > alignment
The horizontal alignment of the text inside the space of the widget.
Definition text_widget.hpp:70
An interactive graphical object as part of the user-interface.
Definition widget.hpp:45
widget(widget *parent) noexcept
widget * parent
Pointer to the parent widget.
Definition widget.hpp:50
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:59
The constraints of a widget.
Definition widget_constraints.hpp:26
The layout of a widget.
Definition widget_layout.hpp:40
Definition text_widget.hpp:33