Skip to main content

day_toolkit_xaml_sys/
lib.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4//! day-toolkit-xaml-sys — raw `extern "C"` declarations for the C++/WinRT XAML-Islands shim
5//! (src/shim.cpp) compiled by build.rs. Handles are opaque `Windows.UI.Xaml.UIElement*`
6//! heap-boxed by the shim; `day_xaml_delete` releases the WinRT reference.
7
8#![cfg(windows)]
9
10use std::os::raw::{c_char, c_double, c_int, c_uint, c_void};
11
12/// One `AnimSpec` as the shim plays it (docs/tween.md "The animation contract"): the delay,
13/// one cycle's length, the cycles beyond the first (`u32::MAX` for ever), auto-reverse, and
14/// the progress of one forward cycle sampled `frames` times at uniform offsets
15/// (`AnimSpec::keyframes`). `progress` must stay valid for the call.
16#[repr(C)]
17pub struct DayAnim {
18    pub delay_ms: c_int,
19    pub duration_ms: c_int,
20    pub repeat: c_uint,
21    pub autoreverse: c_int,
22    pub frames: c_int,
23    pub progress: *const c_double,
24}
25
26/// What [`day_xaml_read_native`] reads back from an element: the shim's `DayXamlNative`,
27/// field for field. A member the element does not carry keeps its "not read" value: `0` in a
28/// `has_*` flag, `-1` in a tri-state (`checked`, `enabled`, `visible`), a null string. Strings
29/// are heap copies to release with [`day_xaml_string_free`].
30#[repr(C)]
31pub struct DayXamlNative {
32    /// The accessibility group (`role` through `identifier`) was read.
33    pub found: c_int,
34    /// [`day_xaml_set_a11y`]'s role table; `0` when the element carries none of it.
35    pub role: c_int,
36    /// The heading level, with role 5.
37    pub level: c_int,
38    pub label: *mut c_char,
39    pub value: *mut c_char,
40    pub identifier: *mut c_char,
41    /// The text on screen; null for a `PasswordBox` and elements without text.
42    pub text: *mut c_char,
43    pub has_number: c_int,
44    pub number: c_double,
45    pub checked: c_int,
46    pub enabled: c_int,
47    pub visible: c_int,
48    pub has_frame: c_int,
49    pub x: c_double,
50    pub y: c_double,
51    pub w: c_double,
52    pub h: c_double,
53}
54
55/// What a window wears (docs/window-chrome.md): the shim's `DayXamlChrome`, field for field,
56/// passed to [`day_xaml_window_new`] and [`day_xaml_window_new2`].
57#[repr(C)]
58#[derive(Clone, Copy, Debug, Default)]
59pub struct DayXamlChrome {
60    /// 0 standard, 1 overlay title bar, 2 frameless.
61    pub chrome: c_int,
62    /// 0 opaque, 1 transparent (not drawn: the window stays opaque), 2 a system material.
63    pub background: c_int,
64    /// With `background` 2: 0 window (Mica), 1 sidebar (Mica Alt), 2 transient (Acrylic).
65    pub material: c_int,
66    /// 0 drops a frameless window's shadow.
67    pub shadow: c_int,
68    /// 0 takes the sizing border and the maximize box away.
69    pub resizable: c_int,
70    /// 0 automatic, 1 centered on the active window's monitor, 2 at (`x`, `y`).
71    pub placement: c_int,
72    /// With `placement` 2: the outer frame's top-left corner, in points.
73    pub x: c_double,
74    pub y: c_double,
75}
76
77/// One display (docs/windows.md "Monitors"): the shim's `DayXamlMonitor`, field for field.
78/// Rectangles are `[x, y, width, height]` in points on the desktop.
79#[repr(C)]
80pub struct DayXamlMonitor {
81    pub frame: [c_double; 4],
82    /// The frame minus the taskbar and docked app bars.
83    pub work: [c_double; 4],
84    /// Device pixels per point.
85    pub scale: c_double,
86    pub primary: c_int,
87    /// NUL-terminated UTF-8: the monitor's device interface path, else its adapter output.
88    pub id: [c_char; 160],
89    /// NUL-terminated UTF-8: the name Windows shows for the monitor.
90    pub name: [c_char; 128],
91}
92
93unsafe extern "C" {
94    #[cfg(feature = "winui")]
95    pub fn day_xaml_canvas_bitmap(
96        id: u64,
97        nums: *const f64,
98        n: c_int,
99        texts: *const c_char,
100        width: c_int,
101        height: c_int,
102        scale: f64,
103    ) -> c_int;
104    #[cfg(feature = "winui")]
105    pub fn day_xaml_encode_png(id: u64, fit_w: c_int, fit_h: c_int, len: *mut c_int) -> *mut u8;
106    #[cfg(feature = "winui")]
107    pub fn day_xaml_bytes_free(bytes: *mut u8);
108    // window / app lifecycle
109    pub fn day_xaml_window_new(
110        title: *const c_char,
111        w: c_int,
112        h: c_int,
113        min_w: c_int,
114        min_h: c_int,
115        chrome: *const DayXamlChrome,
116    ) -> *mut c_void;
117    pub fn day_xaml_window_root(win: *mut c_void) -> *mut c_void;
118    /// The ROOT canvas, above the docked chrome — unlike [`day_xaml_window_root`], which returns
119    /// the content canvas day's tree mounts into. Only a fullscreen cover needs this.
120    pub fn day_xaml_window_chrome_root(win: *mut c_void) -> *mut c_void;
121    /// The root's laid-out size in DIPs: the whole client area, chrome included. The resize
122    /// callback reports the CONTENT size instead, which is smaller by exactly that chrome.
123    pub fn day_xaml_window_chrome_size(win: *mut c_void, out_w: *mut f64, out_h: *mut f64);
124    pub fn day_xaml_window_show(win: *mut c_void);
125    // Secondary windows (docs/windows.md): per-window event callbacks keyed by day node id.
126    pub fn day_xaml_set_window_events_cb(
127        resized: extern "C" fn(u64, c_int, c_int),
128        closed: extern "C" fn(u64),
129        focused: extern "C" fn(u64, c_int),
130    );
131    pub fn day_xaml_window_new2(
132        title: *const c_char,
133        w: c_int,
134        h: c_int,
135        node: u64,
136        fixed: c_int,
137        chrome: *const DayXamlChrome,
138    ) -> *mut c_void;
139    pub fn day_xaml_window_content2(win: *mut c_void) -> *mut c_void;
140    pub fn day_xaml_window_close2(win: *mut c_void);
141    pub fn day_xaml_window_raise2(win: *mut c_void);
142    pub fn day_xaml_window_set_title2(win: *mut c_void, title: *const c_char);
143    pub fn day_xaml_window_destroy2(win: *mut c_void);
144    /// Window properties (docs/windows.md "Window properties"). `win` is either window token:
145    /// the primary's from [`day_xaml_window_new`] or a secondary's from [`day_xaml_window_new2`].
146    /// Ask for a `day_spec::WindowState` code (0 normal, 1 minimized, 2 maximized, 3 borderless
147    /// fullscreen); the outcome comes back through [`day_xaml_set_window_state_cb`].
148    pub fn day_xaml_window_set_state(win: *mut c_void, state: c_int);
149    /// Keep the window out of captures (`WDA_EXCLUDEFROMCAPTURE`, `WDA_MONITOR` before Windows
150    /// 10 2004) when `on` is non-zero; `WDA_NONE` otherwise.
151    pub fn day_xaml_window_set_protected(win: *mut c_void, on: c_int);
152    /// `cb(node, state)` on every change of a window's display state, and once for a request
153    /// that did not land: the secondary window's day node id, or `u64::MAX`
154    /// (`day_spec::WINDOW_NODE`) for the primary; `state` a `day_spec::WindowState` code.
155    pub fn day_xaml_set_window_state_cb(cb: extern "C" fn(u64, c_int));
156    /// `cb(node, top)` when an overlay window's title bar (plus any docked menu bar and toolbar
157    /// below it) covers a new height of its content, in DIPs: the window's safe-area top inset.
158    /// `node` as for [`day_xaml_set_window_state_cb`].
159    pub fn day_xaml_set_chrome_inset_cb(cb: extern "C" fn(u64, c_double));
160    /// 1 where Windows draws the system backdrops (Windows 11 22621 and later).
161    pub fn day_xaml_materials_supported() -> c_int;
162    /// Mark (`on` non-zero) or unmark the element as a drag region (`.window_drag_region()`):
163    /// a press on its own background moves the window like its title bar.
164    pub fn day_xaml_set_drag_region(h: *mut c_void, on: c_int);
165
166    // The app outside its windows (docs/status-item.md).
167    /// `cb(0, id)` runs a status item's click action or menu choice by dispatch id; `cb(1, 0)` is
168    /// its menu's Quit role.
169    pub fn day_xaml_set_status_cb(cb: extern "C" fn(c_int, u64));
170    /// Add or update the notification-area icon `id`: `glyph` an icon-font code point in hex, else
171    /// `image` an image file path, else the app's icon; `templ` draws the image in the taskbar's
172    /// color; `activate` the dispatch id a primary click runs (0: a click opens the menu);
173    /// `menu` the app menu's spec lines.
174    pub fn day_xaml_status_set(
175        id: *const c_char,
176        tip: *const c_char,
177        glyph: *const c_char,
178        image: *const c_char,
179        templ: c_int,
180        activate: u64,
181        menu: *const c_char,
182    );
183    /// Remove every status item whose id is not in `ids` (newline-joined).
184    pub fn day_xaml_status_retain(ids: *const c_char);
185    /// Non-zero: Day's posts stay deliverable once the primary window is gone.
186    pub fn day_xaml_set_keep_running(keep: c_int);
187    /// The primary's taskbar progress: 0 none, 1 indeterminate, 2 value, 3 paused, 4 error.
188    pub fn day_xaml_set_app_progress(kind: c_int, value: c_double);
189    /// The primary's taskbar overlay badge: 0 none, 1 `count` (0 clears), 2 a dot.
190    pub fn day_xaml_set_app_badge(kind: c_int, count: c_uint);
191
192    // Single instance and the jump list (docs/deep-links.md).
193    /// `cb(data, len)` with the arguments a second instance forwarded: UTF-8, NUL-separated.
194    /// Called on the UI thread from inside a sent message, so it must only post.
195    pub fn day_xaml_set_forward_cb(cb: extern "C" fn(*const c_char, c_int));
196    /// Claim `app_id` for this process before any window opens: 1 carry on (first instance, or
197    /// no usable id); 0 the running instance took this process's arguments, so end it now. The
198    /// first instance also gets `app_id` as its `AppUserModelID` when it runs unpackaged.
199    pub fn day_xaml_claim_instance(app_id: *const c_char) -> c_int;
200    /// Replace the jump list's Tasks with `spec`'s `label \t link` lines (empty clears it).
201    pub fn day_xaml_set_jump_tasks(app_id: *const c_char, spec: *const c_char);
202
203    // Window properties (docs/windows.md "Window properties"); `win` as for the state calls.
204    /// Move (outer top-left, points on the desktop) and/or resize (content size, points).
205    pub fn day_xaml_window_set_frame(
206        win: *mut c_void,
207        has_origin: c_int,
208        x: c_double,
209        y: c_double,
210        has_size: c_int,
211        w: c_double,
212        h: c_double,
213    );
214    /// Content-size limits in points; 0 lifts a bound.
215    pub fn day_xaml_window_set_limits(
216        win: *mut c_void,
217        min_w: c_double,
218        min_h: c_double,
219        max_w: c_double,
220        max_h: c_double,
221    );
222    /// One on/off property: 0 floating, 1 left off the taskbar, 2 resizable, 3 minimizable,
223    /// 4 maximizable, 5 closable, 6 visible.
224    pub fn day_xaml_window_set_flag(win: *mut c_void, which: c_int, on: c_int);
225    /// The window's own scheme: -1 the app's, 0 light, 1 dark.
226    pub fn day_xaml_window_set_appearance(win: *mut c_void, mode: c_int);
227    /// Flash the taskbar button (`critical` 0: three times; 1: until the window is in front).
228    pub fn day_xaml_window_attention(win: *mut c_void, critical: c_int);
229    /// The outer frame in points on the desktop into `out[0..4]`; 0 when unknown.
230    pub fn day_xaml_window_frame(win: *mut c_void, out: *mut c_double) -> c_int;
231    /// Every attached display into `out` (up to `cap`); returns how many there are.
232    pub fn day_xaml_monitors(out: *mut DayXamlMonitor, cap: c_int) -> c_int;
233    /// Top-level host HWND of the (single, v1) app window — for a piece that needs the window handle
234    /// behind the XAML island. The WebView2 web view passes it as the composition controller's
235    /// parentWindow (DPI / IME / input association) while rendering windowless into the XAML tree.
236    pub fn day_xaml_host_hwnd() -> *mut c_void;
237    /// The pointer's shape over an element (docs/cursor.md): 0 releases it, 1..=16 name a
238    /// Win32 `IDC_*` shape in the shim's table, 17 hides the pointer.
239    pub fn day_xaml_set_cursor(h: *mut c_void, code: c_int);
240    /// Title-bar + taskbar icon from a multi-size `.ico` (§18.2).
241    pub fn day_xaml_set_app_icon(win: *mut c_void, ico_path: *const c_char);
242    pub fn day_xaml_window_on_resize(win: *mut c_void, cb: extern "C" fn(c_int, c_int));
243    pub fn day_xaml_run(win: *mut c_void);
244    /// End the app — day-core's close policy decided the last primary window is gone.
245    pub fn day_xaml_quit();
246    /// The primary window was closed by the user: day-core applies the close policy and drives
247    /// the teardown, exactly as it does for a secondary window (docs/windows.md).
248    pub fn day_xaml_set_primary_closed_cb(cb: extern "C" fn());
249    /// Destroy the primary window's host, once day-core has released its root handle.
250    pub fn day_xaml_destroy_primary();
251    /// Appearance (docs/settings.md): the effective dark/light for the `dark_mode` duty, and a
252    /// callback fired when the user flips the system setting while the app runs.
253    pub fn day_xaml_set_appearance_cb(cb: extern "C" fn());
254    pub fn day_xaml_is_dark() -> c_int;
255    /// The app's own override: 0 follow the system, 1 light, 2 dark. Re-themes every live window.
256    pub fn day_xaml_set_appearance(mode: c_int);
257    /// The color of the theme resource `key` (a Fluent brush or color key) in the light
258    /// (`dark` 0) or dark appearance, as ARGB in `out`; 0 when no theme dictionary has it.
259    pub fn day_xaml_theme_color(key: *const c_char, dark: c_int, out: *mut c_uint) -> c_int;
260    /// 1 when the element is shown dark: its window's own scheme where it has one, else the
261    /// app's.
262    pub fn day_xaml_element_dark(h: *mut c_void) -> c_int;
263    /// Pass-through (docs/gestures.md): a label, image or divider takes no pointer input until
264    /// [`day_xaml_hit_on`].
265    pub fn day_xaml_set_passive(h: *mut c_void);
266    /// The node takes pointer input over its whole box from now on.
267    pub fn day_xaml_hit_on(h: *mut c_void);
268    /// Reduce motion (docs/accessibility.md): 1 while Windows' "Show animations" switch is off
269    /// (`UISettings.AnimationsEnabled` false), read fresh on every call.
270    pub fn day_xaml_reduce_motion() -> c_int;
271    /// Fire `cb` on the UI thread whenever that switch flips while the app runs. The shim
272    /// subscribes once; a later call only replaces the callback.
273    pub fn day_xaml_watch_reduce_motion(cb: extern "C" fn());
274    pub fn day_xaml_request_frame(token: u64, cb: extern "C" fn(u64, f64));
275    pub fn day_xaml_cancel_frame(token: u64);
276    pub fn day_xaml_post(cb: extern "C" fn(*mut c_void), data: *mut c_void);
277    /// Run `cb(data)` on the UI thread after `ms` milliseconds (a `SetTimer` armed there).
278    pub fn day_xaml_post_delayed(ms: u32, cb: extern "C" fn(*mut c_void), data: *mut c_void);
279
280    // containers
281    pub fn day_xaml_container_new() -> *mut c_void;
282    pub fn day_xaml_container_set_card(h: *mut c_void, radius: f64);
283    // A ScrollViewer (docs §7.6): returns the host; `out_content` receives the inner content Canvas
284    // (day adds children there and reports the content extent via set_content_size).
285    pub fn day_xaml_scroll_new(out_content: *mut *mut c_void, horizontal: c_int) -> *mut c_void;
286    pub fn day_xaml_scroll_set_content_size(content: *mut c_void, w: c_int, h: c_int);
287    pub fn day_xaml_scroll_offset(sv: *mut c_void, out_x: *mut c_double, out_y: *mut c_double);
288    pub fn day_xaml_scroll_to(sv: *mut c_void, y: c_int, h: c_int, animated: c_int);
289    pub fn day_xaml_container_set_bg(w: *mut c_void, argb: u32);
290    // Backend-executed animation (DESIGN.md §8.4): day passes a target value + intent and XAML's
291    // own compositor runs it. `dur_ms <= 0` sets the value outright. `curve`: 0 linear, 1 ease-in,
292    // 2 ease-out, 3 ease-in-out, 4 spring — the same encoding day-toolkit-qt's shim takes.
293    pub fn day_xaml_set_opacity(w: *mut c_void, opacity: c_double, anim: *const DayAnim);
294    /// The transform channels about the element's center, played under `anim` (null: at once).
295    pub fn day_xaml_set_transform(
296        w: *mut c_void,
297        tx: c_double,
298        ty: c_double,
299        sx: c_double,
300        sy: c_double,
301        rotate_deg: c_double,
302        anim: *const DayAnim,
303    );
304    /// A container's fill, played under `anim` from the color shown now (null: at once).
305    pub fn day_xaml_container_animate_bg(w: *mut c_void, argb: u32, anim: *const DayAnim);
306    /// An animated frame: position and size played under `anim` from the frame shown now.
307    pub fn day_xaml_set_geometry_animated(
308        w: *mut c_void,
309        x: c_double,
310        y: c_double,
311        width: c_double,
312        height: c_double,
313        anim: *const DayAnim,
314    );
315    /// What the element shows now (docs/tween.md): `out[0]` opacity, `out[1..3]` translation,
316    /// `out[3..7]` frame before any transform (window content space), `out[7..11]` a
317    /// container's fill as r, g, b, a. The result's bits say which were read: 1 opacity,
318    /// 2 translation, 4 frame, 8 fill.
319    pub fn day_xaml_read_displayed(w: *mut c_void, out: *mut c_double) -> c_int;
320    pub fn day_xaml_cover_ground(w: *mut c_void);
321    /// Best-effort rounded clip for a `corner_radius` container: a rounded `RectangleGeometry`
322    /// Clip whose Rect tracks the element size (`SizeChanged`). Corner support is limited on a bare
323    /// Canvas, so this is best-effort (docs).
324    pub fn day_xaml_container_set_corner(w: *mut c_void, radius: c_double);
325    /// Turn a container into a styled surface (docs/surfaces.md): a `Border` behind the
326    /// children that rounds only the corners in `corners` (`Corners::bits`: 1 top-left, 2
327    /// top-right, 4 bottom-right, 8 bottom-left) by `radius`, and, when `clips` is nonzero, a
328    /// Composition clip of that shape over the children. Call it before the setters below, which
329    /// do nothing on a container that is not a styled surface. Once it is one,
330    /// [`day_xaml_container_set_bg`] and [`day_xaml_container_animate_bg`] fill the `Border`.
331    /// Called again, it reshapes the surface in place; on a plain container it replaces the
332    /// plain fill and rounded clip.
333    pub fn day_xaml_container_set_surface(
334        w: *mut c_void,
335        radius: c_double,
336        corners: c_int,
337        clips: c_int,
338    );
339    /// A line of `width` points inside a styled surface's frame, following its corners, drawn
340    /// over the children. A width of zero removes it.
341    pub fn day_xaml_container_set_border(w: *mut c_void, argb: u32, width: c_double);
342    /// Fill a styled surface with a linear gradient between two unit points of its frame:
343    /// `line` is `[start x, start y, end x, end y]`; `offsets` and `colors` (ARGB) are `n`
344    /// parallel stops.
345    pub fn day_xaml_container_set_gradient(
346        w: *mut c_void,
347        line: *const c_double,
348        offsets: *const c_double,
349        colors: *const u32,
350        n: c_int,
351    );
352    /// The shadow of a styled surface's outline, outside its frame: a Composition `DropShadow`
353    /// of `argb`, `blur` points wide (twice the Gaussian's standard deviation), moved by
354    /// (`dx`, `dy`). Called again it updates the shadow; a transparent `argb` hides it.
355    pub fn day_xaml_container_set_shadow(
356        w: *mut c_void,
357        argb: u32,
358        blur: c_double,
359        dx: c_double,
360        dy: c_double,
361    );
362    /// Fill a styled surface with a radial gradient around the unit point (`cx`, `cy`) of its
363    /// frame, `radius` frame-widths across and frame-heights down; `offsets` and `colors` (ARGB)
364    /// are `n` parallel stops.
365    pub fn day_xaml_container_set_radial(
366        w: *mut c_void,
367        cx: c_double,
368        cy: c_double,
369        radius: c_double,
370        offsets: *const c_double,
371        colors: *const u32,
372        n: c_int,
373    );
374    /// Fill a styled surface with a conic gradient around the unit point (`cx`, `cy`) of its
375    /// frame, its first stop at `start_deg` clockwise from +x; drawn by the canvas painter at each size.
376    pub fn day_xaml_container_set_conic(
377        w: *mut c_void,
378        cx: c_double,
379        cy: c_double,
380        start_deg: c_double,
381        offsets: *const c_double,
382        colors: *const u32,
383        n: c_int,
384    );
385    /// The canvas painter's conic-gradient arithmetic, for tests: writes the ARGB color at
386    /// `turn` (0..=1 of a full turn) to `color` and the number of wedge edges to `edges`, and
387    /// returns the number of equal steps a fan reaching `reach` units is cut into.
388    #[cfg(feature = "winui")]
389    pub fn day_xaml_conic_probe(
390        offsets: *const c_double,
391        colors: *const u32,
392        n: c_int,
393        reach: c_double,
394        turn: c_double,
395        color: *mut u32,
396        edges: *mut c_int,
397    ) -> c_int;
398    /// A canvas that can hold keyboard focus (docs/menus.md): `handles` asks whether the app
399    /// claimed a key before the shim consumes it, `cb` delivers `(id, key_name, modifier_mask)`.
400    pub fn day_xaml_canvas_new(
401        id: u64,
402        handles: extern "C" fn(u64) -> c_int,
403        handles_text: extern "C" fn(u64) -> c_int,
404        cb: extern "C" fn(u64, *const c_char, *const c_char, c_int),
405    ) -> *mut c_void;
406    /// Render a canvas display list (`day_spec::encode_ops` output) into the Canvas.
407    pub fn day_xaml_canvas_set_ops(
408        w: *mut c_void,
409        nums: *const c_double,
410        n: c_int,
411        texts_joined: *const c_char,
412    );
413
414    // recycling list host (docs/list.md): a ScrollViewer + content Canvas
415    pub fn day_xaml_list_new(out_content: *mut *mut c_void) -> *mut c_void;
416    pub fn day_xaml_list_set_content_size(content: *mut c_void, w: c_int, h: c_int);
417    pub fn day_xaml_list_viewport(sv: *mut c_void, out_offset: *mut f64, out_height: *mut f64);
418    /// Report Escape over a presented sheet cover to `cb` (docs/cover.md "Modal sheet").
419    pub fn day_xaml_cover_escape(w: *mut c_void, node: u64, cb: extern "C" fn(u64));
420    pub fn day_xaml_list_keynav(sv: *mut c_void, node: u64, cb: extern "C" fn(u64, c_int) -> c_int);
421    pub fn day_xaml_list_on_scroll(sv: *mut c_void, node: u64, cb: extern "C" fn(u64));
422    // Emulated list drag-to-reorder (docs/list.md): the content Canvas accepts day-row drops —
423    // every hovered slot is vetted synchronously through `can` (accepted index or -1; the system
424    // shows the no-drop cursor on -1), and the drop commits via `mv`.
425    pub fn day_xaml_list_enable_reorder(
426        content: *mut c_void,
427        id: u64,
428        row_h: c_int,
429        can: extern "C" fn(u64, c_int, c_int) -> c_int,
430        mv: extern "C" fn(u64, c_int, c_int),
431    );
432    // Arm the WinRT drag start on one cell (cell index == row for its whole life).
433    pub fn day_xaml_cell_drag(cell: *mut c_void, id: u64, row: c_int);
434    // Emulated list row selection (docs/list.md): report a press on one cell as (node, row, mods)
435    // — mods bit 0 = ctrl (toggle), bit 1 = shift (range) — leaving the semantics to Rust. Also
436    // makes the cell hit-testable across its whole band.
437    pub fn day_xaml_list_cell_click(
438        cell: *mut c_void,
439        id: u64,
440        row: c_int,
441        cb: extern "C" fn(u64, c_int, c_int),
442    );
443    // Paint one cell's selected treatment (0 clears it).
444    pub fn day_xaml_cell_set_selected(cell: *mut c_void, on: c_int);
445
446    // navigation sidebar menu (docs/navigation.md): a single-select ListView. `sections_joined`
447    // runs parallel to `items_joined`, one line per row, naming the section title that opens
448    // before that row (an empty line for none). Indices in and out count rows only.
449    pub fn day_xaml_navlist_new(id: u64, cb: extern "C" fn(u64, c_int)) -> *mut c_void;
450    pub fn day_xaml_navlist_set_items(
451        w: *mut c_void,
452        items_joined: *const c_char,
453        sections_joined: *const c_char,
454    );
455    pub fn day_xaml_navlist_set_selected(w: *mut c_void, idx: c_int);
456
457    // native NavigationView split nav (docs/navigation.md): the idiomatic Windows sidebar+header,
458    // as in Settings. `out_content` receives the detail-page Canvas. Callbacks: sel(id, index) on a
459    // user menu pick; size(id, region, w, h) on a region reflow (region 0 = content, 1 = pane header);
460    // back(id) on the back button.
461    pub fn day_xaml_nav_new(
462        id: u64,
463        sel_cb: extern "C" fn(u64, c_int),
464        size_cb: extern "C" fn(u64, c_int, c_int, c_int),
465        back_cb: extern "C" fn(u64),
466        out_content: *mut *mut c_void,
467        stack: c_int,
468        rtl: c_int,
469        documents: c_int,
470        can_add: c_int,
471        new_label: *const c_char,
472        document_cb: extern "C" fn(u64, c_int, c_int, *const c_char),
473    ) -> *mut c_void;
474    pub fn day_xaml_document_chrome(host: *mut c_void, native: c_int);
475    pub fn day_xaml_document_items(nav: *mut c_void, titles: *const c_char, keys: *const c_char);
476    pub fn day_xaml_nav_set_items(
477        nav: *mut c_void,
478        items_joined: *const c_char,
479        icons_joined: *const c_char,
480        geoms_joined: *const c_char,
481        tints_joined: *const c_char,
482        badge_icons_joined: *const c_char,
483        badge_geoms_joined: *const c_char,
484        badge_tints_joined: *const c_char,
485        sections_joined: *const c_char,
486    );
487    pub fn day_xaml_nav_set_selected(nav: *mut c_void, idx: c_int);
488    // Inspector (docs/inspector.md): a right-pane SplitView. `out_content`/`out_panel` receive
489    // the two Canvas hosts; size(id, region, w, h) reports a region reflow (0 = content,
490    // 1 = panel), the NavigationView contract.
491    pub fn day_xaml_inspector_new(
492        id: u64,
493        panel_width: c_double,
494        open: c_int,
495        leading: c_int,
496        size_cb: extern "C" fn(u64, c_int, c_int, c_int),
497        out_content: *mut *mut c_void,
498        out_panel: *mut *mut c_void,
499    ) -> *mut c_void;
500    pub fn day_xaml_inspector_set_open(h: *mut c_void, open: c_int);
501    pub fn day_xaml_nav_set_pane_mode(nav: *mut c_void, mode: c_int);
502    pub fn day_xaml_nav_set_header(nav: *mut c_void, title: *const c_char);
503    pub fn day_xaml_nav_set_pane_header(nav: *mut c_void, element: *mut c_void);
504    pub fn day_xaml_nav_set_back_visible(nav: *mut c_void, visible: c_int);
505
506    // leaves
507    pub fn day_xaml_label_new(text: *const c_char, wraps: c_int) -> *mut c_void;
508    pub fn day_xaml_label_set_text(w: *mut c_void, text: *const c_char);
509    pub fn day_xaml_label_runs_begin(h: *mut c_void, node: u64);
510    /// Install the trampoline a link run's Hyperlink Click reports through (docs/text-runs.md).
511    pub fn day_xaml_label_link_cb(cb: extern "C" fn(u64, *const c_char));
512    pub fn day_xaml_label_runs_add(
513        h: *mut c_void,
514        text: *const c_char,
515        flags: c_int,
516        argb: u32,
517        bg_argb: u32,
518        scale_permille: c_int,
519        link: *const c_char,
520    );
521    pub fn day_xaml_label_set_font(
522        w: *mut c_void,
523        pt: c_double,
524        weight: c_int,
525        italic: c_int,
526        tabular: c_int,
527    );
528    /// Bundled custom font (§18.4): `spec` is a `FontFamily` source of the form
529    /// "<ms-appx:///fonts>/<file>#<family>" (the font staged under `<exe>/fonts/`).
530    /// The paragraph attributes of a label (docs/text.md): one line (`wraps` 0) or at most
531    /// `max_lines` (0 = unlimited) with an ellipsis, letter spacing in ems, line height as a
532    /// multiple of the font size (0 = the font's own).
533    pub fn day_xaml_label_set_paragraph(
534        w: *mut c_void,
535        wraps: c_int,
536        max_lines: c_int,
537        letter_ems: c_double,
538        line_multiple: c_double,
539    );
540    /// Whether the label was built to wrap (`LabelProps::wraps`).
541    pub fn day_xaml_label_wraps(w: *mut c_void) -> c_int;
542    /// The label's text, runs flattened: a heap copy for [`day_xaml_string_free`].
543    pub fn day_xaml_label_text(w: *mut c_void) -> *mut c_char;
544    /// Small capitals and old-style figures (`FontSpec::{small_caps, oldstyle_figures}`).
545    pub fn day_xaml_label_set_features(w: *mut c_void, small_caps: c_int, oldstyle: c_int);
546    /// Show an elided string while the accessible name keeps the whole text.
547    pub fn day_xaml_label_show_elided(w: *mut c_void, shown: *const c_char, full: *const c_char);
548    /// The one-line width of `text` in the label's font and letter spacing, in DIPs.
549    pub fn day_xaml_label_text_width(w: *mut c_void, text: *const c_char) -> c_double;
550    /// The label's own reading direction and its alignment (0 leading, 1 center, 2 trailing,
551    /// 3 justified) read against it.
552    pub fn day_xaml_label_set_direction(w: *mut c_void, rtl: c_int, align: c_int);
553    /// A leaf control's reading direction; panels are left alone.
554    pub fn day_xaml_set_flow_direction(w: *mut c_void, rtl: c_int);
555    /// Report the label's selection as UTF-16 offsets `(start, end)` whenever it changes.
556    pub fn day_xaml_label_report_selection(
557        w: *mut c_void,
558        id: u64,
559        cb: extern "C" fn(u64, c_int, c_int),
560    );
561    /// Windows' text-size factor (`UISettings.TextScaleFactor`).
562    pub fn day_xaml_text_scale() -> c_double;
563    /// Call `cb` on the UI thread whenever the text-size factor changes.
564    pub fn day_xaml_watch_text_scale(cb: extern "C" fn());
565    pub fn day_xaml_label_set_font_family(w: *mut c_void, spec: *const c_char);
566    /// Make a label's text user-selectable (the `.selectable()` modifier). No-op on non-labels.
567    pub fn day_xaml_label_set_selectable(w: *mut c_void, on: c_int);
568    /// TextBlock.Foreground = SolidColorBrush(argb); alpha 0 restores the inherited default.
569    pub fn day_xaml_label_set_color(w: *mut c_void, argb: u32);
570    /// The platform's secondary text color (`TextRole::Secondary`), theme-tracking.
571    pub fn day_xaml_label_set_secondary(w: *mut c_void);
572    /// Wrapped lines' alignment within the label's width: 0 leading, 1 center, 2 trailing.
573    pub fn day_xaml_label_set_align(w: *mut c_void, mode: c_int);
574
575    pub fn day_xaml_button_new(
576        title: *const c_char,
577        id: u64,
578        cb: extern "C" fn(u64),
579    ) -> *mut c_void;
580    pub fn day_xaml_button_set_style(h: *mut c_void, kind: c_int, argb: u32, fg_argb: u32);
581    /// `ButtonProps::selected`: the theme's accent fill on a plain Button (a `ToggleButton`'s
582    /// `IsChecked`), kept across a restyle and read back as `checked`.
583    pub fn day_xaml_button_set_selected(h: *mut c_void, on: c_int);
584    pub fn day_xaml_button_set_content(
585        h: *mut c_void,
586        title: *const c_char,
587        glyph: *const c_char,
588        image: *const c_char,
589        geometry: *const c_char,
590        icon_only: c_int,
591    );
592    pub fn day_xaml_button_set_title(w: *mut c_void, title: *const c_char);
593
594    pub fn day_xaml_toggle_new(on: c_int, id: u64, cb: extern "C" fn(u64, c_int)) -> *mut c_void;
595    pub fn day_xaml_toggle_set(w: *mut c_void, on: c_int);
596
597    pub fn day_xaml_slider_new(
598        value: f64,
599        min: f64,
600        max: f64,
601        step: f64,
602        id: u64,
603        cb: extern "C" fn(u64, f64, c_int),
604    ) -> *mut c_void;
605    pub fn day_xaml_slider_set(w: *mut c_void, value: f64);
606
607    pub fn day_xaml_progress_new(determinate: c_int, value: c_int) -> *mut c_void;
608    pub fn day_xaml_progress_is_ring(w: *mut c_void) -> c_int;
609    pub fn day_xaml_progress_set(w: *mut c_void, value: c_int);
610
611    pub fn day_xaml_tabs_new(id: u64, cb: extern "C" fn(u64, c_int)) -> *mut c_void;
612    pub fn day_xaml_tabs_add_page(
613        tabs: *mut c_void,
614        page: *mut c_void,
615        title: *const c_char,
616        index: c_int,
617    );
618    pub fn day_xaml_tabs_remove_page(tabs: *mut c_void, page: *mut c_void);
619    pub fn day_xaml_tabs_set_current(tabs: *mut c_void, index: c_int);
620    pub fn day_xaml_tabs_content_size(tabs: *mut c_void, w: *mut f64, h: *mut f64);
621
622    pub fn day_xaml_textbox_new(
623        text: *const c_char,
624        placeholder: *const c_char,
625        id: u64,
626        cb: extern "C" fn(u64, *const c_char),
627    ) -> *mut c_void;
628    pub fn day_xaml_textbox_set_text(w: *mut c_void, text: *const c_char);
629    pub fn day_xaml_textbox_set_placeholder(w: *mut c_void, text: *const c_char);
630    /// Select characters (Unicode scalar values) `start..end`, held to the text, caret at `end`
631    /// (docs/textfield.md "Selection"). A `PasswordBox` takes only a request for everything.
632    pub fn day_xaml_textbox_select(w: *mut c_void, start: c_int, end: c_int);
633    /// The callback a text field asks about its Up, Down and Escape (docs/textfield.md "Keys"):
634    /// `cb(node, name, modifiers)` answers 1 when the node claims the key, having reported it.
635    pub fn day_xaml_set_field_keys(cb: extern "C" fn(u64, *const c_char, c_int) -> c_int);
636    // Entry traits (docs/textfield.md). A secure field is a `PasswordBox`, a class of its own, so
637    // the two text setters above and every generic entry point accept either class.
638    /// 1 while the field is the secure class (`PasswordBox`).
639    pub fn day_xaml_field_is_secure(w: *mut c_void) -> c_int;
640    /// Rebuild the field as the secure class or the plain one, wired to the same callbacks
641    /// `day_xaml_textbox_new` and `day_xaml_enable_focus` take. Returns the replacement, already
642    /// in the old control's place and holding its text, state and focus, or null when the field
643    /// is that class already (or is not a text field). After a non-null return the caller owns
644    /// both handles and deletes `w`.
645    pub fn day_xaml_field_set_secure(
646        w: *mut c_void,
647        secure: c_int,
648        id: u64,
649        text_cb: extern "C" fn(u64, *const c_char),
650        focus_cb: extern "C" fn(u64, c_int),
651    ) -> *mut c_void;
652    /// The traits that are properties. `scope`: 0 default, 1 name, 2 email, 3 URL, 4 phone,
653    /// 5 number. `plain` turns spell checking and prediction off.
654    pub fn day_xaml_field_set_traits(w: *mut c_void, read_only: c_int, scope: c_int, plain: c_int);
655
656    /// `vertical`: 1 for a rule down a row (a 1px-wide Border), 0 for one across a column.
657    pub fn day_xaml_divider_new(vertical: c_int) -> *mut c_void;
658    pub fn day_xaml_image_new(uri: *const c_char, mode: c_int) -> *mut c_void;
659    // Raster images from bytes (docs/images.md): the shim holds the ENCODED buffer per id, since
660    // a `BitmapImage` is UI-thread-bound and decodes lazily.
661    /// Hold `bytes` under `id`; 0 when the buffer was empty.
662    pub fn day_xaml_image_decode(id: u64, bytes: *const u8, len: c_int) -> c_int;
663    /// Copy the bytes `id` holds into `out` (at most `cap`), returning the full length; 0 when
664    /// the id names nothing.
665    pub fn day_xaml_image_bytes(id: u64, out: *mut u8, cap: c_int) -> c_int;
666    /// Drop a held bitmap.
667    pub fn day_xaml_image_release(id: u64);
668    /// An image viewport over raw encoded bytes.
669    pub fn day_xaml_image_bytes_new(bytes: *const u8, len: c_int, mode: c_int) -> *mut c_void;
670    /// An image viewport over a bitmap already held under `id`.
671    pub fn day_xaml_image_bitmap_new(id: u64, mode: c_int) -> *mut c_void;
672    /// Replace the raster/vector content of a stable image viewport. A source that will not
673    /// load leaves the view as it was.
674    pub fn day_xaml_image_set_vector(w: *mut c_void, spec: *const c_char);
675    /// Tint (`tinted` nonzero) or untint an image viewport. A vector recomposes its brushes;
676    /// a raster (a file, bytes, a held bitmap) is recolored to `argb` keeping its alpha, on
677    /// WinUI, and the tint stays through later source swaps (docs/images.md "Tinting").
678    pub fn day_xaml_image_set_tint(w: *mut c_void, argb: u32, tinted: c_int);
679    /// A tinted image's tint color again, its tint mode kept; untinted images are left alone.
680    pub fn day_xaml_image_retint(w: *mut c_void, argb: u32);
681    pub fn day_xaml_image_set_uri(w: *mut c_void, uri: *const c_char);
682    pub fn day_xaml_image_set_bytes(w: *mut c_void, bytes: *const u8, len: c_int);
683    pub fn day_xaml_image_set_bitmap(w: *mut c_void, id: u64);
684    /// A vector glyph as real XAML `Path` geometry inside a scaling `Viewbox` (docs/vectors.md):
685    /// resolution-independent. `tinted` 1 composes `argb` over the shapes as a brush; 2 draws
686    /// them in the theme foreground brush (a template glyph, re-resolved on a theme change); 0
687    /// keeps the authored paints; 3 is an explicitly tinted template. Null when the spec
688    /// carried no drawable geometry, so the caller falls back to the raster.
689    pub fn day_xaml_vector_new(
690        spec: *const c_char,
691        mode: c_int,
692        argb: u32,
693        tinted: c_int,
694    ) -> *mut c_void;
695    /// A tinted vector glyph as a monochrome `BitmapIcon` — the raster fallback for art that
696    /// could not be converted to geometry. `tinted` as above (1 = `argb`, 2 = the theme
697    /// foreground); null when unresolved or `tinted` is 0.
698    pub fn day_xaml_image_tinted_new(
699        icon_file: *const c_char,
700        mode: c_int,
701        argb: u32,
702        tinted: c_int,
703    ) -> *mut c_void;
704
705    // External-piece / tweaks handle seam (docs/tweaks.md): box a WinRT ABI pointer into a day
706    // handle, and borrow the ABI pointer back out. `day_xaml_unbox` returns winrt::get_abi —
707    // a BORROWED IUIElement*, valid while the handle's Node holds its reference; callers that
708    // retain must copy_from_abi (AddRef) on their own side.
709    pub fn day_xaml_box(iinspectable_abi: *mut c_void) -> *mut c_void;
710    pub fn day_xaml_unbox(handle: *mut c_void) -> *mut c_void;
711
712    // tree / geometry / props
713    pub fn day_xaml_add_child(parent: *mut c_void, child: *mut c_void);
714    /// Move a child that already has a parent. [`day_xaml_add_child`] cannot: XAML allows one
715    /// logical parent, so appending an already-parented element throws and is swallowed.
716    pub fn day_xaml_reparent(parent: *mut c_void, child: *mut c_void);
717    pub fn day_xaml_remove_child(parent: *mut c_void, child: *mut c_void);
718    pub fn day_xaml_delete(w: *mut c_void);
719    pub fn day_xaml_set_geometry(w: *mut c_void, x: c_int, y: c_int, width: c_int, height: c_int);
720    /// Report template readiness for controls; other elements need no subscription.
721    pub fn day_xaml_on_control_loaded(w: *mut c_void, id: u64, cb: extern "C" fn(u64));
722    pub fn day_xaml_measure(
723        w: *mut c_void,
724        avail_w: c_double,
725        avail_h: c_double,
726        out_w: *mut c_double,
727        out_h: *mut c_double,
728    );
729    pub fn day_xaml_set_enabled(w: *mut c_void, enabled: c_int);
730    pub fn day_xaml_set_visible(w: *mut c_void, visible: c_int);
731    pub fn day_xaml_widget_size(w: *mut c_void, out_w: *mut f64, out_h: *mut f64);
732    /// First text baseline from the element's top for a box `box_h` tall; `-1` ⇒ no text
733    /// (docs/baseline.md).
734    pub fn day_xaml_baseline(w: *mut c_void, box_h: f64) -> f64;
735    pub fn day_xaml_set_name(w: *mut c_void, name: *const c_char);
736    /// A node's accessibility annotations (docs/accessibility.md), each applied only when set:
737    /// a null or empty string, role 0 and hidden 0 leave the element alone. `role` is
738    /// `day_spec::Role`'s declaration order (0 None, 1 Button, 2 Toggle, 3 Slider, 4 `TextInput`,
739    /// 5 Heading, 6 Image, 7 Meter, 8 Group, 9 Tree, 10 `TreeItem`, 11 Tab, 12 `TabList`); `level` is the 1-based
740    /// heading level, read only with role 5. The automation id stays with [`day_xaml_set_name`].
741    pub fn day_xaml_set_a11y(
742        w: *mut c_void,
743        label: *const c_char,
744        hint: *const c_char,
745        value: *const c_char,
746        role: c_int,
747        level: c_int,
748        hidden: c_int,
749    );
750    /// Read back what the element's native control reports into `out` (see
751    /// [`DayXamlNative`]); every string in it is released with [`day_xaml_string_free`].
752    pub fn day_xaml_read_native(w: *mut c_void, out: *mut DayXamlNative);
753    /// Speak `text` through the screen reader without moving its focus — a UIA notification
754    /// raised from the primary window's tree; `urgent` != 0 interrupts the current speech.
755    /// Nothing happens before the window exists or with no screen reader listening.
756    pub fn day_xaml_announce(text: *const c_char, urgent: c_int);
757
758    // gestures (docs/shapes.md): attach a native recognizer. kind 0 Tap / 1 LongPress / 2 Drag /
759    // 3 Hover / 4 Pinch / 5 Pan (every wheel tick, a canvas) / 6 Pan (sideways ticks only, a
760    // container) / 7 Rotate; cb(id, phase, x, y, tx, ty) with phase 0 Tap, 1/2/3 Drag
761    // Began/Changed/Ended, 4 LongPress, 5/6/7 Pinch Began/Changed/Ended (tx = scale), 8 Pan
762    // (tx,ty = delta), 10/11/12 Hover Began/Changed/Ended, 13/14/15 Rotate Began/Changed/Ended
763    // (tx = cumulative radians, clockwise positive).
764    pub fn day_xaml_enable_gesture(
765        elem: *mut c_void,
766        id: u64,
767        kind: c_int,
768        cb: extern "C" fn(u64, c_int, c_double, c_double, c_double, c_double),
769    );
770
771    /// Where the touches recognizer (`day_xaml_enable_gesture` kind 10) reports: the node and
772    /// its contacts as `"id,phase,x,y,pressure,kind;…"` (phase 0 began, 1 moved, 2 stationary,
773    /// 3 ended, 4 cancelled; kind 0 touch, 1 mouse, 2 stylus), valid for the call.
774    pub fn day_xaml_set_touches_cb(cb: extern "C" fn(u64, *const c_char));
775    /// Grow the area in which a container takes pointer input by the four insets, in DIPs
776    /// (docs/gestures.md "Hit slop"); all zero restores its own bounds. Panels only.
777    pub fn day_xaml_set_hit_slop(
778        elem: *mut c_void,
779        left: c_double,
780        top: c_double,
781        right: c_double,
782        bottom: c_double,
783    );
784    /// The drag's axis: 0 any direction, 1 horizontal, 2 vertical (docs/gestures.md).
785    pub fn day_xaml_set_drag_axis(elem: *mut c_void, axis: c_int);
786    /// Make a container a tab stop that routes keys like a canvas and reports its own focus
787    /// changes (docs/focus.md); a control is made a tab stop only. WinUI only.
788    pub fn day_xaml_set_focusable(
789        elem: *mut c_void,
790        id: u64,
791        handles: extern "C" fn(u64) -> c_int,
792        handles_text: extern "C" fn(u64) -> c_int,
793        key_cb: extern "C" fn(u64, *const c_char, *const c_char, c_int),
794        focus_cb: extern "C" fn(u64, c_int),
795    );
796    /// Disable (0) or re-enable (1) every control under `elem` and its pointer input
797    /// (docs/forms.md "Disabling a group"); nested calls count.
798    pub fn day_xaml_set_subtree_enabled(elem: *mut c_void, enabled: c_int);
799    /// The input kind at launch: 0 touch, 1 mouse, 2 stylus (docs/gestures.md "Input kind").
800    pub fn day_xaml_primary_pointer() -> c_int;
801    /// Where a change of input kind is reported, with the same codes.
802    pub fn day_xaml_set_pointer_kind_cb(cb: extern "C" fn(c_int));
803
804    // focus (docs/focus.md): observe via GotFocus/LostFocus (kind 1 gained / 0 lost / 2
805    // submitted); drive via Focus(Programmatic), resigning to the window's focus sink.
806    pub fn day_xaml_enable_focus(elem: *mut c_void, id: u64, cb: extern "C" fn(u64, c_int));
807    pub fn day_xaml_control_focus(elem: *mut c_void, focused: c_int);
808
809    /// Capture the window's client area to a PNG file. Returns 0 on success.
810    pub fn day_xaml_snapshot_png(win: *mut c_void, path: *const c_char) -> c_int;
811    /// The same capture against a SECONDARY window's token — a `screenshot: { window: … }` step.
812    pub fn day_xaml_snapshot_png2(win: *mut c_void, path: *const c_char) -> c_int;
813    /// Where the content sits in `day_xaml_snapshot_png`'s capture, in DIPs, written to
814    /// `out[0..2]` as x, y. Returns 0 on success.
815    pub fn day_xaml_snapshot_origin(win: *mut c_void, out: *mut f64) -> c_int;
816
817    // Canvas fonts (docs/fonts.md).
818    /// The DirectWrite system font collection in Day's font-list text; a heap string to
819    /// release with [`day_xaml_string_free`].
820    pub fn day_xaml_font_families() -> *mut c_char;
821    /// Release a string returned by [`day_xaml_font_families`]. Safe to call with null.
822    pub fn day_xaml_string_free(p: *mut c_char);
823    /// Measure one line of canvas text; `out` (3 doubles) receives width, height, ascent.
824    /// Returns 0 on success.
825    pub fn day_xaml_measure_text(
826        text: *const c_char,
827        size: f64,
828        weight: c_int,
829        italic: c_int,
830        family: *const c_char,
831        out: *mut f64,
832    ) -> c_int;
833
834    // lifecycle (docs/lifecycle.md): phase codes match day_spec::Lifecycle order.
835    pub fn day_xaml_set_lifecycle_cb(cb: extern "C" fn(c_int));
836
837    /// Open a URL in the system's default handler (the `link` piece's seam).
838    pub fn day_xaml_open_url(url: *const c_char);
839
840    // menus (docs/menus.md): a tab/newline spec parsed by the shim into MenuFlyout / MenuBar.
841    pub fn day_xaml_set_menu_cb(cb: extern "C" fn(u64));
842    pub fn day_xaml_set_context_menu(elem: *mut c_void, spec: *const c_char);
843    /// Show `spec` (the menu serialization `day_xaml_set_context_menu` takes) as a menu under
844    /// the button `elem` (docs/menus.md "Menu buttons").
845    pub fn day_xaml_show_button_menu(elem: *mut c_void, spec: *const c_char);
846    pub fn day_xaml_set_app_menu(win: *mut c_void, spec: *const c_char);
847
848    // Window toolbar (docs/toolbars.md): a CommandBar under the menu bar, edited one item at a
849    // time. Each item crosses as its own tab/newline spec, the same format the menus use (the
850    // format is documented on both sides — `serialize_toolbar` in day-toolkit-winui, the parser in
851    // shim.cpp). Buttons ride `day_xaml_set_menu_cb`; values arrive on the toolbar callback as
852    // (action, kind, on, text) with kind 0 = toggle, 1 = search text, 2 = segment index.
853    pub fn day_xaml_set_toolbar_cb(cb: extern "C" fn(u64, c_int, c_int, *const c_char));
854    /// Put the item `spec` describes at position `index` of window `win`'s bar (`secondary` != 0:
855    /// `win` is a secondary window).
856    pub fn day_xaml_toolbar_insert(
857        win: *mut c_void,
858        secondary: c_int,
859        index: c_int,
860        spec: *const c_char,
861    );
862    /// Take item `id` off window `win`'s bar.
863    pub fn day_xaml_toolbar_remove(win: *mut c_void, id: *const c_char);
864    /// End an edit: undock an empty bar and lay the window's chrome out.
865    pub fn day_xaml_toolbar_done(win: *mut c_void, secondary: c_int);
866    // Targeted patches, addressed by the item's id (no-op if the bar has no such item).
867    // Targeted item patches. `win` is the window whose toolbar owns the item: every window
868    // installs the same item ids, so a patch has to name the window as well as the id.
869    pub fn day_xaml_toolbar_focus(win: *mut c_void, id: *const c_char);
870    pub fn day_xaml_toolbar_set_text(win: *mut c_void, id: *const c_char, text: *const c_char);
871    pub fn day_xaml_toolbar_set_checked(win: *mut c_void, id: *const c_char, on: c_int);
872    pub fn day_xaml_toolbar_set_selected(win: *mut c_void, id: *const c_char, index: c_int);
873    pub fn day_xaml_toolbar_set_enabled(win: *mut c_void, id: *const c_char, on: c_int);
874    /// The app menu docked in a SECONDARY window (docs/windows.md): day's app menu has no
875    /// window parameter, so the same spec is installed into each window that opens.
876    pub fn day_xaml_window_set_menu2(win: *mut c_void, spec: *const c_char);
877    // Show/hide the split NavigationView's pane — the `SidebarToggle` item's behavior, also
878    // reachable from dayscript through the toolkit duty. 0 = no split nav in this window.
879    pub fn day_xaml_toggle_sidebar() -> c_int;
880    // Completions for a toolbar search field: the AutoSuggestBox's own ItemsSource
881    // (docs/search.md). Unit-separated (\x1f) list; empty clears it.
882    pub fn day_xaml_toolbar_set_suggestions(
883        win: *mut c_void,
884        id: *const c_char,
885        joined: *const c_char,
886    );
887
888    // present / dismiss (docs/dialogs.md): ContentDialog (alert/prompt) + WinRT file pickers.
889    // The cb delivers a result as (req, tag, index, text) — tag matches PresentResult::decode.
890    pub fn day_xaml_set_present_cb(cb: extern "C" fn(u64, c_int, i64, *const c_char));
891    pub fn day_xaml_present_dialog(
892        req: u64,
893        title: *const c_char,
894        message: *const c_char,
895        buttons_joined: *const c_char,
896        roles_joined: *const c_char,
897        win: *mut c_void,
898    );
899    pub fn day_xaml_present_prompt(
900        req: u64,
901        title: *const c_char,
902        message: *const c_char,
903        placeholder: *const c_char,
904        initial: *const c_char,
905        ok: *const c_char,
906        cancel: *const c_char,
907        win: *mut c_void,
908    );
909    /// `multiple` ≠ 0 picks several files (`PickMultipleFilesAsync`); the answer joins every
910    /// chosen path with the unit separator (tag 3, `PresentResult::decode`).
911    pub fn day_xaml_present_file_open(
912        req: u64,
913        title: *const c_char,
914        filters_joined: *const c_char,
915        multiple: c_int,
916        win: *mut c_void,
917    );
918    /// A WinRT `FolderPicker`, answered like a file.
919    pub fn day_xaml_present_folder_open(req: u64, title: *const c_char, win: *mut c_void);
920    pub fn day_xaml_present_file_save(
921        req: u64,
922        title: *const c_char,
923        suggested: *const c_char,
924        filters_joined: *const c_char,
925        win: *mut c_void,
926    );
927    pub fn day_xaml_dismiss_present(req: u64);
928}
929
930unsafe extern "C" {
931    pub fn day_xaml_tree_new(
932        id: u64,
933        height: f64,
934        indent: f64,
935        selectable: c_int,
936        multi: c_int,
937        expanded: extern "C" fn(u64, u64, c_int),
938        selected: extern "C" fn(u64, *const u64, c_int),
939        viewport: extern "C" fn(*mut c_void),
940    ) -> *mut c_void;
941    pub fn day_xaml_tree_begin(w: *mut c_void);
942    pub fn day_xaml_tree_add(
943        w: *mut c_void,
944        token: u64,
945        parent: u64,
946        has_parent: c_int,
947        text: *const c_char,
948        expandable: c_int,
949        header: c_int,
950        open: c_int,
951    );
952    pub fn day_xaml_tree_end(w: *mut c_void);
953    pub fn day_xaml_tree_cell(w: *mut c_void, token: u64) -> *mut c_void;
954    pub fn day_xaml_tree_frame(w: *mut c_void, token: u64, width: *mut f64) -> c_int;
955    pub fn day_xaml_tree_expand(w: *mut c_void, token: u64, open: c_int);
956    pub fn day_xaml_tree_select(w: *mut c_void, tokens: *const u64, len: c_int);
957    pub fn day_xaml_tree_reveal(w: *mut c_void, token: u64);
958}
959
960unsafe extern "C" {
961    pub fn day_xaml_tree_forget(w: *mut c_void);
962    pub fn day_xaml_nav_custom_sidebar(w: *mut c_void, page: *mut c_void);
963}
964
965#[cfg(feature = "winui")]
966#[repr(C)]
967#[derive(Clone, Copy)]
968pub struct DayWinuiListCell {
969    pub cell: *mut std::ffi::c_void,
970    pub row: i32,
971    pub generation: u64,
972    pub width: f64,
973    pub visible: i32,
974}
975
976#[cfg(feature = "winui")]
977unsafe extern "C" {
978    pub fn day_winui_list_new(
979        pitch: f64,
980        selectable: i32,
981        activatable: i32,
982        reorderable: i32,
983        changed: extern "C" fn(*mut c_void),
984        selected: extern "C" fn(*mut c_void, i32, i32),
985        offer: extern "C" fn(*mut c_void, *mut c_void, i32),
986        action: extern "C" fn(*mut c_void, i32, u64, i32, i32),
987        can_move: extern "C" fn(*mut c_void, i32, i32) -> i32,
988        moved: extern "C" fn(*mut c_void, i32, i32),
989        reader: extern "C" fn(*mut c_void),
990    ) -> *mut c_void;
991    pub fn day_winui_list_forget(host: *mut c_void);
992    pub fn day_winui_list_frame(host: *mut c_void, width: f64, height: f64);
993    pub fn day_winui_list_reload(host: *mut c_void, count: i32);
994    pub fn day_winui_list_layout(host: *mut c_void);
995    pub fn day_winui_list_cells(
996        host: *mut c_void,
997        out: *mut DayWinuiListCell,
998        capacity: i32,
999    ) -> i32;
1000    pub fn day_winui_list_cell_size(
1001        host: *mut c_void,
1002        cell: *mut c_void,
1003        generation: u64,
1004        width: f64,
1005        height: f64,
1006    );
1007    pub fn day_winui_list_scroll(host: *mut c_void, row: i32);
1008    /// Scroll preferences and reports (docs/scroll.md): hidden bars, snapping (0 none, 1 page,
1009    /// 2 every `interval`), zoom between `zoom_min` and `zoom_max` (0 = no zoom), and the
1010    /// reports `cb(id, kind, a, b)`: kind 0 the offset, 1 the phase (0 idle, 1 dragging,
1011    /// 2 coasting), 2 the zoom scale.
1012    pub fn day_xaml_scroll_configure(
1013        sv: *mut c_void,
1014        id: u64,
1015        hide_bars: c_int,
1016        snap: c_int,
1017        interval: c_double,
1018        zoom_min: c_double,
1019        zoom_max: c_double,
1020        track_offset: c_int,
1021        track_phase: c_int,
1022        cb: extern "C" fn(u64, c_int, c_double, c_double),
1023    );
1024    /// Zoom to `scale` about the viewport's center, animated or not.
1025    pub fn day_xaml_scroll_zoom(sv: *mut c_void, scale: c_double, animated: c_int);
1026    /// Scroll row `row` (-1: the end of the content) into view with an alignment (0 nearest,
1027    /// 1 start, 2 center, 3 end), animated or not (docs/list.md).
1028    pub fn day_winui_list_scroll_to(host: *mut c_void, row: i32, align: c_int, animated: c_int);
1029    /// 1 while the list's own scroll is still on its way: a row jump that has not reached its
1030    /// row, or an animated one still moving, on a shown list; each for a bounded time only
1031    /// (`Toolkit::ui_idle`, docs/list.md "Visible rows").
1032    pub fn day_winui_list_settling(host: *mut c_void) -> c_int;
1033    /// The scroll extent, offset and viewport height, in DIPs.
1034    pub fn day_winui_list_metrics(
1035        host: *mut c_void,
1036        extent: *mut c_double,
1037        offset: *mut c_double,
1038        viewport: *mut c_double,
1039    );
1040    /// The list's supplementary rows (no row chrome, never pinned), sent before each reload.
1041    pub fn day_winui_list_plain(host: *mut c_void, rows: *const i32, len: i32);
1042    pub fn day_winui_list_select(host: *mut c_void, rows: *const i32, len: i32);
1043    pub fn day_winui_list_actions_begin(host: *mut c_void, cell: *mut c_void);
1044    pub fn day_winui_list_action_add(
1045        host: *mut c_void,
1046        cell: *mut c_void,
1047        token: u64,
1048        edge: i32,
1049        index: i32,
1050        label: *const c_char,
1051        glyph: *const c_char,
1052        destructive: i32,
1053        color: *const f64,
1054    );
1055    pub fn day_winui_list_actions_end(host: *mut c_void, cell: *mut c_void);
1056    /// A sectioned list's header rows; the first call makes the pinned header.
1057    pub fn day_winui_list_headers(host: *mut c_void, rows: *const i32, len: i32);
1058    /// The header row the pinned copy should show (-1 for none), with its cell and width.
1059    pub fn day_winui_list_pinned(host: *mut c_void, cell: *mut *mut c_void, width: *mut f64)
1060    -> i32;
1061    /// The pinned copy now holds header `row`, laid out at `width` × `height`.
1062    pub fn day_winui_list_pinned_bound(host: *mut c_void, row: i32, width: f64, height: f64);
1063}