File: Tab.h

package info (click to toggle)
lsp-plugins 1.2.21-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 120,408 kB
  • sloc: cpp: 589,849; xml: 74,078; makefile: 13,396; php: 1,268; sh: 185
file content (176 lines) | stat: -rw-r--r-- 10,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2025 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-tk-lib
 * Created on: 9 нояб. 2022 г.
 *
 * lsp-tk-lib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-tk-lib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-tk-lib. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LSP_PLUG_IN_TK_WIDGETS_CONTAINERS_TAB_H_
#define LSP_PLUG_IN_TK_WIDGETS_CONTAINERS_TAB_H_

#ifndef LSP_PLUG_IN_TK_IMPL
    #error "use <lsp-plug.in/tk/tk.h>"
#endif

namespace lsp
{
    namespace tk
    {
        // Style definition
        namespace style
        {
            typedef struct TabColors
            {
                prop::Color                 sColor;                 // Heading tab color
                prop::Color                 sBorderColor;           // Heading tab border color
                prop::Color                 sTextColor;             // Heading tab text color

                void listener(tk::prop::Listener *listener);
                bool property_changed(Property *prop);
            } TabColors;

            enum TabColorState
            {
                TAB_NORMAL              = 0,
                TAB_SELECTED            = 1 << 0,
                TAB_HOVER               = 1 << 1,
                TAB_INACTIVE            = 1 << 2,

                TAB_TOTAL               = 1 << 3
            };

            LSP_TK_STYLE_DEF_BEGIN(Tab, WidgetContainer)
                TabColors                   vColors[TAB_TOTAL];

                prop::Layout                sLayout;                // Widget layout inside of the tab
                prop::String                sText;                  // Heading tab text
                prop::TextAdjust            sTextAdjust;            // Heading tab text adjustment
                prop::TextLayout            sTextLayout;            // Heading tab text layout
                prop::Padding               sTextPadding;           // Heading tab text padding
                prop::Font                  sFont;                  // Heading tab font
                prop::Integer               sBorderSize;            // Border size of the heading tab
                prop::Integer               sBorderRadius;          // Border radius of the heading tab
                prop::Boolean               sActive;                // Activity flag
            LSP_TK_STYLE_DEF_END
        } /* namespace style */

        class Tab: public WidgetContainer
        {
            public:
                static const w_class_t      metadata;

            private:
                friend class TabControl;

            protected:
                enum titm_flags_t
                {
                    TAB_0           = style::TAB_NORMAL,
                    TAB_1           = style::TAB_SELECTED,
                    TAB_2           = style::TAB_HOVER,
                    TAB_3           = style::TAB_SELECTED | style::TAB_HOVER,
                    TAB_4           = style::TAB_INACTIVE,
                    TAB_5           = style::TAB_SELECTED | style::TAB_INACTIVE,
                    TAB_6           = style::TAB_HOVER | style::TAB_INACTIVE,
                    TAB_7           = style::TAB_SELECTED | style::TAB_HOVER | style::TAB_INACTIVE,

                    TAB_TOTAL       = style::TAB_TOTAL
                };

            protected:
                Widget                     *pWidget;

                style::TabColors            vColors[style::TAB_TOTAL];
                prop::Layout                sLayout;                // Widget layout inside of the tab
                prop::String                sText;                  // Heading tab text
                prop::TextAdjust            sTextAdjust;            // Heading tab text adjustment
                prop::TextLayout            sTextLayout;            // Heading tab text layout
                prop::Padding               sTextPadding;           // Heading tab text padding
                prop::Font                  sFont;                  // Heading tab font
                prop::Integer               sBorderSize;            // Border size of the heading tab
                prop::Integer               sBorderRadius;          // Border radius of the heading tab
                prop::Boolean               sActive;                // Activity flag

            protected:
                void                    do_destroy();
                style::TabColors       *select_colors(bool selected, bool hover);

            protected:
                virtual void            property_changed(Property *prop) override;
                virtual void            size_request(ws::size_limit_t *r) override;
                virtual void            realize(const ws::rectangle_t *r) override;

            public:
                explicit Tab(Display *dpy);
                Tab(const Tab &) = delete;
                Tab(Tab &&) = delete;
                virtual ~Tab() override;

                Tab & operator = (const Tab &) = delete;
                Tab & operator = (Tab &&) = delete;

                virtual status_t            init() override;
                virtual void                destroy() override;

            public:
                LSP_TK_PROPERTY(Color,              color,                                  &vColors[TAB_0].sColor);
                LSP_TK_PROPERTY(Color,              border_color,                           &vColors[TAB_0].sBorderColor);
                LSP_TK_PROPERTY(Color,              text_color,                             &vColors[TAB_0].sTextColor);
                LSP_TK_PROPERTY(Color,              selected_color,                         &vColors[TAB_1].sColor);
                LSP_TK_PROPERTY(Color,              border_selected_color,                  &vColors[TAB_1].sBorderColor);
                LSP_TK_PROPERTY(Color,              text_selected_color,                    &vColors[TAB_1].sTextColor);
                LSP_TK_PROPERTY(Color,              hover_color,                            &vColors[TAB_2].sColor);
                LSP_TK_PROPERTY(Color,              border_hover_color,                     &vColors[TAB_2].sBorderColor);
                LSP_TK_PROPERTY(Color,              text_hover_color,                       &vColors[TAB_2].sTextColor);
                LSP_TK_PROPERTY(Color,              hover_selected_color,                   &vColors[TAB_3].sColor);
                LSP_TK_PROPERTY(Color,              border_hover_selected_color,            &vColors[TAB_3].sBorderColor);
                LSP_TK_PROPERTY(Color,              text_hover_selected_color,              &vColors[TAB_3].sTextColor);
                LSP_TK_PROPERTY(Color,              inactive_color,                         &vColors[TAB_4].sColor);
                LSP_TK_PROPERTY(Color,              inactive_border_color,                  &vColors[TAB_4].sBorderColor);
                LSP_TK_PROPERTY(Color,              inactive_text_color,                    &vColors[TAB_4].sTextColor);
                LSP_TK_PROPERTY(Color,              inactive_selected_color,                &vColors[TAB_5].sColor);
                LSP_TK_PROPERTY(Color,              inactive_border_selected_color,         &vColors[TAB_5].sBorderColor);
                LSP_TK_PROPERTY(Color,              inactive_text_selected_color,           &vColors[TAB_5].sTextColor);
                LSP_TK_PROPERTY(Color,              inactive_hover_color,                   &vColors[TAB_6].sColor);
                LSP_TK_PROPERTY(Color,              inactive_border_hover_color,            &vColors[TAB_6].sBorderColor);
                LSP_TK_PROPERTY(Color,              inactive_text_hover_color,              &vColors[TAB_6].sTextColor);
                LSP_TK_PROPERTY(Color,              inactive_hover_selected_color,          &vColors[TAB_7].sColor);
                LSP_TK_PROPERTY(Color,              inactive_border_hover_selected_color,   &vColors[TAB_7].sBorderColor);
                LSP_TK_PROPERTY(Color,              inactive_text_hover_selected_color,     &vColors[TAB_7].sTextColor);

                LSP_TK_PROPERTY(Layout,             layout,                                 &sLayout);
                LSP_TK_PROPERTY(String,             text,                                   &sText);
                LSP_TK_PROPERTY(TextAdjust,         text_adjust,                            &sTextAdjust);
                LSP_TK_PROPERTY(TextLayout,         text_layout,                            &sTextLayout);
                LSP_TK_PROPERTY(Padding,            text_padding,                           &sTextPadding);
                LSP_TK_PROPERTY(Font,               font,                                   &sFont);
                LSP_TK_PROPERTY(Integer,            border_size,                            &sBorderSize);
                LSP_TK_PROPERTY(Integer,            border_radius,                          &sBorderRadius);
                LSP_TK_PROPERTY(Boolean,            active,                                 &sActive);

            public:
                virtual Widget             *find_widget(ssize_t x, ssize_t y) override;
                virtual void                render(ws::ISurface *s, const ws::rectangle_t *area, bool force) override;
                virtual status_t            add(Widget *widget) override;
                virtual status_t            remove(Widget *widget) override;
        };

    } /* namespace tk */
} /* namespace lsp */


#endif /* LSP_PLUG_IN_TK_WIDGETS_CONTAINERS_TAB_H_ */