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 hi::inline v1 {
10
12public:
14 using delegate_type = typename super::delegate_type;
15
16 template<typename Label>
17 momentary_button_widget(gui_window &window, widget *parent, Label &&label, std::weak_ptr<delegate_type> delegate) noexcept :
18 momentary_button_widget(window, parent, std::forward<Label>(label), weak_or_unique_ptr{std::move(delegate)})
19 {
20 }
21
22 template<typename Label>
23 momentary_button_widget(gui_window &window, widget *parent, Label &&label) noexcept :
24 momentary_button_widget(window, parent, std::forward<Label>(label), std::make_unique<delegate_type>())
25 {
26 }
27
29 widget_constraints const &set_constraints() noexcept override;
30 void set_layout(widget_layout const &layout) noexcept override;
31 void draw(draw_context const &context) noexcept override;
33private:
34 template<typename Label>
36 gui_window &window,
37 widget *parent,
38 Label &&label,
39 weak_or_unique_ptr<delegate_type> delegate) noexcept :
40 super(window, parent, std::move(delegate))
41 {
42 alignment = alignment::middle_center();
43 set_label(std::forward<Label>(label));
44 }
45
46 void draw_label_button(draw_context const &context) noexcept;
47};
48
49} // namespace hi::inline v1
Definition alignment.hpp:64
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:52
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
Definition button_delegate.hpp:14
Definition momentary_button_widget.hpp:11
An interactive graphical object as part of the user-interface.
Definition widget.hpp:39
Definition widget_constraints.hpp:13
Definition widget_layout.hpp:18
T move(T... args)