Library or Application Defined Widgets
Some applications and libraries find it useful to define their own widgets.
This is done using REGISTER_WIDGET()
, just as in LibGUI. The syntax of the macro is as follows:
(namespace, class_name) REGISTER_WIDGET
This means that every registered widget has to be placed in a namespace. For applications that usually do not need their own namespace, a common approach is to use the application name as the namespace for these registered widgets.
Note that registered widgets need to be constructible without any arguments.
@Web::OutOfProcessWebView {
name: "web_view"
min_width: 340
min_height: 160
visible: false
}
// OutOfProcessWebView.cpp
(Web, OutOfProcessWebView)
REGISTER_WIDGET
...
::OutOfProcessWebView()
OutOfProcessWebView{
(true);
set_should_hide_unnecessary_scrollbars(GUI::FocusPolicy::StrongFocus);
set_focus_policy
();
create_client}
...