lecui 1.0.0-alpha.20
lecui C++ user interface library
custom.h
1//
2// custom.h - custom 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 custom : public widget, public badge_widget {
24 public:
33 std::function<void(
34 void* _ID2D1HwndRenderTarget,
35 void* _IDWriteFactory,
36 void* _IWICImagingFactory)>
37 on_create_resources = nullptr;
38
43 std::function<void()> on_discard_resources = nullptr;
44
52 std::function<void(
53 void* _D2D1_RECT_F,
54 bool _enabled,
55 bool _hit,
56 bool _pressed,
57 bool _selected)>
58 on_render = nullptr;
59
64 bool operator==(const custom& param);
65
70 bool operator!=(const custom& param);
71
72 // generic widget
73
76 std::string& text() override;
77
81 custom& text(const std::string& text);
82
85 std::string& tooltip() override;
86
90 custom& tooltip(const std::string& tooltip);
91
94 badge_specs& badge() override;
95
99 custom& badge(const badge_specs& badge);
100
104 lecui::rect& rect() override;
105
110
114
118 custom& on_resize(const resize_params& on_resize);
119
122 cursor_type& cursor() override;
123
127 custom& cursor(const cursor_type cursor);
128
131 std::string& font() override;
132
136 custom& font(const std::string& font);
137
140 float& font_size() override;
141
145 custom& font_size(const float& font_size);
146
149 color& color_text() override;
150
154 custom& color_text(const color& color_text);
155
158 color& color_fill() override;
159
163 custom& color_fill(const color& color_fill);
164
167 color& color_hot() override;
168
172 custom& color_hot(const color& color_hot);
173
177
181 custom& color_selected(const color& color_selected);
182
186
190 custom& color_disabled(const color& color_disabled);
191
192 public:
199 [[nodiscard]]
200 static custom& add(containers::page& page, const std::string& alias = std::string());
201
208 [[nodiscard]]
209 static custom& get(form& fm, const std::string& path);
210 };
211 }
212 }
213}
214
215#if defined(lecui_helper)
217#define get_custom(path) liblec::lecui::widgets::custom::get(*this, path)
218#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
Badge specifications.
Definition: widget.h:177
Base class for all widgets with badges.
Definition: widget.h:292
Custom widget. To instantiate and add to a container use the add static method.
Definition: custom.h:23
color & color_disabled() override
Get or set the widget's color when it is disabled.
custom & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
custom & font_size(const float &font_size)
Set the widget's font size.
custom & tooltip(const std::string &tooltip)
Set the tooltip text.
custom & text(const std::string &text)
Set the widget's text.
std::string & text() override
Get or set the widget text.
custom & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
custom & color_text(const color &color_text)
Set the color of the widget's text.
color & color_fill() override
Get or set the fill color of the widget.
static custom & add(containers::page &page, const std::string &alias=std::string())
Add a custom widget to a container.
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
custom & color_selected(const color &color_selected)
Set the widget's color when selected.
color & color_selected() override
Get or set the widget's color when selected.
custom & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
bool operator==(const custom &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
custom & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
custom & font(const std::string &font)
Set the default widget font.
custom & color_fill(const color &color_fill)
Set the fill color of the widget.
custom & badge(const badge_specs &badge)
Set the badge specs.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
std::string & tooltip() override
Get or set the widget's tooltip text.
badge_specs & badge() override
Get or set the badge specs.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
custom & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
bool operator!=(const custom &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
color & color_text() override
Get or set the color of the widget's text.
static custom & get(form &fm, const std::string &path)
Get the specifications of a custom 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