lecui 1.0.0-alpha.20
lecui C++ user interface library
tab_pane.h
1//
2// tab_pane.h - tab pane interface
3//
4// lecui user interface library, part of the liblec library
5// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
6//
7// Released under the MIT license. For full details see the
8// file LICENSE.txt
9//
10
11#pragma once
12
13#if defined(LECUI_EXPORTS)
14#include "../widgets/widget.h"
15#else
16#include <liblec/lecui/widgets/widget.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
21 namespace containers {
22#if defined(LECUI_EXPORTS)
23 class tab_pane_builder;
24 class tab_builder;
25#endif
26
28 class lecui_api tab_pane : public widgets::widget {
29 public:
31 enum class side {
32 left,
33 right,
34 top,
35 bottom,
36 };
37
39 enum class orientation {
40 horizontal,
41 vertical,
42 };
43
44 private:
45 float _border = .5f;
46 color _color_border;
47 float _corner_radius_x = 5.f;
48 float _corner_radius_y = 5.f;
49 side _tab_side = side::top;
50 std::vector<std::string> _caption_reserve;
51 orientation _caption_orientation = orientation::horizontal;
52 color _color_tabs;
53 color _color_tabs_border;
54 float _tabs_border = .5f;
55 std::string _selected;
56 containers::page* _p_page = nullptr;
57
58#if defined(LECUI_EXPORTS)
59 friend class tab_pane_builder;
60 friend class tab_builder;
61#endif
62 public:
65
70 bool operator==(const tab_pane& param);
71
76 bool operator!=(const tab_pane& param);
77
78 // generic widget
79
83 std::string& text() override;
84
89 tab_pane& text(const std::string& text);
90
94 std::string& tooltip() override;
95
100 tab_pane& tooltip(const std::string& tooltip);
101
105 lecui::rect& rect() override;
106
111
115
119 tab_pane& on_resize(const resize_params& on_resize);
120
124 cursor_type& cursor() override;
125
130
134 std::string& font() override;
135
140 tab_pane& font(const std::string& font);
141
145 float& font_size() override;
146
151 tab_pane& font_size(const float& font_size);
152
156 color& color_text() override;
157
162 tab_pane& color_text(const color& color_text);
163
166 color& color_fill() override;
167
171 tab_pane& color_fill(const color& color_fill);
172
176 color& color_hot() override;
177
182 tab_pane& color_hot(const color& color_hot);
183
188
193 tab_pane& color_selected(const color& color_selected);
194
198
202 tab_pane& color_disabled(const color& color_disabled);
203
204 // widget specific widget
205
208 float& border();
209
213 tab_pane& border(const float& border);
214
218
222 tab_pane& color_border(const color& color_border);
223
227
231 tab_pane& corner_radius_x(const float& corner_radius_x);
232
236
240 tab_pane& corner_radius_y(const float& corner_radius_y);
241
245
249 tab_pane& tab_side(const side& tab_side);
250
264 std::vector<std::string>& caption_reserve();
265
280 tab_pane& caption_reserve(const std::vector<std::string>& caption_reserve);
281
285
289 tab_pane& caption_orientation(const orientation& caption_orientation);
290
294
298 tab_pane& color_tabs(const color& color_tabs);
299
303
307 tab_pane& color_tabs_border(const color& color_tabs_border);
308
311 float& tabs_border();
312
316 tab_pane& tabs_border(const float& tabs_border);
317
320 std::string& selected();
321
325 tab_pane& selected(const std::string& selected);
326
327 public:
335 [[nodiscard]]
336 static tab_pane& add(containers::page& page, const std::string& alias = std::string(), const float& content_margin = 10.f);
337
344 [[nodiscard]]
345 static tab_pane& get(form& fm, const std::string& path);
346 };
347
353 class lecui_api tab : public containers::page, public widgets::badge_widget {
354 public:
360 tab(form& fm, const std::string& tab_name);
361
366 bool operator==(const tab& param);
367
372 bool operator!=(const tab& param);
373
377
382
390 [[nodiscard]] const lecui::size size();
391
398 [[nodiscard]]
399 static tab& add(containers::tab_pane& tp, const std::string& tab_name);
400
409 [[nodiscard]]
410 static tab& get(form& fm, const std::string& path);
411
412 private:
413 // Default constructor and copying an object of this class are not allowed
414 tab() = delete;
415 tab(const tab&) = delete;
416 tab& operator=(const tab&) = delete;
417
418 friend class tab_builder;
419 };
420 }
421 }
422}
423
424#if defined(lecui_helper)
426#define get_tab_pane(path) liblec::lecui::containers::tab_pane::get(*this, path)
427
429#define get_tab(path) liblec::lecui::containers::tab::get(*this, path)
430#endif
431
RGBA color on a standard 0 to 255 scale. For the alpha channel 0 is transparent and 255 is opaque.
Definition: lecui.h:583
Page container.
Definition: page.h:32
Tab pane. To instantiate and add to a container use the add static method.
Definition: tab_pane.h:28
tab_pane & color_tabs(const color &color_tabs)
Set the fill color of the tabs.
color & color_fill() override
Get or set the fill color of the widget.
std::string & selected()
Get or set the selected tab.
color & color_text() override
Get or set the color of the widget's text.
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
tab_pane & corner_radius_y(const float &corner_radius_y)
Set the vertical radius of the corners.
tab_pane & caption_reserve(const std::vector< std::string > &caption_reserve)
Set the caption reserve property.
tab_pane & color_selected(const color &color_selected)
Set the widget's color when selected.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
tab_pane & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
tab_pane & caption_orientation(const orientation &caption_orientation)
Set the orientation of the caption text.
tab_pane & color_tabs_border(const color &color_tabs_border)
Set the color of the tab borders.
float & border()
Get or set the thickness of the border.
tab_pane & tab_side(const side &tab_side)
Set the side on which to place the tab.
float & corner_radius_y()
Get or set the vertical radius of the corners.
bool operator==(const tab_pane &param)
Check whether tab pane specs are equal. Only those properties that require the widget resources to be...
std::string & text() override
Get or set the widget text.
tab_pane & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
float & corner_radius_x()
Get or set the horizontal radius of the corners.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
tab_pane & text(const std::string &text)
Set the widget's text.
orientation
Orientation of tab captions.
Definition: tab_pane.h:39
tab_pane & font_size(const float &font_size)
Set the widget's font size.
tab_pane & border(const float &border)
Set the thickness of the border.
tab_pane & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
tab_pane & corner_radius_x(const float &corner_radius_x)
Set the horizontal radius of the corners.
orientation & caption_orientation()
Get or set the orientation of the caption text.
color & color_tabs()
Get or set the fill color of the tabs.
static tab_pane & add(containers::page &page, const std::string &alias=std::string(), const float &content_margin=10.f)
Make a tab pane.
tab_pane & tabs_border(const float &tabs_border)
Set the thickness of the tab borders.
std::vector< std::string > & caption_reserve()
Get or set the caption reserve property.
tab_pane()
Class constructor.
Definition: tab_pane.h:64
color & color_selected() override
Get or set the widget's color when selected.
tab_pane & tooltip(const std::string &tooltip)
Set the tooltip text.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
color & color_border()
Get or set the color of the border.
tab_pane & color_text(const color &color_text)
Set the color of the widget's text.
color & color_disabled() override
Get or set the widget's color when it is disabled.
side & tab_side()
Get or set the side on which to place the tab.
static tab_pane & get(form &fm, const std::string &path)
Get the specifications of a pane.
tab_pane & font(const std::string &font)
Set the default widget font.
tab_pane & selected(const std::string &selected)
Set the selected tab.
tab_pane & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
color & color_tabs_border()
Get or set the color of the tab borders.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
bool operator!=(const tab_pane &param)
Check whether tab pane specs are NOT equal. Only those properties that require the widget resources t...
side
The side to place the tabs on.
Definition: tab_pane.h:31
float & tabs_border()
Get or set the thickness of the tab borders.
std::string & tooltip() override
Get or set the widget's tooltip text.
tab_pane & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
tab_pane & color_fill(const color &color_fill)
Set the fill color of the widget.
tab_pane & color_border(const color &color_border)
Set the color of the border.
Tab container. To instantiate and add to a tab pane use the add static method.
Definition: tab_pane.h:353
static tab & get(form &fm, const std::string &path)
Get the tab container page of an existing tab.
const lecui::size size()
Get the size of the tab's page.
bool operator==(const tab &param)
Check whether two tabs are equal. Only those properties that require the widget resources to be re-cr...
tab(form &fm, const std::string &tab_name)
Class constructor.
widgets::badge_specs & badge() override
Get or set the badge specs.
tab & badge(const widgets::badge_specs &badge)
Set the badge specs.
bool operator!=(const tab &param)
Check whether two tabs are NOT equal. Only those properties that require the widget resources to be r...
static tab & add(containers::tab_pane &tp, const std::string &tab_name)
Create a pane.
Form base class. The user must inherit from this class and call one of the two constructors from its ...
Definition: form.h:122
Rectangle class.
Definition: lecui.h:158
Resize parameters.
Definition: lecui.h:363
Size of a rectangular structure.
Definition: lecui.h:117
Badge specifications.
Definition: widget.h:177
Base class for all widgets with badges.
Definition: widget.h:292
Base class for all widgets.
Definition: widget.h:24
cursor_type
Mouse cursor type.
Definition: widget.h:27
@ right
Align text to the right.
@ left
Align text to the left edge.
@ bottom
Align paragraph to the bottom.
@ top
Align paragraph to the top.
Top level namespace for the liblec libraries.
Definition: appearance.h:19