@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { batch } from "@gtkx/ffi";
|
|
2
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
3
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { hasChanged } from "./internal/utils.js";
|
|
4
4
|
import { SlotNode } from "./slot.js";
|
|
5
5
|
export class NavigationPageNode extends SlotNode {
|
|
6
6
|
static priority = 1;
|
|
@@ -9,48 +9,43 @@ export class NavigationPageNode extends SlotNode {
|
|
|
9
9
|
}
|
|
10
10
|
updateProps(oldProps, newProps) {
|
|
11
11
|
super.updateProps(oldProps, newProps);
|
|
12
|
+
this.applyOwnProps(oldProps, newProps);
|
|
13
|
+
}
|
|
14
|
+
applyOwnProps(oldProps, newProps) {
|
|
12
15
|
const child = this.child;
|
|
13
16
|
if (!(child instanceof Adw.NavigationPage)) {
|
|
14
17
|
return;
|
|
15
18
|
}
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
child.setTag(newProps.id);
|
|
19
|
-
}
|
|
19
|
+
if (hasChanged(oldProps, newProps, "id") && newProps.id !== undefined) {
|
|
20
|
+
child.setTag(newProps.id);
|
|
20
21
|
}
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
child.setTitle(newProps.title);
|
|
24
|
-
}
|
|
22
|
+
if (hasChanged(oldProps, newProps, "title") && newProps.title !== undefined) {
|
|
23
|
+
child.setTitle(newProps.title);
|
|
25
24
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
child.setCanPop(newProps.canPop);
|
|
29
|
-
}
|
|
25
|
+
if (hasChanged(oldProps, newProps, "canPop") && newProps.canPop !== undefined) {
|
|
26
|
+
child.setCanPop(newProps.canPop);
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
onChildChange(oldChild) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.child
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
navigationView.remove(oldChild);
|
|
45
|
-
}
|
|
46
|
-
if (this.child) {
|
|
47
|
-
navigationView.add(this.child);
|
|
48
|
-
}
|
|
30
|
+
const navigationView = this.getParent();
|
|
31
|
+
const title = this.props.title ?? "";
|
|
32
|
+
if (this.child) {
|
|
33
|
+
this.child = this.props.id
|
|
34
|
+
? Adw.NavigationPage.newWithTag(this.child, title, this.props.id)
|
|
35
|
+
: new Adw.NavigationPage(this.child, title);
|
|
36
|
+
this.updateProps(null, this.props);
|
|
37
|
+
}
|
|
38
|
+
if (navigationView instanceof Adw.NavigationView) {
|
|
39
|
+
if (oldChild instanceof Adw.NavigationPage) {
|
|
40
|
+
navigationView.remove(oldChild);
|
|
49
41
|
}
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
if (this.child) {
|
|
43
|
+
navigationView.add(this.child);
|
|
52
44
|
}
|
|
53
|
-
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
super.onChildChange(oldChild);
|
|
48
|
+
}
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
registerNodeClass(NavigationPageNode);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
-
import {
|
|
5
|
-
import { filterProps, isContainerType } from "./internal/utils.js";
|
|
3
|
+
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
+
import { filterProps, hasChanged, matchesAnyClass, primitiveArrayEqual } from "./internal/utils.js";
|
|
6
5
|
import { NavigationPageNode } from "./navigation-page.js";
|
|
7
6
|
import { SlotNode } from "./slot.js";
|
|
8
7
|
import { WidgetNode } from "./widget.js";
|
|
9
|
-
const
|
|
8
|
+
const OWN_PROPS = ["history", "onHistoryChanged"];
|
|
10
9
|
class NavigationViewNode extends WidgetNode {
|
|
11
10
|
static priority = 1;
|
|
12
11
|
static matches(_type, containerOrClass) {
|
|
13
|
-
return
|
|
12
|
+
return matchesAnyClass([Adw.NavigationView], containerOrClass);
|
|
14
13
|
}
|
|
15
14
|
appendChild(child) {
|
|
16
15
|
if (child instanceof NavigationPageNode) {
|
|
@@ -45,35 +44,38 @@ class NavigationViewNode extends WidgetNode {
|
|
|
45
44
|
throw new Error(`Cannot remove '${child.typeName}' from 'NavigationView': expected x.NavigationPage or Widget`);
|
|
46
45
|
}
|
|
47
46
|
updateProps(oldProps, newProps) {
|
|
47
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
48
|
+
this.applyOwnProps(oldProps, newProps);
|
|
49
|
+
}
|
|
50
|
+
applyOwnProps(oldProps, newProps) {
|
|
48
51
|
const oldHistory = oldProps?.history;
|
|
49
52
|
const newHistory = newProps.history;
|
|
50
|
-
if (newHistory && !
|
|
53
|
+
if (newHistory && !primitiveArrayEqual(oldHistory, newHistory)) {
|
|
51
54
|
this.syncHistory(newHistory);
|
|
52
55
|
}
|
|
53
|
-
if (
|
|
56
|
+
if (hasChanged(oldProps, newProps, "onHistoryChanged")) {
|
|
54
57
|
const onHistoryChanged = newProps.onHistoryChanged;
|
|
55
58
|
if (onHistoryChanged) {
|
|
56
59
|
const handleHistoryChanged = () => {
|
|
57
60
|
const history = this.getCurrentHistory();
|
|
58
61
|
onHistoryChanged(history);
|
|
59
62
|
};
|
|
60
|
-
signalStore.set(this, this.container, "popped", handleHistoryChanged);
|
|
61
|
-
signalStore.set(this, this.container, "pushed", handleHistoryChanged);
|
|
62
|
-
signalStore.set(this, this.container, "replaced", handleHistoryChanged);
|
|
63
|
+
this.signalStore.set(this, this.container, "popped", handleHistoryChanged);
|
|
64
|
+
this.signalStore.set(this, this.container, "pushed", handleHistoryChanged);
|
|
65
|
+
this.signalStore.set(this, this.container, "replaced", handleHistoryChanged);
|
|
63
66
|
}
|
|
64
67
|
else {
|
|
65
|
-
signalStore.set(this, this.container, "popped", null);
|
|
66
|
-
signalStore.set(this, this.container, "pushed", null);
|
|
67
|
-
signalStore.set(this, this.container, "replaced", null);
|
|
68
|
+
this.signalStore.set(this, this.container, "popped", null);
|
|
69
|
+
this.signalStore.set(this, this.container, "pushed", null);
|
|
70
|
+
this.signalStore.set(this, this.container, "replaced", null);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
super.updateProps(filterProps(oldProps ?? {}, PROPS), filterProps(newProps, PROPS));
|
|
71
73
|
}
|
|
72
74
|
syncHistory(history) {
|
|
73
75
|
const container = this.container;
|
|
74
76
|
scheduleAfterCommit(() => {
|
|
75
77
|
container.replaceWithTags(history, history.length);
|
|
76
|
-
});
|
|
78
|
+
}, CommitPriority.NORMAL);
|
|
77
79
|
}
|
|
78
80
|
getCurrentHistory() {
|
|
79
81
|
const stack = this.container.getNavigationStack();
|
|
@@ -88,18 +90,5 @@ class NavigationViewNode extends WidgetNode {
|
|
|
88
90
|
}
|
|
89
91
|
return history;
|
|
90
92
|
}
|
|
91
|
-
arraysEqual(a, b) {
|
|
92
|
-
if (a === b)
|
|
93
|
-
return true;
|
|
94
|
-
if (!a || !b)
|
|
95
|
-
return false;
|
|
96
|
-
if (a.length !== b.length)
|
|
97
|
-
return false;
|
|
98
|
-
for (let i = 0; i < a.length; i++) {
|
|
99
|
-
if (a[i] !== b[i])
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
93
|
}
|
|
105
94
|
registerNodeClass(NavigationViewNode);
|
|
@@ -4,10 +4,10 @@ import { SlotNode } from "./slot.js";
|
|
|
4
4
|
type Props = Partial<SlotProps>;
|
|
5
5
|
export declare class NotebookPageTabNode extends SlotNode<Props> {
|
|
6
6
|
static priority: number;
|
|
7
|
-
private notebook
|
|
8
|
-
private page
|
|
7
|
+
private notebook;
|
|
8
|
+
private page;
|
|
9
9
|
static matches(type: string): boolean;
|
|
10
|
-
setPage(notebook
|
|
10
|
+
setPage(notebook: Gtk.Notebook | null, page: Gtk.Widget | null): void;
|
|
11
11
|
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
12
12
|
private getNotebook;
|
|
13
13
|
private getPage;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { batch } from "@gtkx/ffi";
|
|
2
1
|
import { registerNodeClass } from "../registry.js";
|
|
3
2
|
import { SlotNode } from "./slot.js";
|
|
4
3
|
export class NotebookPageTabNode extends SlotNode {
|
|
5
4
|
static priority = 1;
|
|
6
|
-
notebook;
|
|
7
|
-
page;
|
|
5
|
+
notebook = null;
|
|
6
|
+
page = null;
|
|
8
7
|
static matches(type) {
|
|
9
8
|
return type === "NotebookPageTab";
|
|
10
9
|
}
|
|
@@ -29,17 +28,15 @@ export class NotebookPageTabNode extends SlotNode {
|
|
|
29
28
|
return this.page;
|
|
30
29
|
}
|
|
31
30
|
onChildChange(_oldChild) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
notebook.setTabLabel(page, this.child);
|
|
42
|
-
});
|
|
31
|
+
if (!this.notebook || !this.page) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const notebook = this.getNotebook();
|
|
35
|
+
const page = this.getPage();
|
|
36
|
+
if (notebook.pageNum(page) === -1) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
notebook.setTabLabel(page, this.child);
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
registerNodeClass(NotebookPageTabNode);
|
|
@@ -5,18 +5,20 @@ import { SlotNode } from "./slot.js";
|
|
|
5
5
|
type Props = Partial<NotebookPageProps>;
|
|
6
6
|
export declare class NotebookPageNode extends SlotNode<Props> {
|
|
7
7
|
static priority: number;
|
|
8
|
-
position
|
|
9
|
-
private tabNode
|
|
8
|
+
position: number | null;
|
|
9
|
+
private tabNode;
|
|
10
10
|
static matches(type: string): boolean;
|
|
11
|
-
|
|
12
|
-
setPosition(position
|
|
11
|
+
setParent(parent: Gtk.Widget | null): void;
|
|
12
|
+
setPosition(position: number | null): void;
|
|
13
13
|
private getNotebook;
|
|
14
14
|
private updateTabNode;
|
|
15
15
|
appendChild(child: Node): void;
|
|
16
|
-
removeChild(child
|
|
16
|
+
removeChild(child: Node): void;
|
|
17
17
|
unmount(): void;
|
|
18
18
|
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
19
|
+
protected applyOwnProps(oldProps: Props | null, newProps: Props): void;
|
|
19
20
|
private attachPage;
|
|
21
|
+
private applyPageProps;
|
|
20
22
|
private detachPage;
|
|
21
23
|
protected onChildChange(oldChild: Gtk.Widget | null): void;
|
|
22
24
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { batch } from "@gtkx/ffi";
|
|
2
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
2
|
import { registerNodeClass } from "../registry.js";
|
|
4
|
-
import { scheduleAfterCommit } from "../scheduler.js";
|
|
3
|
+
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
+
import { hasChanged } from "./internal/utils.js";
|
|
5
5
|
import { NotebookPageTabNode } from "./notebook-page-tab.js";
|
|
6
6
|
import { SlotNode } from "./slot.js";
|
|
7
7
|
import { WidgetNode } from "./widget.js";
|
|
8
8
|
export class NotebookPageNode extends SlotNode {
|
|
9
9
|
static priority = 1;
|
|
10
|
-
position;
|
|
11
|
-
tabNode;
|
|
10
|
+
position = null;
|
|
11
|
+
tabNode = null;
|
|
12
12
|
static matches(type) {
|
|
13
13
|
return type === "NotebookPage";
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
setParent(parent) {
|
|
16
|
+
super.setParent(parent);
|
|
17
17
|
this.updateTabNode();
|
|
18
18
|
}
|
|
19
19
|
setPosition(position) {
|
|
@@ -35,7 +35,7 @@ export class NotebookPageNode extends SlotNode {
|
|
|
35
35
|
this.tabNode = child;
|
|
36
36
|
scheduleAfterCommit(() => {
|
|
37
37
|
this.updateTabNode();
|
|
38
|
-
});
|
|
38
|
+
}, CommitPriority.NORMAL);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
if (!(child instanceof WidgetNode)) {
|
|
@@ -48,26 +48,31 @@ export class NotebookPageNode extends SlotNode {
|
|
|
48
48
|
this.onChildChange(oldChild ?? null);
|
|
49
49
|
}
|
|
50
50
|
this.updateTabNode();
|
|
51
|
-
});
|
|
51
|
+
}, CommitPriority.NORMAL);
|
|
52
52
|
}
|
|
53
53
|
removeChild(child) {
|
|
54
54
|
if (child instanceof NotebookPageTabNode) {
|
|
55
|
-
this.tabNode =
|
|
55
|
+
this.tabNode = null;
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
super.removeChild();
|
|
58
|
+
super.removeChild(child);
|
|
59
59
|
}
|
|
60
60
|
unmount() {
|
|
61
|
-
this.tabNode =
|
|
61
|
+
this.tabNode = null;
|
|
62
62
|
super.unmount();
|
|
63
63
|
}
|
|
64
64
|
updateProps(oldProps, newProps) {
|
|
65
65
|
super.updateProps(oldProps, newProps);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
this.applyOwnProps(oldProps, newProps);
|
|
67
|
+
}
|
|
68
|
+
applyOwnProps(oldProps, newProps) {
|
|
69
|
+
if (hasChanged(oldProps, newProps, "label") && this.child && this.parent && !this.tabNode?.child) {
|
|
70
|
+
const tabLabel = this.getNotebook().getTabLabel(this.child);
|
|
71
|
+
tabLabel.setLabel(newProps.label ?? "");
|
|
72
|
+
}
|
|
73
|
+
const pagePropsChanged = hasChanged(oldProps, newProps, "tabExpand") || hasChanged(oldProps, newProps, "tabFill");
|
|
74
|
+
if (this.child && this.parent && pagePropsChanged) {
|
|
75
|
+
this.applyPageProps();
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
attachPage() {
|
|
@@ -84,9 +89,26 @@ export class NotebookPageNode extends SlotNode {
|
|
|
84
89
|
}
|
|
85
90
|
if (this.position != null) {
|
|
86
91
|
notebook.insertPage(child, this.position, tabLabel);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
notebook.appendPage(child, tabLabel);
|
|
95
|
+
}
|
|
96
|
+
this.applyPageProps();
|
|
97
|
+
}
|
|
98
|
+
applyPageProps() {
|
|
99
|
+
const child = this.child;
|
|
100
|
+
if (!child || !this.parent)
|
|
87
101
|
return;
|
|
102
|
+
const notebook = this.getNotebook();
|
|
103
|
+
const page = notebook.getPage(child);
|
|
104
|
+
if (!page)
|
|
105
|
+
return;
|
|
106
|
+
if (this.props.tabExpand !== undefined) {
|
|
107
|
+
page.setTabExpand(this.props.tabExpand);
|
|
108
|
+
}
|
|
109
|
+
if (this.props.tabFill !== undefined) {
|
|
110
|
+
page.setTabFill(this.props.tabFill);
|
|
88
111
|
}
|
|
89
|
-
notebook.appendPage(child, tabLabel);
|
|
90
112
|
}
|
|
91
113
|
detachPage(childToDetach) {
|
|
92
114
|
const notebook = this.getNotebook();
|
|
@@ -94,14 +116,12 @@ export class NotebookPageNode extends SlotNode {
|
|
|
94
116
|
notebook.removePage(pageNum);
|
|
95
117
|
}
|
|
96
118
|
onChildChange(oldChild) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
});
|
|
119
|
+
if (oldChild) {
|
|
120
|
+
this.detachPage(oldChild);
|
|
121
|
+
}
|
|
122
|
+
if (this.child) {
|
|
123
|
+
this.attachPage();
|
|
124
|
+
}
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
127
|
registerNodeClass(NotebookPageNode);
|
package/dist/nodes/notebook.js
CHANGED
|
@@ -12,7 +12,7 @@ class NotebookNode extends WidgetNode {
|
|
|
12
12
|
if (!(child instanceof NotebookPageNode)) {
|
|
13
13
|
throw new Error(`Cannot append '${child.typeName}' to 'Notebook': expected x.NotebookPage`);
|
|
14
14
|
}
|
|
15
|
-
child.
|
|
15
|
+
child.setParent(this.container);
|
|
16
16
|
}
|
|
17
17
|
insertBefore(child, before) {
|
|
18
18
|
if (!(child instanceof NotebookPageNode) || !(before instanceof NotebookPageNode)) {
|
|
@@ -20,7 +20,7 @@ class NotebookNode extends WidgetNode {
|
|
|
20
20
|
}
|
|
21
21
|
const beforePosition = this.container.pageNum(before.getChild());
|
|
22
22
|
child.setPosition(beforePosition);
|
|
23
|
-
child.
|
|
23
|
+
child.setParent(this.container);
|
|
24
24
|
}
|
|
25
25
|
removeChild(child) {
|
|
26
26
|
if (!(child instanceof NotebookPageNode)) {
|
|
@@ -1,49 +1,109 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
+
import { VirtualNode } from "./virtual.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
class OverlayChildNode extends VirtualNode {
|
|
5
7
|
static priority = 1;
|
|
6
8
|
static matches(type) {
|
|
7
9
|
return type === "OverlayChild";
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
parent = null;
|
|
12
|
+
children = new Set();
|
|
13
|
+
canBeChildOf(parent) {
|
|
14
|
+
return parent instanceof WidgetNode;
|
|
15
|
+
}
|
|
16
|
+
attachTo(parent) {
|
|
17
|
+
if (parent instanceof WidgetNode) {
|
|
18
|
+
this.parent = parent.container;
|
|
12
19
|
}
|
|
13
|
-
return this.parent;
|
|
14
20
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
21
|
+
detachFrom(_parent) { }
|
|
22
|
+
unmount() {
|
|
23
|
+
if (this.parent && this.children.size > 0) {
|
|
24
|
+
const parent = this.parent;
|
|
25
|
+
const children = [...this.children];
|
|
26
|
+
this.children.clear();
|
|
27
|
+
for (const child of children) {
|
|
28
|
+
const currentParent = child.getParent();
|
|
29
|
+
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
30
|
+
parent.removeOverlay(child);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
this.parent = null;
|
|
35
|
+
super.unmount();
|
|
36
|
+
}
|
|
37
|
+
appendChild(child) {
|
|
38
|
+
if (!(child instanceof WidgetNode)) {
|
|
39
|
+
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
23
40
|
}
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
const widget = child.container;
|
|
42
|
+
this.children.add(widget);
|
|
43
|
+
scheduleAfterCommit(() => {
|
|
44
|
+
if (this.parent) {
|
|
45
|
+
this.attachChild(widget);
|
|
46
|
+
}
|
|
47
|
+
}, CommitPriority.NORMAL);
|
|
48
|
+
}
|
|
49
|
+
insertBefore(child, _before) {
|
|
50
|
+
if (!(child instanceof WidgetNode)) {
|
|
51
|
+
throw new Error(`Cannot insert '${child.typeName}' into '${this.typeName}': expected Widget`);
|
|
26
52
|
}
|
|
53
|
+
const widget = child.container;
|
|
54
|
+
this.children.add(widget);
|
|
55
|
+
scheduleAfterCommit(() => {
|
|
56
|
+
if (this.parent) {
|
|
57
|
+
this.attachChild(widget);
|
|
58
|
+
}
|
|
59
|
+
}, CommitPriority.NORMAL);
|
|
27
60
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
61
|
+
removeChild(child) {
|
|
62
|
+
if (!(child instanceof WidgetNode)) {
|
|
63
|
+
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
64
|
+
}
|
|
65
|
+
const widget = child.container;
|
|
66
|
+
const parent = this.parent;
|
|
67
|
+
this.children.delete(widget);
|
|
68
|
+
scheduleAfterCommit(() => {
|
|
69
|
+
if (parent) {
|
|
70
|
+
const currentParent = widget.getParent();
|
|
71
|
+
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
72
|
+
parent.removeOverlay(widget);
|
|
35
73
|
}
|
|
36
74
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
75
|
+
}, CommitPriority.HIGH);
|
|
76
|
+
}
|
|
77
|
+
updateProps(oldProps, newProps) {
|
|
78
|
+
super.updateProps(oldProps, newProps);
|
|
79
|
+
if (!this.parent) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const measureChanged = oldProps?.measure !== newProps.measure;
|
|
83
|
+
const clipOverlayChanged = oldProps?.clipOverlay !== newProps.clipOverlay;
|
|
84
|
+
if (measureChanged || clipOverlayChanged) {
|
|
85
|
+
const parent = this.parent;
|
|
86
|
+
for (const child of this.children) {
|
|
87
|
+
if (measureChanged) {
|
|
88
|
+
parent.setMeasureOverlay(child, newProps.measure ?? false);
|
|
41
89
|
}
|
|
42
|
-
if (
|
|
43
|
-
|
|
90
|
+
if (clipOverlayChanged) {
|
|
91
|
+
parent.setClipOverlay(child, newProps.clipOverlay ?? false);
|
|
44
92
|
}
|
|
45
93
|
}
|
|
46
|
-
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
attachChild(widget) {
|
|
97
|
+
if (!this.parent) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.parent.addOverlay(widget);
|
|
101
|
+
if (this.props.measure !== undefined) {
|
|
102
|
+
this.parent.setMeasureOverlay(widget, this.props.measure);
|
|
103
|
+
}
|
|
104
|
+
if (this.props.clipOverlay !== undefined) {
|
|
105
|
+
this.parent.setClipOverlay(widget, this.props.clipOverlay);
|
|
106
|
+
}
|
|
47
107
|
}
|
|
48
108
|
}
|
|
49
109
|
registerNodeClass(OverlayChildNode);
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { VirtualChildNode } from "./virtual-child.js";
|
|
3
|
-
type PackableWidget = Gtk.Widget & {
|
|
4
|
-
packStart(child: Gtk.Widget): void;
|
|
5
|
-
packEnd(child: Gtk.Widget): void;
|
|
6
|
-
remove(child: Gtk.Widget): void;
|
|
7
|
-
};
|
|
8
|
-
export declare class PackChild extends VirtualChildNode<PackableWidget> {
|
|
9
|
-
static priority: number;
|
|
10
|
-
static matches(type: string): boolean;
|
|
11
|
-
protected getPositionLabel(): string;
|
|
12
|
-
protected attachChild(parent: PackableWidget, widget: Gtk.Widget): void;
|
|
13
|
-
}
|
|
14
1
|
export {};
|
package/dist/nodes/pack-child.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { VirtualContainerNode } from "./abstract/virtual-container.js";
|
|
3
|
+
class PackStartNode extends VirtualContainerNode {
|
|
4
4
|
static priority = 1;
|
|
5
5
|
static matches(type) {
|
|
6
|
-
return type === "PackStart"
|
|
6
|
+
return type === "PackStart";
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
attachChild(parent, widget) {
|
|
9
|
+
parent.packStart(widget);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class PackEndNode extends VirtualContainerNode {
|
|
13
|
+
static priority = 1;
|
|
14
|
+
static matches(type) {
|
|
15
|
+
return type === "PackEnd";
|
|
10
16
|
}
|
|
11
17
|
attachChild(parent, widget) {
|
|
12
|
-
|
|
13
|
-
parent.packStart(widget);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
parent.packEnd(widget);
|
|
17
|
-
}
|
|
18
|
+
parent.packEnd(widget);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
registerNodeClass(
|
|
21
|
+
registerNodeClass(PackStartNode);
|
|
22
|
+
registerNodeClass(PackEndNode);
|
package/dist/nodes/pack.d.ts
CHANGED
package/dist/nodes/pack.js
CHANGED
|
@@ -1,46 +1,13 @@
|
|
|
1
1
|
import { PACK_INTERFACE_METHODS } from "../generated/internal.js";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { PositionalParentNode } from "./abstract/positional-parent.js";
|
|
3
4
|
import { matchesInterface } from "./internal/utils.js";
|
|
4
|
-
|
|
5
|
-
import { SlotNode } from "./slot.js";
|
|
6
|
-
import { WidgetNode } from "./widget.js";
|
|
7
|
-
class PackNode extends WidgetNode {
|
|
5
|
+
class PackNode extends PositionalParentNode {
|
|
8
6
|
static priority = 0;
|
|
7
|
+
acceptedPositionalChildTypes = new Set(["PackStart", "PackEnd"]);
|
|
8
|
+
containerTypeName = "Pack";
|
|
9
9
|
static matches(_type, containerOrClass) {
|
|
10
10
|
return matchesInterface(PACK_INTERFACE_METHODS, containerOrClass);
|
|
11
11
|
}
|
|
12
|
-
appendChild(child) {
|
|
13
|
-
if (child instanceof PackChild) {
|
|
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 'Pack': expected x.PackStart, x.PackEnd, or Widget`);
|
|
22
|
-
}
|
|
23
|
-
insertBefore(child, before) {
|
|
24
|
-
if (child instanceof PackChild) {
|
|
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 'Pack': expected x.PackStart, x.PackEnd, or Widget`);
|
|
33
|
-
}
|
|
34
|
-
removeChild(child) {
|
|
35
|
-
if (child instanceof PackChild) {
|
|
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 'Pack': expected x.PackStart, x.PackEnd, or Widget`);
|
|
44
|
-
}
|
|
45
12
|
}
|
|
46
13
|
registerNodeClass(PackNode);
|