TermOx
confirm_button.hpp
1 #ifndef TERMOX_WIDGET_WIDGETS_CONFIRM_BUTTON_HPP
2 #define TERMOX_WIDGET_WIDGETS_CONFIRM_BUTTON_HPP
3 #include <memory>
4 
5 #include <signals_light/signal.hpp>
6 
7 #include <termox/painter/glyph_string.hpp>
8 #include <termox/widget/array.hpp>
9 #include <termox/widget/tuple.hpp>
10 #include <termox/widget/widgets/button.hpp>
11 
12 namespace ox::detail {
13 
14 class Confirm_page : public HArray<Button, 2> {
15  public:
16  struct Parameters {
17  Glyph_string confirm_text;
18  };
19 
20  public:
21  Button& confirm_btn = this->get<0>();
22  Button& exit_btn = this->get<1>();
23 
24  public:
25  explicit Confirm_page(Glyph_string confirm_text);
26 
27  explicit Confirm_page(Parameters p);
28 };
29 
30 } // namespace ox::detail
31 
32 namespace ox {
33 
35 
36 class Confirm_button : public STuple<Button, detail::Confirm_page> {
37  public:
38  struct Parameters {
39  Glyph_string label = U"";
40  Glyph_string confirm_text = U"Confirm";
41  };
42 
43  public:
45  sl::Signal<void()> pressed;
46 
47  public:
48  Button& main_btn = this->get<0>();
49  detail::Confirm_page& confirm_page = this->get<1>();
50 
51  public:
53  explicit Confirm_button(Glyph_string label = U"",
54  Glyph_string confirm_text = U"Confirm");
55 
56  explicit Confirm_button(Parameters p);
57 
58  private:
59  static auto constexpr front_page_ = 0uL;
60  static auto constexpr confirm_page_ = 1uL;
61 };
62 
64 [[nodiscard]] auto confirm_button(Glyph_string label = U"",
65  Glyph_string confirm_text = U"Confirm")
66  -> std::unique_ptr<Confirm_button>;
67 
69 [[nodiscard]] auto confirm_button(Confirm_button::Parameters p)
70  -> std::unique_ptr<Confirm_button>;
71 
72 } // namespace ox
73 #endif // TERMOX_WIDGET_WIDGETS_CONFIRM_BUTTON_HPP
Homogeneous collection of Widgets within a Layout_t<Widget_t>.
Definition: array.hpp:18
Button widget that emits Signal on a left mouse button press.
Definition: button.hpp:18
A Button with a confirm screen after the initial press.
Definition: confirm_button.hpp:36
Confirm_button(Glyph_string label=U"", Glyph_string confirm_text=U"Confirm")
Construct a Button with label and corresponding confirm_text.
Definition: confirm_button.cpp:30
sl::Signal< void()> pressed
Emitted once confirmation has been made.
Definition: confirm_button.hpp:45
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
Heterogeneous collection of Widgets within a Layout_t.
Definition: tuple.hpp:17
Definition: confirm_button.hpp:14
Definition: confirm_button.hpp:38
Definition: confirm_button.hpp:16