TermOx
color_select.hpp
1 #ifndef TERMOX_WIDGET_WIDGETS_COLOR_SELECT_HPP
2 #define TERMOX_WIDGET_WIDGETS_COLOR_SELECT_HPP
3 #include <memory>
4 
5 #include <signals_light/signal.hpp>
6 
7 #include <termox/painter/color.hpp>
8 #include <termox/widget/layouts/horizontal.hpp>
9 #include <termox/widget/layouts/vertical.hpp>
10 #include <termox/widget/widgets/button.hpp>
11 
12 namespace ox {
13 
14 class Color_tile : public Button {
15  public:
16  enum class Display { None, Number };
17 
18  struct Parameters {
19  Color color;
20  Display display = Display::None;
21  };
22 
23  public:
24  explicit Color_tile(Color c, Display display = Display::None);
25 
26  explicit Color_tile(Parameters p);
27 };
28 
30 
32 
33 class Color_select : public layout::Vertical<Color_line> {
34  public:
35  struct Parameters {
36  Color_tile::Display display = Color_tile::Display::None;
37  };
38 
39  public:
40  sl::Signal<void(Color)> color_selected;
41 
42  public:
43  explicit Color_select(
44  Color_tile::Display display = Color_tile::Display::None);
45 
46  explicit Color_select(Parameters p);
47 
48  private:
49  void set_palette(Palette const& pal);
50 
51  private:
52  Color_tile::Display display_;
53 };
54 
56 [[nodiscard]] auto color_select(
57  Color_tile::Display display = Color_tile::Display::None)
58  -> std::unique_ptr<Color_select>;
59 
61 [[nodiscard]] auto color_select(Color_select::Parameters p)
62  -> std::unique_ptr<Color_select>;
63 
64 } // namespace ox
65 #endif // TERMOX_WIDGET_WIDGETS_COLOR_SELECT_HPP
Button widget that emits Signal on a left mouse button press.
Definition: button.hpp:18
Displays each color of the current palette.
Definition: color_select.hpp:33
Definition: color_select.hpp:14
Color numbers [0 - 180] are valid.
Definition: color.hpp:16
Lays out Widgets in 2D, sharing space in a primary dimension.
Definition: linear_layout.hpp:35
Definition: color_select.hpp:35
Definition: color_select.hpp:18