@gtkx/react 0.15.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 +1 -0
- 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 +1489 -1300
- 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 +107 -166
- package/dist/jsx.js +58 -69
- 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 +17 -43
- 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 +3 -3
- package/dist/nodes/column-view-column.js +1 -1
- package/dist/nodes/column-view.js +36 -39
- package/dist/nodes/dialog.d.ts +11 -0
- package/dist/nodes/dialog.js +20 -0
- package/dist/nodes/drawing-area.js +24 -7
- 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 -48
- 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 +17 -9
- package/dist/nodes/index.js +17 -9
- 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 -15
- package/dist/nodes/internal/list-item-renderer.js +51 -77
- 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 +25 -2
- package/dist/nodes/internal/predicates.js +53 -41
- 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 -4
- package/dist/nodes/internal/signal-store.js +30 -28
- 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 +15 -14
- package/dist/nodes/internal/tree-list-item-renderer.js +85 -96
- 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 +19 -54
- package/dist/nodes/list-item.d.ts +6 -3
- package/dist/nodes/list-item.js +7 -4
- package/dist/nodes/list-view.js +15 -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 +27 -32
- package/dist/nodes/navigation-view.js +17 -28
- package/dist/nodes/notebook-page-tab.d.ts +3 -3
- package/dist/nodes/notebook-page-tab.js +11 -14
- package/dist/nodes/notebook-page.d.ts +7 -5
- package/dist/nodes/notebook-page.js +45 -25
- 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 -45
- package/dist/nodes/scrolled-window.js +7 -6
- 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 -37
- package/dist/nodes/shortcut-controller.js +24 -8
- package/dist/nodes/shortcut.d.ts +5 -4
- package/dist/nodes/shortcut.js +11 -5
- 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.js +80 -29
- package/dist/nodes/stack-page.js +20 -22
- 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 +30 -0
- package/dist/nodes/text-view.js +49 -21
- 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 +7 -6
- package/dist/nodes/virtual.d.ts +1 -1
- package/dist/nodes/widget.d.ts +2 -16
- package/dist/nodes/widget.js +105 -294
- package/dist/nodes/window.d.ts +9 -3
- package/dist/nodes/window.js +29 -15
- 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 -136
- package/package.json +3 -3
- package/dist/nodes/adjustment.d.ts +0 -48
- package/dist/nodes/adjustment.js +0 -70
- 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 -24
- 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/source-buffer.d.ts +0 -73
- package/dist/nodes/source-buffer.js +0 -149
- package/dist/nodes/text-buffer.d.ts +0 -43
- package/dist/nodes/text-buffer.js +0 -81
- package/dist/nodes/virtual-child.d.ts +0 -18
- package/dist/nodes/virtual-child.js +0 -62
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
|
+
import { VirtualSingleChildNode } from "./virtual-single-child.js";
|
|
3
|
+
export class PositionalChildNode extends VirtualSingleChildNode {
|
|
4
|
+
unmount() {
|
|
5
|
+
if (this.parent && this.child) {
|
|
6
|
+
const parent = this.parent;
|
|
7
|
+
const oldChild = this.child;
|
|
8
|
+
this.child = null;
|
|
9
|
+
const parentOfOld = oldChild.getParent();
|
|
10
|
+
if (parentOfOld && isObjectEqual(parentOfOld, parent)) {
|
|
11
|
+
this.detachFromParent(parent, oldChild);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
this.parent = null;
|
|
15
|
+
super.unmount();
|
|
16
|
+
}
|
|
17
|
+
onChildChange(oldChild) {
|
|
18
|
+
const parent = this.getParent();
|
|
19
|
+
if (oldChild) {
|
|
20
|
+
const parentOfOld = oldChild.getParent();
|
|
21
|
+
if (parentOfOld && isObjectEqual(parentOfOld, parent)) {
|
|
22
|
+
this.detachFromParent(parent, oldChild);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (this.child) {
|
|
26
|
+
this.attachToParent(parent, this.child);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Node } from "../../node.js";
|
|
3
|
+
import type { Props } from "../../types.js";
|
|
4
|
+
import { WidgetNode } from "../widget.js";
|
|
5
|
+
type PositionalChildParentWidget = Gtk.Widget & {
|
|
6
|
+
remove(child: Gtk.Widget): void;
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class PositionalParentNode<T extends PositionalChildParentWidget = PositionalChildParentWidget, P extends Props = Props> extends WidgetNode<T, P> {
|
|
9
|
+
protected abstract acceptedPositionalChildTypes: Set<string>;
|
|
10
|
+
protected abstract containerTypeName: string;
|
|
11
|
+
private isPositionalChild;
|
|
12
|
+
private formatExpectedTypes;
|
|
13
|
+
private assertValidChild;
|
|
14
|
+
appendChild(child: Node): void;
|
|
15
|
+
insertBefore(child: Node, before: Node): void;
|
|
16
|
+
removeChild(child: Node): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SlotNode } from "../slot.js";
|
|
2
|
+
import { WidgetNode } from "../widget.js";
|
|
3
|
+
import { VirtualContainerNode } from "./virtual-container.js";
|
|
4
|
+
export class PositionalParentNode extends WidgetNode {
|
|
5
|
+
isPositionalChild(child) {
|
|
6
|
+
return child instanceof VirtualContainerNode && this.acceptedPositionalChildTypes.has(child.typeName);
|
|
7
|
+
}
|
|
8
|
+
formatExpectedTypes() {
|
|
9
|
+
const types = Array.from(this.acceptedPositionalChildTypes)
|
|
10
|
+
.map((t) => `x.${t}`)
|
|
11
|
+
.join(", ");
|
|
12
|
+
return `${types}, or Widget`;
|
|
13
|
+
}
|
|
14
|
+
assertValidChild(child, operation) {
|
|
15
|
+
if (child instanceof SlotNode || child instanceof WidgetNode)
|
|
16
|
+
return;
|
|
17
|
+
const [verb, prep] = operation === "append"
|
|
18
|
+
? ["append", "to"]
|
|
19
|
+
: operation === "insert"
|
|
20
|
+
? ["insert", "into"]
|
|
21
|
+
: ["remove", "from"];
|
|
22
|
+
throw new Error(`Cannot ${verb} '${child.typeName}' ${prep} '${this.containerTypeName}': expected ${this.formatExpectedTypes()}`);
|
|
23
|
+
}
|
|
24
|
+
appendChild(child) {
|
|
25
|
+
if (this.isPositionalChild(child)) {
|
|
26
|
+
child.setParent(this.container);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.assertValidChild(child, "append");
|
|
30
|
+
super.appendChild(child);
|
|
31
|
+
}
|
|
32
|
+
insertBefore(child, before) {
|
|
33
|
+
if (this.isPositionalChild(child)) {
|
|
34
|
+
child.setParent(this.container);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.assertValidChild(child, "insert");
|
|
38
|
+
super.insertBefore(child, before);
|
|
39
|
+
}
|
|
40
|
+
removeChild(child) {
|
|
41
|
+
if (this.isPositionalChild(child)) {
|
|
42
|
+
child.unmount();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.assertValidChild(child, "remove");
|
|
46
|
+
super.removeChild(child);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 VirtualContainerNode<P extends ChildParentWidget = ChildParentWidget> extends VirtualNode {
|
|
8
|
+
protected parent: P | null;
|
|
9
|
+
setParent(newParent: P | null): void;
|
|
10
|
+
protected getParent(): P;
|
|
11
|
+
protected abstract attachChild(parent: P, widget: Gtk.Widget): void;
|
|
12
|
+
unmount(): void;
|
|
13
|
+
appendChild(child: Node): void;
|
|
14
|
+
insertBefore(child: Node, _before: Node): void;
|
|
15
|
+
removeChild(child: Node): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
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 VirtualContainerNode extends VirtualNode {
|
|
6
|
+
parent = null;
|
|
7
|
+
setParent(newParent) {
|
|
8
|
+
this.parent = newParent;
|
|
9
|
+
}
|
|
10
|
+
getParent() {
|
|
11
|
+
if (!this.parent) {
|
|
12
|
+
throw new Error(`Expected parent widget to be set on ${this.typeName}`);
|
|
13
|
+
}
|
|
14
|
+
return this.parent;
|
|
15
|
+
}
|
|
16
|
+
unmount() {
|
|
17
|
+
this.parent = null;
|
|
18
|
+
super.unmount();
|
|
19
|
+
}
|
|
20
|
+
appendChild(child) {
|
|
21
|
+
if (!(child instanceof WidgetNode)) {
|
|
22
|
+
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
23
|
+
}
|
|
24
|
+
const widget = child.container;
|
|
25
|
+
scheduleAfterCommit(() => {
|
|
26
|
+
const parent = this.parent;
|
|
27
|
+
if (parent) {
|
|
28
|
+
this.attachChild(parent, widget);
|
|
29
|
+
}
|
|
30
|
+
}, CommitPriority.NORMAL);
|
|
31
|
+
}
|
|
32
|
+
insertBefore(child, _before) {
|
|
33
|
+
if (!(child instanceof WidgetNode)) {
|
|
34
|
+
throw new Error(`Cannot insert '${child.typeName}' into '${this.typeName}': expected Widget`);
|
|
35
|
+
}
|
|
36
|
+
const widget = child.container;
|
|
37
|
+
scheduleAfterCommit(() => {
|
|
38
|
+
const parent = this.parent;
|
|
39
|
+
if (parent) {
|
|
40
|
+
this.attachChild(parent, widget);
|
|
41
|
+
}
|
|
42
|
+
}, CommitPriority.NORMAL);
|
|
43
|
+
}
|
|
44
|
+
removeChild(child) {
|
|
45
|
+
if (!(child instanceof WidgetNode)) {
|
|
46
|
+
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
47
|
+
}
|
|
48
|
+
const widget = child.container;
|
|
49
|
+
const parent = this.parent;
|
|
50
|
+
scheduleAfterCommit(() => {
|
|
51
|
+
if (parent) {
|
|
52
|
+
const currentParent = widget.getParent();
|
|
53
|
+
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
54
|
+
parent.remove(widget);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, CommitPriority.HIGH);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Node } from "../../node.js";
|
|
3
|
+
import type { Props } from "../../types.js";
|
|
4
|
+
import type { Attachable } from "../internal/predicates.js";
|
|
5
|
+
import { VirtualNode } from "../virtual.js";
|
|
6
|
+
export declare abstract class VirtualSingleChildNode<P extends Props = Props> extends VirtualNode<P> implements Attachable {
|
|
7
|
+
protected parent: Gtk.Widget | null;
|
|
8
|
+
child: Gtk.Widget | null;
|
|
9
|
+
setParent(parent: Gtk.Widget | null): void;
|
|
10
|
+
protected getParent(): Gtk.Widget;
|
|
11
|
+
protected getTypedParent<T extends Gtk.Widget>(): T;
|
|
12
|
+
protected abstract onChildChange(oldChild: Gtk.Widget | null): void;
|
|
13
|
+
appendChild(child: Node): void;
|
|
14
|
+
removeChild(child: Node): void;
|
|
15
|
+
canBeChildOf(parent: Node): boolean;
|
|
16
|
+
attachTo(parent: Node): void;
|
|
17
|
+
detachFrom(_parent: Node): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CommitPriority, scheduleAfterCommit } from "../../scheduler.js";
|
|
2
|
+
import { VirtualNode } from "../virtual.js";
|
|
3
|
+
import { WidgetNode } from "../widget.js";
|
|
4
|
+
export class VirtualSingleChildNode extends VirtualNode {
|
|
5
|
+
parent = null;
|
|
6
|
+
child = null;
|
|
7
|
+
setParent(parent) {
|
|
8
|
+
this.parent = parent;
|
|
9
|
+
}
|
|
10
|
+
getParent() {
|
|
11
|
+
if (!this.parent) {
|
|
12
|
+
throw new Error(`Expected parent widget to be set on ${this.typeName}`);
|
|
13
|
+
}
|
|
14
|
+
return this.parent;
|
|
15
|
+
}
|
|
16
|
+
getTypedParent() {
|
|
17
|
+
return this.getParent();
|
|
18
|
+
}
|
|
19
|
+
appendChild(child) {
|
|
20
|
+
if (!(child instanceof WidgetNode)) {
|
|
21
|
+
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
22
|
+
}
|
|
23
|
+
const oldChild = this.child;
|
|
24
|
+
this.child = child.container;
|
|
25
|
+
scheduleAfterCommit(() => {
|
|
26
|
+
if (this.parent) {
|
|
27
|
+
this.onChildChange(oldChild);
|
|
28
|
+
}
|
|
29
|
+
}, CommitPriority.NORMAL);
|
|
30
|
+
}
|
|
31
|
+
removeChild(child) {
|
|
32
|
+
if (!(child instanceof WidgetNode)) {
|
|
33
|
+
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
34
|
+
}
|
|
35
|
+
const oldChild = this.child;
|
|
36
|
+
scheduleAfterCommit(() => {
|
|
37
|
+
if (oldChild === this.child) {
|
|
38
|
+
this.child = null;
|
|
39
|
+
}
|
|
40
|
+
if (this.parent && oldChild) {
|
|
41
|
+
this.onChildChange(oldChild);
|
|
42
|
+
}
|
|
43
|
+
}, CommitPriority.HIGH);
|
|
44
|
+
}
|
|
45
|
+
canBeChildOf(parent) {
|
|
46
|
+
return parent instanceof WidgetNode;
|
|
47
|
+
}
|
|
48
|
+
attachTo(parent) {
|
|
49
|
+
if (parent instanceof WidgetNode) {
|
|
50
|
+
this.setParent(parent.container);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
detachFrom(_parent) { }
|
|
54
|
+
}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { VirtualChildNode } from "./virtual-child.js";
|
|
3
|
-
type PrefixSuffixWidget = Gtk.Widget & {
|
|
4
|
-
addPrefix(child: Gtk.Widget): void;
|
|
5
|
-
addSuffix(child: Gtk.Widget): void;
|
|
6
|
-
remove(child: Gtk.Widget): void;
|
|
7
|
-
};
|
|
8
|
-
export declare class ActionRowChild extends VirtualChildNode<PrefixSuffixWidget> {
|
|
9
|
-
static priority: number;
|
|
10
|
-
static matches(type: string): boolean;
|
|
11
|
-
protected getPositionLabel(): string;
|
|
12
|
-
protected attachChild(parent: PrefixSuffixWidget, widget: Gtk.Widget): void;
|
|
13
|
-
}
|
|
14
1
|
export {};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { VirtualContainerNode } from "./abstract/virtual-container.js";
|
|
3
|
+
class ActionRowPrefixNode extends VirtualContainerNode {
|
|
4
4
|
static priority = 1;
|
|
5
5
|
static matches(type) {
|
|
6
|
-
return type === "ActionRowPrefix"
|
|
6
|
+
return type === "ActionRowPrefix";
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
attachChild(parent, widget) {
|
|
9
|
+
parent.addPrefix(widget);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class ActionRowSuffixNode extends VirtualContainerNode {
|
|
13
|
+
static priority = 1;
|
|
14
|
+
static matches(type) {
|
|
15
|
+
return type === "ActionRowSuffix";
|
|
10
16
|
}
|
|
11
17
|
attachChild(parent, widget) {
|
|
12
|
-
|
|
13
|
-
parent.addPrefix(widget);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
parent.addSuffix(widget);
|
|
17
|
-
}
|
|
18
|
+
parent.addSuffix(widget);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
registerNodeClass(
|
|
21
|
+
registerNodeClass(ActionRowPrefixNode);
|
|
22
|
+
registerNodeClass(ActionRowSuffixNode);
|
package/dist/nodes/action-row.js
CHANGED
|
@@ -1,46 +1,13 @@
|
|
|
1
1
|
import { PREFIX_SUFFIX_INTERFACE_METHODS } from "../generated/internal.js";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
3
|
+
import { PositionalParentNode } from "./abstract/positional-parent.js";
|
|
4
4
|
import { matchesInterface } from "./internal/utils.js";
|
|
5
|
-
|
|
6
|
-
import { WidgetNode } from "./widget.js";
|
|
7
|
-
class ActionRowNode extends WidgetNode {
|
|
5
|
+
class ActionRowNode extends PositionalParentNode {
|
|
8
6
|
static priority = 0;
|
|
7
|
+
acceptedPositionalChildTypes = new Set(["ActionRowPrefix", "ActionRowSuffix"]);
|
|
8
|
+
containerTypeName = "ActionRow";
|
|
9
9
|
static matches(_type, containerOrClass) {
|
|
10
10
|
return matchesInterface(PREFIX_SUFFIX_INTERFACE_METHODS, containerOrClass);
|
|
11
11
|
}
|
|
12
|
-
appendChild(child) {
|
|
13
|
-
if (child instanceof ActionRowChild) {
|
|
14
|
-
child.setParent(this.container);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
18
|
-
super.appendChild(child);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
throw new Error(`Cannot append '${child.typeName}' to 'ActionRow': expected x.ActionRowPrefix, x.ActionRowSuffix, or Widget`);
|
|
22
|
-
}
|
|
23
|
-
insertBefore(child, before) {
|
|
24
|
-
if (child instanceof ActionRowChild) {
|
|
25
|
-
child.setParent(this.container);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
29
|
-
super.insertBefore(child, before);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`Cannot insert '${child.typeName}' into 'ActionRow': expected x.ActionRowPrefix, x.ActionRowSuffix, or Widget`);
|
|
33
|
-
}
|
|
34
|
-
removeChild(child) {
|
|
35
|
-
if (child instanceof ActionRowChild) {
|
|
36
|
-
child.unmount();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
40
|
-
super.removeChild(child);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
throw new Error(`Cannot remove '${child.typeName}' from 'ActionRow': expected x.ActionRowPrefix, x.ActionRowSuffix, or Widget`);
|
|
44
|
-
}
|
|
45
12
|
}
|
|
46
13
|
registerNodeClass(ActionRowNode);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Container, ContainerClass, Props } from "../types.js";
|
|
3
|
+
import type { AdjustableWidget } from "./internal/predicates.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
type AdjustableProps = Props & {
|
|
6
|
+
value?: number;
|
|
7
|
+
lower?: number;
|
|
8
|
+
upper?: number;
|
|
9
|
+
stepIncrement?: number;
|
|
10
|
+
pageIncrement?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
onValueChanged?: ((value: number, self: AdjustableWidget) => void) | null;
|
|
13
|
+
};
|
|
14
|
+
export declare class AdjustableNode<T extends AdjustableWidget = AdjustableWidget> extends WidgetNode<T, AdjustableProps> {
|
|
15
|
+
static priority: number;
|
|
16
|
+
private adjustment;
|
|
17
|
+
static matches(_type: string, containerOrClass?: Container | ContainerClass | null): boolean;
|
|
18
|
+
updateProps(oldProps: AdjustableProps | null, newProps: AdjustableProps): void;
|
|
19
|
+
protected ensureAdjustment(props: AdjustableProps): Gtk.Adjustment;
|
|
20
|
+
protected applyOwnProps(oldProps: AdjustableProps | null, newProps: AdjustableProps): void;
|
|
21
|
+
private updateValueChangedHandler;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { ADJUSTABLE_INTERFACE_METHODS } from "../generated/internal.js";
|
|
3
|
+
import { registerNodeClass } from "../registry.js";
|
|
4
|
+
import { filterProps, hasChanged, matchesInterface } from "./internal/utils.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
const OWN_PROPS = ["value", "lower", "upper", "stepIncrement", "pageIncrement", "pageSize", "onValueChanged"];
|
|
7
|
+
export class AdjustableNode extends WidgetNode {
|
|
8
|
+
static priority = 2;
|
|
9
|
+
adjustment = null;
|
|
10
|
+
static matches(_type, containerOrClass) {
|
|
11
|
+
return matchesInterface(ADJUSTABLE_INTERFACE_METHODS, containerOrClass);
|
|
12
|
+
}
|
|
13
|
+
updateProps(oldProps, newProps) {
|
|
14
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
15
|
+
this.applyOwnProps(oldProps, newProps);
|
|
16
|
+
}
|
|
17
|
+
ensureAdjustment(props) {
|
|
18
|
+
if (!this.adjustment) {
|
|
19
|
+
this.adjustment = new Gtk.Adjustment(props.value ?? 0, props.lower ?? 0, props.upper ?? 100, props.stepIncrement ?? 1, props.pageIncrement ?? 10, props.pageSize ?? 0);
|
|
20
|
+
this.container.setAdjustment(this.adjustment);
|
|
21
|
+
}
|
|
22
|
+
return this.adjustment;
|
|
23
|
+
}
|
|
24
|
+
applyOwnProps(oldProps, newProps) {
|
|
25
|
+
const adjustment = this.ensureAdjustment(newProps);
|
|
26
|
+
if (hasChanged(oldProps, newProps, "onValueChanged")) {
|
|
27
|
+
this.updateValueChangedHandler(newProps);
|
|
28
|
+
}
|
|
29
|
+
if (!oldProps)
|
|
30
|
+
return;
|
|
31
|
+
if (hasChanged(oldProps, newProps, "lower")) {
|
|
32
|
+
adjustment.setLower(newProps.lower ?? 0);
|
|
33
|
+
}
|
|
34
|
+
if (hasChanged(oldProps, newProps, "upper")) {
|
|
35
|
+
adjustment.setUpper(newProps.upper ?? 100);
|
|
36
|
+
}
|
|
37
|
+
if (hasChanged(oldProps, newProps, "stepIncrement")) {
|
|
38
|
+
adjustment.setStepIncrement(newProps.stepIncrement ?? 1);
|
|
39
|
+
}
|
|
40
|
+
if (hasChanged(oldProps, newProps, "pageIncrement")) {
|
|
41
|
+
adjustment.setPageIncrement(newProps.pageIncrement ?? 10);
|
|
42
|
+
}
|
|
43
|
+
if (hasChanged(oldProps, newProps, "pageSize")) {
|
|
44
|
+
adjustment.setPageSize(newProps.pageSize ?? 0);
|
|
45
|
+
}
|
|
46
|
+
if (hasChanged(oldProps, newProps, "value") && newProps.value !== undefined) {
|
|
47
|
+
adjustment.setValue(newProps.value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
updateValueChangedHandler(props) {
|
|
51
|
+
if (!this.adjustment)
|
|
52
|
+
return;
|
|
53
|
+
const { onValueChanged } = props;
|
|
54
|
+
if (onValueChanged) {
|
|
55
|
+
this.signalStore.set(this, this.container, "value-changed", (self) => onValueChanged(self.getValue(), self));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.signalStore.set(this, this.container, "value-changed", null);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
registerNodeClass(AdjustableNode);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
+
import { hasChanged } from "./internal/utils.js";
|
|
5
|
+
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
class AlertDialogResponseNode extends VirtualNode {
|
|
8
|
+
static priority = 1;
|
|
9
|
+
dialog = null;
|
|
10
|
+
responseId = null;
|
|
11
|
+
static matches(type) {
|
|
12
|
+
return type === "AlertDialogResponse";
|
|
13
|
+
}
|
|
14
|
+
canBeChildOf(parent) {
|
|
15
|
+
return parent instanceof WidgetNode && parent.container instanceof Adw.AlertDialog;
|
|
16
|
+
}
|
|
17
|
+
attachTo(parent) {
|
|
18
|
+
if (!(parent instanceof WidgetNode) || !(parent.container instanceof Adw.AlertDialog)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (this.dialog)
|
|
22
|
+
return;
|
|
23
|
+
this.dialog = parent.container;
|
|
24
|
+
this.responseId = this.props.id;
|
|
25
|
+
const dialog = this.dialog;
|
|
26
|
+
const id = this.responseId;
|
|
27
|
+
const label = this.props.label;
|
|
28
|
+
scheduleAfterCommit(() => {
|
|
29
|
+
if (this.dialog) {
|
|
30
|
+
dialog.addResponse(id, label);
|
|
31
|
+
this.applyOptionalProps(null, this.props);
|
|
32
|
+
}
|
|
33
|
+
}, CommitPriority.NORMAL);
|
|
34
|
+
}
|
|
35
|
+
detachFrom(_parent) {
|
|
36
|
+
this.removeFromDialog();
|
|
37
|
+
}
|
|
38
|
+
removeFromDialog() {
|
|
39
|
+
if (!this.dialog || !this.responseId)
|
|
40
|
+
return;
|
|
41
|
+
const dialog = this.dialog;
|
|
42
|
+
const id = this.responseId;
|
|
43
|
+
this.dialog = null;
|
|
44
|
+
this.responseId = null;
|
|
45
|
+
scheduleAfterCommit(() => {
|
|
46
|
+
dialog.removeResponse(id);
|
|
47
|
+
}, CommitPriority.HIGH);
|
|
48
|
+
}
|
|
49
|
+
updateProps(oldProps, newProps) {
|
|
50
|
+
super.updateProps(oldProps, newProps);
|
|
51
|
+
if (!this.dialog || !this.responseId)
|
|
52
|
+
return;
|
|
53
|
+
if (hasChanged(oldProps, newProps, "id")) {
|
|
54
|
+
const oldId = this.responseId;
|
|
55
|
+
const newId = newProps.id;
|
|
56
|
+
const dialog = this.dialog;
|
|
57
|
+
const label = newProps.label;
|
|
58
|
+
this.responseId = newId;
|
|
59
|
+
scheduleAfterCommit(() => {
|
|
60
|
+
dialog.removeResponse(oldId);
|
|
61
|
+
dialog.addResponse(newId, label);
|
|
62
|
+
this.applyOptionalProps(null, newProps);
|
|
63
|
+
}, CommitPriority.NORMAL);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (hasChanged(oldProps, newProps, "label")) {
|
|
67
|
+
this.dialog.setResponseLabel(this.responseId, newProps.label);
|
|
68
|
+
}
|
|
69
|
+
this.applyOptionalProps(oldProps, newProps);
|
|
70
|
+
}
|
|
71
|
+
applyOptionalProps(oldProps, newProps) {
|
|
72
|
+
if (!this.dialog || !this.responseId)
|
|
73
|
+
return;
|
|
74
|
+
if (hasChanged(oldProps, newProps, "appearance") && newProps.appearance !== undefined) {
|
|
75
|
+
this.dialog.setResponseAppearance(this.responseId, newProps.appearance);
|
|
76
|
+
}
|
|
77
|
+
if (hasChanged(oldProps, newProps, "enabled") && newProps.enabled !== undefined) {
|
|
78
|
+
this.dialog.setResponseEnabled(this.responseId, newProps.enabled);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
unmount() {
|
|
82
|
+
this.removeFromDialog();
|
|
83
|
+
super.unmount();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
registerNodeClass(AlertDialogResponseNode);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type Transition } from "./animation-factory.js";
|
|
3
|
+
import { type AnimatableProperty } from "./property-mapper.js";
|
|
4
|
+
export type AnimatableProperties = Partial<Record<AnimatableProperty, number>>;
|
|
5
|
+
export declare class AnimationController {
|
|
6
|
+
private widget;
|
|
7
|
+
private activeAnimations;
|
|
8
|
+
private pendingCompletions;
|
|
9
|
+
private onComplete;
|
|
10
|
+
setWidget(widget: Gtk.Widget | null): void;
|
|
11
|
+
applyImmediate(properties: AnimatableProperties): void;
|
|
12
|
+
animate(from: AnimatableProperties, to: AnimatableProperties, transition: Transition, onComplete?: () => void): void;
|
|
13
|
+
private startPropertyAnimation;
|
|
14
|
+
private onAnimationDone;
|
|
15
|
+
skipAll(): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import { createAnimation } from "./animation-factory.js";
|
|
3
|
+
import { getPropertyAccessor, isAnimatableProperty, isTransformProperty, } from "./property-mapper.js";
|
|
4
|
+
import { registerWidget, unregisterWidget } from "./widget-registry.js";
|
|
5
|
+
const DEFAULT_SPRING = { type: "spring", stiffness: 100, damping: 10 };
|
|
6
|
+
const DEFAULT_TIMED = { type: "timed", duration: 250, easing: Adw.Easing.EASE_OUT_CUBIC };
|
|
7
|
+
function getDefaultTransition(property) {
|
|
8
|
+
return isTransformProperty(property) ? DEFAULT_SPRING : DEFAULT_TIMED;
|
|
9
|
+
}
|
|
10
|
+
function isEmptyTransition(transition) {
|
|
11
|
+
return transition.type === undefined && !("duration" in transition) && !("stiffness" in transition);
|
|
12
|
+
}
|
|
13
|
+
export class AnimationController {
|
|
14
|
+
widget = null;
|
|
15
|
+
activeAnimations = new Map();
|
|
16
|
+
pendingCompletions = new Set();
|
|
17
|
+
onComplete = null;
|
|
18
|
+
setWidget(widget) {
|
|
19
|
+
if (this.widget === widget)
|
|
20
|
+
return;
|
|
21
|
+
if (this.widget) {
|
|
22
|
+
this.skipAll();
|
|
23
|
+
unregisterWidget(this.widget);
|
|
24
|
+
}
|
|
25
|
+
this.widget = widget;
|
|
26
|
+
if (widget) {
|
|
27
|
+
registerWidget(widget);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
applyImmediate(properties) {
|
|
31
|
+
if (!this.widget)
|
|
32
|
+
return;
|
|
33
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
34
|
+
if (value === undefined || !isAnimatableProperty(key))
|
|
35
|
+
continue;
|
|
36
|
+
const accessor = getPropertyAccessor(key);
|
|
37
|
+
accessor.set(this.widget, value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
animate(from, to, transition, onComplete) {
|
|
41
|
+
if (!this.widget)
|
|
42
|
+
return;
|
|
43
|
+
this.skipAll();
|
|
44
|
+
this.onComplete = onComplete ?? null;
|
|
45
|
+
this.pendingCompletions.clear();
|
|
46
|
+
const useDefaultTransitions = isEmptyTransition(transition);
|
|
47
|
+
const propertiesToAnimate = new Set([...Object.keys(from), ...Object.keys(to)]);
|
|
48
|
+
for (const key of propertiesToAnimate) {
|
|
49
|
+
if (!isAnimatableProperty(key))
|
|
50
|
+
continue;
|
|
51
|
+
const fromValue = from[key];
|
|
52
|
+
const toValue = to[key];
|
|
53
|
+
if (fromValue === undefined && toValue === undefined)
|
|
54
|
+
continue;
|
|
55
|
+
const accessor = getPropertyAccessor(key);
|
|
56
|
+
const currentValue = fromValue ?? accessor.get(this.widget);
|
|
57
|
+
const targetValue = toValue ?? accessor.get(this.widget);
|
|
58
|
+
if (currentValue === targetValue)
|
|
59
|
+
continue;
|
|
60
|
+
const effectiveTransition = useDefaultTransitions ? getDefaultTransition(key) : transition;
|
|
61
|
+
this.pendingCompletions.add(key);
|
|
62
|
+
this.startPropertyAnimation(key, currentValue, targetValue, effectiveTransition);
|
|
63
|
+
}
|
|
64
|
+
if (this.pendingCompletions.size === 0 && this.onComplete) {
|
|
65
|
+
this.onComplete();
|
|
66
|
+
this.onComplete = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
startPropertyAnimation(property, from, to, transition) {
|
|
70
|
+
if (!this.widget)
|
|
71
|
+
return;
|
|
72
|
+
const accessor = getPropertyAccessor(property);
|
|
73
|
+
const widget = this.widget;
|
|
74
|
+
const animation = createAnimation(widget, from, to, transition, (value) => {
|
|
75
|
+
accessor.set(widget, value);
|
|
76
|
+
});
|
|
77
|
+
const connectionId = animation.connect("done", () => {
|
|
78
|
+
this.onAnimationDone(property);
|
|
79
|
+
});
|
|
80
|
+
this.activeAnimations.set(property, { animation, connectionId });
|
|
81
|
+
animation.play();
|
|
82
|
+
}
|
|
83
|
+
onAnimationDone(property) {
|
|
84
|
+
this.activeAnimations.delete(property);
|
|
85
|
+
this.pendingCompletions.delete(property);
|
|
86
|
+
if (this.pendingCompletions.size === 0 && this.onComplete) {
|
|
87
|
+
const callback = this.onComplete;
|
|
88
|
+
this.onComplete = null;
|
|
89
|
+
callback();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
skipAll() {
|
|
93
|
+
this.onComplete = null;
|
|
94
|
+
this.pendingCompletions.clear();
|
|
95
|
+
for (const { animation } of this.activeAnimations.values()) {
|
|
96
|
+
animation.skip();
|
|
97
|
+
}
|
|
98
|
+
this.activeAnimations.clear();
|
|
99
|
+
}
|
|
100
|
+
dispose() {
|
|
101
|
+
this.skipAll();
|
|
102
|
+
if (this.widget) {
|
|
103
|
+
unregisterWidget(this.widget);
|
|
104
|
+
}
|
|
105
|
+
this.widget = null;
|
|
106
|
+
}
|
|
107
|
+
}
|