lecui 1.0.0-alpha.20
lecui C++ user interface library
line.h
1//
2// line.h - line widget 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 "widget.h"
15#else
16#include <liblec/lecui/widgets/widget.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
21 namespace widgets {
23 class lecui_api line : public widget {
24 float _thickness = 1.f;
25 std::vector<point> _points;
26
27 public:
32 bool operator==(const line& param);
33
38 bool operator!=(const line& param);
39
40 // generic widget
41
44 std::string& text() override;
45
49 line& text(const std::string& text);
50
53 std::string& tooltip() override;
54
58 line& tooltip(const std::string& tooltip);
59
63 lecui::rect& rect() override;
64
69
73
77 line& on_resize(const resize_params& on_resize);
78
81 cursor_type& cursor() override;
82
86 line& cursor(const cursor_type cursor);
87
90 std::string& font() override;
91
95 line& font(const std::string& font);
96
99 float& font_size() override;
100
104 line& font_size(const float& font_size);
105
108 color& color_text() override;
109
113 line& color_text(const color& color_text);
114
117 color& color_fill() override;
118
122 line& color_fill(const color& color_fill);
123
126 color& color_hot() override;
127
131 line& color_hot(const color& color_hot);
132
136
140 line& color_selected(const color& color_selected);
141
145
149 line& color_disabled(const color& color_disabled);
150
151 // widget specific widget
152
155 float& thickness();
156
160 line& thickness(const float& thickness);
161
166 std::vector<point>& points();
167
172 line& points(const std::vector<point>& points);
173
174 public:
181 [[nodiscard]]
182 static line& add(containers::page& page, const std::string& alias = std::string());
183
190 [[nodiscard]]
191 static line& get(form& fm, const std::string& path);
192 };
193 }
194 }
195}
196
197#if defined(lecui_helper)
199#define get_line(path) liblec::lecui::widgets::line::get(*this, path)
200#endif
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
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
Line widget. To instantiate and add to a container use the add static method.
Definition: line.h:23
line & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
std::string & text() override
Get or set the widget text.
line & tooltip(const std::string &tooltip)
Set the tooltip text.
static line & add(containers::page &page, const std::string &alias=std::string())
Add a line widget to a container.
color & color_text() override
Get or set the color of the widget's text.
float & thickness()
Get or set the line's thickness.
line & thickness(const float &thickness)
Set the line's thickness.
line & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
line & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
line & text(const std::string &text)
Set the widget's text.
line & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
line & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
color & color_disabled() override
Get or set the widget's color when it is disabled.
line & color_fill(const color &color_fill)
Set the fill color of the widget.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
line & font_size(const float &font_size)
Set the widget's font size.
std::vector< point > & points()
Get or set the points, in order, for the line to go through. These are relative to the top left corne...
line & font(const std::string &font)
Set the default widget font.
bool operator==(const line &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
static line & get(form &fm, const std::string &path)
Get the specifications of a line.
line & points(const std::vector< point > &points)
Set the points, in order, for the line line to go through. These are relative to the top left corner ...
bool operator!=(const line &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
color & color_selected() override
Get or set the widget's color when selected.
line & color_text(const color &color_text)
Set the color of the widget's text.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
line & color_selected(const color &color_selected)
Set the widget's color when selected.
std::string & tooltip() override
Get or set the widget's tooltip text.
color & color_fill() override
Get or set the fill color of the widget.
Base class for all widgets.
Definition: widget.h:24
cursor_type
Mouse cursor type.
Definition: widget.h:27
Top level namespace for the liblec libraries.
Definition: appearance.h:19