13
13
14
14
namespace cycfi ::elements
15
15
{
16
- // //////////////////////////////////////////////////////////////////////////
17
- // Child window: Are floating elements that may overlap and move to front
18
- // when clicked.
19
- // //////////////////////////////////////////////////////////////////////////
16
+ /* *
17
+ * \class child_window_element
18
+ *
19
+ * \brief
20
+ * Class that represents a child window within a larger display context.
21
+ *
22
+ * Child windows are floating elements that may overlap with other
23
+ * elements and can move to the front when clicked.
24
+ */
20
25
class child_window_element : public floating_element
21
26
{
22
27
public:
@@ -26,26 +31,48 @@ namespace cycfi::elements
26
31
bool click (context const & ctx, mouse_button btn) override ;
27
32
};
28
33
34
+ /* *
35
+ * \brief
36
+ * Factory function to create a child window element.
37
+ *
38
+ * This function creates a child window by wrapping the given subject
39
+ * (element) in a child_window_element. The resulting window has a
40
+ * specified rectangular area.
41
+ *
42
+ * \tparam Subject
43
+ * Subject must meet the `concepts::Element` concept.
44
+ *
45
+ * \param bounds
46
+ * The boundaries of the child window.
47
+ *
48
+ * \param subject
49
+ * An rvalue reference to the subject, the element to be wrapped in a
50
+ * child window.
51
+ *
52
+ * \return
53
+ * A proxy object of type `child_window_element` containing the
54
+ * subject element, within defined boundaries.
55
+ */
29
56
template <concepts::Element Subject>
30
57
inline proxy<remove_cvref_t <Subject>, child_window_element>
31
58
child_window (rect bounds, Subject&& subject)
32
59
{
33
60
return {std::forward<Subject>(subject), bounds};
34
61
}
35
62
36
- // //////////////////////////////////////////////////////////////////////////
37
- // Movable: Allows an element (e.g. title_bar) to be movable if it is
38
- // contained inside a floating_element. The whole floating_element moves
39
- // when the element is dragged around.
40
- // //////////////////////////////////////////////////////////////////////////
41
-
42
63
struct movable_tracker_info : tracker_info
43
64
{
44
65
using tracker_info::tracker_info;
45
66
46
67
float _offs_top, _offs_bottom;
47
68
};
48
69
70
+ /* *
71
+ * \class movable_base
72
+ *
73
+ * \brief
74
+ * A base class representing a movable element in the UI.
75
+ */
49
76
class movable_base : public tracker <proxy_base, movable_tracker_info>
50
77
{
51
78
public:
@@ -58,18 +85,45 @@ namespace cycfi::elements
58
85
void keep_tracking (context const & ctx, tracker_info& track_info) override ;
59
86
};
60
87
88
+ /* *
89
+ * \brief
90
+ * Make an element movable.
91
+ *
92
+ * movable allows an element (e.g. title_bar) to be movable if it is
93
+ * contained inside a floating_element. The whole floating_element
94
+ * moves when the element is dragged around.
95
+ *
96
+ * \tparam Subject
97
+ * The type of the subject. The Subject must meet the
98
+ * `concepts::Element` concept.
99
+ *
100
+ * \param subject
101
+ * The subject element that will be made movable.
102
+ *
103
+ * \return
104
+ * The movable element.
105
+ */
61
106
template <concepts::Element Subject>
62
107
inline proxy<remove_cvref_t <Subject>, movable_base>
63
108
movable (Subject&& subject)
64
109
{
65
110
return {std::forward<Subject>(subject)};
66
111
}
67
112
68
- // //////////////////////////////////////////////////////////////////////////
69
- // Closable: When contained inside a floating_element, allows a button (or
70
- // any clickable element) to close the floating_element when it is
71
- // clicked.
72
- // //////////////////////////////////////////////////////////////////////////
113
+ /* *
114
+ * \class closable_element
115
+ *
116
+ * \brief
117
+ * Class that encapsulates a closable UI element functionality.
118
+ *
119
+ * When contained inside a floating_element, this class allows a button
120
+ * (or any clickable element) to close (or hide) the floating_element
121
+ * when it is clicked.
122
+ *
123
+ * \tparam Subject
124
+ * The type of the subject. Must satisfy the `concepts::Element`
125
+ * concept.
126
+ */
73
127
template <concepts::Element Subject>
74
128
class closable_element : public proxy <Subject>
75
129
{
@@ -80,6 +134,24 @@ namespace cycfi::elements
80
134
void prepare_subject (context& ctx) override ;
81
135
};
82
136
137
+ /* *
138
+ * \brief
139
+ * Create a closable element.
140
+ *
141
+ * If the subject is a part of a floating_element, this function
142
+ * enables the subject to close its parent floating_element upon a
143
+ * click event.
144
+ *
145
+ * \tparam Subject
146
+ * The type of the subject. Must satisfy the `concepts::Element`
147
+ * concept.
148
+ *
149
+ * \param subject
150
+ * The element that is to be made closable.
151
+ *
152
+ * \return
153
+ * The closable element.
154
+ */
83
155
template <concepts::Element Subject>
84
156
inline closable_element<remove_cvref_t <Subject>>
85
157
closable (Subject&& subject)
@@ -100,7 +172,7 @@ namespace cycfi::elements
100
172
{
101
173
auto fl = find_parent<floating_element*>(ctx);
102
174
if (fl)
103
- close_floating_element (ctx, fl);
175
+ close_floating_element (ctx, fl);
104
176
};
105
177
}
106
178
}
0 commit comments