day_toolkit_qt_sys/lib.rs
1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4//! day-toolkit-qt-sys — raw `extern "C"` declarations for the Qt 6 shim compiled by build.rs.
5//! Handles are opaque `QWidget*`; ownership stays with Qt's parent/child tree (Day's release
6//! calls `day_qt_delete` = deleteLater, per §4.3's deferred-destruction allowance).
7
8use std::os::raw::{c_char, c_double, c_int, c_void};
9
10unsafe extern "C" {
11 pub fn day_qt_app_new(app_name: *const c_char) -> *mut c_void;
12 pub fn day_qt_app_run(app: *mut c_void);
13 pub fn day_qt_window_new(title: *const c_char, w: c_int, h: c_int) -> *mut c_void;
14 pub fn day_qt_window_show(win: *mut c_void);
15 pub fn day_qt_window_on_resize(win: *mut c_void, cb: extern "C" fn(c_int, c_int));
16 // Secondary windows (docs/windows.md): per-window event callbacks keyed by day node id.
17 pub fn day_qt_set_window_events_cb(
18 resized: extern "C" fn(u64, c_int, c_int),
19 closed: extern "C" fn(u64),
20 focused: extern "C" fn(u64, c_int),
21 );
22 pub fn day_qt_window_new2(
23 title: *const c_char,
24 w: c_int,
25 h: c_int,
26 node: u64,
27 fixed: c_int,
28 ) -> *mut c_void;
29 pub fn day_qt_window_content(win: *mut c_void) -> *mut c_void;
30 #[cfg(target_os = "macos")]
31 pub fn day_qt_window_nsview(window: *mut c_void) -> *mut c_void;
32 pub fn day_qt_window_close(win: *mut c_void);
33 pub fn day_qt_window_raise(win: *mut c_void);
34 pub fn day_qt_window_set_title(win: *mut c_void, title: *const c_char);
35 pub fn day_qt_window_destroy(win: *mut c_void);
36 pub fn day_qt_window_is_active(win: *mut c_void) -> c_int;
37 /// Display-state reports for every Day window (docs/windows.md "Window properties"): the
38 /// window's node id (0 = the primary) and a `day_spec::WindowState` code.
39 pub fn day_qt_set_window_state_cb(state: extern "C" fn(u64, c_int));
40 /// Ask for a display state by `day_spec::WindowState` code (showNormal / showMinimized /
41 /// showMaximized / showFullScreen); the outcome comes back through the state callback.
42 pub fn day_qt_window_set_state(win: *mut c_void, code: c_int);
43
44 // The desktop shell (docs/window-chrome.md, docs/windows.md, docs/status-item.md).
45 /// Keep the process when the primary window closes; its close then reports as node 0.
46 pub fn day_qt_set_keep_running(on: c_int);
47 /// `QCoreApplication::quit`.
48 pub fn day_qt_quit();
49 /// Whether Qt runs on its Wayland platform (no window positions there).
50 pub fn day_qt_is_wayland() -> c_int;
51 /// The chrome a window opens with, before it is first shown.
52 pub fn day_qt_window_set_chrome(
53 win: *mut c_void,
54 frameless: c_int,
55 transparent: c_int,
56 shadow: c_int,
57 resizable: c_int,
58 );
59 /// Open position: 1 centered, 2 at (x, y).
60 pub fn day_qt_window_place(win: *mut c_void, mode: c_int, x: c_double, y: c_double);
61 /// Move (frame top-left) and/or resize (content size).
62 pub fn day_qt_window_set_frame(
63 win: *mut c_void,
64 has_origin: c_int,
65 x: c_double,
66 y: c_double,
67 has_size: c_int,
68 w: c_double,
69 h: c_double,
70 );
71 /// Resize to `w`×`h` of content and keep it there (`WindowOptions::size_to_fit`): a
72 /// fixed-size panel moves its pin, a resizable window just resizes.
73 pub fn day_qt_window_fit(win: *mut c_void, w: c_double, h: c_double);
74 /// The frame into `out[4]`; 0 where the platform does not say.
75 pub fn day_qt_window_frame(win: *mut c_void, out: *mut c_double) -> c_int;
76 /// Content-size limits; negative lifts a bound.
77 pub fn day_qt_window_set_limits(
78 win: *mut c_void,
79 min_w: c_double,
80 min_h: c_double,
81 max_w: c_double,
82 max_h: c_double,
83 );
84 /// 0 on top, 1 tool window, 2 minimize, 3 maximize, 4 close button, 5 resizable, 6 visible.
85 pub fn day_qt_window_set_switch(win: *mut c_void, which: c_int, on: c_int);
86 pub fn day_qt_window_alert(win: *mut c_void, critical: c_int);
87 pub fn day_qt_screen_count() -> c_int;
88 /// `out[9]`: frame, work area, scale. Returns 1 primary, 0 other, -1 out of range.
89 pub fn day_qt_screen_info(
90 i: c_int,
91 out: *mut c_double,
92 name: *mut c_char,
93 name_len: c_int,
94 id: *mut c_char,
95 id_len: c_int,
96 ) -> c_int;
97 pub fn day_qt_set_drag_region(widget: *mut c_void, on: c_int);
98 pub fn day_qt_tray_available() -> c_int;
99 pub fn day_qt_tray_new() -> *mut c_void;
100 pub fn day_qt_tray_update(
101 tray: *mut c_void,
102 icon: *const c_char,
103 fallback: c_int,
104 mask: c_int,
105 tooltip: *const c_char,
106 menu: *mut c_void,
107 activate: u64,
108 );
109 pub fn day_qt_tray_delete(tray: *mut c_void);
110 pub fn day_qt_container_new() -> *mut c_void;
111 pub fn day_qt_app_set_rtl();
112 pub fn day_qt_open_url(url: *const c_char);
113 #[cfg(target_os = "macos")]
114 pub fn day_qt_share_url(url: *const c_char, title: *const c_char) -> bool;
115 /// The widget's opacity, shown through its `DayEffect`: at once with a null `anim`, which
116 /// also stops a run in flight, or animated under `anim` from the opacity shown now.
117 pub fn day_qt_set_opacity(w: *mut c_void, opacity: f64, anim: *const DayQtAnim);
118 /// The widget's transform (translation in points, scale, rotation in degrees about its
119 /// center), shown through its `DayEffect`, at once or animated as `day_qt_set_opacity` is.
120 pub fn day_qt_set_transform(
121 w: *mut c_void,
122 tx: f64,
123 ty: f64,
124 sx: f64,
125 sy: f64,
126 rot: f64,
127 anim: *const DayQtAnim,
128 );
129 /// The widget's frame in its parent, at once or animated as `day_qt_set_opacity` is.
130 pub fn day_qt_set_frame(
131 w: *mut c_void,
132 x: c_int,
133 y: c_int,
134 width: c_int,
135 height: c_int,
136 anim: *const DayQtAnim,
137 );
138 /// What the widget shows now, mid-animation included (`Toolkit::read_displayed`).
139 pub fn day_qt_read_displayed(w: *mut c_void, out: *mut DayQtDisplayed);
140 /// Update only the background color, preserving the corner radius captured by the last
141 /// `day_qt_widget_set_surface` (so a reactive `.background` keeps its rounded corners).
142 /// Animated under `anim` from the fill shown now when both ends are a fill; at once
143 /// otherwise.
144 pub fn day_qt_widget_set_bg(
145 w: *mut c_void,
146 r: c_double,
147 g: c_double,
148 b: c_double,
149 a: c_double,
150 anim: *const DayQtAnim,
151 );
152 /// A styled surface (docs/surfaces.md): fill or gradient, per-corner rounding, border and
153 /// shadow on one container. `spec` is 24 numbers (fill r,g,b,a · radius · corner bits ·
154 /// clips · border r,g,b,a · border width · shadow r,g,b,a · shadow blur, dx, dy ·
155 /// gradient kind (0 none, 1 linear, 2 radial, 3 conic) · the gradient's four numbers:
156 /// linear start x,y and end x,y, radial center x,y and radius, conic center x,y and start
157 /// degrees clockwise from +x) and `stops` is `n_stops` groups of (offset, r, g, b, a),
158 /// ascending; `stops` may be null when `n_stops` is 0. The border is drawn over the
159 /// container's children. Idempotent: sent again for a reactive surface and on an
160 /// appearance switch.
161 pub fn day_qt_widget_set_styled_surface(
162 w: *mut c_void,
163 spec: *const c_double,
164 stops: *const c_double,
165 n_stops: c_int,
166 );
167 /// Nonzero once the container paints its own surface (`day_qt_widget_set_styled_surface`).
168 pub fn day_qt_widget_has_styled_surface(w: *mut c_void) -> c_int;
169 pub fn day_qt_widget_set_section_card(w: *mut c_void, radius: f64);
170 /// `SurfaceRole::Window`: the window's own background (`palette(window)`), rounded and, with
171 /// `clips`, clipping its children to the rounding.
172 pub fn day_qt_widget_set_window_surface(w: *mut c_void, radius: f64, clips: c_int);
173 /// `QWidget::setCursor(Qt::CursorShape)`; a negative shape unsets it (docs/cursor.md).
174 pub fn day_qt_widget_set_cursor(w: *mut c_void, shape: c_int);
175 /// Apply a `background`/`corner_radius` surface via a scoped stylesheet (`#objName { ... }`
176 /// so children don't inherit the fill) + `WA_StyledBackground`. `r,g,b` are 0..1, `a` is the
177 /// alpha 0..1; `radius` in px; `clips != 0` requests rounded-child clipping (best-effort).
178 pub fn day_qt_widget_set_surface(
179 w: *mut c_void,
180 r: c_double,
181 g: c_double,
182 b: c_double,
183 a: c_double,
184 radius: c_double,
185 clips: c_int,
186 );
187
188 /// Nonzero when Qt's palette is a dark one (system scheme, `DAY_THEME`, or the
189 /// pre-6.8 Fusion fallback alike).
190 pub fn day_qt_dark_mode() -> c_int;
191 /// The application palette's color for the `day_spec::SystemColor` wire number `role`,
192 /// written to `rgba` (0..1); 0 when the palette has no color for that role.
193 pub fn day_qt_system_color(role: c_int, rgba: *mut c_double) -> c_int;
194 /// Day's appearance override: 1 dark, 0 light, -1 the system's again
195 /// (`QStyleHints::setColorScheme`, Qt 6.8+). Nonzero when the request was made.
196 pub fn day_qt_set_appearance(mode: c_int) -> c_int;
197 /// Nonzero when this Qt can override the color scheme (6.8+).
198 pub fn day_qt_appearance_settable() -> c_int;
199 /// Called once per turn of the event loop after the palette or the color scheme changed.
200 pub fn day_qt_on_appearance(cb: extern "C" fn());
201
202 pub fn day_qt_label_new(text: *const c_char, wraps: c_int) -> *mut c_void;
203 pub fn day_qt_label_set_text(w: *mut c_void, text: *const c_char);
204 /// 0 leading, 1 center, 2 trailing, 3 justified; leading and trailing follow the label's
205 /// direction.
206 pub fn day_qt_label_set_align(w: *mut c_void, align: c_int);
207 pub fn day_qt_label_set_rich_text(w: *mut c_void, html: *const c_char);
208 pub fn day_qt_label_on_link(w: *mut c_void, id: u64, cb: extern "C" fn(u64, *const c_char));
209 /// The label's base font. `tabular`, `small_caps` and `oldstyle` ask the face for the
210 /// OpenType `tnum`, `smcp` and `onum` features (Qt 6.7+).
211 pub fn day_qt_label_set_font(
212 w: *mut c_void,
213 pt: c_double,
214 weight: c_int,
215 italic: c_int,
216 tabular: c_int,
217 small_caps: c_int,
218 oldstyle: c_int,
219 );
220 /// The paragraph attributes, whole (docs/text.md): the line limit (0 = unlimited), the
221 /// truncation mode (0 tail, 1 head, 2 middle), the letter spacing in ems and the line height
222 /// as a multiple of the font size (nonpositive = natural). Idempotent.
223 pub fn day_qt_label_set_paragraph(
224 w: *mut c_void,
225 max_lines: c_int,
226 truncation: c_int,
227 letter_em: c_double,
228 line_multiple: c_double,
229 );
230 /// Report the reader's selection in the label to `cb(id, start, end)`, byte offsets into
231 /// the text the label displays (`start == end` when cleared).
232 pub fn day_qt_label_on_selection(w: *mut c_void, id: u64, cb: extern "C" fn(u64, c_int, c_int));
233 /// The widget's own reading direction (`Toolkit::set_layout_direction`).
234 pub fn day_qt_widget_set_direction(w: *mut c_void, rtl: c_int);
235 /// The desktop's text-size factor for Day's point-sized text (1.0 at the default).
236 pub fn day_qt_text_scale() -> c_double;
237 /// Call `cb` when [`day_qt_text_scale`] may have changed.
238 pub fn day_qt_on_text_scale(cb: extern "C" fn());
239 /// The label's unwrapped single-line natural width (font metrics — not the sizeHint
240 /// heuristic, which suggests a narrow "readable" column for word-wrapped labels).
241 pub fn day_qt_label_natural_width(w: *mut c_void) -> c_int;
242 /// Text color via the label palette (`on == 0` restores the theme default).
243 pub fn day_qt_label_set_color(
244 w: *mut c_void,
245 r: c_double,
246 g: c_double,
247 b: c_double,
248 a: c_double,
249 on: c_int,
250 );
251 /// Swap the label's font family to a bundled one (after `day_qt_label_set_font`).
252 pub fn day_qt_label_set_font_family(w: *mut c_void, family: *const c_char);
253 pub fn day_qt_label_set_monospace(w: *mut c_void);
254 /// Make a label's text user-selectable (the `.selectable()` modifier). No-op on non-labels.
255 pub fn day_qt_label_set_selectable(w: *mut c_void, on: c_int);
256 /// `QFontDatabase::addApplicationFont` — returns the font id (>= 0) or -1 on failure.
257 /// Requires a constructed `QApplication`.
258 pub fn day_qt_register_font(path: *const c_char) -> c_int;
259 pub fn day_qt_label_height_for_width(w: *mut c_void, width: c_int) -> c_int;
260
261 pub fn day_qt_button_new(title: *const c_char, id: u64, cb: extern "C" fn(u64)) -> *mut c_void;
262 pub fn day_qt_button_set_content(
263 w: *mut c_void,
264 title: *const c_char,
265 icon: *const c_char,
266 fallback: c_int,
267 icon_only: c_int,
268 );
269 pub fn day_qt_button_set_title(w: *mut c_void, title: *const c_char);
270 pub fn day_qt_button_set_style(w: *mut c_void, kind: c_int, argb: u32, fg_argb: u32);
271 /// `ButtonProps::selected`: a checked `QPushButton`, restored after each click.
272 pub fn day_qt_button_set_selected(w: *mut c_void, on: c_int);
273
274 pub fn day_qt_checkbox_new(on: c_int, id: u64, cb: extern "C" fn(u64, c_int)) -> *mut c_void;
275 pub fn day_qt_checkbox_set(w: *mut c_void, on: c_int);
276
277 pub fn day_qt_slider_new(
278 value: c_int,
279 id: u64,
280 cb: extern "C" fn(u64, c_int, c_int),
281 ) -> *mut c_void;
282 pub fn day_qt_slider_set(w: *mut c_void, value: c_int);
283
284 pub fn day_qt_lineedit_new(
285 text: *const c_char,
286 placeholder: *const c_char,
287 id: u64,
288 cb: extern "C" fn(u64, *const c_char),
289 ) -> *mut c_void;
290 pub fn day_qt_lineedit_set_text(w: *mut c_void, text: *const c_char);
291 pub fn day_qt_lineedit_set_placeholder(w: *mut c_void, text: *const c_char);
292 /// Hand Up, Down and Escape to `cb(node, name, modifiers, deliver, phase)` before the line
293 /// edit sees them (docs/textfield.md "Keys"); a nonzero answer claims the key. `deliver` is
294 /// 0 for Qt's shortcut-override question, 1 for the press itself; `phase` 0 down, 1 repeat,
295 /// 2 up (the release of a claimed key, always delivered).
296 pub fn day_qt_lineedit_enable_field_keys(
297 w: *mut c_void,
298 node: u64,
299 cb: extern "C" fn(u64, *const c_char, c_int, c_int, c_int) -> c_int,
300 );
301 /// Select characters (Unicode scalar values) `start..end`, held to the text, caret at
302 /// `end`. No-op on a widget that is not a `QLineEdit`.
303 pub fn day_qt_lineedit_select(w: *mut c_void, start: c_int, end: c_int);
304 /// How a line edit takes its text (`Toolkit::set_input_traits`): password echo, read-only,
305 /// and the input-method hints for `purpose` (0 text, 1 name, 2 email, 3 url, 4 phone,
306 /// 5 number, 6 decimal, 7 username, 8 password, 9 new password, 10 one-time code). Every
307 /// member is applied on every call. No-op on a widget that is not a `QLineEdit`.
308 pub fn day_qt_lineedit_set_traits(
309 w: *mut c_void,
310 secure: c_int,
311 read_only: c_int,
312 purpose: c_int,
313 );
314
315 /// `vertical`: 1 for a rule down a row (`QFrame::VLine`), 0 for one across a column.
316 pub fn day_qt_separator_new(vertical: c_int) -> *mut c_void;
317
318 pub fn day_qt_progress_new(determinate: c_int, value: c_int) -> *mut c_void;
319 pub fn day_qt_progress_set(w: *mut c_void, value: c_int);
320
321 pub fn day_qt_tabs_chrome(tabs: *mut c_void, native: c_int);
322 pub fn day_qt_tabs_documents(
323 tabs: *mut c_void,
324 id: u64,
325 new_label: *const c_char,
326 close_label: *const c_char,
327 can_add: c_int,
328 cb: extern "C" fn(u64, c_int, c_int, c_int),
329 );
330 pub fn day_qt_tabs_move_page(tabs: *mut c_void, page: *mut c_void, index: c_int);
331 pub fn day_qt_tabs_new(id: u64, cb: extern "C" fn(u64, c_int)) -> *mut c_void;
332 /// The first `QTabWidget` above `w`, or null — how a nav menu finds the suite drawing its rows.
333 pub fn day_qt_enclosing_tabs(w: *mut c_void) -> *mut c_void;
334 /// The suite's sidebar page, whose rows became the bar: kept under the `QTabWidget` for the
335 /// menu's parent chain, never a tab, so tab i is destination i.
336 pub fn day_qt_tabs_park(tabs: *mut c_void, page: *mut c_void);
337 pub fn day_qt_tabs_add_page(
338 tabs: *mut c_void,
339 page: *mut c_void,
340 title: *const c_char,
341 index: c_int,
342 );
343 /// Set (or clear, with an empty path) a tab's leading icon.
344 pub fn day_qt_tabs_set_icon(tabs: *mut c_void, index: c_int, path: *const c_char);
345 pub fn day_qt_tabs_remove_page(tabs: *mut c_void, page: *mut c_void);
346 pub fn day_qt_tabs_set_title(tabs: *mut c_void, index: c_int, title: *const c_char);
347 pub fn day_qt_tabs_set_current(tabs: *mut c_void, index: c_int);
348 pub fn day_qt_tabs_content_size(tabs: *mut c_void, w: *mut f64, h: *mut f64);
349
350 pub fn day_qt_scroll_new(horizontal: c_int) -> *mut c_void;
351 pub fn day_qt_scroll_content(w: *mut c_void) -> *mut c_void;
352 pub fn day_qt_scroll_bar_inset(w: *mut c_void, vertical: c_int) -> c_int;
353 pub fn day_qt_scroll_set_content_size(w: *mut c_void, cw: c_int, ch: c_int);
354 /// The scroll piece's preferences (docs/scroll.md): `hidden` drops both scroll bars;
355 /// `snap` 0 = none, 1 = pages, 2 = every `interval` points (emulated: a glide to the
356 /// nearest resting point once the user's scrolling goes quiet).
357 pub fn day_qt_scroll_configure(w: *mut c_void, hidden: c_int, snap: c_int, interval: c_double);
358 /// `track_offset`: report the content offset to `node` through `cb` as it moves, at most
359 /// once per frame and once more at rest.
360 pub fn day_qt_scroll_track_offset(
361 w: *mut c_void,
362 node: u64,
363 cb: extern "C" fn(u64, c_double, c_double),
364 );
365 /// The content offset of any Qt scroll area (the scroll piece or a list), in points.
366 pub fn day_qt_scroll_offset(w: *mut c_void, x: *mut c_double, y: *mut c_double);
367 // The list (docs/list.md): a QListView over a count-only model. Day's cells are placed
368 // over rows as viewport children and recycled through the Rust side's pool; selection,
369 // keys and drag are the view's.
370 pub fn day_qt_list_new(
371 node: u64,
372 row_h: c_int,
373 selectable: c_int,
374 multi: c_int,
375 reorderable: c_int,
376 separators: c_int,
377 on_select: extern "C" fn(u64, *const c_int, c_int),
378 on_activate: extern "C" fn(u64, c_int),
379 can: extern "C" fn(u64, c_int, c_int) -> c_int,
380 mv: extern "C" fn(u64, c_int, c_int),
381 on_window: extern "C" fn(u64),
382 ) -> *mut c_void;
383 /// Bring the row count to `n` with one model delta; no selection report for rows dropped.
384 pub fn day_qt_list_set_count(w: *mut c_void, n: c_int);
385 /// One sequential row delta: kind 0 = insert at `a`, 1 = remove `a`, 2 = move `a` to `b`.
386 pub fn day_qt_list_splice(w: *mut c_void, kind: c_int, a: c_int, b: c_int) -> c_int;
387 /// A whole splice: `count` `kind, a, b` triples, after which the source holds `final_len`
388 /// rows. Applied delta by delta when they fit the view's rows and end at `final_len`;
389 /// otherwise a model reset to `final_len` that keeps the scroll position. 1 = applied,
390 /// 0 = reset.
391 pub fn day_qt_list_splice_all(
392 w: *mut c_void,
393 triples: *const c_int,
394 count: c_int,
395 final_len: c_int,
396 ) -> c_int;
397 /// The list's supplementary rows (docs/list.md "Header, footer and empty state"): no
398 /// flags, no chrome, sized to their content.
399 pub fn day_qt_list_set_supplements(w: *mut c_void, rows: *const c_int, n: c_int);
400 /// What the list shows: first and last rows with any part in view and the distance from
401 /// the viewport's end to the content's. 0 = nothing to report (no rows, no height).
402 pub fn day_qt_list_viewport(
403 w: *mut c_void,
404 first: *mut c_int,
405 last: *mut c_int,
406 end_distance: *mut c_double,
407 ) -> c_int;
408 /// Scroll to `row` (-1: the end) aligned as `align` says (0 Nearest, 1 Start, 2 Center,
409 /// 3 End), gliding when `animated`; queued behind a pending height relayout.
410 pub fn day_qt_list_scroll(w: *mut c_void, row: c_int, align: c_int, animated: c_int);
411 pub fn day_qt_list_set_automatic(w: *mut c_void);
412 /// Row `row` is `height` tall; coalesced into one relayout per loop turn.
413 pub fn day_qt_list_set_row_height(w: *mut c_void, row: c_int, height: c_int);
414 /// The height of a row Day has not measured yet.
415 pub fn day_qt_list_set_estimate(w: *mut c_void, height: c_int);
416 /// Forget every measured height (the rows moved under them).
417 pub fn day_qt_list_clear_heights(w: *mut c_void);
418 /// Show Day's cell over `row`; the view keeps it there through scrolls and relayouts.
419 pub fn day_qt_list_place_cell(w: *mut c_void, row: c_int, cell: *mut c_void);
420 /// The cell went back to the pool: hidden, never deleted.
421 pub fn day_qt_list_park_cell(w: *mut c_void, cell: *mut c_void);
422 pub fn day_qt_list_cell_frame(
423 w: *mut c_void,
424 row: c_int,
425 x: *mut c_int,
426 y: *mut c_int,
427 width: *mut c_int,
428 height: *mut c_int,
429 );
430 /// The rows on screen (`last` < `first` before the view has laid anything out).
431 pub fn day_qt_list_visible_rows(w: *mut c_void, first: *mut c_int, last: *mut c_int);
432 pub fn day_qt_list_viewport_width(w: *mut c_void) -> c_double;
433 pub fn day_qt_list_on_viewport_resized(w: *mut c_void, cb: extern "C" fn(*mut c_void));
434 /// The reader started a scroll (docs/list.md "Following the end"): a wheel step, the scroll
435 /// bar or a key moved the list. Never for a programmatic scroll.
436 pub fn day_qt_list_on_reader_scroll(w: *mut c_void, cb: extern "C" fn(u64));
437 /// Programmatic selection sync: no echo back through `on_select`.
438 pub fn day_qt_list_set_selected(w: *mut c_void, rows: *const c_int, n: c_int);
439 pub fn day_qt_list_scroll_to_row(w: *mut c_void, row: c_int);
440 pub fn day_qt_list_scroll_to_end(w: *mut c_void);
441 /// A sectioned list's header rows (docs/list.md "Sections"): unselectable, painted as
442 /// headers, sized apart from the item rows.
443 pub fn day_qt_list_set_headers(w: *mut c_void, rows: *const c_int, n: c_int);
444 /// The header of the section holding `row` (the nearest at or before it), or -1.
445 pub fn day_qt_list_header_for(w: *mut c_void, row: c_int) -> c_int;
446 /// The pinned header's cell, made on the first call; it lives as long as the list.
447 pub fn day_qt_list_pin_cell(w: *mut c_void) -> *mut c_void;
448 /// The pinned cell shows header `row` (-1: none), laid `height` tall.
449 pub fn day_qt_list_pin_bound(w: *mut c_void, row: c_int, height: c_int);
450 /// The least scroll that shows the content rect, gliding when `animated`.
451 pub fn day_qt_scroll_to_rect(
452 w: *mut c_void,
453 x: c_int,
454 y: c_int,
455 rw: c_int,
456 rh: c_int,
457 animated: c_int,
458 );
459
460 pub fn day_qt_add_child(parent: *mut c_void, child: *mut c_void);
461 /// Raise a presented cover over its siblings; `opaque` fills it with the window color
462 /// (a composed sheet's cover is clear, docs/cover.md "Modal sheet").
463 pub fn day_qt_cover_top(w: *mut c_void, opaque: c_int);
464 /// Report Escape over a presented sheet cover to `cb` (docs/cover.md "Modal sheet").
465 pub fn day_qt_cover_escape(w: *mut c_void, node: u64, cb: extern "C" fn(u64));
466 pub fn day_qt_remove_child(child: *mut c_void);
467 pub fn day_qt_delete(w: *mut c_void);
468 pub fn day_qt_set_geometry(w: *mut c_void, x: c_int, y: c_int, width: c_int, height: c_int);
469 pub fn day_qt_size_hint(w: *mut c_void, out_w: *mut c_double, out_h: *mut c_double);
470 /// First text baseline from the widget's top for a widget `h` tall; `-1` ⇒ no text
471 /// (docs/baseline.md).
472 pub fn day_qt_baseline(w: *mut c_void, h: c_double) -> c_double;
473 pub fn day_qt_set_enabled(w: *mut c_void, enabled: c_int);
474 pub fn day_qt_set_object_name(w: *mut c_void, name: *const c_char);
475 pub fn day_qt_set_tooltip(w: *mut c_void, text: *const c_char);
476 pub fn day_qt_set_accessible_name(w: *mut c_void, name: *const c_char);
477 pub fn day_qt_set_accessible_description(w: *mut c_void, text: *const c_char);
478 /// Explicit role, spoken value and hidden flag, served by the shim's own accessible
479 /// interface (docs/accessibility.md). `role` follows `day_spec::Role` declaration order
480 /// (shim.cpp carries the same table): 0 none (the widget's own role stays), 1 Button,
481 /// 2 Toggle, 3 Slider, 4 `TextInput`, 5 Heading with `level`, 6 Image, 7 Meter, 8 Group,
482 /// 9 Tree, 10 `TreeItem`, 11 Tab, 12 `TabList`. `value` NULL = none. Once hidden, a widget
483 /// stays hidden. `selected` -1 = unset, else the selected state.
484 pub fn day_qt_set_a11y_traits(
485 w: *mut c_void,
486 role: c_int,
487 level: c_int,
488 value: *const c_char,
489 hidden: c_int,
490 selected: c_int,
491 );
492 /// 1 when the Qt linked carries `QAccessibleAnnouncementEvent` (6.8+), else 0.
493 pub fn day_qt_can_announce() -> c_int;
494 /// Speak `text` through the running screen reader, posted on window `w`; nothing without
495 /// one. `urgent` interrupts the current speech.
496 pub fn day_qt_announce(w: *mut c_void, text: *const c_char, urgent: c_int);
497 /// Read a widget's native state back into `out` (`Toolkit::read_native`, docs/testing.md).
498 /// Release its strings with [`day_qt_native_free`].
499 pub fn day_qt_read_native(w: *mut c_void, out: *mut DayQtNative);
500 /// Release the strings [`day_qt_read_native`] wrote, and null them.
501 pub fn day_qt_native_free(n: *mut DayQtNative);
502
503 pub fn day_qt_canvas_new() -> *mut c_void;
504 pub fn day_qt_canvas_set_ops(
505 w: *mut c_void,
506 nums: *const c_double,
507 n: c_int,
508 texts_joined: *const c_char,
509 );
510 // Canvas export (docs/canvas.md "Exporting"): the widget's painter, replayed offscreen.
511 /// Render encoded ops into a `pw`×`ph` pixel bitmap at `scale` pixels per point and store it
512 /// in the decoded-bitmap registry under `id`. Returns 0 when the image could not be made.
513 pub fn day_qt_canvas_render_image(
514 id: u64,
515 nums: *const c_double,
516 n: c_int,
517 texts_joined: *const c_char,
518 pw: c_int,
519 ph: c_int,
520 scale: c_double,
521 ) -> c_int;
522 /// Write `count` pages into one PDF. A heap buffer of `*out_len` bytes, released with
523 /// [`day_qt_bytes_free`]; null on failure with `*err` set to a heap string, released with
524 /// [`day_qt_string_free`]. `title`/`author` may be null.
525 pub fn day_qt_canvas_render_pdf(
526 pages: *const DayQtPdfPage,
527 count: c_int,
528 title: *const c_char,
529 author: *const c_char,
530 out_len: *mut c_int,
531 err: *mut *mut c_char,
532 ) -> *mut u8;
533 /// `tint` is "#rrggbb" or "" for the authored colors.
534 pub fn day_qt_image_new(path: *const c_char, mode: c_int, tint: *const c_char) -> *mut c_void;
535 /// Repaint a realized glyph with a new tint ("" restores the authored colors).
536 pub fn day_qt_image_set_tint(w: *mut c_void, tint: *const c_char);
537 // Raster images from bytes (docs/images.md): the shim owns a `QImage` registry keyed by the
538 // id day-core minted, because the pixels must outlive any one widget.
539 /// Decode bytes into the registry under `id`; `out` (3 doubles) receives width, height and
540 /// 1/0 for an alpha channel. Returns 0 when the bytes are not an image Qt reads.
541 pub fn day_qt_image_decode(id: u64, bytes: *const u8, len: c_int, out: *mut f64) -> c_int;
542 /// Re-encode a decoded bitmap. `quality` -1 takes the format's default; `fit_w`/`fit_h` 0
543 /// means no downscale. A heap buffer of `*out_len` bytes, released with [`day_qt_bytes_free`].
544 pub fn day_qt_image_encode(
545 id: u64,
546 format: *const c_char,
547 quality: c_int,
548 fit_w: c_double,
549 fit_h: c_double,
550 out_len: *mut c_int,
551 ) -> *mut u8;
552 /// Release a buffer returned by [`day_qt_image_encode`]. Safe to call with null.
553 pub fn day_qt_bytes_free(p: *mut u8);
554 /// Drop a decoded bitmap from the registry.
555 pub fn day_qt_image_release(id: u64);
556 /// An image widget showing a decoded bitmap rather than a staged file. `tint` is
557 /// "#aarrggbb" to recolor it keeping its alpha, or "" for the authored colors.
558 pub fn day_qt_image_new_bitmap(id: u64, mode: c_int, tint: *const c_char) -> *mut c_void;
559 /// An image widget showing raw encoded bytes.
560 pub fn day_qt_image_new_bytes(
561 bytes: *const u8,
562 len: c_int,
563 mode: c_int,
564 tint: *const c_char,
565 ) -> *mut c_void;
566 /// Point a realized image widget at a decoded bitmap (the `Source` patch).
567 pub fn day_qt_image_set_bitmap(w: *mut c_void, id: u64);
568 /// Point a realized image widget at raw encoded bytes (the `Source` patch).
569 pub fn day_qt_image_set_bytes(w: *mut c_void, bytes: *const u8, len: c_int);
570 /// Point a realized image widget at a different staged file (the `Source` patch), recording
571 /// the path so a later tint re-renders from the right source.
572 pub fn day_qt_image_set_path(w: *mut c_void, path: *const c_char);
573 // App icon (§18.2): Dock icon on macOS, taskbar icon on Linux/Windows.
574 pub fn day_qt_set_app_icon(path: *const c_char);
575 /// A heap `QIcon` resolved like a toolbar item's icon (`theme|outline.svg`, a vector path,
576 /// or a `QStyle` standard pixmap), for a piece shim that draws icons of its own.
577 pub fn day_qt_icon_new(spec: *const c_char, standard_pixmap: c_int, px: c_int) -> *mut c_void;
578 pub fn day_qt_icon_delete(icon: *mut c_void);
579
580 // Native Qt Resource System (§18.3): register the .rcc blob; read data zero-copy.
581 pub fn day_qt_register_resource(path: *const c_char);
582 pub fn day_qt_resource_data(respath: *const c_char, out_len: *mut usize) -> *const c_void;
583 pub fn day_qt_resource_exists(respath: *const c_char) -> c_int;
584 // kind: 0 tap, 1 drag, 2 pinch, 3 pan, 4 hover, 5 rotate, 6 press, 7 long press, 8 double
585 // tap, 9 touches. Callback phase codes: 0 tap; 1..=3 drag began/changed/ended; 4..=6 pinch
586 // (tx = cumulative scale); 7..=9 pan (tx/ty = delta); 10..=12 hover; 13..=15 rotate (tx =
587 // cumulative radians, clockwise positive); 16 long press; 17 double tap; 18 press in;
588 // 19 press out. The contacts of kind 9 go to the callback `day_qt_set_touches_cb` set.
589 pub fn day_qt_enable_gesture(
590 w: *mut c_void,
591 node: u64,
592 kind: c_int,
593 cb: extern "C" fn(u64, c_int, c_double, c_double, c_double, c_double),
594 );
595 /// Where the contact lists of every touches recognizer go (docs/gestures.md "Touches"):
596 /// `cb(node, numbers, count)`, six numbers per contact (id, phase, x, y, pressure, kind),
597 /// valid for the call.
598 pub fn day_qt_set_touches_cb(cb: extern "C" fn(u64, *const c_double, c_int));
599 /// The axis `w`'s drag follows: 0 any, 1 horizontal, 2 vertical (docs/gestures.md
600 /// "Gestures inside a scroll view").
601 pub fn day_qt_set_drag_axis(w: *mut c_void, axis: c_int);
602 /// Install the application filter that routes presses for hit slop and pass-through and
603 /// reports the input kind to `cb` (0 touch, 1 mouse, 2 stylus) when it changes. Needs the
604 /// `QApplication`; once is enough, a second call replaces the callback.
605 pub fn day_qt_install_input_router(cb: extern "C" fn(c_int));
606 /// Mark `w` as a Day view that takes no pointer input until a recognizer, a menu, a drag,
607 /// a drop or focus is attached (docs/gestures.md "Pass-through").
608 pub fn day_qt_set_passive(w: *mut c_void);
609 /// Grow the area `w` takes pointer input in by these points per edge; zeros restore its
610 /// bounds (docs/gestures.md "Hit slop").
611 pub fn day_qt_set_hit_slop(
612 w: *mut c_void,
613 top: c_double,
614 leading: c_double,
615 bottom: c_double,
616 trailing: c_double,
617 );
618 /// Disable (0) or enable (1) the subtree under `w`, counted per call (docs/forms.md
619 /// "Disabling a group").
620 pub fn day_qt_subtree_enabled(w: *mut c_void, enabled: c_int);
621 /// `.focusable()` beyond the keys and the focus reports: pointer input and the keyboard
622 /// focus indicator (docs/focus.md).
623 pub fn day_qt_set_focusable(w: *mut c_void);
624 // Focus (docs/focus.md): observe via event filter (kind: 1 gained, 0 lost, 2 submitted);
625 // drive via setFocus/clearFocus.
626 pub fn day_qt_enable_focus(w: *mut c_void, node: u64, cb: extern "C" fn(u64, c_int));
627 /// Make `w` focusable and route its arrow keys to `cb(node, code, modifiers, phase)`, which
628 /// answers whether the app claimed the key (docs/menus.md). `code`: 0 left, 1 right, 2 up,
629 /// 3 down, 10..=19 the digits; `phase` 0 down, 1 repeat, 2 up (only for a claimed down).
630 pub fn day_qt_enable_keys(
631 w: *mut c_void,
632 node: u64,
633 cb: extern "C" fn(u64, c_int, c_int, c_int) -> c_int,
634 );
635 pub fn day_qt_widget_focus(w: *mut c_void, focused: c_int);
636 pub fn day_qt_set_present_cb(cb: extern "C" fn(u64, c_int, i64, *const c_char));
637 pub fn day_qt_present_dialog(
638 req: u64,
639 title: *const c_char,
640 message: *const c_char,
641 buttons_joined: *const c_char,
642 roles_joined: *const c_char,
643 parent: *mut c_void,
644 );
645 pub fn day_qt_present_prompt(
646 req: u64,
647 title: *const c_char,
648 message: *const c_char,
649 placeholder: *const c_char,
650 initial: *const c_char,
651 ok: *const c_char,
652 cancel: *const c_char,
653 parent: *mut c_void,
654 );
655 /// `multiple` ≠ 0 lets the user pick several files; the answer joins every chosen path
656 /// with the unit separator (tag 3, `PresentResult::decode`).
657 pub fn day_qt_present_file_open(
658 req: u64,
659 title: *const c_char,
660 filters_joined: *const c_char,
661 multiple: c_int,
662 parent: *mut c_void,
663 );
664 /// A directory chooser (`QFileDialog::Directory` + `ShowDirsOnly`), answered like a file.
665 pub fn day_qt_present_folder_open(req: u64, title: *const c_char, parent: *mut c_void);
666 pub fn day_qt_present_file_save(
667 req: u64,
668 title: *const c_char,
669 suggested: *const c_char,
670 filters_joined: *const c_char,
671 parent: *mut c_void,
672 );
673 pub fn day_qt_dismiss_present(req: u64);
674 /// Install the stack-nav back header into a splitter's detail side; returns the NEW pages
675 /// host below it (use in place of pane 1). `cb(id)` fires on the back button.
676 pub fn day_qt_nav_header_install(
677 splitter: *mut c_void,
678 id: u64,
679 cb: extern "C" fn(u64),
680 ) -> *mut c_void;
681 /// Show/hide the back header + set its title (activates layout synchronously).
682 pub fn day_qt_nav_header_update(splitter: *mut c_void, visible: c_int, title: *const c_char);
683 pub fn day_qt_navlist_new(id: u64, cb: extern "C" fn(u64, c_int)) -> *mut c_void;
684 /// `joined` = row titles (U+001F-separated). `icons` = a PARALLEL list of icon file
685 /// paths (also U+001F-separated, empty entry = no icon for that row). `tints` = a
686 /// PARALLEL list of per-row "#rrggbb" icon tints (empty entry = palette text color).
687 /// `sections` = a PARALLEL list of section headings, each opening a group before its row
688 /// (empty entry = the row continues the current group). The shim draws a heading as an item
689 /// of its own but keeps reporting and accepting DAY's row indices, so headings never shift
690 /// what `day_qt_navlist_set_selected` and the selection callback mean.
691 pub fn day_qt_navlist_set_items(
692 w: *mut c_void,
693 joined: *const c_char,
694 icons: *const c_char,
695 tints: *const c_char,
696 badge_icons: *const c_char,
697 badge_tints: *const c_char,
698 badges: *const c_char,
699 sections: *const c_char,
700 );
701 /// New words or decorations for the comma-joined Day `rows` of the same row set, in place.
702 pub fn day_qt_navlist_update_rows(
703 w: *mut c_void,
704 rows: *const c_char,
705 joined: *const c_char,
706 icons: *const c_char,
707 tints: *const c_char,
708 badge_icons: *const c_char,
709 badge_tints: *const c_char,
710 badges: *const c_char,
711 );
712 pub fn day_qt_navlist_set_selected(w: *mut c_void, idx: c_int);
713 /// The navigation splitter: sidebar, content list, detail. `list_width` <= 0 hides the
714 /// list pane; the minimums are the drag limits (docs/navigation.md).
715 pub fn day_qt_splitter_new(
716 list_width: c_double,
717 sidebar_min: c_double,
718 list_min: c_double,
719 ) -> *mut c_void;
720 /// Give one pane a width, taking the difference from the last pane.
721 pub fn day_qt_splitter_set_pane_width(w: *mut c_void, index: c_int, width: c_double);
722 /// `leading` nonzero puts the panel pane first (docs/inspector.md `.edge`).
723 pub fn day_qt_inspector_new(panel_width: c_double, leading: c_int) -> *mut c_void;
724 pub fn day_qt_splitter_pane(w: *mut c_void, index: c_int) -> *mut c_void;
725 /// A two-pane `QSplitter` (docs/split.md), stacked when `vertical`, each pane at least
726 /// `min_pane` along the axis.
727 pub fn day_qt_split_new(vertical: c_int, min_pane: c_double) -> *mut c_void;
728 pub fn day_qt_split_set_orientation(w: *mut c_void, vertical: c_int, min_pane: c_double);
729 pub fn day_qt_split_set_fraction(w: *mut c_void, fraction: c_double);
730 pub fn day_qt_split_fraction(w: *mut c_void) -> c_double;
731 pub fn day_qt_splitter_on_moved(w: *mut c_void, cb: extern "C" fn(*mut c_void));
732 /// Report a splitter's pane geometry on every layout pass Qt runs on it — the first of
733 /// which is what turns the constructor's placeholder sizes into real ones.
734 pub fn day_qt_splitter_on_resized(w: *mut c_void, cb: extern "C" fn(*mut c_void));
735 pub fn day_qt_widget_size(w: *mut c_void, out_w: *mut c_double, out_h: *mut c_double);
736 pub fn day_qt_set_visible(w: *mut c_void, visible: c_int);
737 pub fn day_qt_post(cb: extern "C" fn(*mut c_void), data: *mut c_void);
738 pub fn day_qt_request_frame(host: *mut c_void, token: u64, cb: extern "C" fn(u64, f64));
739 pub fn day_qt_cancel_frame(token: u64);
740 pub fn day_qt_post_delayed(ms: c_int, cb: extern "C" fn(*mut c_void), data: *mut c_void);
741 /// `scale` > 0 renders at that many pixels per point; 0 keeps the widget's own ratio.
742 pub fn day_qt_snapshot_png(widget: *mut c_void, path: *const c_char, scale: f64) -> c_int;
743
744 // Canvas fonts (docs/fonts.md).
745 /// The `QFontDatabase` families and styles in Day's font-list text format; a heap string to
746 /// release with [`day_qt_string_free`]. Requires a constructed `QApplication`.
747 pub fn day_qt_font_families() -> *mut c_char;
748 /// Release a string returned by [`day_qt_font_families`]. Safe to call with null.
749 pub fn day_qt_string_free(p: *mut c_char);
750 /// Measure one line of canvas text; `out` (3 doubles) receives width, height, ascent.
751 pub fn day_qt_measure_text(
752 text: *const c_char,
753 size: f64,
754 weight: c_int,
755 italic: c_int,
756 family: *const c_char,
757 out: *mut f64,
758 );
759
760 // Lifecycle (docs/lifecycle.md): phase codes match day_spec::Lifecycle order.
761 pub fn day_qt_set_lifecycle_cb(cb: extern "C" fn(c_int));
762
763 // The full key route (docs/menus.md "The full route"): the query says whether a node took
764 // the whole keyboard, the callback carries every key it did by its day name.
765 // The last argument is the key's phase: 0 down, 1 repeat, 2 up.
766 pub fn day_qt_set_text_keys(
767 query: extern "C" fn(u64) -> c_int,
768 cb: extern "C" fn(u64, *const c_char, *const c_char, c_int, c_int) -> c_int,
769 );
770
771 // Menus (docs/menus.md): a flat builder walked from the day-neutral MenuItem tree.
772 pub fn day_qt_set_menu_cb(cb: extern "C" fn(u64));
773 pub fn day_qt_window_menubar(win: *mut c_void) -> *mut c_void;
774 pub fn day_qt_window_menubar_done(win: *mut c_void);
775 pub fn day_qt_menubar_add_menu(bar: *mut c_void, label: *const c_char) -> *mut c_void;
776
777 // Window toolbar (docs/toolbars.md), edited one item at a time. Buttons ride
778 // `day_qt_set_menu_cb`; values arrive on the toolbar callback as (action, kind, on, text)
779 // with kind 0 = toggle, 1 = search text, 2 = segment index.
780 pub fn day_qt_set_toolbar_cb(cb: extern "C" fn(u64, c_int, c_int, *const c_char));
781 /// The window's bar, created and laid out for the window on first use; begins an edit.
782 pub fn day_qt_window_toolbar(win: *mut c_void) -> *mut c_void;
783 /// Aim the next `add_*` at `group` (0 leading, 1 principal, 2 trailing) of column `col`
784 /// (0 sidebar, 1 list, 2 detail), right after item `after` ("" = first in the group).
785 /// `index` is the item's place in Day's order, which a change of layout re-places by.
786 pub fn day_qt_toolbar_begin_insert(
787 bar: *mut c_void,
788 index: c_int,
789 col: c_int,
790 group: c_int,
791 after: *const c_char,
792 );
793 /// Take one item off the window's bar.
794 pub fn day_qt_toolbar_remove(win: *mut c_void, id: *const c_char);
795 /// End the edit: show the bar while it has items, and lay the window out.
796 pub fn day_qt_window_toolbar_done(win: *mut c_void);
797 #[allow(clippy::too_many_arguments)]
798 pub fn day_qt_toolbar_add_action(
799 bar: *mut c_void,
800 id: *const c_char,
801 label: *const c_char,
802 theme_icon: *const c_char,
803 standard_pixmap: c_int,
804 tooltip: *const c_char,
805 action: u64,
806 enabled: c_int,
807 checkable: c_int,
808 checked: c_int,
809 );
810 pub fn day_qt_toolbar_add_menu(
811 bar: *mut c_void,
812 id: *const c_char,
813 label: *const c_char,
814 theme_icon: *const c_char,
815 standard_pixmap: c_int,
816 tooltip: *const c_char,
817 enabled: c_int,
818 ) -> *mut c_void;
819 pub fn day_qt_toolbar_add_search(
820 bar: *mut c_void,
821 id: *const c_char,
822 text: *const c_char,
823 placeholder: *const c_char,
824 action: u64,
825 enabled: c_int,
826 );
827 pub fn day_qt_toolbar_add_label(bar: *mut c_void, id: *const c_char, text: *const c_char);
828 pub fn day_qt_toolbar_add_separator(bar: *mut c_void, id: *const c_char);
829 /// Whether this bar is laid out in columns (its window has a navigation splitter).
830 pub fn day_qt_toolbar_has_columns(bar: *mut c_void) -> c_int;
831 /// Re-size the column tracks to the splitter's panes.
832 pub fn day_qt_toolbar_sync_columns(splitter: *mut c_void);
833 pub fn day_qt_toolbar_focus(win: *mut c_void, id: *const c_char);
834 pub fn day_qt_toolbar_set_text(win: *mut c_void, id: *const c_char, text: *const c_char);
835 pub fn day_qt_toolbar_set_suggestions(
836 win: *mut c_void,
837 id: *const c_char,
838 joined: *const c_char,
839 );
840 pub fn day_qt_toolbar_set_checked(win: *mut c_void, id: *const c_char, on: c_int);
841 pub fn day_qt_toolbar_add_segmented(
842 bar: *mut c_void,
843 id: *const c_char,
844 titles: *const c_char,
845 icons: *const c_char,
846 selected: c_int,
847 action: u64,
848 enabled: c_int,
849 );
850 pub fn day_qt_toolbar_set_selected(win: *mut c_void, id: *const c_char, index: c_int);
851 pub fn day_qt_toolbar_set_enabled(win: *mut c_void, id: *const c_char, on: c_int);
852 pub fn day_qt_toolbar_set_words(
853 win: *mut c_void,
854 id: *const c_char,
855 label: *const c_char,
856 tooltip: *const c_char,
857 );
858 pub fn day_qt_toolbar_set_placeholder(win: *mut c_void, id: *const c_char, text: *const c_char);
859 pub fn day_qt_menu_new() -> *mut c_void;
860 pub fn day_qt_menu_add_submenu(menu: *mut c_void, label: *const c_char) -> *mut c_void;
861 pub fn day_qt_menu_add_separator(menu: *mut c_void);
862 pub fn day_qt_menu_add_action(
863 menu: *mut c_void,
864 label: *const c_char,
865 id: u64,
866 shortcut: *const c_char,
867 enabled: c_int,
868 // `theme-name|outline.svg` (or a bare path) + a QStyle standard-pixmap fallback —
869 // the same icon spec toolbar items take.
870 icon: *const c_char,
871 icon_fallback: c_int,
872 // -1 for a plain command; 0/1 makes the action checkable and sets the mark.
873 checked: c_int,
874 );
875 pub fn day_qt_menu_add_role(
876 menu: *mut c_void,
877 label: *const c_char,
878 role: c_int,
879 shortcut: *const c_char,
880 );
881 pub fn day_qt_set_context_menu(widget: *mut c_void, menu: *mut c_void);
882 /// Summon-time context menus (docs/menus.md): `cb` receives (node, x, y) in widget
883 /// coordinates and returns a fresh `QMenu`* (null = show nothing this time).
884 pub fn day_qt_context_menu_fn(
885 widget: *mut c_void,
886 node: u64,
887 cb: extern "C" fn(u64, c_double, c_double) -> *mut c_void,
888 );
889 /// Menu buttons (docs/menus.md "Menu buttons"): the `QPushButton` `widget`'s click calls
890 /// `cb(key, 0, 0)` for a fresh `QMenu`* (null = show nothing this time) and pops it under the
891 /// button instead of reporting the press.
892 pub fn day_qt_button_menu_fn(
893 widget: *mut c_void,
894 key: u64,
895 cb: extern "C" fn(u64, c_double, c_double) -> *mut c_void,
896 );
897 /// The modifier keys held right now (docs/menus.md): shift 1, primary 2, alt 4. A query,
898 /// not a callback — Qt exposes the live keyboard state directly.
899 pub fn day_qt_modifiers() -> c_int;
900 /// Per-row context menus for the nav list (docs/menus.md): a parallel array of `QMenu`*
901 /// (null = no menu for that row); the shim maps a custom-context request to its row.
902 pub fn day_qt_navlist_set_row_menus(w: *mut c_void, menus: *const *mut c_void, n: i32);
903}
904
905/// One page of [`day_qt_canvas_render_pdf`] (shim.cpp's `DayQtPdfPage`): its size in PDF points
906/// and its ops as `day_spec::encode_ops` flattens them, texts joined with U+001F. The pointers
907/// are borrowed for the call.
908#[repr(C)]
909pub struct DayQtPdfPage {
910 pub w: c_double,
911 pub h: c_double,
912 pub nums: *const c_double,
913 pub n: c_int,
914 pub texts: *const c_char,
915}
916
917/// A widget's native state as `day_qt_read_native` writes it (shim.cpp's `DayQtNative`). Each
918/// field holds what was read from the widget, or its "not read" value: NULL, `checked` -1,
919/// `number_kind` 0, `frame_ok` 0.
920#[repr(C)]
921pub struct DayQtNative {
922 /// Nonzero when the accessibility group (`role` through `identifier`) was read.
923 pub found: c_int,
924 /// The reported role as a Day role code (the `day_qt_set_a11y_traits` table), 0 for none.
925 pub role: c_int,
926 /// A heading's level.
927 pub level: c_int,
928 /// The accessible name.
929 pub label: *mut c_char,
930 /// The accessible value.
931 pub value: *mut c_char,
932 /// The objectName, where Day puts `.id()`.
933 pub identifier: *mut c_char,
934 /// The displayed text, mnemonic markers stripped; NULL where it is masked or does not apply.
935 pub text: *mut c_char,
936 /// 0 none, 1 slider ticks, 2 progress ticks (both 0..=1000).
937 pub number_kind: c_int,
938 /// The ticks `number_kind` names.
939 pub number: c_int,
940 /// A checkable button's state, -1 when the widget is not checkable.
941 pub checked: c_int,
942 /// `isEnabled`.
943 pub enabled: c_int,
944 /// `isVisible`: shown, and every ancestor too.
945 pub visible: c_int,
946 /// Nonzero when the frame was read.
947 pub frame_ok: c_int,
948 /// The frame in the window content's coordinates, logical px.
949 pub x: c_double,
950 pub y: c_double,
951 pub w: c_double,
952 pub h: c_double,
953}
954
955unsafe extern "C" {
956 pub fn day_qt_tree_new(
957 id: u64,
958 height: f64,
959 indent: f64,
960 selectable: c_int,
961 multi: c_int,
962 expanded: extern "C" fn(u64, u64, c_int),
963 selected: extern "C" fn(u64, *const u64, c_int),
964 viewport: extern "C" fn(*mut c_void),
965 ) -> *mut c_void;
966 pub fn day_qt_tree_begin(w: *mut c_void);
967 pub fn day_qt_tree_add(
968 w: *mut c_void,
969 token: u64,
970 parent: u64,
971 has_parent: c_int,
972 text: *const c_char,
973 expandable: c_int,
974 header: c_int,
975 open: c_int,
976 );
977 pub fn day_qt_tree_end(w: *mut c_void);
978 pub fn day_qt_tree_cell(w: *mut c_void, token: u64) -> *mut c_void;
979 pub fn day_qt_tree_frame(w: *mut c_void, token: u64, width: *mut f64) -> c_int;
980 pub fn day_qt_tree_expand(w: *mut c_void, token: u64, open: c_int);
981 pub fn day_qt_tree_select(w: *mut c_void, tokens: *const u64, len: c_int);
982 pub fn day_qt_tree_reveal(w: *mut c_void, token: u64);
983}
984
985/// An `AnimSpec` as the shim's animation runs take it (shim.cpp's `DayQtAnim`, docs/tween.md
986/// "The animation contract").
987#[repr(C)]
988#[derive(Clone, Copy, Debug)]
989pub struct DayQtAnim {
990 /// The delay before the first cycle, in milliseconds.
991 pub delay_ms: c_int,
992 /// One cycle, in milliseconds.
993 pub duration_ms: c_int,
994 /// How many cycles play; `-1` repeats until the property is next set.
995 pub cycles: c_int,
996 /// Nonzero when every second cycle plays backwards.
997 pub autoreverse: c_int,
998 /// One forward cycle's progress at `n_keys` evenly spaced points, first `0`, last `1`;
999 /// alive for the call (the shim copies them).
1000 pub keys: *const c_double,
1001 /// How many `keys` there are.
1002 pub n_keys: c_int,
1003}
1004
1005/// What a widget shows now, as `day_qt_read_displayed` writes it (shim.cpp's
1006/// `DayQtDisplayed`).
1007#[repr(C)]
1008#[derive(Clone, Copy, Debug, Default)]
1009pub struct DayQtDisplayed {
1010 /// The opacity shown, `0..=1`.
1011 pub opacity: c_double,
1012 /// The translation shown, in points.
1013 pub tx: c_double,
1014 /// The translation shown, in points.
1015 pub ty: c_double,
1016 /// Nonzero when `x`, `y`, `w`, `h` were read (not for a window's top widget).
1017 pub frame_ok: c_int,
1018 /// The frame shown, against the window content, in points.
1019 pub x: c_double,
1020 /// See `x`.
1021 pub y: c_double,
1022 /// See `x`.
1023 pub w: c_double,
1024 /// See `x`.
1025 pub h: c_double,
1026 /// Nonzero when the widget paints a fill, given in `r`, `g`, `b`, `a` (sRGB, `0..=1`).
1027 pub fill_ok: c_int,
1028 /// See `fill_ok`.
1029 pub r: c_double,
1030 /// See `fill_ok`.
1031 pub g: c_double,
1032 /// See `fill_ok`.
1033 pub b: c_double,
1034 /// See `fill_ok`.
1035 pub a: c_double,
1036}