Skip to content

Commit 97d3823

Browse files
committed
document modal
1 parent 9c8ac08 commit 97d3823

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

lib/include/elements/element/modal.hpp

+60-7
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@
1212

1313
namespace cycfi::elements
1414
{
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+
*/
1832
template <concepts::Element Subject>
1933
class modal_element : public proxy<Subject>
2034
{
@@ -32,13 +46,38 @@ namespace cycfi::elements
3246
bool wants_control() const override { return true; }
3347
};
3448

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+
*/
3567
template <concepts::Element Subject>
3668
inline modal_element<remove_cvref_t<Subject>>
3769
modal(Subject&& subject)
3870
{
3971
return {std::forward<Subject>(subject)};
4072
}
4173

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+
*/
4281
template <concepts::Element Subject>
4382
inline modal_element<Subject>::modal_element(Subject subject)
4483
: base_type(std::move(subject))
@@ -74,10 +113,24 @@ namespace cycfi::elements
74113
return true;
75114
}
76115

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+
*/
81134
inline auto ui_block(color color_ = {0.0, 0.0, 0.0, 0.5})
82135
{
83136
return modal(box_element{color_});

0 commit comments

Comments
 (0)