docs
Loading...
Searching...
No Matches
CAPI_Layout.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5/// @file CAPI_Layout.h
6///
7/// Panels and containers for arranging Views across an AppCore window in C.
8///
9/// `#include <AppCore/CAPI/CAPI_Layout.h>`
10///
11/// The layout C API arranges Views across an AppCore window using a tree of panels and containers.
12/// Each panel hosts a single View, while row and column containers organize them into a tiled
13/// hierarchy.
14///
15/// You declare sizes once when creating nodes, so you don't need to recalculate bounds manually
16/// when the window resizes or its display scale changes.
17///
18/// This example splits a window into a resizable sidebar and a content pane:
19///
20/// ```c
21/// static ULWindow main_window = NULL; // From ulCreateWindow().
22/// static ULPanel sidebar = NULL;
23/// static ULPanel content = NULL;
24///
25/// void BuildLayout(void) {
26/// ULContainerDesc body_desc = {0};
27/// body_desc.struct_size = sizeof(ULContainerDesc);
28/// body_desc.key = "body";
29/// body_desc.flags = kULLayoutFlags_Resizable;
30///
31/// ULPanelDesc sidebar_desc = {0};
32/// sidebar_desc.struct_size = sizeof(ULPanelDesc);
33/// sidebar_desc.key = "sidebar";
34/// sidebar_desc.size = ulLayoutSizePx(240);
35/// sidebar_desc.min_size = ulLayoutSizePx(160);
36///
37/// ULContainer root = ulWindowGetLayout(main_window);
38/// ULContainer body = ulContainerAddRow(root, &body_desc, NULL);
39/// sidebar = ulContainerAddPanel(body, &sidebar_desc, NULL, NULL);
40/// content = ulContainerAddPanel(body, NULL, NULL, NULL);
41///
42/// // The tree keeps both containers.
43/// ulDestroyContainer(body);
44/// ulDestroyContainer(root);
45/// }
46/// ```
47///
48/// ## Building the Layout Tree
49///
50/// The C++ layout headers (starting with `<AppCore/Layout.h>`) explain the underlying concepts for
51/// organizing panels into nested rows and columns under a window's root container. The C API
52/// doesn't provide a fluent builder, so you build the tree one call at a time.
53///
54/// Call ulWindowGetLayout() to obtain the window's root container, which is a column that spans the
55/// window's content area. To configure the root container's options (such as padding, gap, or
56/// resizable dividers), call ulWindowConfigureLayout().
57///
58/// ## Descriptors and Sizes
59///
60/// Zero-initialize every descriptor struct. Passing `NULL` applies default options for every field.
61///
62/// Construct ULLayoutSize values using ulLayoutSizePx() for logical pixels, ulLayoutSizePct() for
63/// percentages, or ulLayoutSizeFr() for flex factors. A zero-initialized ULLayoutSize leaves the
64/// dimension unset so the field's default applies, which differs from an explicit `0px`.
65///
66/// @warning Leaving `struct_size` set to 0 causes the library to ignore the descriptor, log a
67/// warning, and fall back to default values.
68///
69/// ## Handle Ownership
70///
71/// Layout handles manage references independently of the tree:
72///
73/// - **Layout getters and factory functions return owned handles.** Release them with matching
74/// destroy functions such as ulDestroyContainer(), ulDestroyPanel(), or ulDestroyLayoutNode().
75/// - **Destroying a handle doesn't remove the node from the tree.** To detach a node and its
76/// children from the layout, call ulContainerRemove() (or ulForegroundRemove() for a floating
77/// panel).
78/// - **ulPanelGetView() returns an owned View handle.** Destroying it releases only your reference,
79/// while the panel keeps the hosted View alive until removed.
80///
81/// @note A View that outlives its panel loses its `ulViewSet*Callback()` callbacks-- register them
82/// again after adopting the View into another panel.
83///
84/// ## Handle Identity and Lifetime
85///
86/// Layout handles track identity rather than lifetime:
87///
88/// - **Compare node identity with ulLayoutNodeIsSame(), never `==`.** Separate lookups of the same
89/// node return distinct pointer addresses. To compare two panel or container handles, convert
90/// both to ULLayoutNode handles using ulPanelAsLayoutNode() or ulContainerAsLayoutNode(), and
91/// destroy those temporary handles when you're done.
92/// - **Handles whose node is gone or whose window has closed remain safe to call.** Passing `NULL`
93/// behaves the same way. An `IsAlive` function like ulLayoutNodeIsAlive() returns `false` for
94/// both `NULL` handles and handles whose node is gone, so check for `NULL` first to tell the two
95/// apart.
96/// - **Call layout operations on the main thread.** Reference, destroy, and `IsAlive` functions
97/// (such as ulCreateLayoutNodeRef(), ulDestroyLayoutNode(), and ulLayoutNodeIsAlive()) are safe
98/// from any thread.
99///
100/// ## Event Callbacks
101///
102/// Layout and window events use individual callback setters:
103///
104/// - **Each event accepts only one callback per node, panel, or window.** Setting a new callback
105/// replaces the existing registration, and passing `NULL` removes it.
106/// - **Releasing a handle leaves its callbacks active.** A callback continues firing until you
107/// replace or clear it, remove the node, or close the window.
108/// - **Pass application state through `user_data`.** The optional `destroy_user_data` hook (see
109/// ULUserDataDestroyCallback) cleans up that state when the library drops the registration.
110/// - **Callback parameters are borrowed handles.** They stay valid only during the call, and you
111/// must never destroy them. To keep a handle beyond the callback, duplicate it using
112/// ulCreateLayoutNodeRef() or ulCreatePanelRef().
113/// - **Compare window handles in callbacks using ulWindowIsSame(), never `==`.** Focus-change and
114/// editable-state callbacks pass a borrowed ULWindow handle that doesn't equal your original
115/// window pointer.
116///
117/// This example tracks a container's bounds to resize an external drawing viewport:
118///
119/// ```c
120/// static void OnViewportLayout(void* user_data, ULLayoutNode node) {
121/// (void)user_data;
122/// ResizeViewport(ulLayoutNodeGetDeviceBounds(node)); // node is borrowed
123/// }
124///
125/// // Reserve a region of the row for your own drawing.
126/// void AddViewport(ULContainer body) {
127/// ULContainer viewport = ulContainerAddColumn(body, NULL, NULL);
128/// ULLayoutNode node = ulContainerAsLayoutNode(viewport);
129/// ulLayoutNodeSetLayoutChangeCallback(node, OnViewportLayout, NULL, NULL);
130/// ulDestroyLayoutNode(node);
131/// ulDestroyContainer(viewport);
132/// }
133/// ```
134///
135/// @see ulWindowGetLayout(), ulWindowGetForeground(), ulContainerAddPanel(), ulContainerRemove(),
136/// ulLayoutNodeIsSame(), ulWindowIsSame(), ulWindowConfigureLayout(),
137/// ULUserDataDestroyCallback
138///
139#ifndef APPCORE_CAPI_LAYOUT_H
140#define APPCORE_CAPI_LAYOUT_H
141
144
145#ifdef __cplusplus
146extern "C" {
147#endif
148
149/// Opaque handle to a layout node, the shared base of panels and containers.
150/// @see ulPanelAsLayoutNode(), ulContainerAsLayoutNode(), ulLayoutNodeIsSame(),
151/// ulDestroyLayoutNode()
152typedef struct C_LayoutNode* ULLayoutNode;
153
154/// Opaque handle to a panel (a layout node hosting a View). @see ulContainerAddPanel(),
155/// ulDestroyPanel()
156typedef struct C_Panel* ULPanel;
157
158/// Opaque handle to a container (a row or column of child nodes). @see ulWindowGetLayout(),
159/// ulContainerAddRow(), ulDestroyContainer()
160typedef struct C_Container* ULContainer;
161
162/// Opaque handle to a window's foreground layer (floating panels composited above the
163/// tiled layout). @see ulWindowGetForeground(), ulDestroyForeground()
164typedef struct C_Foreground* ULForeground;
165
166///
167/// The unit of a ULLayoutSize.
168///
169typedef enum {
170 kULLayoutSizeUnit_Default = 0, ///< Unset: the receiving field's default applies.
171 kULLayoutSizeUnit_Px = 1, ///< Logical pixels.
172 kULLayoutSizeUnit_Pct = 2, ///< For a size, percent of the container's free space.
173 ///< For a constraint, percent of the container's content box.
174 kULLayoutSizeUnit_Fr = 3, ///< A flex factor (sizes only). A constraint field
175 ///< treats it as unset with a warning.
177
178///
179/// A size or constraint length, as a value plus a unit.
180///
181/// Passed and returned by value. This API is purely numeric-- CSS strings never cross the C
182/// boundary, so each language binding owns its own literal form.
183///
184/// A zero-initialized ULLayoutSize is unset (the receiving field's default applies), which
185/// is distinct from an explicit `0px`.
186///
187typedef struct {
188 double value; ///< The numeric value (px, percent points, or flex factor).
189 unsigned char unit; ///< A ULLayoutSizeUnit value.
191
192///
193/// Create a ULLayoutSize in logical pixels.
194///
195static inline ULLayoutSize ulLayoutSizePx(double value) {
196 ULLayoutSize size;
197 size.value = value;
199 return size;
200}
201
202///
203/// Create a percent ULLayoutSize.
204///
205/// For a size, the value is a percent of the container's free space. For a constraint, it is
206/// a percent of the container's content box.
207///
208static inline ULLayoutSize ulLayoutSizePct(double value) {
209 ULLayoutSize size;
210 size.value = value;
212 return size;
213}
214
215///
216/// Create a flex-factor ULLayoutSize (sizes only).
217///
218static inline ULLayoutSize ulLayoutSizeFr(double value) {
219 ULLayoutSize size;
220 size.value = value;
222 return size;
223}
224
225///
226/// A rectangle in device pixels (window-backbuffer space).
227///
228typedef struct {
229 int x;
230 int y;
231 int width;
234
235///
236/// The kind of a layout node.
237///
238/// @see ulLayoutNodeGetKind()
239///
245
246///
247/// Flags for the desc structs' `flags` field.
248///
249typedef enum {
250 kULLayoutFlags_Fixed = 1 << 0, ///< The user cannot resize this node with a divider
251 ///< drag (panels and containers).
252 kULLayoutFlags_Hidden = 1 << 1, ///< Created hidden, shows later without a layout
253 ///< flash (all descs).
254 kULLayoutFlags_Resizable = 1 << 2, ///< The user can resize this container's children by
255 ///< dragging the dividers between them (containers
256 ///< only).
258
259///
260/// Options for creating a panel.
261///
262/// @see ulContainerAddPanel()
263///
264typedef struct {
265 uint32_t struct_size; ///< Must be sizeof(ULPanelDesc).
266
267 ///
268 /// Optional identity for lookup (ulContainerFind()) and diagnostics, as null-terminated
269 /// UTF-8 (copied). NULL means unkeyed, and unkeyed panels are fully supported. Duplicate
270 /// keys log a warning, and lookup returns the most recently created match.
271 ///
272 const char* key;
273
274 ///
275 /// The panel's size along its container's axis. Unset means one flex share (1fr). A percent
276 /// value is relative to the container's free space (after gaps and pixel sizes).
277 ///
279
280 ///
281 /// Minimum size constraint. A percent value is relative to the container's content box. Unset
282 /// means no minimum.
283 ///
285
286 ///
287 /// Maximum size constraint. A percent value is relative to the container's content box. Unset
288 /// means no maximum.
289 ///
291
292 uint32_t flags; ///< A ULLayoutFlags combination: Fixed, Hidden.
294
295///
296/// Options for creating a container (a row or column of child nodes).
297///
298/// @see ulContainerAddRow(), ulContainerAddColumn()
299///
300typedef struct {
301 uint32_t struct_size; ///< Must be sizeof(ULContainerDesc).
302
303 /// Optional identity for lookup and diagnostics (see ULPanelDesc.key).
304 const char* key;
305
306 /// The container's size along its parent's axis. Unset means one flex share (1fr).
308
309 /// Minimum size constraint (see ULPanelDesc.min_size).
311
312 /// Maximum size constraint (see ULPanelDesc.max_size).
314
315 uint32_t flags; ///< A ULLayoutFlags combination: Fixed, Resizable, Hidden.
316
317 ///
318 /// The gap between adjacent children (logical px only, other units are ignored with a
319 /// warning). Unset means no gap.
320 ///
322
323 ///
324 /// Padding between the container's edges and its children, applied on all four sides
325 /// (logical px only). Unset means no padding.
326 ///
329
330///
331/// Styling for the dividers between a resizable container's children.
332///
333/// Fields left unset fall back to the window's style, then to the built-in defaults.
334///
335/// @see ulWindowSetDividerStyle(), ulContainerSetDividerStyle()
336///
337typedef struct {
338 uint32_t struct_size; ///< Must be sizeof(ULDividerStyleDesc).
339
340 ///
341 /// The width of the divider's pointer target, in logical px. Zero means the default (6).
342 ///
343 double hit_width;
344
345 ///
346 /// The thickness of the painted divider line, in logical px. Zero means the default (1).
347 ///
349
350 ///
351 /// The color of the divider line. Unset means no line is painted (the window background
352 /// shows through).
353 ///
355
356 ///
357 /// The hover highlight color, shown over the divider while the pointer rests on it or
358 /// drags it. Unset means the default (a half-opacity gray).
359 ///
362
363///
364/// Keyboard-focus policy for a foreground (floating) panel.
365///
366typedef enum {
367 kULFocusPolicy_Auto = 0, ///< Takes focus when clicked, like any panel. Showing the panel
368 ///< never takes focus.
369 kULFocusPolicy_Grab = 1, ///< Takes keyboard focus when created (unless hidden) and each time
370 ///< it is shown, even from inside a click handler (dropdowns,
371 ///< palettes, in-window dialogs).
372 kULFocusPolicy_None = 2, ///< Never takes keyboard focus. Calling ulPanelFocus() on it is
373 ///< ignored with a warning (toasts, HUDs).
375
376///
377/// The placement form of a ULAnchorDesc.
378///
379typedef enum {
380 kULAnchorKind_Default = 0, ///< The window origin (with the default 100% sizes, a
381 ///< full-window panel).
382 kULAnchorKind_At = 1, ///< Absolute window-space logical px.
383 kULAnchorKind_WindowCorner = 2, ///< A window corner, following the window.
384 kULAnchorKind_WindowCenter = 3, ///< Centered in the window, following the window.
385 kULAnchorKind_Below = 4, ///< Under an anchor rect in a target panel.
387
388///
389/// A window corner (kULAnchorKind_WindowCorner).
390///
397
398///
399/// Cross-axis alignment of the floating panel against its anchor rect (kULAnchorKind_Below).
400///
401typedef enum {
402 kULAnchorAlign_Start = 0, ///< Left edges align.
404 kULAnchorAlign_End = 2, ///< Right edges align.
406
407///
408/// Fit behavior when an anchored floating panel does not fit on its preferred side
409/// (kULAnchorKind_Below).
410///
411typedef enum {
413 kULAnchorFit_Flip = 1, ///< Place above the rect when it does not fit beneath.
415
416///
417/// Placement for a foreground (floating) panel, the flattened form of the C++ Anchor.
418///
419/// Zero-initialize the desc. Only the fields the declared `kind` reads are meaningful, and
420/// the rest stay zero. A zero-initialized desc is the window origin.
421///
422typedef struct {
423 unsigned char kind; ///< A ULAnchorKind value.
424 unsigned char corner; ///< A ULAnchorCorner value (WindowCorner).
425 unsigned char align; ///< A ULAnchorAlign value (Below).
426 unsigned char fit; ///< A ULAnchorFit value (Below).
427 double x; ///< At: absolute window-space logical px.
428 double y;
429 double offset_x; ///< A logical-px nudge applied after any placement form resolves.
430 double offset_y;
431
432 ///
433 /// Below: the panel the anchor rect is local to (borrowed at the call, the floating
434 /// panel keeps its own reference). Must be a live panel of the same window.
435 ///
437
438 ///
439 /// Below: the anchor rect in the target panel's local logical px, which equals the
440 /// hosted page's CSS px (an element rect passes straight through).
441 ///
444
445///
446/// Options for creating a foreground (floating) panel.
447///
448/// A zero-initialized desc creates an unkeyed, full-window floating panel.
449///
450/// @see ulForegroundAddPanel()
451///
452typedef struct {
453 uint32_t struct_size; ///< Must be sizeof(ULForegroundPanelDesc).
454
455 /// Optional identity for lookup and diagnostics (see ULPanelDesc.key).
456 const char* key;
457
458 ///
459 /// The panel's width. Percent means percent of the window's width. A flex factor is
460 /// treated as unset with a warning. Unset means 100%.
461 ///
463
464 /// The panel's height (see `width`, percent of the window's height).
466
467 /// Where the panel sits in the window. Zero-initialized means the window origin.
469
470 ///
471 /// The auto-dismiss policy, as a ULDismiss value (see `<AppCore/CAPI.h>`).
472 ///
473 /// kULDismiss_Auto hides the panel the way native menus close (a press outside it, Esc, a
474 /// window move/resize/deactivation), firing its dismiss callbacks. The closing press is
475 /// consumed. (Default = kULDismiss_Manual)
476 ///
477 unsigned char dismiss;
478
479 /// The keyboard-focus policy, as a ULFocusPolicy value. (Default = kULFocusPolicy_Auto)
480 unsigned char focus;
481
482 uint32_t flags; ///< A ULLayoutFlags combination: Hidden.
484
485///
486/// The callback invoked for a layout node event.
487///
488/// @param node The node the event is about. Borrowed. Call ulCreateLayoutNodeRef() to
489/// keep it beyond the call.
490///
491/// @see ulLayoutNodeSetLayoutChangeCallback(), ulLayoutNodeSetUserResizeCallback()
492///
493typedef void (*ULLayoutNodeCallback)(void* user_data, ULLayoutNode node);
494
495///
496/// The callback invoked for a panel event.
497///
498/// @param panel The panel the event is about. Borrowed. Call ulCreatePanelRef() to keep
499/// it beyond the call.
500///
501/// @see ulPanelSetDismissCallback()
502///
503typedef void (*ULPanelCallback)(void* user_data, ULPanel panel);
504
505///
506/// The callback invoked when a window's focused panel changes.
507///
508/// @param window The window whose focused panel changed. Borrowed, valid only for the
509/// duration of the call. Keep your own window handle if you need one
510/// afterwards, and never destroy this one. Compare it to your own handle
511/// with ulWindowIsSame(), never `==`.
512///
513/// @param focused The panel that now holds focus, or NULL when no panel does. Borrowed.
514/// Call ulCreatePanelRef() to keep it beyond the call.
515///
516/// @see ulWindowSetFocusChangeCallback()
517///
518typedef void (*ULFocusChangeCallback)(void* user_data, ULWindow window, ULPanel focused);
519
520///
521/// The callback invoked when the focused panel's editable state changes.
522///
523/// @param window The window reporting the change. Borrowed, with the same rules as
524/// ULFocusChangeCallback's `window`.
525///
526/// @param panel The panel the state describes, or NULL when no panel holds focus.
527/// Borrowed. Call ulCreatePanelRef() to keep it beyond the call.
528///
529/// @param state The new editable state (see ULEditableState in
530/// `<Ultralight/CAPI/CAPI_Editor.h>`).
531///
532/// @see ulWindowSetEditableStateCallback()
533///
534typedef void (*ULEditableStateCallback)(void* user_data, ULWindow window, ULPanel panel,
535 ULEditableState state);
536
537///
538/// The callback invoked to lay out a container's children manually.
539///
540/// @param container The container being laid out. Borrowed. Call
541/// ulCreateContainerRef() to keep it beyond the call.
542///
543/// @param content_box The container's content box, in container-local logical pixels.
544///
545/// @see ulContainerSetLayoutOverride()
546///
547typedef void (*ULLayoutOverrideCallback)(void* user_data, ULContainer container,
548 ULLayoutRect content_box);
549
550/******************************************************************************
551 * Handle lifetime
552 *****************************************************************************/
553
554///
555/// Duplicate a layout-node handle.
556///
557/// @return Returns a new ULLayoutNode referring to the same node. You must call
558/// ulDestroyLayoutNode() when finished, on this handle and the original both.
559///
560/// @note Safe to call from any thread.
561///
563
564///
565/// Destroy a layout-node handle.
566///
567/// Destroying a handle never removes the node from its tree (see ulContainerRemove()).
568///
569/// @note Safe to call from any thread.
570///
572
573///
574/// Whether or not the node is still part of a live window's tree.
575///
576/// @note Safe to call from any thread. The answer is advisory, since it can change as
577/// soon as it is returned.
578///
580
581///
582/// Duplicate a panel handle.
583///
584/// @return Returns a new ULPanel referring to the same panel. You must call
585/// ulDestroyPanel() when finished, on this handle and the original both.
586///
587/// @note Safe to call from any thread.
588///
590
591///
592/// Destroy a panel handle.
593///
594/// Destroying a handle never removes the panel from its tree (see ulContainerRemove()).
595///
596/// @note Safe to call from any thread.
597///
599
600///
601/// Whether or not the panel is still part of a live window's tree.
602///
603/// @note Safe to call from any thread. The answer is advisory.
604///
606
607///
608/// Duplicate a container handle.
609///
610/// @return Returns a new ULContainer referring to the same container. You must call
611/// ulDestroyContainer() when finished, on this handle and the original both.
612///
613/// @note Safe to call from any thread.
614///
616
617///
618/// Destroy a container handle.
619///
620/// Destroying a handle never removes the container from its tree (see ulContainerRemove()).
621///
622/// @note Safe to call from any thread.
623///
625
626///
627/// Whether or not the container is still part of a live window's tree.
628///
629/// @note Safe to call from any thread. The answer is advisory.
630///
632
633///
634/// Duplicate a foreground handle.
635///
636/// @return Returns a new ULForeground referring to the same foreground layer. You must
637/// call ulDestroyForeground() when finished, on this handle and the original both.
638///
639/// @note Safe to call from any thread.
640///
642
643///
644/// Destroy a foreground handle.
645///
646/// Destroying a handle never affects the foreground layer or its floating panels.
647///
648/// @note Safe to call from any thread.
649///
651
652///
653/// Whether or not the foreground still belongs to a live window.
654///
655/// @note Safe to call from any thread. The answer is advisory.
656///
658
659///
660/// Whether or not two handles refer to the same node.
661///
662/// Handles are references, so two lookups of one node return distinct handles that compare
663/// equal here.
664///
665/// @return Returns false when either handle is NULL, or when the nodes differ.
666///
668
669///
670/// Whether or not two handles refer to the same window.
671///
672/// The focus-change and editable-state callbacks pass a borrowed window handle that never
673/// equals the one ulCreateWindow() returned, so compare the two with this.
674///
675/// @param a The first window handle (can be NULL).
676///
677/// @param b The second window handle (can be NULL).
678///
679/// @return Returns false when either handle is NULL, or when the windows differ.
680///
682
683///
684/// Get the kind of a layout node.
685///
686/// @return Returns the node's kind, or kULLayoutNodeKind_None when `node` is NULL.
687///
689
690///
691/// Get a node as a panel.
692///
693/// @return Returns a new ULPanel instance, or NULL when the node is not a panel. You must
694/// call ulDestroyPanel() when finished.
695///
697
698///
699/// Get a node as a container.
700///
701/// @return Returns a new ULContainer instance, or NULL when the node is not a container.
702/// You must call ulDestroyContainer() when finished.
703///
705
706///
707/// Get a panel's base layout-node handle.
708///
709/// @return Returns a new ULLayoutNode instance (NULL when `panel` is NULL). You must call
710/// ulDestroyLayoutNode() when finished.
711///
713
714///
715/// Get a container's base layout-node handle.
716///
717/// @return Returns a new ULLayoutNode instance (NULL when `container` is NULL). You must
718/// call ulDestroyLayoutNode() when finished.
719///
721
722/******************************************************************************
723 * LayoutNode
724 *****************************************************************************/
725
726///
727/// Get the node's key (empty if unkeyed).
728///
729/// @return Returns a new ULString instance. You must call ulDestroyString() when finished.
730///
732
733///
734/// Get the node's parent container.
735///
736/// @return Returns a new ULContainer instance, or NULL at the root or when detached. You
737/// must call ulDestroyContainer() when finished.
738///
740
741///
742/// Get the node's index within its parent.
743///
744/// @return Returns the index, or -1 when the node is detached.
745///
747
748///
749/// Hide the node, redistributing its space to its siblings.
750///
751/// The declared size is remembered and restored by ulLayoutNodeShow(). Hiding a container
752/// hides its whole subtree.
753///
754/// @note A hidden panel's View stops rendering entirely. Painting and animations suspend,
755/// and the page receives a `visibilitychange` event (a per-panel signal).
756///
758
759///
760/// Show the node again, restoring its remembered size exactly.
761///
763
764///
765/// Whether or not the node is hidden.
766///
767/// This reports the node's own hidden flag, so a node inside a hidden container still
768/// reports its own state.
769///
771
772///
773/// Get the node's rect from the most recent layout, in container-local logical pixels.
774///
775/// This is the same space ulLayoutNodeSetBounds() takes.
776///
777/// @return Returns the node's rect, or a zero rect before the node's first layout and after
778/// the node is removed or its window closes.
779///
781
782///
783/// Get the node's rect from the most recent layout, in window back-buffer device pixels.
784///
785/// This is the coordinate space your own drawing uses.
786///
787/// @return Returns the node's rect, or a zero rect before the node's first layout and after
788/// the node is removed or its window closes.
789///
791
792///
793/// Place the node manually, in container-local logical pixels.
794///
795/// @pre Only legal inside its container's layout delegate (see
796/// ulContainerSetLayoutOverride()). Anywhere else this is a no-op with a warning.
797///
799
800///
801/// Set the node's declared size along its container's axis.
802///
804
805///
806/// Set the node's minimum size constraint (px or percent, an `fr` unit is ignored with a
807/// warning).
808///
810
811///
812/// Set the node's maximum size constraint (px or percent, an `fr` unit is ignored with a
813/// warning).
814///
816
817/******************************************************************************
818 * Container
819 *****************************************************************************/
820
821///
822/// Create a panel in a container.
823///
824/// @param container The receiving container.
825///
826/// @param desc The panel's options (may be NULL for all defaults).
827///
828/// @param view_config Configuration for the panel's new View (may be NULL for window
829/// defaults). The fields describing the hosting window (device
830/// scale, display id, acceleration) are filled in from the window
831/// for you, and every other field is yours.
832///
833/// @param insert_before The direct child to insert before (may be NULL to append at
834/// the end). An anchor that is not a direct child logs a warning
835/// and the panel appends at the end.
836///
837/// @return Returns a new ULPanel instance. If the container was removed or its window
838/// closed, it logs a warning and returns a panel that isn't in any window (changes
839/// to it do nothing). You must call ulDestroyPanel() when finished.
840///
841/// @note To host a deliberately CPU-rendered View on a GPU window, create the View with
842/// ulCreateView() and adopt it with ulContainerAdoptPanel().
843///
844/// @see Container::AddPanel()
845///
847 ULViewConfig view_config, ULLayoutNode insert_before);
848
849///
850/// Create a panel that adopts an existing View (including a View created through a
851/// Session).
852///
853/// The panel takes a reference to the View and resizes it to the panel's bounds.
854///
855/// @param container The receiving container.
856///
857/// @param desc The panel's options (may be NULL for all defaults).
858///
859/// @param view The View to adopt. Must not be NULL.
860///
861/// @param insert_before The direct child to insert before (may be NULL to append at
862/// the end).
863///
864/// @return Returns a new ULPanel instance. If the container was removed or its window
865/// closed, or `view` is NULL, it logs a warning and returns a panel that isn't in any
866/// window (changes to it do nothing). You must call ulDestroyPanel() when finished.
867///
868/// @see Container::AdoptPanel()
869///
871 ULView view, ULLayoutNode insert_before);
872
873///
874/// Create a child row container (children arranged horizontally).
875///
876/// @param container The receiving container.
877///
878/// @param desc The new container's options (may be NULL for all defaults).
879///
880/// @param insert_before The direct child to insert before (may be NULL to append at
881/// the end).
882///
883/// @return Returns a new ULContainer instance. If the container was removed or its window
884/// closed, it logs a warning and returns a container that isn't in any window
885/// (changes to it do nothing). You must call ulDestroyContainer() when finished.
886///
887/// @see Container::AddRow()
888///
890 ULLayoutNode insert_before);
891
892///
893/// Create a child column container (children arranged vertically).
894///
895/// @param container The receiving container.
896///
897/// @param desc The new container's options (may be NULL for all defaults).
898///
899/// @param insert_before The direct child to insert before (may be NULL to append at
900/// the end).
901///
902/// @return Returns a new ULContainer instance. If the container was removed or its window
903/// closed, it logs a warning and returns a container that isn't in any window
904/// (changes to it do nothing). You must call ulDestroyContainer() when finished.
905///
906/// @see Container::AddColumn()
907///
909 ULLayoutNode insert_before);
910
911///
912/// Remove a direct child (and, for a container child, its whole subtree) from the tree.
913///
914/// Removal detaches the child and drops each removed panel's reference to its View. A View
915/// you hold a reference to survives removal and can be adopted into another panel or
916/// window. Removed handles stay safe to use, and changes to them do nothing.
917///
918/// @return Returns whether or not the node was a direct child and was removed.
919///
921
922///
923/// Remove every child. Equivalent to ulContainerRemove() on each child in turn.
924///
926
927///
928/// Reorder a direct child within its container.
929///
930/// A node from a different container (or window) is a no-op with a warning. An anchor that
931/// is not a direct child falls back to the end, with a warning.
932///
933/// @param container The container holding the child.
934///
935/// @param node The direct child to move.
936///
937/// @param move_before The direct child to move `node` before (may be NULL to move to
938/// the end).
939///
940/// @return Returns whether or not the node was reordered.
941///
943 ULLayoutNode move_before);
944
945///
946/// Get the number of children.
947///
949
950///
951/// Get the child at an index.
952///
953/// @return Returns a new ULLayoutNode instance, or NULL when the index is out of range.
954/// You must call ulDestroyLayoutNode() when finished.
955///
957
958///
959/// Find a descendant by key.
960///
961/// @return Returns a new ULLayoutNode instance, or NULL when not found. With duplicate
962/// keys the most recently created match wins. You must call ulDestroyLayoutNode()
963/// when finished.
964///
966
967///
968/// Find a descendant panel by key.
969///
970/// @return Returns a new ULPanel instance, or NULL when not found or the match is not a
971/// panel. You must call ulDestroyPanel() when finished.
972///
974
975///
976/// Find a descendant container by key.
977///
978/// @return Returns a new ULContainer instance, or NULL when not found or the match is not
979/// a container. You must call ulDestroyContainer() when finished.
980///
982
983///
984/// Override a container's layout with a layout delegate.
985///
986/// The delegate runs each time the window performs layout (after any layout change, a resize, or a
987/// display scale change). It never runs while the container has no children.
988///
989/// The delegate places the container's **direct** children by calling ulLayoutNodeSetBounds().
990///
991/// `content_box` is the container's content box (inside its padding) in container-local logical
992/// pixels.
993///
994/// Placed rects are snapped and clipped to the content box.
995///
996/// A placed rect persists until the delegate places that child again.
997///
998/// Children the delegate has never placed occupy no region.
999///
1000/// Pass a NULL `callback` to restore default layout.
1001///
1002/// @note The `Resizable` flag is ignored (with a warning) while a container has a layout
1003/// delegate. Dividers only exist between children the container itself lays out.
1004///
1006 ULLayoutOverrideCallback callback,
1007 void* user_data,
1008 ULUserDataDestroyCallback destroy_user_data);
1009
1010///
1011/// Whether or not a container has a layout delegate installed.
1012///
1014
1015///
1016/// Set this container's divider style, overriding the window style field by field for the
1017/// dividers between its own children.
1018///
1019/// @param container The container whose dividers to style.
1020///
1021/// @param style The style desc, or NULL to clear the override back to the window
1022/// style. A zeroed desc clears it too.
1023///
1024/// @note Negative or non-finite widths and invalid colors are ignored with a warning.
1025///
1026/// @see Container::SetDividerStyle()
1027///
1029 const ULDividerStyleDesc* style);
1030
1031/******************************************************************************
1032 * Panel
1033 *****************************************************************************/
1034
1035///
1036/// Get the panel's hosted View.
1037///
1038/// @return Returns a new ULView instance referring to the panel's View, or NULL after the
1039/// panel is removed or its window closes. You must call ulDestroyView() when
1040/// finished, which releases only your reference, never the panel's.
1041///
1043
1044///
1045/// Grant the panel exclusive keyboard focus.
1046///
1047/// You should always focus a panel through this function (or a user click) rather than
1048/// focusing its View directly, otherwise the panel's window won't know where to route
1049/// keyboard input.
1050///
1051/// @note Focusing a hidden panel (or one inside a hidden container) is ignored with a
1052/// warning. Focusing a foreground panel created with kULFocusPolicy_None is ignored too,
1053/// since such a panel never takes keyboard focus.
1054///
1056
1057///
1058/// Bring a floating panel to the top of the foreground layer.
1059///
1060/// The panel paints on top of other floating panels and receives mouse input first.
1061///
1062/// @note A tiled panel composites in tree order. Calling this function on a tiled panel is a
1063/// no-op with a warning.
1064///
1066
1067/******************************************************************************
1068 * Foreground
1069 *****************************************************************************/
1070
1071///
1072/// Create a floating panel, composited above every tiled panel.
1073///
1074/// The panel is sized on both axes against the window and placed per its ULAnchorDesc.
1075/// Floating panels stack in creation order, refined by ulPanelBringToFront(), and the
1076/// top-most panel is hit-tested first.
1077///
1078/// @param foreground The window's foreground layer.
1079///
1080/// @param desc The panel's options, or NULL for an unkeyed full-window floating
1081/// panel.
1082///
1083/// @param view_config The View configuration, or NULL for the window default. The
1084/// fields describing the hosting window (device scale, display id,
1085/// acceleration) are filled in from the window for you, and every
1086/// other field is yours.
1087///
1088/// @return Returns a new ULPanel instance. If the window has closed, it logs a warning and
1089/// returns a panel that isn't in any window (changes to it do nothing). You must call
1090/// ulDestroyPanel() when finished.
1091///
1092/// @see Foreground::AddPanel()
1093///
1095 ULViewConfig view_config);
1096
1097///
1098/// Create a floating panel that adopts an existing View (including one created through a
1099/// Session, or one that survived a removal).
1100///
1101/// The panel takes a reference to the View and resizes it to the panel's bounds.
1102///
1103/// @param foreground The window's foreground layer.
1104///
1105/// @param desc The panel's options, or NULL for an unkeyed full-window floating
1106/// panel.
1107///
1108/// @param view The View to adopt. Must not be NULL.
1109///
1110/// @return Returns a new ULPanel instance. If `view` is NULL or the window has closed, it
1111/// logs a warning and returns a panel that isn't in any window (changes to it do
1112/// nothing). You must call ulDestroyPanel() when finished.
1113///
1114/// @see Foreground::AdoptPanel()
1115///
1117 ULView view);
1118
1119///
1120/// Remove a floating panel from the foreground layer.
1121///
1122/// Removal drops the panel's reference to its View, and a reference you hold keeps the View
1123/// adoptable. The removed handle stays safe to use, and changes to it do nothing.
1124///
1125/// @return Returns whether or not the panel was one of this window's floating panels and
1126/// was removed. A panel that is not one of them is a no-op with a warning.
1127///
1129
1130///
1131/// Get the number of floating panels (hidden panels included).
1132///
1134
1135///
1136/// Get the floating panel at an index in current z-order, bottom-most first.
1137///
1138/// @return Returns a new ULPanel instance, or NULL when the index is out of range. You
1139/// must call ulDestroyPanel() when finished.
1140///
1142
1143///
1144/// Find a floating panel by key.
1145///
1146/// @return Returns a new ULPanel instance, or NULL when not found. With duplicate keys the
1147/// most recently created match wins. You must call ulDestroyPanel() when finished.
1148///
1150
1151/******************************************************************************
1152 * Window entries
1153 *****************************************************************************/
1154
1155///
1156/// Get a window's layout, the root container of the tiled panel tree (a column).
1157///
1158/// Build the window's content by adding panels and nested containers to it.
1159///
1160/// @return Returns a new ULContainer instance (after the window closes, changes to it do
1161/// nothing). You must call ulDestroyContainer() when finished.
1162///
1164
1165///
1166/// Get a window's foreground layer, which holds floating panels displayed above the
1167/// window's layout (eg, a toast, an in-window dialog, or a command palette).
1168///
1169/// Floating panels clip to the window. For menus and dropdowns that need to extend
1170/// outside it, use ulCreatePopupWindow() instead.
1171///
1172/// @return Returns a new ULForeground instance (after the window closes, changes to it do
1173/// nothing). You must call ulDestroyForeground() when finished.
1174///
1175/// @see Window::foreground()
1176///
1178
1179///
1180/// Configure the window's root container.
1181///
1182/// This applies `key`, the Resizable and Hidden flags, `gap`, and `padding` from the desc
1183/// to the root of the tiled tree. The root always fills the window, so the sizing fields
1184/// and the Fixed flag are ignored.
1185///
1186/// The desc re-applies wholesale on every call, so an unset field restores its default.
1187///
1188/// @param window The window whose root container to configure.
1189///
1190/// @param desc The root's options, or NULL to reset the root to defaults.
1191///
1192/// @see Window::BuildLayout()
1193///
1195
1196///
1197/// Add a panel to the window's root container.
1198///
1199/// This is shorthand for ulContainerAddPanel() on ulWindowGetLayout() with an append
1200/// position. A bare panel with a NULL desc fills the whole window.
1201///
1202/// @param window The window to add the panel to.
1203///
1204/// @param desc The panel's options (may be NULL for all defaults).
1205///
1206/// @param view_config Configuration for the panel's new View (may be NULL for window
1207/// defaults, see ulContainerAddPanel()).
1208///
1209/// @return Returns a new ULPanel instance, or NULL when `window` is NULL. After the window
1210/// closes, it logs a warning and returns a panel that isn't in any window (changes to
1211/// it do nothing). You must call ulDestroyPanel() when finished.
1212///
1214 ULViewConfig view_config);
1215
1216///
1217/// Find a panel by key anywhere in the window: the tiled layout first, then the foreground
1218/// layer.
1219///
1220/// @return Returns a new ULPanel instance, or NULL when not found. You must call
1221/// ulDestroyPanel() when finished.
1222///
1224
1225///
1226/// Get the panel holding keyboard focus.
1227///
1228/// @return Returns a new ULPanel instance, or NULL when no panel holds focus. You must
1229/// call ulDestroyPanel() when finished.
1230///
1232
1233///
1234/// Take keyboard focus away from every panel.
1235///
1236/// As with ulViewUnfocus(), the page's focused element gets a blur event but stays focused
1237/// in the document, and shows focus again the next time you call ulPanelFocus().
1238///
1239/// @note If a panel had focus, the window's focus-change callback fires with a NULL panel.
1240///
1241/// @see ulPanelFocus(), ulWindowSetFocusChangeCallback()
1242///
1244
1245///
1246/// Set the window-level divider style, the field-by-field fallback for every resizable
1247/// container that does not override a field itself.
1248///
1249/// @param window The window whose dividers to style.
1250///
1251/// @param style The style desc, or NULL to restore the built-in defaults. A zeroed desc
1252/// restores them too.
1253///
1254/// @note Negative or non-finite widths and invalid colors are ignored with a warning.
1255///
1256/// @see Window::SetDividerStyle()
1257///
1259
1260/******************************************************************************
1261 * Callbacks
1262 *****************************************************************************/
1263
1264///
1265/// Set callback for when the user resizes the node with a divider.
1266///
1267/// It fires on drag release and after a double-click reset, and only when the node's size
1268/// changed.
1269///
1271 ULLayoutNodeCallback callback,
1272 void* user_data,
1273 ULUserDataDestroyCallback destroy_user_data);
1274
1275///
1276/// Set callback for when layout changes the node's bounds.
1277///
1278/// The callback runs at most once per frame.
1279///
1280/// Use this callback to follow a node's geometry, such as a reserved region your own drawing
1281/// fills.
1282///
1284 ULLayoutNodeCallback callback,
1285 void* user_data,
1286 ULUserDataDestroyCallback destroy_user_data);
1287
1288///
1289/// Set callback for when the library dismisses a floating panel (an auto-dismiss trigger,
1290/// see ULForegroundPanelDesc).
1291///
1292/// Application-initiated hides never fire it.
1293///
1295 void* user_data,
1296 ULUserDataDestroyCallback destroy_user_data);
1297
1298///
1299/// Set callback for when the window's focused panel changes (the new panel may be NULL).
1300///
1302 void* user_data,
1303 ULUserDataDestroyCallback destroy_user_data);
1304
1305///
1306/// Set callback for when the focused panel's editable state changes.
1307///
1308/// This is the window-level form of ulViewSetChangeEditableStateCallback(): one callback
1309/// reports the focused panel's state, so a multi-panel app doesn't need to set one on each
1310/// View. You can use it to show and hide an on-screen keyboard, for example.
1311///
1312/// @note The window uses each panel View's editable-state hook to track this. If you call
1313/// ulViewSetChangeEditableStateCallback() on a hosted View, that View's changes stop
1314/// reaching this callback and the window's input method handling.
1315///
1317 ULEditableStateCallback callback,
1318 void* user_data,
1319 ULUserDataDestroyCallback destroy_user_data);
1320
1321#ifdef __cplusplus
1322} // extern "C"
1323#endif
1324
1325#endif // APPCORE_CAPI_LAYOUT_H
Common declarations for the AppCore C API.
struct C_Window * ULWindow
Opaque handle to a Window object.
Definition CAPI_Defines.h:43
#define ACExport
Definition CAPI_Defines.h:28
Text-editing interface for a View.
ULPanel ulWindowGetFocusedPanel(ULWindow window)
Get the panel holding keyboard focus.
ULContainer ulWindowGetLayout(ULWindow window)
Get a window's layout, the root container of the tiled panel tree (a column).
void(*) ULEditableStateCallback(void *user_data, ULWindow window, ULPanel panel, ULEditableState state)
The callback invoked when the focused panel's editable state changes.
Definition CAPI_Layout.h:534
ULLayoutNode ulContainerAsLayoutNode(ULContainer container)
Get a container's base layout-node handle.
ULContainer ulLayoutNodeGetParent(ULLayoutNode node)
Get the node's parent container.
ULPanel ulCreatePanelRef(ULPanel panel)
Duplicate a panel handle.
ULForeground ulCreateForegroundRef(ULForeground foreground)
Duplicate a foreground handle.
void(*) ULLayoutNodeCallback(void *user_data, ULLayoutNode node)
The callback invoked for a layout node event.
Definition CAPI_Layout.h:493
void ulPanelBringToFront(ULPanel panel)
Bring a floating panel to the top of the foreground layer.
void ulLayoutNodeSetLayoutChangeCallback(ULLayoutNode node, ULLayoutNodeCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when layout changes the node's bounds.
void ulContainerSetDividerStyle(ULContainer container, const ULDividerStyleDesc *style)
Set this container's divider style, overriding the window style field by field for the dividers betwe...
bool ulLayoutNodeIsHidden(ULLayoutNode node)
Whether or not the node is hidden.
void ulLayoutNodeSetSize(ULLayoutNode node, ULLayoutSize size)
Set the node's declared size along its container's axis.
void ulPanelFocus(ULPanel panel)
Grant the panel exclusive keyboard focus.
bool ulContainerHasLayoutOverride(ULContainer container)
Whether or not a container has a layout delegate installed.
ULAnchorCorner
A window corner (kULAnchorKind_WindowCorner).
Definition CAPI_Layout.h:391
@ kULAnchorCorner_BottomRight
Definition CAPI_Layout.h:395
@ kULAnchorCorner_BottomLeft
Definition CAPI_Layout.h:394
@ kULAnchorCorner_TopLeft
Definition CAPI_Layout.h:392
@ kULAnchorCorner_TopRight
Definition CAPI_Layout.h:393
bool ulWindowIsSame(ULWindow a, ULWindow b)
Whether or not two handles refer to the same window.
ULPanel ulLayoutNodeAsPanel(ULLayoutNode node)
Get a node as a panel.
int ulForegroundGetPanelCount(ULForeground foreground)
Get the number of floating panels (hidden panels included).
void ulContainerSetLayoutOverride(ULContainer container, ULLayoutOverrideCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Override a container's layout with a layout delegate.
bool ulContainerIsAlive(ULContainer container)
Whether or not the container is still part of a live window's tree.
ULLayoutFlags
Flags for the desc structs' flags field.
Definition CAPI_Layout.h:249
@ kULLayoutFlags_Fixed
The user cannot resize this node with a divider drag (panels and containers).
Definition CAPI_Layout.h:250
@ kULLayoutFlags_Hidden
Created hidden, shows later without a layout flash (all descs).
Definition CAPI_Layout.h:252
@ kULLayoutFlags_Resizable
The user can resize this container's children by dragging the dividers between them (containers only)...
Definition CAPI_Layout.h:254
ULPanel ulContainerAdoptPanel(ULContainer container, const ULPanelDesc *desc, ULView view, ULLayoutNode insert_before)
Create a panel that adopts an existing View (including a View created through a Session).
bool ulContainerRemove(ULContainer container, ULLayoutNode node)
Remove a direct child (and, for a container child, its whole subtree) from the tree.
void ulLayoutNodeSetMaxSize(ULLayoutNode node, ULLayoutSize max_size)
Set the node's maximum size constraint (px or percent, an fr unit is ignored with a warning).
ULPanel ulContainerFindPanel(ULContainer container, const char *key)
Find a descendant panel by key.
ULLayoutNode ulContainerGetChildAt(ULContainer container, int index)
Get the child at an index.
ULView ulPanelGetView(ULPanel panel)
Get the panel's hosted View.
ULLayoutRect ulLayoutNodeGetBounds(ULLayoutNode node)
Get the node's rect from the most recent layout, in container-local logical pixels.
void(*) ULLayoutOverrideCallback(void *user_data, ULContainer container, ULLayoutRect content_box)
The callback invoked to lay out a container's children manually.
Definition CAPI_Layout.h:547
ULPanel ulWindowAddPanel(ULWindow window, const ULPanelDesc *desc, ULViewConfig view_config)
Add a panel to the window's root container.
bool ulForegroundIsAlive(ULForeground foreground)
Whether or not the foreground still belongs to a live window.
ULLayoutNode ulPanelAsLayoutNode(ULPanel panel)
Get a panel's base layout-node handle.
void(*) ULFocusChangeCallback(void *user_data, ULWindow window, ULPanel focused)
The callback invoked when a window's focused panel changes.
Definition CAPI_Layout.h:518
bool ulLayoutNodeIsAlive(ULLayoutNode node)
Whether or not the node is still part of a live window's tree.
void ulLayoutNodeSetBounds(ULLayoutNode node, ULLayoutRect bounds)
Place the node manually, in container-local logical pixels.
void ulWindowConfigureLayout(ULWindow window, const ULContainerDesc *desc)
Configure the window's root container.
ULContainer ulLayoutNodeAsContainer(ULLayoutNode node)
Get a node as a container.
void ulDestroyContainer(ULContainer container)
Destroy a container handle.
struct C_Foreground * ULForeground
Opaque handle to a window's foreground layer (floating panels composited above the tiled layout).
Definition CAPI_Layout.h:164
ULPanel ulForegroundGetPanelAt(ULForeground foreground, int index)
Get the floating panel at an index in current z-order, bottom-most first.
void ulLayoutNodeHide(ULLayoutNode node)
Hide the node, redistributing its space to its siblings.
void ulPanelSetDismissCallback(ULPanel panel, ULPanelCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the library dismisses a floating panel (an auto-dismiss trigger,...
struct C_LayoutNode * ULLayoutNode
Opaque handle to a layout node, the shared base of panels and containers.
Definition CAPI_Layout.h:152
ULLayoutNodeKind ulLayoutNodeGetKind(ULLayoutNode node)
Get the kind of a layout node.
ULPanel ulContainerAddPanel(ULContainer container, const ULPanelDesc *desc, ULViewConfig view_config, ULLayoutNode insert_before)
Create a panel in a container.
ULLayoutNodeKind
The kind of a layout node.
Definition CAPI_Layout.h:240
@ kULLayoutNodeKind_Container
Definition CAPI_Layout.h:243
@ kULLayoutNodeKind_None
NULL or invalid handle.
Definition CAPI_Layout.h:241
@ kULLayoutNodeKind_Panel
Definition CAPI_Layout.h:242
ULLayoutSizeUnit
The unit of a ULLayoutSize.
Definition CAPI_Layout.h:169
@ kULLayoutSizeUnit_Pct
For a size, percent of the container's free space.
Definition CAPI_Layout.h:172
@ kULLayoutSizeUnit_Default
Unset: the receiving field's default applies.
Definition CAPI_Layout.h:170
@ kULLayoutSizeUnit_Fr
A flex factor (sizes only).
Definition CAPI_Layout.h:174
@ kULLayoutSizeUnit_Px
Logical pixels.
Definition CAPI_Layout.h:171
void ulLayoutNodeSetMinSize(ULLayoutNode node, ULLayoutSize min_size)
Set the node's minimum size constraint (px or percent, an fr unit is ignored with a warning).
ULAnchorKind
The placement form of a ULAnchorDesc.
Definition CAPI_Layout.h:379
@ kULAnchorKind_WindowCorner
A window corner, following the window.
Definition CAPI_Layout.h:383
@ kULAnchorKind_Below
Under an anchor rect in a target panel.
Definition CAPI_Layout.h:385
@ kULAnchorKind_WindowCenter
Centered in the window, following the window.
Definition CAPI_Layout.h:384
@ kULAnchorKind_At
Absolute window-space logical px.
Definition CAPI_Layout.h:382
@ kULAnchorKind_Default
The window origin (with the default 100% sizes, a full-window panel).
Definition CAPI_Layout.h:380
ULContainer ulContainerAddRow(ULContainer container, const ULContainerDesc *desc, ULLayoutNode insert_before)
Create a child row container (children arranged horizontally).
ULLayoutNode ulCreateLayoutNodeRef(ULLayoutNode node)
Duplicate a layout-node handle.
ULFocusPolicy
Keyboard-focus policy for a foreground (floating) panel.
Definition CAPI_Layout.h:366
@ kULFocusPolicy_Auto
Takes focus when clicked, like any panel.
Definition CAPI_Layout.h:367
@ kULFocusPolicy_None
Never takes keyboard focus.
Definition CAPI_Layout.h:372
@ kULFocusPolicy_Grab
Takes keyboard focus when created (unless hidden) and each time it is shown, even from inside a click...
Definition CAPI_Layout.h:369
void ulDestroyPanel(ULPanel panel)
Destroy a panel handle.
ULContainer ulContainerFindContainer(ULContainer container, const char *key)
Find a descendant container by key.
ULPanel ulForegroundAdoptPanel(ULForeground foreground, const ULForegroundPanelDesc *desc, ULView view)
Create a floating panel that adopts an existing View (including one created through a Session,...
void ulLayoutNodeSetUserResizeCallback(ULLayoutNode node, ULLayoutNodeCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the user resizes the node with a divider.
ULLayoutDeviceRect ulLayoutNodeGetDeviceBounds(ULLayoutNode node)
Get the node's rect from the most recent layout, in window back-buffer device pixels.
int ulContainerGetChildCount(ULContainer container)
Get the number of children.
ULForeground ulWindowGetForeground(ULWindow window)
Get a window's foreground layer, which holds floating panels displayed above the window's layout (eg,...
void ulLayoutNodeShow(ULLayoutNode node)
Show the node again, restoring its remembered size exactly.
ULLayoutNode ulContainerFind(ULContainer container, const char *key)
Find a descendant by key.
ULPanel ulForegroundAddPanel(ULForeground foreground, const ULForegroundPanelDesc *desc, ULViewConfig view_config)
Create a floating panel, composited above every tiled panel.
ULPanel ulWindowFindPanel(ULWindow window, const char *key)
Find a panel by key anywhere in the window: the tiled layout first, then the foreground layer.
void ulDestroyForeground(ULForeground foreground)
Destroy a foreground handle.
void ulWindowSetDividerStyle(ULWindow window, const ULDividerStyleDesc *style)
Set the window-level divider style, the field-by-field fallback for every resizable container that do...
void ulContainerRemoveAll(ULContainer container)
Remove every child.
void ulWindowClearFocus(ULWindow window)
Take keyboard focus away from every panel.
ULContainer ulCreateContainerRef(ULContainer container)
Duplicate a container handle.
ULString ulLayoutNodeGetKey(ULLayoutNode node)
Get the node's key (empty if unkeyed).
void ulWindowSetFocusChangeCallback(ULWindow window, ULFocusChangeCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the window's focused panel changes (the new panel may be NULL).
bool ulPanelIsAlive(ULPanel panel)
Whether or not the panel is still part of a live window's tree.
bool ulContainerMove(ULContainer container, ULLayoutNode node, ULLayoutNode move_before)
Reorder a direct child within its container.
void ulDestroyLayoutNode(ULLayoutNode node)
Destroy a layout-node handle.
void(*) ULPanelCallback(void *user_data, ULPanel panel)
The callback invoked for a panel event.
Definition CAPI_Layout.h:503
bool ulForegroundRemove(ULForeground foreground, ULPanel panel)
Remove a floating panel from the foreground layer.
ULAnchorAlign
Cross-axis alignment of the floating panel against its anchor rect (kULAnchorKind_Below).
Definition CAPI_Layout.h:401
@ kULAnchorAlign_End
Right edges align.
Definition CAPI_Layout.h:404
@ kULAnchorAlign_Center
Definition CAPI_Layout.h:403
@ kULAnchorAlign_Start
Left edges align.
Definition CAPI_Layout.h:402
void ulWindowSetEditableStateCallback(ULWindow window, ULEditableStateCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the focused panel's editable state changes.
int ulLayoutNodeGetIndex(ULLayoutNode node)
Get the node's index within its parent.
ULAnchorFit
Fit behavior when an anchored floating panel does not fit on its preferred side (kULAnchorKind_Below)...
Definition CAPI_Layout.h:411
@ kULAnchorFit_None
Definition CAPI_Layout.h:412
@ kULAnchorFit_Flip
Place above the rect when it does not fit beneath.
Definition CAPI_Layout.h:413
ULContainer ulContainerAddColumn(ULContainer container, const ULContainerDesc *desc, ULLayoutNode insert_before)
Create a child column container (children arranged vertically).
struct C_Container * ULContainer
Opaque handle to a container (a row or column of child nodes).
Definition CAPI_Layout.h:160
struct C_Panel * ULPanel
Opaque handle to a panel (a layout node hosting a View).
Definition CAPI_Layout.h:156
ULPanel ulForegroundFindPanel(ULForeground foreground, const char *key)
Find a floating panel by key.
bool ulLayoutNodeIsSame(ULLayoutNode a, ULLayoutNode b)
Whether or not two handles refer to the same node.
struct C_View * ULView
Opaque handle to a View object.
Definition CAPI_Defines.h:87
struct C_String * ULString
Opaque handle to a String object.
Definition CAPI_Defines.h:96
struct C_ViewConfig * ULViewConfig
Opaque handle to a ViewConfig object.
Definition CAPI_Defines.h:84
void(*) ULUserDataDestroyCallback(void *user_data)
Callback invoked exactly once when the library finally drops a piece of user data.
Definition CAPI_Defines.h:139
Placement for a foreground (floating) panel, the flattened form of the C++ Anchor.
Definition CAPI_Layout.h:422
ULLayoutRect rect
Below: the anchor rect in the target panel's local logical px, which equals the hosted page's CSS px ...
Definition CAPI_Layout.h:442
double offset_y
Definition CAPI_Layout.h:430
double offset_x
A logical-px nudge applied after any placement form resolves.
Definition CAPI_Layout.h:429
ULPanel target
Below: the panel the anchor rect is local to (borrowed at the call, the floating panel keeps its own ...
Definition CAPI_Layout.h:436
double y
Definition CAPI_Layout.h:428
unsigned char align
A ULAnchorAlign value (Below).
Definition CAPI_Layout.h:425
unsigned char fit
A ULAnchorFit value (Below).
Definition CAPI_Layout.h:426
unsigned char kind
A ULAnchorKind value.
Definition CAPI_Layout.h:423
unsigned char corner
A ULAnchorCorner value (WindowCorner).
Definition CAPI_Layout.h:424
double x
At: absolute window-space logical px.
Definition CAPI_Layout.h:427
A color value.
Definition CAPI_ColorTypes.h:45
Options for creating a container (a row or column of child nodes).
Definition CAPI_Layout.h:300
ULLayoutSize padding
Padding between the container's edges and its children, applied on all four sides (logical px only).
Definition CAPI_Layout.h:327
uint32_t flags
A ULLayoutFlags combination: Fixed, Resizable, Hidden.
Definition CAPI_Layout.h:315
uint32_t struct_size
Must be sizeof(ULContainerDesc).
Definition CAPI_Layout.h:301
ULLayoutSize min_size
Minimum size constraint (see ULPanelDesc.min_size).
Definition CAPI_Layout.h:310
ULLayoutSize gap
The gap between adjacent children (logical px only, other units are ignored with a warning).
Definition CAPI_Layout.h:321
ULLayoutSize size
The container's size along its parent's axis. Unset means one flex share (1fr).
Definition CAPI_Layout.h:307
ULLayoutSize max_size
Maximum size constraint (see ULPanelDesc.max_size).
Definition CAPI_Layout.h:313
const char * key
Optional identity for lookup and diagnostics (see ULPanelDesc.key).
Definition CAPI_Layout.h:304
Styling for the dividers between a resizable container's children.
Definition CAPI_Layout.h:337
double hit_width
The width of the divider's pointer target, in logical px.
Definition CAPI_Layout.h:343
ULColor color
The color of the divider line.
Definition CAPI_Layout.h:354
uint32_t struct_size
Must be sizeof(ULDividerStyleDesc).
Definition CAPI_Layout.h:338
ULColor hover_color
The hover highlight color, shown over the divider while the pointer rests on it or drags it.
Definition CAPI_Layout.h:360
double visual_thickness
The thickness of the painted divider line, in logical px.
Definition CAPI_Layout.h:348
The conditions that decide whether an input method should be active.
Definition CAPI_Editor.h:519
Options for creating a foreground (floating) panel.
Definition CAPI_Layout.h:452
unsigned char focus
The keyboard-focus policy, as a ULFocusPolicy value. (Default = kULFocusPolicy_Auto).
Definition CAPI_Layout.h:480
ULLayoutSize height
The panel's height (see width, percent of the window's height).
Definition CAPI_Layout.h:465
uint32_t flags
A ULLayoutFlags combination: Hidden.
Definition CAPI_Layout.h:482
ULAnchorDesc placement
Where the panel sits in the window. Zero-initialized means the window origin.
Definition CAPI_Layout.h:468
uint32_t struct_size
Must be sizeof(ULForegroundPanelDesc).
Definition CAPI_Layout.h:453
const char * key
Optional identity for lookup and diagnostics (see ULPanelDesc.key).
Definition CAPI_Layout.h:456
unsigned char dismiss
The auto-dismiss policy, as a ULDismiss value (see <AppCore/CAPI.h>).
Definition CAPI_Layout.h:477
ULLayoutSize width
The panel's width.
Definition CAPI_Layout.h:462
A rectangle in device pixels (window-backbuffer space).
Definition CAPI_Layout.h:228
int y
Definition CAPI_Layout.h:230
int width
Definition CAPI_Layout.h:231
int x
Definition CAPI_Layout.h:229
int height
Definition CAPI_Layout.h:232
A rectangle in logical (DPI-independent) pixels.
Definition CAPI_Defines.h:56
A size or constraint length, as a value plus a unit.
Definition CAPI_Layout.h:187
unsigned char unit
A ULLayoutSizeUnit value.
Definition CAPI_Layout.h:189
double value
The numeric value (px, percent points, or flex factor).
Definition CAPI_Layout.h:188
Options for creating a panel.
Definition CAPI_Layout.h:264
uint32_t flags
A ULLayoutFlags combination: Fixed, Hidden.
Definition CAPI_Layout.h:292
uint32_t struct_size
Must be sizeof(ULPanelDesc).
Definition CAPI_Layout.h:265
ULLayoutSize min_size
Minimum size constraint.
Definition CAPI_Layout.h:284
ULLayoutSize size
The panel's size along its container's axis.
Definition CAPI_Layout.h:278
ULLayoutSize max_size
Maximum size constraint.
Definition CAPI_Layout.h:290
const char * key
Optional identity for lookup (ulContainerFind()) and diagnostics, as null-terminated UTF-8 (copied).
Definition CAPI_Layout.h:272