8#include "../GUI/draw_context.hpp"
9#include "../stencils/label_stencil.hpp"
10#include "../observable.hpp"
11#include "../alignment.hpp"
26 template<
typename Label>
31 Label &&
label) noexcept
34 _alignment(alignment),
39 template<
typename Label>
48 void init() noexcept
override {
49 _label_callback =
label.subscribe([
this](
auto...) {
50 _request_reconstrain =
true;
59 _label_cell = stencil::make_unique(_alignment, *
label, theme::global->labelStyle);
60 _preferred_size = interval_vec2::make_minimum(_label_cell->preferred_extent());
71 need_layout |= std::exchange(this->_request_relayout,
false);
83 context.line_color = theme::global->labelStyle.color;
86 _label_cell->draw(context,
true);
93 typename decltype(
label)::callback_ptr_type _label_callback;
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:33
Definition gui_window.hpp:39
A localized text + icon label.
Definition label.hpp:76
Definition observable.hpp:20
int recurse_lock_count() const noexcept
This function should be used in tt_axiom() to check if the lock is held by current thread.
Definition unfair_recursive_mutex.hpp:60
Definition label_widget.hpp:20
void init() noexcept override
Should be called right after allocating and constructing a widget.
Definition label_widget.hpp:48
bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override
Update the constraints of the widget.
Definition label_widget.hpp:54
void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept override
Draw the widget.
Definition label_widget.hpp:78
void update_layout(hires_utc_clock::time_point displayTimePoint, bool need_layout) noexcept override
Update the internal layout of the widget.
Definition label_widget.hpp:67
virtual void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept
Update the internal layout of the widget.
observable< bool > enabled
The widget is enabled.
Definition widget.hpp:105
widget(gui_window &window, std::shared_ptr< abstract_container_widget > parent) noexcept
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:100
virtual void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept
Draw the widget.
Definition widget.hpp:460
float base_line() const noexcept
Get the base-line in local coordinates.
Definition widget.hpp:350
virtual bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept
Update the constraints of the widget.
abstract_container_widget const & parent() const noexcept
Get a reference to the parent.
virtual aarect window_clipping_rectangle() const noexcept
Get the clipping-rectangle in window coordinates.
Definition widget.hpp:320
aarect rectangle() const noexcept
Get the rectangle in local coordinates.
Definition widget.hpp:340