TermOx
titlebar.hpp
1 #ifndef TERMOX_WIDGET_WIDGETS_TITLEBAR_HPP
2 #define TERMOX_WIDGET_WIDGETS_TITLEBAR_HPP
3 #include <memory>
4 
5 #include <termox/painter/glyph_string.hpp>
6 #include <termox/widget/pair.hpp>
7 #include <termox/widget/widgets/button.hpp>
8 #include <termox/widget/widgets/label.hpp>
9 
10 namespace ox {
11 
13 
15 class Titlebar : public HPair<HLabel, Button> {
16  public:
17  struct Parameters {
18  Glyph_string title_text = U"";
19  };
20 
21  public:
22  HLabel& title = this->first;
23  Button& exit_button = this->second;
24 
25  public:
27  explicit Titlebar(Glyph_string title_text = U"");
28 
30  explicit Titlebar(Parameters p);
31 
32  private:
33  inline static auto constexpr exit_width = 3;
34  inline static auto constexpr extra_left = 0;
35  inline static auto constexpr extra_right = exit_width;
36 };
37 
39 [[nodiscard]] auto titlebar(Glyph_string title_text = U"")
40  -> std::unique_ptr<Titlebar>;
41 
43 [[nodiscard]] auto titlebar(Titlebar::Parameters p)
44  -> std::unique_ptr<Titlebar>;
45 
46 } // namespace ox
47 #endif // TERMOX_WIDGET_WIDGETS_TITLEBAR_HPP
Button widget that emits Signal on a left mouse button press.
Definition: button.hpp:18
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
A single line of text with alignment, non-editable.
Definition: label.hpp:22
Provides a centered title and flush-right exit button.
Definition: titlebar.hpp:15
Titlebar(Glyph_string title_text=U"")
Construct a Titlebar with centered title.
Definition: titlebar.cpp:17
Heterogeneous pair of Widgets within a Layout.
Definition: pair.hpp:14
Definition: titlebar.hpp:17