HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
momentary_button_widget.hpp
1// Copyright Take Vos 2019-2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "abstract_button_widget.hpp"
8
9namespace tt {
10
12public:
14 using delegate_type = typename super::delegate_type;
15 using callback_ptr_type = typename delegate_type::callback_ptr_type;
16
17 template<typename Label>
21 Label &&label,
22 std::weak_ptr<delegate_type> delegate) noexcept :
23 momentary_button_widget(window, parent, std::forward<Label>(label), weak_or_unique_ptr{std::move(delegate)})
24 {
25 }
26
27 template<typename Label>
30 window,
31 parent,
32 std::forward<Label>(label),
33 std::make_unique<delegate_type>())
34 {
35 }
36
38 [[nodiscard]] bool constrain(utc_nanoseconds display_time_point, bool need_reconstrain) noexcept override;
39 [[nodiscard]] void layout(utc_nanoseconds displayTimePoint, bool need_layout) noexcept override;
40 void draw(draw_context context, utc_nanoseconds display_time_point) noexcept override;
42private:
43 template<typename Label>
47 Label &&label,
48 weak_or_unique_ptr<delegate_type> delegate) noexcept :
49 super(window, parent, std::move(delegate))
50 {
51 label_alignment = alignment::middle_left;
52 set_label(std::forward<Label>(label));
53 }
54
55 void draw_label_button(draw_context const &context) noexcept;
56};
57
58} // namespace tt
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:28
Definition gui_window.hpp:39
A label consisting of localizable text and an icon.
Definition label.hpp:27
Class that hold either a weak_ptr or a unique_ptr This class is to hold a weak_ptr,...
Definition weak_or_unique_ptr.hpp:25
Definition abstract_button_widget.hpp:23
void set_label(Label const &rhs) noexcept
Set on/off/other labels of the button to the same value.
Definition abstract_button_widget.hpp:48
observable< alignment > label_alignment
The alignment of the on/off/other label.
Definition abstract_button_widget.hpp:43
Definition button_delegate.hpp:14
Definition momentary_button_widget.hpp:11
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget *const parent
Pointer to the parent widget.
Definition widget.hpp:46
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:41
T move(T... args)