12
12
13
13
namespace cycfi ::elements
14
14
{
15
- // //////////////////////////////////////////////////////////////////////////
16
- // Modal element hugs the UI and prevents any event from passing through
17
- // //////////////////////////////////////////////////////////////////////////
15
+ /* *
16
+ * \class modal_element
17
+ *
18
+ * \brief
19
+ * A template class for creating modal UI elements that block
20
+ * interaction with underlying UI elements.
21
+ *
22
+ * Wrap around any UI element, making it modal. This means the wrapped
23
+ * element becomes the sole focus of interaction, preventing any events
24
+ * from reaching other elements beneath it. It's particularly useful
25
+ * for implementing dialog boxes, overlays, and other interactive
26
+ * components that require user attention before allowing interaction
27
+ * with other parts of the UI.
28
+ *
29
+ * \tparam Subject
30
+ * The type of the UI element to be wrapped.
31
+ */
18
32
template <concepts::Element Subject>
19
33
class modal_element : public proxy <Subject>
20
34
{
@@ -32,13 +46,38 @@ namespace cycfi::elements
32
46
bool wants_control () const override { return true ; }
33
47
};
34
48
49
+ /* *
50
+ * \brief
51
+ * Create a modal_element with the specified subject.
52
+ *
53
+ * This function wraps a given UI element in a modal_element, making it
54
+ * the focal point for user interaction within its context. It
55
+ * effectively blocks interaction with other UI elements beneath it.
56
+ *
57
+ * \tparam Subject
58
+ * The type of the UI element to be wrapped. Must conform to the
59
+ * `concepts::Element` concept.
60
+ *
61
+ * \param subject
62
+ * The UI element to be wrapped by the modal_element.
63
+ *
64
+ * \return
65
+ * A modal_element wrapping the specified subject.
66
+ */
35
67
template <concepts::Element Subject>
36
68
inline modal_element<remove_cvref_t <Subject>>
37
69
modal (Subject&& subject)
38
70
{
39
71
return {std::forward<Subject>(subject)};
40
72
}
41
73
74
+ /* *
75
+ * \brief
76
+ * Constructor that initializes the modal_element with a given subject.
77
+ *
78
+ * \param subject
79
+ * The UI element to be wrapped by this modal_element.
80
+ */
42
81
template <concepts::Element Subject>
43
82
inline modal_element<Subject>::modal_element(Subject subject)
44
83
: base_type(std::move(subject))
@@ -74,10 +113,24 @@ namespace cycfi::elements
74
113
return true ;
75
114
}
76
115
77
- // //////////////////////////////////////////////////////////////////////////
78
- // An element that prevents any event from passing through. Add this as a
79
- // topmost layer in a view to lock the UI.
80
- // //////////////////////////////////////////////////////////////////////////
116
+ /* *
117
+ * \brief
118
+ * Creates a modal_element that acts as a UI blocker that prevents any
119
+ * event from passing through. Add this as a topmost layer in a view to
120
+ * lock the UI.
121
+ *
122
+ * This function creates a modal_element with a semi-transparent
123
+ * overlay, effectively locking the UI and preventing any interaction
124
+ * with underlying UI elements. It's useful for creating overlays that
125
+ * require user interaction before proceeding.
126
+ *
127
+ * \param color_
128
+ * The color of the overlay, including opacity. Defaults to a
129
+ * semi-transparent black.
130
+ *
131
+ * \return
132
+ * A modal_element that acts as a UI blocker.
133
+ */
81
134
inline auto ui_block (color color_ = {0.0 , 0.0 , 0.0 , 0.5 })
82
135
{
83
136
return modal (box_element{color_});
0 commit comments