HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
toolbar_button_widget.hpp
1// Copyright Take Vos 2021.
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#include "default_button_delegate.hpp"
9
10namespace hi::inline v1 {
11
13public:
15 using delegate_type = typename super::delegate_type;
16
17 template<typename Label>
18 toolbar_button_widget(gui_window &window, widget *parent, Label &&label, std::weak_ptr<delegate_type> delegate) noexcept :
19 toolbar_button_widget(window, parent, std::forward<Label>(label), weak_or_unique_ptr{std::move(delegate)})
20 {
21 }
22
23 template<typename Label>
24 toolbar_button_widget(gui_window &window, widget *parent, Label &&label) noexcept :
25 toolbar_button_widget(window, parent, std::forward<Label>(label), std::make_unique<button_delegate>())
26 {
27 }
28
30 widget_constraints const &set_constraints() noexcept override;
31 void set_layout(widget_layout const &layout) noexcept override;
32 void draw(draw_context const &context) noexcept override;
33 [[nodiscard]] bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept override;
34 // @endprivatesection
35private:
36 template<typename Label>
37 toolbar_button_widget(gui_window &window, widget *parent, Label &&label, weak_or_unique_ptr<delegate_type> delegate) noexcept
38 :
39 super(window, parent, std::move(delegate))
40 {
41 alignment = alignment::middle_left();
42 set_label(std::forward<Label>(label));
43 }
44
45 void draw_toolbar_button(draw_context const &context) noexcept;
46};
47
48} // 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 toolbar_button_widget.hpp:12
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)