|
Ultralight C++ API 2.0.0
|
#include <AppCore/layout/Panel.h>
A layout node that hosts a single web view.
Panels are the leaf nodes of an AppCore layout tree and the elements of its floating layer. Every panel hosts a single View, sizing the view to match its layout bounds and routing user input to the page.
This example adds a panel to a window, loads a page into its view, and gives the panel keyboard focus:
Call view() to access the hosted View.
You can create a panel with a new View or adopt an existing View:
A window directs keyboard events to one panel at a time:
Public Member Functions | |
| virtual RefPtr< View > | view ()=0 |
| Get the hosted View. | |
| virtual void | Focus ()=0 |
| Grant this panel exclusive keyboard focus. | |
| virtual void | BringToFront ()=0 |
| Bring this floating panel to the top of the foreground layer so it paints on top of other floating panels and receives mouse input first. | |
| virtual LayoutCallback | OnDismiss (LayoutPanelCallback callback, void *user_data, LayoutDestroyUserDataCallback destroy_user_data)=0 |
| Register a callback fired when the library dismisses this panel. | |
| template<typename Callback> requires std::invocable<Callback&, Panel&> || std::invocable<Callback&> | |
| LayoutCallback | OnDismiss (Callback callback) |
| Register a dismiss callback (invocable form). | |
| Public Member Functions inherited from LayoutNode | |
| virtual String | key () const =0 |
| Get the node's key (empty if unkeyed). | |
| virtual RefPtr< Container > | parent () const =0 |
| Get the node's parent container (null at the root or when detached). | |
| virtual int | index () const =0 |
| Get the node's index within its parent (-1 when detached). | |
| virtual RefPtr< Panel > | AsPanel ()=0 |
| Get this node as a Panel (null if it is not one). | |
| virtual RefPtr< Container > | AsContainer ()=0 |
| Get this node as a Container (null if it is not one). | |
| virtual void | Hide ()=0 |
| Hide the node and redistribute its space to its siblings. | |
| virtual void | Show ()=0 |
| Show the node again, restoring its remembered size exactly. | |
| virtual bool | is_hidden () const =0 |
| Whether or not the node is hidden. | |
| virtual Rect | bounds () const =0 |
| Get the node's rect from the most recent layout in container-local logical pixels (the same space SetBounds() takes). | |
| 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 own drawing uses). | |
| virtual void | SetBounds (const Rect &bounds)=0 |
| Place this node manually. | |
| virtual void | SetSize (Size size)=0 |
| Set the node's declared size along its container's axis. | |
| virtual void | SetMinSize (Length min_size)=0 |
| Set the node's minimum size constraint. | |
| virtual void | SetMaxSize (Length max_size)=0 |
| Set the node's maximum size constraint. | |
| 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 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). | |
| template<typename Callback> requires std::invocable<Callback&, LayoutNode&> || std::invocable<Callback&> | |
| LayoutCallback | OnUserResize (Callback callback) |
| Register a user-resize callback (invocable form). | |
| template<typename Callback> requires std::invocable<Callback&, LayoutNode&> || std::invocable<Callback&> | |
| LayoutCallback | OnLayoutChange (Callback callback) |
| Register a layout-change callback (invocable form). | |
| RefPtr< LayoutNode > | next_sibling () const |
| Get the sibling after this node (null at the end, at the root, or when detached). | |
| RefPtr< LayoutNode > | previous_sibling () const |
| Get the sibling before this node (null at the start, at the root, or when detached). | |
| Public Member Functions inherited from RefCounted | |
| virtual void | AddRef () const =0 |
| Increment the reference count (thread-safe). | |
| virtual void | Release () const =0 |
| Decrement the reference count (thread-safe). | |
| virtual int | ref_count () const =0 |
| Get the current reference count. | |
| virtual WeakControlBlock * | weak_control_block () const |
| Get the control block used to track weak references to this object. | |
Protected Member Functions | |
| virtual | ~Panel () |
| Protected Member Functions inherited from LayoutNode | |
| virtual | ~LayoutNode () |
| Protected Member Functions inherited from RefCounted | |
| virtual | ~RefCounted () |
|
protectedvirtual |
|
pure virtual |
Bring this floating panel to the top of the foreground layer so it paints on top of other floating panels and receives mouse input first.
|
pure virtual |
Grant this panel exclusive keyboard focus.
You should always focus a panel through this method (or a user click) rather than calling View::Focus() directly, otherwise the panel's window won't know where to route keyboard input.
|
inlinenodiscard |
Register a dismiss callback (invocable form).
| callback | Any invocable. It may take the panel as Panel&, or nothing at all. |
|
nodiscardpure virtual |
Register a callback fired when the library dismisses this panel.
The library dismisses a panel when an auto-dismiss trigger fires on a floating panel (see ForegroundPanelOptions). An application-initiated Hide() does not fire it.
| callback | The function to call. It receives user_data and this panel. |
| user_data | Passed back to the callback on every fire (can be nullptr). |
| destroy_user_data | Called once when the registration drops user_data (can be nullptr). |
Get the hosted View.