266 template <
typename Callback>
267 requires std::invocable<Callback&, LayoutNode&> || std::invocable<Callback&>
269 return RegisterInvocable<Callback>(std::move(callback),
true);
280 template <
typename Callback>
281 requires std::invocable<Callback&, LayoutNode&> || std::invocable<Callback&>
283 return RegisterInvocable<Callback>(std::move(callback),
false);
300 template <
typename Callback>
301 LayoutCallback RegisterInvocable(Callback callback,
bool user_resize) {
302 auto* holder =
new Callback(std::move(callback));
304 auto& cb = *
static_cast<Callback*
>(user_data);
305 if constexpr (std::invocable<Callback&, LayoutNode&>)
311 = [](
void* user_data) {
delete static_cast<Callback*
>(user_data); };
312 return user_resize ? OnUserResize(trampoline, holder, destroy)
313 : OnLayoutChange(trampoline, holder, destroy);
#define AExport
Definition Defines.h:41
A layout node that organizes child nodes into a row or column.
Definition Container.h:101
Scoped handle that controls how long a layout callback stays registered.
Definition Callback.h:144
Base class for Panels and Containers in a window layout tree.
Definition LayoutNode.h:108
virtual RefPtr< Panel > AsPanel()=0
Get this node as a Panel (null if it is not one).
virtual void SetSize(Size size)=0
Set the node's declared size along its container's axis.
virtual RefPtr< Container > parent() const =0
Get the node's parent container (null at the root or when detached).
virtual void SetMaxSize(Length max_size)=0
Set the node's maximum size constraint.
virtual int index() const =0
Get the node's index within its parent (-1 when detached).
virtual RefPtr< Container > AsContainer()=0
Get this node as a Container (null if it is not one).
LayoutCallback OnUserResize(Callback callback)
Register a user-resize callback (invocable form).
Definition LayoutNode.h:268
virtual LayoutCallback OnLayoutChange(LayoutNodeCallback callback, void *user_data, LayoutDestroyUserDataCallback destroy_user_data)=0
Register a callback that fires after layout changes this node's bounds (at most once per frame).
virtual void SetBounds(const Rect &bounds)=0
Place this node manually.
virtual void Show()=0
Show the node again, restoring its remembered size exactly.
virtual void Hide()=0
Hide the node and redistribute its space to its siblings.
LayoutCallback OnLayoutChange(Callback callback)
Register a layout-change callback (invocable form).
Definition LayoutNode.h:282
virtual Rect bounds() const =0
Get the node's rect from the most recent layout in container-local logical pixels (the same space Set...
virtual void SetMinSize(Length min_size)=0
Set the node's minimum size constraint.
virtual String key() const =0
Get the node's key (empty if unkeyed).
virtual LayoutCallback OnUserResize(LayoutNodeCallback callback, void *user_data, LayoutDestroyUserDataCallback destroy_user_data)=0
Register a callback fired when the user resizes this node with a divider.
virtual IntRect device_bounds() const =0
Get the node's rect from the most recent layout in window back-buffer device pixels (the space your o...
virtual bool is_hidden() const =0
Whether or not the node is hidden.
A distance or size constraint in an AppCore layout.
Definition Length.h:60
A layout node that hosts a single web view.
Definition Panel.h:59
Interface for all ref-counted objects that will be managed using the RefPtr<> smart pointer.
Definition RefPtr.h:49
A nullable smart pointer.
Definition RefPtr.h:126
Fixed, percentage, and flexible sizes for panels and containers.
Definition Length.h:371
Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.
Definition String.h:31
Root namespace for every public Ultralight type, function, and enumeration.
void(*) LayoutNodeCallback(void *user_data, LayoutNode *node)
Callback fired for a layout node event.
Definition Callback.h:38
void(*) LayoutDestroyUserDataCallback(void *user_data)
Destroy hook for a callback registration's user data.
Definition Callback.h:27
Integer Rectangle Helper.
Definition Geometry.h:533
Float Rectangle Helper.
Definition Geometry.h:416