@gjsify/adwaita-core 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/chrome.js +1 -1
- package/lib/esm/conformance/index.js +1 -1
- package/lib/esm/conformance/rows.js +1 -1
- package/lib/esm/conformance/spinner.js +1 -0
- package/lib/esm/conformance/wrap-box.js +1 -1
- package/lib/esm/easing.js +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/length-unit.js +1 -0
- package/lib/esm/rows.js +1 -1
- package/lib/esm/spinner.js +1 -0
- package/lib/esm/split-view.js +1 -1
- package/lib/esm/view-stack.js +1 -1
- package/lib/esm/view-switcher.js +1 -1
- package/lib/esm/wrap-box.js +1 -0
- package/lib/types/conformance/about-dialog.d.ts +17 -3
- package/lib/types/conformance/carousel.d.ts +19 -5
- package/lib/types/conformance/chrome.d.ts +18 -6
- package/lib/types/conformance/data-grid.d.ts +2 -0
- package/lib/types/conformance/entry-row.d.ts +2 -0
- package/lib/types/conformance/index.d.ts +6 -4
- package/lib/types/conformance/popover.d.ts +2 -0
- package/lib/types/conformance/preferences.d.ts +16 -2
- package/lib/types/conformance/rows.d.ts +23 -0
- package/lib/types/conformance/spinner.d.ts +66 -0
- package/lib/types/conformance/split-button.d.ts +4 -0
- package/lib/types/conformance/split-view.d.ts +14 -3
- package/lib/types/conformance/tab-view.d.ts +9 -1
- package/lib/types/conformance/wrap-box.d.ts +104 -53
- package/lib/types/easing.d.ts +21 -0
- package/lib/types/index.d.ts +10 -3
- package/lib/types/length-unit.d.ts +24 -0
- package/lib/types/rows.d.ts +47 -6
- package/lib/types/spinner.d.ts +117 -0
- package/lib/types/spinner.spec.d.ts +2 -0
- package/lib/types/split-view.d.ts +1 -12
- package/lib/types/view-stack.d.ts +12 -0
- package/lib/types/view-switcher.d.ts +9 -6
- package/lib/types/wrap-box.d.ts +200 -0
- package/lib/types/wrap-box.spec.d.ts +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** `SPIN_DURATION_MS` (adw-spinner-paintable.c:20) — one full turn. */
|
|
2
|
+
export declare const ADW_SPINNER_SPIN_DURATION_MS = 1200;
|
|
3
|
+
/**
|
|
4
|
+
* `START_ANGLE` (adw-spinner-paintable.c:21) — a fixed phase offset added to
|
|
5
|
+
* both arc ends (:379-380), so the figure does not start at 3 o'clock.
|
|
6
|
+
*
|
|
7
|
+
* Neither port had it, which is a constant rotation error rather than a wrong
|
|
8
|
+
* speed — invisible in a still frame, visible against a GTK spinner beside it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ADW_SPINNER_START_ANGLE: number;
|
|
11
|
+
/**
|
|
12
|
+
* `CIRCLE_OPACITY` (adw-spinner-paintable.c:22) — the track is the WIDGET's
|
|
13
|
+
* colour at 15%, not a hardcoded grey.
|
|
14
|
+
*
|
|
15
|
+
* The browser port used `rgba(127, 127, 127, 0.25)`: too dark, and
|
|
16
|
+
* hue-independent, so a spinner on a coloured background lost its track
|
|
17
|
+
* relationship entirely.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ADW_SPINNER_TRACK_OPACITY = 0.15;
|
|
20
|
+
/** `MIN_ARC_LENGTH` (:24) — GSK refuses to draw an arc shorter than this. */
|
|
21
|
+
export declare const ADW_SPINNER_MIN_ARC_LENGTH: number;
|
|
22
|
+
/** `MAX_ARC_LENGTH` (:25) — the LERP TARGET, 162°. The drawn arc peaks at 102.8°. */
|
|
23
|
+
export declare const ADW_SPINNER_MAX_ARC_LENGTH: number;
|
|
24
|
+
/** `IDLE_DISTANCE` (:26). */
|
|
25
|
+
export declare const ADW_SPINNER_IDLE_DISTANCE: number;
|
|
26
|
+
/** `OVERLAP_DISTANCE` (:27). */
|
|
27
|
+
export declare const ADW_SPINNER_OVERLAP_DISTANCE: number;
|
|
28
|
+
/** `EXTEND_DISTANCE` (:28). */
|
|
29
|
+
export declare const ADW_SPINNER_EXTEND_DISTANCE: number;
|
|
30
|
+
/** `CONTRACT_DISTANCE` (:29). */
|
|
31
|
+
export declare const ADW_SPINNER_CONTRACT_DISTANCE: number;
|
|
32
|
+
/**
|
|
33
|
+
* `N_CYCLES` (:33) — how many full TURNS the animation runs before repeating.
|
|
34
|
+
*
|
|
35
|
+
* The C states the constraint it satisfies: the cycle length
|
|
36
|
+
* `IDLE + EXTEND + CONTRACT - OVERLAP` must divide `N_CYCLES * 2pi` exactly, or
|
|
37
|
+
* the arc would jump when the animation loops. It does — 53 turns is 40 arc
|
|
38
|
+
* cycles — and {@link ADW_SPINNER_CYCLES_PER_LOOP} is that quotient, asserted
|
|
39
|
+
* rather than assumed.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ADW_SPINNER_N_CYCLES = 53;
|
|
42
|
+
/**
|
|
43
|
+
* One arc cycle, in radians of base angle:
|
|
44
|
+
* `IDLE_DISTANCE + EXTEND_DISTANCE + CONTRACT_DISTANCE - OVERLAP_DISTANCE`
|
|
45
|
+
* (adw-spinner-paintable.c:112, :130).
|
|
46
|
+
*/
|
|
47
|
+
export declare const ADW_SPINNER_CYCLE_LENGTH: number;
|
|
48
|
+
/** Whole arc cycles per animation loop — an integer, which is the C's constraint. */
|
|
49
|
+
export declare const ADW_SPINNER_CYCLES_PER_LOOP: number;
|
|
50
|
+
/**
|
|
51
|
+
* The base angle a NON-animating spinner is drawn at — `EXTEND_DISTANCE -
|
|
52
|
+
* OVERLAP_DISTANCE / 2` (adw-spinner-paintable.c:375-376), i.e. `pi * 0.75`.
|
|
53
|
+
*
|
|
54
|
+
* Reached whenever there is no animation object: before the paintable has a
|
|
55
|
+
* widget, and in a still frame. Both ports left the resting pose undefined, so a
|
|
56
|
+
* spinner that had not started yet drew whatever its keyframe origin happened to
|
|
57
|
+
* be.
|
|
58
|
+
*/
|
|
59
|
+
export declare const ADW_SPINNER_STILL_PROGRESS: number;
|
|
60
|
+
/**
|
|
61
|
+
* `normalize_angle` (adw-spinner-paintable.c:97-107) — fold into `[0, 2pi]`.
|
|
62
|
+
*
|
|
63
|
+
* The C loops rather than taking a modulo, and the boundary follows: it stops at
|
|
64
|
+
* `angle > G_PI * 2`, so exactly `2pi` is left alone where a modulo would give 0.
|
|
65
|
+
*/
|
|
66
|
+
export declare function normalizeSpinnerAngle(angle: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* `get_arc_start` (adw-spinner-paintable.c:109-125) — the trailing end of the
|
|
69
|
+
* arc, relative to the base angle.
|
|
70
|
+
*
|
|
71
|
+
* The `- angle * MAX_ARC_LENGTH / l` term is the drift that makes the arc
|
|
72
|
+
* advance around the circle as it breathes; without it the figure would pulse in
|
|
73
|
+
* place.
|
|
74
|
+
*/
|
|
75
|
+
export declare function spinnerArcStart(angle: number): number;
|
|
76
|
+
/**
|
|
77
|
+
* `get_arc_end` (adw-spinner-paintable.c:127-145) — the leading end.
|
|
78
|
+
*
|
|
79
|
+
* Its phase is offset by `EXTEND_DISTANCE - OVERLAP_DISTANCE`: the end only
|
|
80
|
+
* starts moving once the start has extended past the overlap, which is what
|
|
81
|
+
* makes the arc grow before it slides.
|
|
82
|
+
*/
|
|
83
|
+
export declare function spinnerArcEnd(angle: number): number;
|
|
84
|
+
/** The two ends of the drawn arc, in radians clockwise from 3 o'clock. */
|
|
85
|
+
export interface SpinnerArc {
|
|
86
|
+
/** Trailing end, folded into `[0, 2pi]`. */
|
|
87
|
+
start: number;
|
|
88
|
+
/** Leading end, folded into `[0, 2pi]`. */
|
|
89
|
+
end: number;
|
|
90
|
+
/**
|
|
91
|
+
* Arc length along the circle, `start - end` unwrapped into `(0, 2pi]`.
|
|
92
|
+
*
|
|
93
|
+
* The segment runs from `end` to `start` (`gsk_path_builder_add_segment
|
|
94
|
+
* (builder, circle, &end_point, &start_point)`, :395) — the naming is the C's
|
|
95
|
+
* and it is the opposite way round from what "start" suggests.
|
|
96
|
+
*/
|
|
97
|
+
length: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The arc for a base angle — `adw_spinner_paintable_snapshot_with_weight`
|
|
101
|
+
* (adw-spinner-paintable.c:373-383).
|
|
102
|
+
*
|
|
103
|
+
* `progress` is the animation's value: 0 at the start of a loop, rising linearly
|
|
104
|
+
* to `N_CYCLES * 2pi`. A renderer that has no animation passes
|
|
105
|
+
* {@link ADW_SPINNER_STILL_PROGRESS}.
|
|
106
|
+
*/
|
|
107
|
+
export declare function spinnerArc(progress: number): SpinnerArc;
|
|
108
|
+
/**
|
|
109
|
+
* The animation's value after `elapsedMs` — `adw_timed_animation_new (widget, 0,
|
|
110
|
+
* N_CYCLES * 2pi, SPIN_DURATION_MS * N_CYCLES, target)` with `ADW_LINEAR` easing
|
|
111
|
+
* and `repeat_count = 0`, i.e. forever (adw-spinner-paintable.c:532-540).
|
|
112
|
+
*
|
|
113
|
+
* A linear ramp over the whole loop reduces to one turn per
|
|
114
|
+
* {@link ADW_SPINNER_SPIN_DURATION_MS}; the loop length only decides where it
|
|
115
|
+
* restarts, and it restarts at a point the arc phase agrees with.
|
|
116
|
+
*/
|
|
117
|
+
export declare function spinnerProgressAt(elapsedMs: number): number;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export type AdwLengthUnit = 'px' | 'pt' | 'sp';
|
|
1
|
+
import { type AdwLengthUnit } from './length-unit.js';
|
|
3
2
|
/** `GtkPackType` — which side of the view a pane is packed on. */
|
|
4
3
|
export type AdwPackType = 'start' | 'end';
|
|
5
4
|
/** `GtkTextDirection` — the reading direction `start`/`end` are resolved against. */
|
|
6
5
|
export type AdwTextDirection = 'ltr' | 'rtl';
|
|
7
|
-
/** The dpi `adw_length_unit_to_px` falls back to when `gtk-xft-dpi` is unset. */
|
|
8
|
-
export declare const DEFAULT_DPI = 96;
|
|
9
6
|
/** `min-sidebar-width` default, in {@link DEFAULT_SIDEBAR_WIDTH_UNIT}. */
|
|
10
7
|
export declare const DEFAULT_MIN_SIDEBAR_WIDTH = 180;
|
|
11
8
|
/** `max-sidebar-width` default, in {@link DEFAULT_SIDEBAR_WIDTH_UNIT}. */
|
|
@@ -16,14 +13,6 @@ export declare const DEFAULT_SIDEBAR_WIDTH_FRACTION = 0.25;
|
|
|
16
13
|
export declare const DEFAULT_SIDEBAR_WIDTH_UNIT: AdwLengthUnit;
|
|
17
14
|
/** The minimum grabbable edge width for the reveal gesture — `ADW_SWIPE_BORDER`. */
|
|
18
15
|
export declare const ADW_SWIPE_BORDER = 32;
|
|
19
|
-
/**
|
|
20
|
-
* `adw_length_unit_to_px` (adw-length-unit.c:57-82) — convert `value` to pixels.
|
|
21
|
-
*
|
|
22
|
-
* `pt` and `sp` both scale with the text-scale factor, which GTK reads from
|
|
23
|
-
* `gtk-xft-dpi`; a renderer that has no such setting passes the default 96, where
|
|
24
|
-
* `sp` is a pixel passthrough and `pt` is the familiar 4/3 ratio.
|
|
25
|
-
*/
|
|
26
|
-
export declare function adwLengthToPx(unit: AdwLengthUnit, value: number, dpi?: number): number;
|
|
27
16
|
/**
|
|
28
17
|
* GLib's `CLAMP` (gmacros.h) — `x > high ? high : x < low ? low : x`.
|
|
29
18
|
*
|
|
@@ -19,6 +19,12 @@ export interface AdwViewStackPageSpec<T = unknown> {
|
|
|
19
19
|
content?: T;
|
|
20
20
|
/** Whether the page participates in selection at all. Defaults to `true`. */
|
|
21
21
|
visible?: boolean;
|
|
22
|
+
/** `AdwViewStackPage:badge-number`. Defaults to 0 — no badge. */
|
|
23
|
+
badgeNumber?: number;
|
|
24
|
+
/** `AdwViewStackPage:needs-attention`. Defaults to `false`. */
|
|
25
|
+
needsAttention?: boolean;
|
|
26
|
+
/** `AdwViewStackPage:use-underline`. Defaults to `false`. */
|
|
27
|
+
useUnderline?: boolean;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* A resolved page descriptor, as a bound switcher reads it.
|
|
@@ -39,6 +45,12 @@ export interface AdwViewStackPageInfo<T = unknown> {
|
|
|
39
45
|
readonly content: T | undefined;
|
|
40
46
|
/** Whether the page can be selected — `AdwViewStackPage:visible`. */
|
|
41
47
|
readonly visible: boolean;
|
|
48
|
+
/** `AdwViewStackPage:badge-number`. 0 means no badge. */
|
|
49
|
+
readonly badgeNumber: number;
|
|
50
|
+
/** `AdwViewStackPage:needs-attention` — the bare dot, with or without a badge. */
|
|
51
|
+
readonly needsAttention: boolean;
|
|
52
|
+
/** `AdwViewStackPage:use-underline` — whether the title carries a mnemonic. */
|
|
53
|
+
readonly useUnderline: boolean;
|
|
42
54
|
}
|
|
43
55
|
/** Payload of a selection change. */
|
|
44
56
|
export interface ViewStackStateChange<T = unknown> {
|
|
@@ -106,12 +106,15 @@ export declare function createViewSwitcherPage(init: AdwViewSwitcherPageInit): A
|
|
|
106
106
|
* Project a wave-1 stack page descriptor onto a switcher page, for a switcher
|
|
107
107
|
* BOUND to an `Adw.ViewStack` rather than owning its own pages.
|
|
108
108
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
109
|
+
* One fidelity note remains: `AdwViewStackPageInfo.title` is already resolved
|
|
110
|
+
* against the page name, so it is never `null` and the button-visibility rule
|
|
111
|
+
* reduces to the `visible` flag.
|
|
112
|
+
*
|
|
113
|
+
* The second one is gone. This used to say the stack page carried none of
|
|
114
|
+
* `badge-number`, `needs-attention` or `use-underline`, "so a bound switcher
|
|
115
|
+
* derives an empty badge and no description" — which made a switcher bound to a
|
|
116
|
+
* stack STRUCTURALLY unable to show a badge, and both `ViewSwitcherBar`s go
|
|
117
|
+
* through here. The stack page carries all three now.
|
|
115
118
|
*/
|
|
116
119
|
export declare function viewSwitcherPageFromStackPage(page: AdwViewStackPageInfo): AdwViewSwitcherPage;
|
|
117
120
|
/** {@link viewSwitcherPageFromStackPage} over a whole page list. */
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { type AdwLengthUnit } from './length-unit.js';
|
|
2
|
+
/** `AdwJustifyMode` — the three values of `Adw.WrapBox:justify` (adw-wrap-layout.h:26-30). */
|
|
3
|
+
export type AdwWrapBoxJustify = 'none' | 'fill' | 'spread';
|
|
4
|
+
/** `AdwWrapPolicy` — whether children may shrink before a line wraps (adw-wrap-layout.h:39-43). */
|
|
5
|
+
export type AdwWrapPolicy = 'minimum' | 'natural';
|
|
6
|
+
/** `AdwPackDirection` — which end of a line children are packed from. */
|
|
7
|
+
export type AdwWrapBoxPackDirection = 'start-to-end' | 'end-to-start';
|
|
8
|
+
/** `GtkOrientation` — the axis children are packed along. */
|
|
9
|
+
export type AdwWrapBoxOrientation = 'horizontal' | 'vertical';
|
|
10
|
+
/** The three justify modes, for validating an attribute against the C enum. */
|
|
11
|
+
export declare const ADW_WRAP_BOX_JUSTIFY_MODES: readonly AdwWrapBoxJustify[];
|
|
12
|
+
/** The two wrap policies, for validating an attribute against the C enum. */
|
|
13
|
+
export declare const ADW_WRAP_POLICIES: readonly AdwWrapPolicy[];
|
|
14
|
+
/**
|
|
15
|
+
* `Adw.WrapBox:child-spacing` and `:line-spacing` defaults, in px.
|
|
16
|
+
*
|
|
17
|
+
* Both are `g_param_spec_int (…, 0, G_MAXINT, 0, …)` — adw-wrap-box.c:285-287
|
|
18
|
+
* and :393-395. The NativeScript port defaulted BOTH to 6 DIPs, so identical
|
|
19
|
+
* markup was looser on a phone than in the browser.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ADW_WRAP_BOX_DEFAULT_SPACING = 0;
|
|
22
|
+
/**
|
|
23
|
+
* `Adw.WrapBox:align` default (adw-wrap-box.c:335-337).
|
|
24
|
+
*
|
|
25
|
+
* Declared `g_param_spec_float (…, 0, 1, 0, …)`, so GObject validates an
|
|
26
|
+
* out-of-range value back into `[0, 1]` on set.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ADW_WRAP_BOX_DEFAULT_ALIGN = 0;
|
|
29
|
+
/** `Adw.WrapBox:justify` default — `ADW_JUSTIFY_NONE` (adw-wrap-box.c:364-366). */
|
|
30
|
+
export declare const ADW_WRAP_BOX_DEFAULT_JUSTIFY: AdwWrapBoxJustify;
|
|
31
|
+
/** `Adw.WrapBox:justify-last-line` default — `FALSE` (adw-wrap-box.c:379-381). */
|
|
32
|
+
export declare const ADW_WRAP_BOX_DEFAULT_JUSTIFY_LAST_LINE = false;
|
|
33
|
+
/** `Adw.WrapBox:wrap-policy` default — `ADW_WRAP_NATURAL` (adw-wrap-box.c:491-495). */
|
|
34
|
+
export declare const ADW_WRAP_BOX_DEFAULT_WRAP_POLICY: AdwWrapPolicy;
|
|
35
|
+
/**
|
|
36
|
+
* `Adw.WrapBox:natural-line-length` default — `-1`, i.e. UNSET
|
|
37
|
+
* (adw-wrap-box.c:438-441, range `-1 … G_MAXINT`).
|
|
38
|
+
*
|
|
39
|
+
* `-1` is not "zero length": it means the box asks for whatever its children
|
|
40
|
+
* need, so a renderer must not write it into a size.
|
|
41
|
+
*/
|
|
42
|
+
export declare const ADW_WRAP_BOX_NATURAL_LINE_LENGTH_UNSET = -1;
|
|
43
|
+
/**
|
|
44
|
+
* The unit default for all three length properties — `ADW_LENGTH_UNIT_PX`
|
|
45
|
+
* (adw-wrap-box.c:300-305, :408-413, :454-458).
|
|
46
|
+
*
|
|
47
|
+
* Note this DIFFERS from the split views, which default to `sp`
|
|
48
|
+
* (`DEFAULT_SIDEBAR_WIDTH_UNIT`). Sharing `normalizeLengthUnit` between them is
|
|
49
|
+
* only safe because the default is the caller's argument, not the helper's.
|
|
50
|
+
*/
|
|
51
|
+
export declare const ADW_WRAP_BOX_DEFAULT_LENGTH_UNIT: AdwLengthUnit;
|
|
52
|
+
/** `Adw.WrapBox:pack-direction` default — `ADW_PACK_START_TO_END` (adw-wrap-box.c:313-318). */
|
|
53
|
+
export declare const ADW_WRAP_BOX_DEFAULT_PACK_DIRECTION: AdwWrapBoxPackDirection;
|
|
54
|
+
/** The two pack directions, for validating an attribute against the C enum. */
|
|
55
|
+
export declare const ADW_WRAP_BOX_PACK_DIRECTIONS: readonly AdwWrapBoxPackDirection[];
|
|
56
|
+
/**
|
|
57
|
+
* `adw_wrap_box_set_child_spacing` / `set_line_spacing`
|
|
58
|
+
* (adw-wrap-box.c:587-588, :927-928) — a negative spacing is clamped to 0 BEFORE
|
|
59
|
+
* anything else happens, so it never reaches the layout.
|
|
60
|
+
*
|
|
61
|
+
* The property is declared with a minimum of 0, which is why the clamp exists at
|
|
62
|
+
* all: without it GObject would reject the value and warn. The non-numeric cases
|
|
63
|
+
* have no C counterpart — the property is an `int` — and resolve to the default,
|
|
64
|
+
* so a typo cannot put `NaN` into a `column-gap` or a native layout pass.
|
|
65
|
+
*/
|
|
66
|
+
export declare function normalizeWrapBoxSpacing(value: unknown): number;
|
|
67
|
+
/** `Adw.WrapBox:align` — `g_param_spec_float (…, 0, 1, 0, …)`, adw-wrap-box.c:335-337. */
|
|
68
|
+
export declare function normalizeWrapBoxAlign(value: unknown): number;
|
|
69
|
+
/** An out-of-range enum value leaves a GObject property at its default. */
|
|
70
|
+
export declare function normalizeWrapBoxJustify(value: unknown): AdwWrapBoxJustify;
|
|
71
|
+
/** `Adw.WrapBox:wrap-policy` — same enum gate, defaulting to `natural`. */
|
|
72
|
+
export declare function normalizeWrapPolicy(value: unknown): AdwWrapPolicy;
|
|
73
|
+
/**
|
|
74
|
+
* `Adw.WrapBox:natural-line-length` — an `int` in `[-1, G_MAXINT]`.
|
|
75
|
+
*
|
|
76
|
+
* Anything below -1 is out of the declared range, so it lands on the sentinel
|
|
77
|
+
* rather than on 0: a GObject setter would have refused it and left the property
|
|
78
|
+
* where it was, and "unset" is what the property was born as.
|
|
79
|
+
*/
|
|
80
|
+
export declare function normalizeNaturalLineLength(value: unknown): number;
|
|
81
|
+
/** `Adw.WrapBox`'s three length units — `px` by default, unlike the split views' `sp`. */
|
|
82
|
+
export declare function normalizeWrapBoxLengthUnit(value: unknown): AdwLengthUnit;
|
|
83
|
+
/** `Adw.WrapBox:pack-direction` — the same enum gate, defaulting to `start-to-end`. */
|
|
84
|
+
export declare function normalizeWrapBoxPackDirection(value: unknown): AdwWrapBoxPackDirection;
|
|
85
|
+
/**
|
|
86
|
+
* One length property resolved to pixels — the `adw_length_unit_to_px` call the
|
|
87
|
+
* measure and allocate paths both make before laying anything out
|
|
88
|
+
* (adw-wrap-layout.c:554-565, :798-804).
|
|
89
|
+
*
|
|
90
|
+
* The UNSET natural line length passes through untouched, mirroring the C's own
|
|
91
|
+
* `if (self->natural_line_length >= 0)` gate (:562): converting `-1` would turn
|
|
92
|
+
* a sentinel into a length, and at dpi ≠ 96 it would not even stay -1.
|
|
93
|
+
*/
|
|
94
|
+
export declare function wrapBoxLengthToPx(value: number, unit: AdwLengthUnit, dpi?: number): number;
|
|
95
|
+
/** What a renderer has to do with a line's leftover space. */
|
|
96
|
+
export interface WrapBoxLineLayout {
|
|
97
|
+
/**
|
|
98
|
+
* The justify mode that governs THIS line, after the last-line gate. It is
|
|
99
|
+
* the widget's `justify` for every line except the final one, and for the
|
|
100
|
+
* final one only when `justify-last-line` is set
|
|
101
|
+
* (adw-wrap-layout.c:397-400, :705-706).
|
|
102
|
+
*/
|
|
103
|
+
justify: AdwWrapBoxJustify;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the CHILDREN absorb the leftover (`allocated_size` grows to
|
|
106
|
+
* `available_size`, adw-wrap-layout.c:336-341). CSS: `flex-grow` on the
|
|
107
|
+
* items.
|
|
108
|
+
*/
|
|
109
|
+
growChildren: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the GAPS absorb the leftover — children keep `minimum_size` and
|
|
112
|
+
* are spread apart by `size_delta` (adw-wrap-layout.c:338-339, :752-757).
|
|
113
|
+
* CSS: `justify-content: space-between`.
|
|
114
|
+
*/
|
|
115
|
+
growGaps: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The MAIN-axis offset factor applied to the whole line block when nothing
|
|
118
|
+
* grows: `widget_offset += roundf (length_delta * align)`
|
|
119
|
+
* (adw-wrap-layout.c:717-725). 0 packs the line at the start of the main
|
|
120
|
+
* axis, 1 at its end. Meaningless — and reported as 0 — as soon as the line
|
|
121
|
+
* is justified, because C only computes `length_delta` inside
|
|
122
|
+
* `if (!justify_line)`.
|
|
123
|
+
*/
|
|
124
|
+
align: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The line-layout decision, straight from the C.
|
|
128
|
+
*
|
|
129
|
+
* `lastLine` is the FINAL line, complete or not (`i == *n_lines - 1`,
|
|
130
|
+
* adw-wrap-layout.c:463-464), so a wrap box whose children all fit on one line
|
|
131
|
+
* has that line governed by `justify-last-line` rather than by `justify` — which
|
|
132
|
+
* makes the single-line case, the common one, the counter-intuitive one.
|
|
133
|
+
*
|
|
134
|
+
* `spread` with exactly ONE child in the line does not spread anything:
|
|
135
|
+
* `n_children > 1` guards the branch that keeps children at `minimum_size`, so a
|
|
136
|
+
* lone child is STRETCHED instead, which the property documentation states
|
|
137
|
+
* outright (adw-wrap-box.c:349-352).
|
|
138
|
+
*
|
|
139
|
+
* Held to `WRAP_BOX_LINE_VECTORS` in `@gjsify/adwaita-core/conformance`, which
|
|
140
|
+
* both renderer suites drive their real widgets with.
|
|
141
|
+
*/
|
|
142
|
+
export declare function resolveWrapBoxLine(input: {
|
|
143
|
+
justify: AdwWrapBoxJustify;
|
|
144
|
+
justifyLastLine: boolean;
|
|
145
|
+
align: number;
|
|
146
|
+
lastLine: boolean;
|
|
147
|
+
childrenInLine: number;
|
|
148
|
+
}): WrapBoxLineLayout;
|
|
149
|
+
/**
|
|
150
|
+
* `wrap-policy` as the child `flex-shrink` both flex-based renderers express it
|
|
151
|
+
* with.
|
|
152
|
+
*
|
|
153
|
+
* `ADW_WRAP_NATURAL` wraps "as soon as the previous line cannot fit any more
|
|
154
|
+
* children without shrinking them past their natural size"; `ADW_WRAP_MINIMUM`
|
|
155
|
+
* "shrink[s] them down to their minimum size before wrapping"
|
|
156
|
+
* (adw-wrap-box.c:476-489).
|
|
157
|
+
*
|
|
158
|
+
* STATE THE LIMIT, because it is not a full mapping. Flexbox breaks lines on the
|
|
159
|
+
* items' HYPOTHETICAL main sizes and `flex-shrink` only distributes negative
|
|
160
|
+
* free space WITHIN a line that is already broken — so no value of it makes CSS
|
|
161
|
+
* pack more children per line, which is exactly what `minimum` is for. What it
|
|
162
|
+
* does decide is whether a line that still overflows squeezes its children or
|
|
163
|
+
* lets them spill, and that half is faithful.
|
|
164
|
+
*
|
|
165
|
+
* The reason to derive it anyway is the default. CSS defaults `flex-shrink` to
|
|
166
|
+
* **1**, i.e. to `minimum`; libadwaita defaults `wrap-policy` to `natural`. Both
|
|
167
|
+
* renderers had no policy at all, so both drew the one Adwaita does not choose,
|
|
168
|
+
* on every wrap box, silently.
|
|
169
|
+
*/
|
|
170
|
+
export declare function wrapPolicyFlexShrink(policy: AdwWrapPolicy): number;
|
|
171
|
+
/** Which child-list operation is being resolved. */
|
|
172
|
+
export type WrapBoxChildOrderOp = 'insert-after' | 'reorder-after';
|
|
173
|
+
/**
|
|
174
|
+
* Where `adw_wrap_box_insert_child_after` / `reorder_child_after` put a child.
|
|
175
|
+
*
|
|
176
|
+
* Both delegate to `gtk_widget_insert_after (child, self, sibling)`
|
|
177
|
+
* (adw-wrap-box.c:1283-1300, :1315-1332), whose documented rule is the
|
|
178
|
+
* counter-intuitive one: a NULL sibling inserts at the FIRST position, not the
|
|
179
|
+
* last. Reading it as "append" is the obvious misreading, and it is silent —
|
|
180
|
+
* the child lands somewhere plausible.
|
|
181
|
+
*
|
|
182
|
+
* The guards are the C's `g_return_if_fail`s, expressed as a refusal rather than
|
|
183
|
+
* a throw because a renderer has no `g_critical` to fall through to: an insert
|
|
184
|
+
* demands the child be UNPARENTED and the sibling be a child of this box, a
|
|
185
|
+
* reorder demands the child already be one, and `child === sibling` is an
|
|
186
|
+
* explicit early return in both.
|
|
187
|
+
*
|
|
188
|
+
* Returns the new child list, or `null` when the operation is refused — the
|
|
189
|
+
* caller then leaves its view tree exactly as it was, which is what C does.
|
|
190
|
+
*/
|
|
191
|
+
export declare function resolveWrapBoxChildOrder<T>(input: {
|
|
192
|
+
/** The box's children, in order. */
|
|
193
|
+
children: readonly T[];
|
|
194
|
+
/** The child being placed. */
|
|
195
|
+
child: T;
|
|
196
|
+
/** The child to place it after, or `null`/`undefined` for the FIRST position. */
|
|
197
|
+
sibling?: T | null;
|
|
198
|
+
/** Which operation — they differ only in whether `child` is expected to be present. */
|
|
199
|
+
op: WrapBoxChildOrderOp;
|
|
200
|
+
}): T[] | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/adwaita-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Headless Adwaita widget behavior (breakpoint condition grammar + apply/unapply state machine, color-scheme observable, avatar derivation) shared by the web and NativeScript Adwaita renderers — pure TS, no platform imports",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"headless"
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@gjsify/cli": "^0.
|
|
50
|
-
"@gjsify/unit": "^0.
|
|
49
|
+
"@gjsify/cli": "^0.34.0",
|
|
50
|
+
"@gjsify/unit": "^0.34.0",
|
|
51
51
|
"@types/node": "^25.9.2",
|
|
52
52
|
"typescript": "^6.0.3"
|
|
53
53
|
},
|