@gtkx/react 0.14.0 → 0.16.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/README.md +28 -27
- package/dist/errors.js +3 -0
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +1 -1
- package/dist/generated/internal.d.ts +28 -1
- package/dist/generated/internal.js +93 -18
- package/dist/generated/jsx.d.ts +1712 -1516
- package/dist/generated/jsx.js +475 -0
- package/dist/host-config.d.ts +3 -1
- package/dist/host-config.js +31 -11
- package/dist/jsx.d.ts +147 -97
- package/dist/jsx.js +89 -21
- package/dist/node.d.ts +3 -1
- package/dist/node.js +5 -3
- package/dist/nodes/abstract/positional-child.d.ts +9 -0
- package/dist/nodes/abstract/positional-child.js +29 -0
- package/dist/nodes/abstract/positional-parent.d.ts +18 -0
- package/dist/nodes/abstract/positional-parent.js +48 -0
- package/dist/nodes/abstract/virtual-container.d.ts +17 -0
- package/dist/nodes/abstract/virtual-container.js +59 -0
- package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
- package/dist/nodes/abstract/virtual-single-child.js +54 -0
- package/dist/nodes/action-row-child.d.ts +0 -13
- package/dist/nodes/action-row-child.js +14 -12
- package/dist/nodes/action-row.d.ts +6 -1
- package/dist/nodes/action-row.js +4 -37
- package/dist/nodes/adjustable.d.ts +23 -0
- package/dist/nodes/adjustable.js +62 -0
- package/dist/nodes/alert-dialog-response.d.ts +1 -0
- package/dist/nodes/alert-dialog-response.js +86 -0
- package/dist/nodes/animation/animation-controller.d.ts +17 -0
- package/dist/nodes/animation/animation-controller.js +107 -0
- package/dist/nodes/animation/animation-factory.d.ts +15 -0
- package/dist/nodes/animation/animation-factory.js +25 -0
- package/dist/nodes/animation/animation-node.d.ts +9 -0
- package/dist/nodes/animation/animation-node.js +126 -0
- package/dist/nodes/animation/animation-style-sheet.d.ts +16 -0
- package/dist/nodes/animation/animation-style-sheet.js +74 -0
- package/dist/nodes/animation/index.d.ts +4 -0
- package/dist/nodes/animation/index.js +1 -0
- package/dist/nodes/animation/property-mapper.d.ts +11 -0
- package/dist/nodes/animation/property-mapper.js +36 -0
- package/dist/nodes/animation/transform-state.d.ts +11 -0
- package/dist/nodes/animation/transform-state.js +57 -0
- package/dist/nodes/animation/widget-registry.d.ts +5 -0
- package/dist/nodes/animation/widget-registry.js +42 -0
- package/dist/nodes/application.js +17 -7
- package/dist/nodes/autowrapped.js +37 -43
- package/dist/nodes/calendar.js +16 -55
- package/dist/nodes/color-dialog-button.d.ts +1 -0
- package/dist/nodes/color-dialog-button.js +70 -0
- package/dist/nodes/column-view-column.d.ts +4 -3
- package/dist/nodes/column-view-column.js +5 -1
- package/dist/nodes/column-view.js +40 -43
- package/dist/nodes/dialog.d.ts +11 -0
- package/dist/nodes/dialog.js +20 -0
- package/dist/nodes/drawing-area.d.ts +1 -0
- package/dist/nodes/drawing-area.js +36 -0
- package/dist/nodes/event-controller.d.ts +1 -0
- package/dist/nodes/event-controller.js +96 -0
- package/dist/nodes/expander-row-child.d.ts +0 -14
- package/dist/nodes/expander-row-child.js +14 -12
- package/dist/nodes/expander-row.d.ts +6 -1
- package/dist/nodes/expander-row.js +11 -47
- package/dist/nodes/fixed-child.js +48 -36
- package/dist/nodes/font-dialog-button.d.ts +1 -0
- package/dist/nodes/font-dialog-button.js +90 -0
- package/dist/nodes/grid-child.js +39 -45
- package/dist/nodes/grid.d.ts +1 -0
- package/dist/nodes/grid.js +41 -0
- package/dist/nodes/index.d.ts +22 -6
- package/dist/nodes/index.js +22 -6
- package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
- package/dist/nodes/internal/base-item-renderer.js +88 -0
- package/dist/nodes/internal/base-store.d.ts +9 -0
- package/dist/nodes/internal/base-store.js +20 -0
- package/dist/nodes/internal/child-attachment.d.ts +26 -0
- package/dist/nodes/internal/child-attachment.js +48 -0
- package/dist/nodes/internal/deferred-action.d.ts +8 -0
- package/dist/nodes/internal/deferred-action.js +19 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -14
- package/dist/nodes/internal/list-item-renderer.js +49 -70
- package/dist/nodes/internal/list-store.d.ts +7 -6
- package/dist/nodes/internal/list-store.js +20 -24
- package/dist/nodes/internal/predicates.d.ts +28 -1
- package/dist/nodes/internal/predicates.js +53 -38
- package/dist/nodes/internal/selection-model.d.ts +30 -0
- package/dist/nodes/internal/selection-model.js +91 -0
- package/dist/nodes/internal/signal-store.d.ts +5 -3
- package/dist/nodes/internal/signal-store.js +30 -21
- package/dist/nodes/internal/simple-list-store.js +6 -9
- package/dist/nodes/internal/text-buffer-controller.d.ts +43 -0
- package/dist/nodes/internal/text-buffer-controller.js +287 -0
- package/dist/nodes/internal/text-tag-styles.d.ts +43 -0
- package/dist/nodes/internal/text-tag-styles.js +52 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +16 -14
- package/dist/nodes/internal/tree-list-item-renderer.js +88 -91
- package/dist/nodes/internal/tree-store.d.ts +10 -9
- package/dist/nodes/internal/tree-store.js +31 -35
- package/dist/nodes/internal/utils.d.ts +7 -4
- package/dist/nodes/internal/utils.js +50 -5
- package/dist/nodes/level-bar.js +18 -66
- package/dist/nodes/list-item.d.ts +6 -3
- package/dist/nodes/list-item.js +7 -4
- package/dist/nodes/list-view.js +19 -11
- package/dist/nodes/menu.d.ts +3 -3
- package/dist/nodes/menu.js +3 -3
- package/dist/nodes/models/list.d.ts +11 -13
- package/dist/nodes/models/list.js +16 -73
- package/dist/nodes/models/menu.d.ts +8 -7
- package/dist/nodes/models/menu.js +43 -50
- package/dist/nodes/models/tree-list.d.ts +6 -12
- package/dist/nodes/models/tree-list.js +30 -93
- package/dist/nodes/navigation-page.d.ts +1 -0
- package/dist/nodes/navigation-page.js +7 -3
- package/dist/nodes/navigation-view.js +17 -28
- package/dist/nodes/notebook-page-tab.d.ts +4 -3
- package/dist/nodes/notebook-page-tab.js +5 -2
- package/dist/nodes/notebook-page.d.ts +7 -5
- package/dist/nodes/notebook-page.js +39 -16
- package/dist/nodes/notebook.js +2 -2
- package/dist/nodes/overlay-child.js +90 -30
- package/dist/nodes/pack-child.d.ts +0 -13
- package/dist/nodes/pack-child.js +14 -12
- package/dist/nodes/pack.d.ts +6 -1
- package/dist/nodes/pack.js +4 -37
- package/dist/nodes/popover-menu.js +2 -2
- package/dist/nodes/scale.js +15 -58
- package/dist/nodes/scrolled-window.js +7 -5
- package/dist/nodes/search-bar.d.ts +1 -0
- package/dist/nodes/search-bar.js +40 -0
- package/dist/nodes/shortcut-controller.d.ts +1 -0
- package/dist/nodes/shortcut-controller.js +90 -0
- package/dist/nodes/shortcut.d.ts +39 -0
- package/dist/nodes/shortcut.js +52 -0
- package/dist/nodes/simple-list-view.js +2 -3
- package/dist/nodes/slot.d.ts +6 -9
- package/dist/nodes/slot.js +27 -42
- package/dist/nodes/source-view.d.ts +1 -0
- package/dist/nodes/source-view.js +93 -0
- package/dist/nodes/stack-page.js +17 -13
- package/dist/nodes/stack.js +19 -5
- package/dist/nodes/text-anchor.d.ts +41 -0
- package/dist/nodes/text-anchor.js +59 -0
- package/dist/nodes/text-content.d.ts +10 -0
- package/dist/nodes/text-content.js +1 -0
- package/dist/nodes/text-paintable.d.ts +17 -0
- package/dist/nodes/text-paintable.js +34 -0
- package/dist/nodes/text-segment.d.ts +15 -0
- package/dist/nodes/text-segment.js +29 -0
- package/dist/nodes/text-tag.d.ts +136 -0
- package/dist/nodes/text-tag.js +202 -0
- package/dist/nodes/text-view.d.ts +31 -0
- package/dist/nodes/text-view.js +73 -0
- package/dist/nodes/toggle-group.js +24 -32
- package/dist/nodes/toggle.d.ts +1 -15
- package/dist/nodes/toggle.js +40 -32
- package/dist/nodes/toolbar-child.js +14 -16
- package/dist/nodes/tree-list-item.d.ts +7 -5
- package/dist/nodes/tree-list-item.js +24 -36
- package/dist/nodes/tree-list-view.js +9 -4
- package/dist/nodes/virtual.d.ts +1 -1
- package/dist/nodes/widget.d.ts +3 -13
- package/dist/nodes/widget.js +117 -231
- package/dist/nodes/window.d.ts +9 -3
- package/dist/nodes/window.js +35 -19
- package/dist/registry.d.ts +1 -1
- package/dist/render.js +8 -6
- package/dist/scheduler.d.ts +11 -1
- package/dist/scheduler.js +16 -4
- package/dist/types.d.ts +2 -110
- package/package.json +3 -3
- package/dist/nodes/calendar-mark.d.ts +0 -15
- package/dist/nodes/calendar-mark.js +0 -29
- package/dist/nodes/internal/constants.d.ts +0 -1
- package/dist/nodes/internal/constants.js +0 -21
- package/dist/nodes/level-bar-offset.d.ts +0 -13
- package/dist/nodes/level-bar-offset.js +0 -35
- package/dist/nodes/scale-mark.d.ts +0 -17
- package/dist/nodes/scale-mark.js +0 -38
- package/dist/nodes/virtual-child.d.ts +0 -18
- package/dist/nodes/virtual-child.js +0 -62
package/dist/scheduler.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority levels for scheduling operations after React commit.
|
|
3
|
+
*
|
|
4
|
+
* Priority guidelines:
|
|
5
|
+
* - HIGH: Removals and detachments (must run before additions to avoid conflicts)
|
|
6
|
+
* - NORMAL: Additions and attachments (standard widget operations)
|
|
7
|
+
* - LOW: Sync operations that depend on all additions being complete (e.g., model updates)
|
|
8
|
+
*
|
|
9
|
+
* Within the same priority level, callbacks execute in FIFO order.
|
|
10
|
+
*/
|
|
1
11
|
export var CommitPriority;
|
|
2
12
|
(function (CommitPriority) {
|
|
3
13
|
/** Runs first. Used for widget removals to unparent before reparenting. */
|
|
4
14
|
CommitPriority[CommitPriority["HIGH"] = 0] = "HIGH";
|
|
5
15
|
/** Runs after HIGH priority. Used for widget additions. */
|
|
6
16
|
CommitPriority[CommitPriority["NORMAL"] = 1] = "NORMAL";
|
|
7
|
-
/** Runs
|
|
17
|
+
/** Runs after NORMAL. Used for model sync operations that need all data to be added first. */
|
|
8
18
|
CommitPriority[CommitPriority["LOW"] = 2] = "LOW";
|
|
9
19
|
})(CommitPriority || (CommitPriority = {}));
|
|
10
20
|
const queues = {
|
|
@@ -22,9 +32,11 @@ export const scheduleAfterCommit = (callback, priority = CommitPriority.NORMAL)
|
|
|
22
32
|
};
|
|
23
33
|
export const flushAfterCommit = () => {
|
|
24
34
|
for (const priority of priorities) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
callback();
|
|
35
|
+
const queue = queues[priority];
|
|
36
|
+
while (queue.length > 0) {
|
|
37
|
+
const callback = queue.shift();
|
|
38
|
+
if (callback)
|
|
39
|
+
callback();
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,112 +1,4 @@
|
|
|
1
|
-
import type * as Gdk from "@gtkx/ffi/gdk";
|
|
2
|
-
import type * as GObject from "@gtkx/ffi/gobject";
|
|
3
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
4
|
-
export type Container = Gtk.Widget | Gtk.Application;
|
|
2
|
+
export type Container = Gtk.Widget | Gtk.Application | Gtk.EventController;
|
|
5
3
|
export type Props = Record<string, unknown>;
|
|
6
|
-
export type ContainerClass = typeof Gtk.Widget | typeof Gtk.Application;
|
|
7
|
-
/**
|
|
8
|
-
* Props for EventController-based event handlers.
|
|
9
|
-
*
|
|
10
|
-
* These props attach EventControllers to widgets for handling
|
|
11
|
-
* pointer motion, clicks, keyboard events, and drag-and-drop.
|
|
12
|
-
*/
|
|
13
|
-
export interface EventControllerProps {
|
|
14
|
-
/** Called when the pointer enters the widget */
|
|
15
|
-
onEnter?: (x: number, y: number) => void;
|
|
16
|
-
/** Called when the pointer leaves the widget */
|
|
17
|
-
onLeave?: () => void;
|
|
18
|
-
/** Called when the pointer moves over the widget */
|
|
19
|
-
onMotion?: (x: number, y: number) => void;
|
|
20
|
-
/** Called when a mouse button is pressed */
|
|
21
|
-
onPressed?: (nPress: number, x: number, y: number) => void;
|
|
22
|
-
/** Called when a mouse button is released */
|
|
23
|
-
onReleased?: (nPress: number, x: number, y: number) => void;
|
|
24
|
-
/** Called when a key is pressed (for focusable widgets) */
|
|
25
|
-
onKeyPressed?: (keyval: number, keycode: number, state: Gdk.ModifierType) => boolean;
|
|
26
|
-
/** Called when a key is released */
|
|
27
|
-
onKeyReleased?: (keyval: number, keycode: number, state: Gdk.ModifierType) => void;
|
|
28
|
-
/** Called when the widget is scrolled */
|
|
29
|
-
onScroll?: (dx: number, dy: number) => boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Props for DragSource controller.
|
|
33
|
-
*
|
|
34
|
-
* Enables dragging content from a widget. Attach a DragSource to make
|
|
35
|
-
* a widget draggable.
|
|
36
|
-
*/
|
|
37
|
-
export interface DragSourceProps {
|
|
38
|
-
/**
|
|
39
|
-
* Called when a drag is about to start. Return a ContentProvider with the data
|
|
40
|
-
* to be dragged, or null to cancel the drag.
|
|
41
|
-
* @param x - X coordinate where drag started
|
|
42
|
-
* @param y - Y coordinate where drag started
|
|
43
|
-
*/
|
|
44
|
-
onDragPrepare?: (x: number, y: number) => Gdk.ContentProvider | null;
|
|
45
|
-
/**
|
|
46
|
-
* Called when the drag operation begins.
|
|
47
|
-
* @param drag - The Gdk.Drag object representing the ongoing drag
|
|
48
|
-
*/
|
|
49
|
-
onDragBegin?: (drag: Gdk.Drag) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Called when the drag operation ends.
|
|
52
|
-
* @param drag - The Gdk.Drag object
|
|
53
|
-
* @param deleteData - Whether the data should be deleted (for move operations)
|
|
54
|
-
*/
|
|
55
|
-
onDragEnd?: (drag: Gdk.Drag, deleteData: boolean) => void;
|
|
56
|
-
/**
|
|
57
|
-
* Called when the drag operation is cancelled.
|
|
58
|
-
* @param drag - The Gdk.Drag object
|
|
59
|
-
* @param reason - The reason for cancellation
|
|
60
|
-
* @returns true if the cancel was handled
|
|
61
|
-
*/
|
|
62
|
-
onDragCancel?: (drag: Gdk.Drag, reason: Gdk.DragCancelReason) => boolean;
|
|
63
|
-
/**
|
|
64
|
-
* The allowed drag actions (COPY, MOVE, LINK, ASK).
|
|
65
|
-
* Defaults to Gdk.DragAction.COPY if not specified.
|
|
66
|
-
*/
|
|
67
|
-
dragActions?: Gdk.DragAction;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Props for DropTarget controller.
|
|
71
|
-
*
|
|
72
|
-
* Enables dropping content onto a widget. Attach a DropTarget to make
|
|
73
|
-
* a widget accept drops.
|
|
74
|
-
*/
|
|
75
|
-
export interface DropTargetProps {
|
|
76
|
-
/**
|
|
77
|
-
* Called when content is dropped on the widget.
|
|
78
|
-
* @param value - The dropped value (use value.getTypeName() to check type, then extract)
|
|
79
|
-
* @param x - X coordinate of drop
|
|
80
|
-
* @param y - Y coordinate of drop
|
|
81
|
-
* @returns true if the drop was accepted
|
|
82
|
-
*/
|
|
83
|
-
onDrop?: (value: GObject.Value, x: number, y: number) => boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Called when a drag enters the widget bounds.
|
|
86
|
-
* @param x - X coordinate
|
|
87
|
-
* @param y - Y coordinate
|
|
88
|
-
* @returns The preferred action, or 0 to reject
|
|
89
|
-
*/
|
|
90
|
-
onDropEnter?: (x: number, y: number) => Gdk.DragAction;
|
|
91
|
-
/**
|
|
92
|
-
* Called when a drag leaves the widget bounds.
|
|
93
|
-
*/
|
|
94
|
-
onDropLeave?: () => void;
|
|
95
|
-
/**
|
|
96
|
-
* Called when a drag moves within the widget bounds.
|
|
97
|
-
* @param x - X coordinate
|
|
98
|
-
* @param y - Y coordinate
|
|
99
|
-
* @returns The preferred action, or 0 to reject
|
|
100
|
-
*/
|
|
101
|
-
onDropMotion?: (x: number, y: number) => Gdk.DragAction;
|
|
102
|
-
/**
|
|
103
|
-
* The allowed drop actions (COPY, MOVE, LINK, ASK).
|
|
104
|
-
* Defaults to Gdk.DragAction.COPY if not specified.
|
|
105
|
-
*/
|
|
106
|
-
dropActions?: Gdk.DragAction;
|
|
107
|
-
/**
|
|
108
|
-
* Array of GTypes that this drop target accepts.
|
|
109
|
-
* Use typeFromName() to get GType values (e.g., typeFromName("gchararray") for strings).
|
|
110
|
-
*/
|
|
111
|
-
dropTypes?: number[];
|
|
112
|
-
}
|
|
4
|
+
export type ContainerClass = typeof Gtk.Widget | typeof Gtk.Application | typeof Gtk.EventController;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"react-reconciler": "^0.33.0",
|
|
40
|
-
"@gtkx/ffi": "0.
|
|
41
|
-
"@gtkx/gir": "0.
|
|
40
|
+
"@gtkx/ffi": "0.16.0",
|
|
41
|
+
"@gtkx/gir": "0.16.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react-reconciler": "^0.32.3"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { VirtualNode } from "./virtual.js";
|
|
3
|
-
export type CalendarMarkProps = {
|
|
4
|
-
day: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class CalendarMarkNode extends VirtualNode<CalendarMarkProps> {
|
|
7
|
-
static priority: number;
|
|
8
|
-
private calendar?;
|
|
9
|
-
private onRebuild?;
|
|
10
|
-
static matches(type: string): boolean;
|
|
11
|
-
setCalendar(calendar: Gtk.Calendar, onRebuild: () => void): void;
|
|
12
|
-
addMark(): void;
|
|
13
|
-
updateProps(oldProps: CalendarMarkProps | null, newProps: CalendarMarkProps): void;
|
|
14
|
-
unmount(): void;
|
|
15
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import { VirtualNode } from "./virtual.js";
|
|
3
|
-
export class CalendarMarkNode extends VirtualNode {
|
|
4
|
-
static priority = 1;
|
|
5
|
-
calendar;
|
|
6
|
-
onRebuild;
|
|
7
|
-
static matches(type) {
|
|
8
|
-
return type === "CalendarMark";
|
|
9
|
-
}
|
|
10
|
-
setCalendar(calendar, onRebuild) {
|
|
11
|
-
this.calendar = calendar;
|
|
12
|
-
this.onRebuild = onRebuild;
|
|
13
|
-
}
|
|
14
|
-
addMark() {
|
|
15
|
-
this.calendar?.markDay(this.props.day);
|
|
16
|
-
}
|
|
17
|
-
updateProps(oldProps, newProps) {
|
|
18
|
-
super.updateProps(oldProps, newProps);
|
|
19
|
-
if (oldProps && this.calendar && oldProps.day !== newProps.day) {
|
|
20
|
-
this.onRebuild?.();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
unmount() {
|
|
24
|
-
this.calendar = undefined;
|
|
25
|
-
this.onRebuild = undefined;
|
|
26
|
-
super.unmount();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
registerNodeClass(CalendarMarkNode);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const EVENT_CONTROLLER_PROPS: Set<string>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const EVENT_CONTROLLER_PROPS = new Set([
|
|
2
|
-
"onEnter",
|
|
3
|
-
"onLeave",
|
|
4
|
-
"onMotion",
|
|
5
|
-
"onPressed",
|
|
6
|
-
"onReleased",
|
|
7
|
-
"onKeyPressed",
|
|
8
|
-
"onKeyReleased",
|
|
9
|
-
"onScroll",
|
|
10
|
-
"onDragPrepare",
|
|
11
|
-
"onDragBegin",
|
|
12
|
-
"onDragEnd",
|
|
13
|
-
"onDragCancel",
|
|
14
|
-
"dragActions",
|
|
15
|
-
"onDrop",
|
|
16
|
-
"onDropEnter",
|
|
17
|
-
"onDropLeave",
|
|
18
|
-
"onDropMotion",
|
|
19
|
-
"dropActions",
|
|
20
|
-
"dropTypes",
|
|
21
|
-
]);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { LevelBarOffsetProps } from "../jsx.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
export declare class LevelBarOffsetNode extends VirtualNode<LevelBarOffsetProps> {
|
|
5
|
-
static priority: number;
|
|
6
|
-
private levelBar?;
|
|
7
|
-
private onRebuild?;
|
|
8
|
-
static matches(type: string): boolean;
|
|
9
|
-
setLevelBar(levelBar: Gtk.LevelBar, onRebuild: () => void): void;
|
|
10
|
-
addOffset(): string | undefined;
|
|
11
|
-
updateProps(oldProps: LevelBarOffsetProps | null, newProps: LevelBarOffsetProps): void;
|
|
12
|
-
unmount(): void;
|
|
13
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import { VirtualNode } from "./virtual.js";
|
|
3
|
-
export class LevelBarOffsetNode extends VirtualNode {
|
|
4
|
-
static priority = 1;
|
|
5
|
-
levelBar;
|
|
6
|
-
onRebuild;
|
|
7
|
-
static matches(type) {
|
|
8
|
-
return type === "LevelBarOffset";
|
|
9
|
-
}
|
|
10
|
-
setLevelBar(levelBar, onRebuild) {
|
|
11
|
-
this.levelBar = levelBar;
|
|
12
|
-
this.onRebuild = onRebuild;
|
|
13
|
-
}
|
|
14
|
-
addOffset() {
|
|
15
|
-
if (!this.levelBar)
|
|
16
|
-
return undefined;
|
|
17
|
-
this.levelBar.addOffsetValue(this.props.id, this.props.value);
|
|
18
|
-
return this.props.id;
|
|
19
|
-
}
|
|
20
|
-
updateProps(oldProps, newProps) {
|
|
21
|
-
super.updateProps(oldProps, newProps);
|
|
22
|
-
if (oldProps && this.levelBar) {
|
|
23
|
-
const changed = oldProps.id !== newProps.id || oldProps.value !== newProps.value;
|
|
24
|
-
if (changed) {
|
|
25
|
-
this.onRebuild?.();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
unmount() {
|
|
30
|
-
this.levelBar = undefined;
|
|
31
|
-
this.onRebuild = undefined;
|
|
32
|
-
super.unmount();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
registerNodeClass(LevelBarOffsetNode);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { VirtualNode } from "./virtual.js";
|
|
3
|
-
export type ScaleMarkProps = {
|
|
4
|
-
value: number;
|
|
5
|
-
position?: Gtk.PositionType;
|
|
6
|
-
label?: string | null;
|
|
7
|
-
};
|
|
8
|
-
export declare class ScaleMarkNode extends VirtualNode<ScaleMarkProps> {
|
|
9
|
-
static priority: number;
|
|
10
|
-
private scale?;
|
|
11
|
-
private onRebuild?;
|
|
12
|
-
static matches(type: string): boolean;
|
|
13
|
-
setScale(scale: Gtk.Scale, onRebuild: () => void): void;
|
|
14
|
-
addMark(): void;
|
|
15
|
-
updateProps(oldProps: ScaleMarkProps | null, newProps: ScaleMarkProps): void;
|
|
16
|
-
unmount(): void;
|
|
17
|
-
}
|
package/dist/nodes/scale-mark.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
export class ScaleMarkNode extends VirtualNode {
|
|
5
|
-
static priority = 1;
|
|
6
|
-
scale;
|
|
7
|
-
onRebuild;
|
|
8
|
-
static matches(type) {
|
|
9
|
-
return type === "ScaleMark";
|
|
10
|
-
}
|
|
11
|
-
setScale(scale, onRebuild) {
|
|
12
|
-
this.scale = scale;
|
|
13
|
-
this.onRebuild = onRebuild;
|
|
14
|
-
}
|
|
15
|
-
addMark() {
|
|
16
|
-
if (!this.scale)
|
|
17
|
-
return;
|
|
18
|
-
const { value, position, label } = this.props;
|
|
19
|
-
this.scale.addMark(value, position ?? Gtk.PositionType.BOTTOM, label);
|
|
20
|
-
}
|
|
21
|
-
updateProps(oldProps, newProps) {
|
|
22
|
-
super.updateProps(oldProps, newProps);
|
|
23
|
-
if (oldProps && this.scale) {
|
|
24
|
-
const changed = oldProps.value !== newProps.value ||
|
|
25
|
-
oldProps.position !== newProps.position ||
|
|
26
|
-
oldProps.label !== newProps.label;
|
|
27
|
-
if (changed) {
|
|
28
|
-
this.onRebuild?.();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
unmount() {
|
|
33
|
-
this.scale = undefined;
|
|
34
|
-
this.onRebuild = undefined;
|
|
35
|
-
super.unmount();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
registerNodeClass(ScaleMarkNode);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Node } from "../node.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
type ChildParentWidget = Gtk.Widget & {
|
|
5
|
-
remove(child: Gtk.Widget): void;
|
|
6
|
-
};
|
|
7
|
-
export declare abstract class VirtualChildNode<P extends ChildParentWidget = ChildParentWidget> extends VirtualNode {
|
|
8
|
-
protected parent?: P;
|
|
9
|
-
protected children: Gtk.Widget[];
|
|
10
|
-
setParent(newParent?: P): void;
|
|
11
|
-
protected abstract getPositionLabel(): string;
|
|
12
|
-
protected abstract attachChild(parent: P, widget: Gtk.Widget): void;
|
|
13
|
-
unmount(): void;
|
|
14
|
-
appendChild(child: Node): void;
|
|
15
|
-
insertBefore(child: Node): void;
|
|
16
|
-
removeChild(child: Node): void;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
|
-
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
import { WidgetNode } from "./widget.js";
|
|
5
|
-
export class VirtualChildNode extends VirtualNode {
|
|
6
|
-
parent;
|
|
7
|
-
children = [];
|
|
8
|
-
setParent(newParent) {
|
|
9
|
-
this.parent = newParent;
|
|
10
|
-
}
|
|
11
|
-
unmount() {
|
|
12
|
-
const parent = this.parent;
|
|
13
|
-
const childrenToRemove = [...this.children];
|
|
14
|
-
if (parent && childrenToRemove.length > 0) {
|
|
15
|
-
scheduleAfterCommit(() => {
|
|
16
|
-
for (const widget of childrenToRemove) {
|
|
17
|
-
const currentParent = widget.getParent();
|
|
18
|
-
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
19
|
-
parent.remove(widget);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}, CommitPriority.HIGH);
|
|
23
|
-
}
|
|
24
|
-
this.children = [];
|
|
25
|
-
this.parent = undefined;
|
|
26
|
-
super.unmount();
|
|
27
|
-
}
|
|
28
|
-
appendChild(child) {
|
|
29
|
-
if (!(child instanceof WidgetNode)) {
|
|
30
|
-
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
31
|
-
}
|
|
32
|
-
const widget = child.container;
|
|
33
|
-
this.children.push(widget);
|
|
34
|
-
scheduleAfterCommit(() => {
|
|
35
|
-
if (this.parent) {
|
|
36
|
-
this.attachChild(this.parent, widget);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
insertBefore(child) {
|
|
41
|
-
this.appendChild(child);
|
|
42
|
-
}
|
|
43
|
-
removeChild(child) {
|
|
44
|
-
if (!(child instanceof WidgetNode)) {
|
|
45
|
-
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
46
|
-
}
|
|
47
|
-
const widget = child.container;
|
|
48
|
-
const parent = this.parent;
|
|
49
|
-
const index = this.children.indexOf(widget);
|
|
50
|
-
if (index !== -1) {
|
|
51
|
-
this.children.splice(index, 1);
|
|
52
|
-
}
|
|
53
|
-
scheduleAfterCommit(() => {
|
|
54
|
-
if (parent) {
|
|
55
|
-
const currentParent = widget.getParent();
|
|
56
|
-
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
57
|
-
parent.remove(widget);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, CommitPriority.HIGH);
|
|
61
|
-
}
|
|
62
|
-
}
|