1 #ifndef CPPURSES_DEMOS_PALETTE_COLOR_DISPLAY_PANEL_HPP
2 #define CPPURSES_DEMOS_PALETTE_COLOR_DISPLAY_PANEL_HPP
3 #include <cppurses/painter/color.hpp>
4 #include <cppurses/widget/layouts/horizontal.hpp>
5 #include <cppurses/widget/widget.hpp>
6 #include <cppurses/widget/widgets/color_select.hpp>
7 
8 namespace palette {
9 
10 /// Displays every light and medium shade of a particular base color.
11 class Shade_display : public cppurses::Widget {
12    public:
13     explicit Shade_display(cppurses::Color base);
14 
15     /// Paint the shades from the top to the bottom.
16     void invert();
17 
18    protected:
19     bool paint_event() override;
20 
21    private:
22     cppurses::Color base_;
23     bool inverted_{false};
24 };
25 
26 /// Top bank of shades to display, the first 8 colors.
27 struct Top_shades : cppurses::layout::Horizontal {
28     Shade_display& black_shade{
29         this->make_child<Shade_display>(cppurses::Color::Black)};
30     Shade_display& dark_red_shade{
31         this->make_child<Shade_display>(cppurses::Color::Dark_red)};
32     Shade_display& dark_blue_shade{
33         this->make_child<Shade_display>(cppurses::Color::Dark_blue)};
34     Shade_display& dark_gray_shade{
35         this->make_child<Shade_display>(cppurses::Color::Dark_gray)};
36     Shade_display& brown_shade{
37         this->make_child<Shade_display>(cppurses::Color::Brown)};
38     Shade_display& green_shade{
39         this->make_child<Shade_display>(cppurses::Color::Green)};
40     Shade_display& red_shade{
41         this->make_child<Shade_display>(cppurses::Color::Red)};
42     Shade_display& gray_shade{
43         this->make_child<Shade_display>(cppurses::Color::Gray)};
44 };
45 
46 /// Bottom bank of shades to display, the last 8 colors.
47 struct Bottom_shades : cppurses::layout::Horizontal {
48     Bottom_shades();
49 
50     Shade_display& blue_shade{
51         this->make_child<Shade_display>(cppurses::Color::Blue)};
52     Shade_display& orange_shade{
53         this->make_child<Shade_display>(cppurses::Color::Orange)};
54     Shade_display& light_gray_shade{
55         this->make_child<Shade_display>(cppurses::Color::Light_gray)};
56     Shade_display& light_green_shade{
57         this->make_child<Shade_display>(cppurses::Color::Light_green)};
58     Shade_display& violet_shade{
59         this->make_child<Shade_display>(cppurses::Color::Violet)};
60     Shade_display& light_blue_shade{
61         this->make_child<Shade_display>(cppurses::Color::Light_blue)};
62     Shade_display& yellow_shade{
63         this->make_child<Shade_display>(cppurses::Color::Yellow)};
64     Shade_display& white_shade{
65         this->make_child<Shade_display>(cppurses::Color::White)};
66 };
67 
68 /// Holds both the pure colors and the various shades.
69 struct All_colors_display : cppurses::layout::Vertical {
70     All_colors_display();
71 
72     Top_shades& top_shades{this->make_child<Top_shades>()};
73     cppurses::Color_select& color_select{
74         this->make_child<cppurses::Color_select>()};
75     Bottom_shades& bottom_shades{this->make_child<Bottom_shades>()};
76 };
77 
78 }  // namespace palette
79 #endif  // CPPURSES_DEMOS_PALETTE_COLOR_DISPLAY_PANEL_HPP
80