@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,53 +1,65 @@
|
|
|
1
|
-
import { batch, isObjectEqual } from "@gtkx/ffi";
|
|
2
1
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { PositionalChildNode } from "./abstract/positional-child.js";
|
|
3
|
+
import { hasChanged } from "./internal/utils.js";
|
|
4
|
+
class FixedChildNode extends PositionalChildNode {
|
|
5
5
|
static priority = 1;
|
|
6
6
|
static matches(type) {
|
|
7
7
|
return type === "FixedChild";
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
onChildChange(oldChild) {
|
|
10
|
+
super.onChildChange(oldChild);
|
|
11
|
+
if (this.child) {
|
|
12
|
+
this.applyTransform();
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
}
|
|
15
|
+
attachToParent(parent, child) {
|
|
16
|
+
const fixed = parent;
|
|
17
|
+
const x = this.props.x ?? 0;
|
|
18
|
+
const y = this.props.y ?? 0;
|
|
19
|
+
fixed.put(child, x, y);
|
|
20
|
+
}
|
|
21
|
+
detachFromParent(parent, child) {
|
|
22
|
+
parent.remove(child);
|
|
14
23
|
}
|
|
15
24
|
updateProps(oldProps, newProps) {
|
|
16
25
|
super.updateProps(oldProps, newProps);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
this.applyOwnProps(oldProps, newProps);
|
|
27
|
+
}
|
|
28
|
+
applyOwnProps(oldProps, newProps) {
|
|
29
|
+
if (!this.parent || !this.child) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const positionChanged = hasChanged(oldProps, newProps, "x") || hasChanged(oldProps, newProps, "y");
|
|
33
|
+
if (positionChanged) {
|
|
34
|
+
this.repositionChild();
|
|
35
|
+
}
|
|
36
|
+
else if (hasChanged(oldProps, newProps, "transform")) {
|
|
37
|
+
this.applyTransform();
|
|
21
38
|
}
|
|
22
39
|
}
|
|
23
|
-
|
|
24
|
-
const fixed = this.
|
|
40
|
+
repositionChild() {
|
|
41
|
+
const fixed = this.getTypedParent();
|
|
42
|
+
const child = this.child;
|
|
43
|
+
if (!child) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
25
46
|
const x = this.props.x ?? 0;
|
|
26
47
|
const y = this.props.y ?? 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const currentParent = child.getParent();
|
|
31
|
-
if (currentParent && isObjectEqual(currentParent, fixed)) {
|
|
32
|
-
fixed.remove(child);
|
|
33
|
-
}
|
|
34
|
-
fixed.put(child, x, y);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
48
|
+
fixed.remove(child);
|
|
49
|
+
fixed.put(child, x, y);
|
|
50
|
+
this.applyTransform();
|
|
37
51
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
52
|
+
applyTransform() {
|
|
53
|
+
if (!this.child || !this.props.transform) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const fixed = this.getTypedParent();
|
|
57
|
+
const layoutManager = fixed.getLayoutManager();
|
|
58
|
+
if (!layoutManager) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const layoutChild = layoutManager.getLayoutChild(this.child);
|
|
62
|
+
layoutChild.setTransform(this.props.transform);
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
65
|
registerNodeClass(FixedChildNode);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
const OWN_PROPS = [
|
|
6
|
+
"fontDesc",
|
|
7
|
+
"onFontDescChanged",
|
|
8
|
+
"title",
|
|
9
|
+
"modal",
|
|
10
|
+
"language",
|
|
11
|
+
"useFont",
|
|
12
|
+
"useSize",
|
|
13
|
+
"level",
|
|
14
|
+
];
|
|
15
|
+
class FontDialogButtonNode extends WidgetNode {
|
|
16
|
+
static priority = 1;
|
|
17
|
+
dialog;
|
|
18
|
+
notifyHandler = null;
|
|
19
|
+
static matches(_type, containerOrClass) {
|
|
20
|
+
return matchesAnyClass([Gtk.FontDialogButton], containerOrClass);
|
|
21
|
+
}
|
|
22
|
+
static createContainer(_props, containerClass) {
|
|
23
|
+
const dialog = new Gtk.FontDialog();
|
|
24
|
+
const button = new containerClass(dialog);
|
|
25
|
+
return button;
|
|
26
|
+
}
|
|
27
|
+
constructor(type, props, container, rootContainer) {
|
|
28
|
+
super(type, props, container, rootContainer);
|
|
29
|
+
const dialog = container.getDialog();
|
|
30
|
+
if (!dialog) {
|
|
31
|
+
throw new Error("FontDialogButton must have a dialog");
|
|
32
|
+
}
|
|
33
|
+
this.dialog = dialog;
|
|
34
|
+
}
|
|
35
|
+
updateProps(oldProps, newProps) {
|
|
36
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
37
|
+
this.applyOwnProps(oldProps, newProps);
|
|
38
|
+
}
|
|
39
|
+
applyOwnProps(oldProps, newProps) {
|
|
40
|
+
if (hasChanged(oldProps, newProps, "title") && newProps.title !== undefined) {
|
|
41
|
+
this.dialog.setTitle(newProps.title);
|
|
42
|
+
}
|
|
43
|
+
if (hasChanged(oldProps, newProps, "modal")) {
|
|
44
|
+
this.dialog.setModal(newProps.modal ?? true);
|
|
45
|
+
}
|
|
46
|
+
if (hasChanged(oldProps, newProps, "language") && newProps.language) {
|
|
47
|
+
this.dialog.setLanguage(newProps.language);
|
|
48
|
+
}
|
|
49
|
+
if (hasChanged(oldProps, newProps, "useFont")) {
|
|
50
|
+
this.container.setUseFont(newProps.useFont ?? false);
|
|
51
|
+
}
|
|
52
|
+
if (hasChanged(oldProps, newProps, "useSize")) {
|
|
53
|
+
this.container.setUseSize(newProps.useSize ?? false);
|
|
54
|
+
}
|
|
55
|
+
if (hasChanged(oldProps, newProps, "level")) {
|
|
56
|
+
this.container.setLevel(newProps.level ?? Gtk.FontLevel.FONT);
|
|
57
|
+
}
|
|
58
|
+
if (hasChanged(oldProps, newProps, "fontDesc") && newProps.fontDesc) {
|
|
59
|
+
this.container.setFontDesc(newProps.fontDesc);
|
|
60
|
+
}
|
|
61
|
+
if (hasChanged(oldProps, newProps, "onFontDescChanged")) {
|
|
62
|
+
this.setupNotifyHandler(newProps.onFontDescChanged);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
setupNotifyHandler(callback) {
|
|
66
|
+
if (this.notifyHandler) {
|
|
67
|
+
this.signalStore.set(this, this.container, "notify", undefined);
|
|
68
|
+
this.notifyHandler = null;
|
|
69
|
+
}
|
|
70
|
+
if (callback) {
|
|
71
|
+
this.notifyHandler = (_button, pspec) => {
|
|
72
|
+
if (pspec.getName() === "font-desc") {
|
|
73
|
+
const fontDesc = this.container.getFontDesc();
|
|
74
|
+
if (fontDesc) {
|
|
75
|
+
callback(fontDesc);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
this.signalStore.set(this, this.container, "notify", this.notifyHandler);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
unmount() {
|
|
83
|
+
if (this.notifyHandler) {
|
|
84
|
+
this.signalStore.set(this, this.container, "notify", undefined);
|
|
85
|
+
this.notifyHandler = null;
|
|
86
|
+
}
|
|
87
|
+
super.unmount();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
registerNodeClass(FontDialogButtonNode);
|
package/dist/nodes/grid-child.js
CHANGED
|
@@ -1,62 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { PositionalChildNode } from "./abstract/positional-child.js";
|
|
4
|
+
import { hasChanged } from "./internal/utils.js";
|
|
5
|
+
class GridChildNode extends PositionalChildNode {
|
|
5
6
|
static priority = 1;
|
|
6
7
|
static matches(type) {
|
|
7
8
|
return type === "GridChild";
|
|
8
9
|
}
|
|
10
|
+
attachToParent(parent, child) {
|
|
11
|
+
const grid = parent;
|
|
12
|
+
const column = this.props.column ?? 0;
|
|
13
|
+
const row = this.props.row ?? 0;
|
|
14
|
+
const columnSpan = this.props.columnSpan ?? 1;
|
|
15
|
+
const rowSpan = this.props.rowSpan ?? 1;
|
|
16
|
+
const existingChild = grid.getChildAt(column, row);
|
|
17
|
+
if (existingChild && !isObjectEqual(existingChild, child)) {
|
|
18
|
+
grid.remove(existingChild);
|
|
19
|
+
}
|
|
20
|
+
grid.attach(child, column, row, columnSpan, rowSpan);
|
|
21
|
+
}
|
|
22
|
+
detachFromParent(parent, child) {
|
|
23
|
+
parent.remove(child);
|
|
24
|
+
}
|
|
9
25
|
updateProps(oldProps, newProps) {
|
|
10
26
|
super.updateProps(oldProps, newProps);
|
|
11
|
-
|
|
12
|
-
oldProps.column !== newProps.column ||
|
|
13
|
-
oldProps.row !== newProps.row ||
|
|
14
|
-
oldProps.columnSpan !== newProps.columnSpan ||
|
|
15
|
-
oldProps.rowSpan !== newProps.rowSpan) {
|
|
16
|
-
if (this.parent && this.child) {
|
|
17
|
-
this.attachChild();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
27
|
+
this.applyOwnProps(oldProps, newProps);
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
applyOwnProps(oldProps, newProps) {
|
|
30
|
+
const positionChanged = hasChanged(oldProps, newProps, "column") ||
|
|
31
|
+
hasChanged(oldProps, newProps, "row") ||
|
|
32
|
+
hasChanged(oldProps, newProps, "columnSpan") ||
|
|
33
|
+
hasChanged(oldProps, newProps, "rowSpan");
|
|
34
|
+
if (positionChanged && this.parent && this.child) {
|
|
35
|
+
this.reattachChild();
|
|
24
36
|
}
|
|
25
|
-
return this.parent;
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
const grid = this.
|
|
38
|
+
reattachChild() {
|
|
39
|
+
const grid = this.getTypedParent();
|
|
40
|
+
const child = this.child;
|
|
41
|
+
if (!child) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
29
44
|
const column = this.props.column ?? 0;
|
|
30
45
|
const row = this.props.row ?? 0;
|
|
31
46
|
const columnSpan = this.props.columnSpan ?? 1;
|
|
32
47
|
const rowSpan = this.props.rowSpan ?? 1;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const currentParent = this.child.getParent();
|
|
40
|
-
if (currentParent && isObjectEqual(currentParent, grid)) {
|
|
41
|
-
grid.remove(this.child);
|
|
42
|
-
}
|
|
43
|
-
grid.attach(this.child, column, row, columnSpan, rowSpan);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
onChildChange(oldChild) {
|
|
48
|
-
const grid = this.getGrid();
|
|
49
|
-
batch(() => {
|
|
50
|
-
if (oldChild) {
|
|
51
|
-
const parent = oldChild.getParent();
|
|
52
|
-
if (parent && isObjectEqual(parent, grid)) {
|
|
53
|
-
grid.remove(oldChild);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (this.child) {
|
|
57
|
-
this.attachChild();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
48
|
+
const existingChild = grid.getChildAt(column, row);
|
|
49
|
+
if (existingChild && !isObjectEqual(existingChild, child)) {
|
|
50
|
+
grid.remove(existingChild);
|
|
51
|
+
}
|
|
52
|
+
grid.remove(child);
|
|
53
|
+
grid.attach(child, column, row, columnSpan, rowSpan);
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
registerNodeClass(GridChildNode);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { isAttachable } from "./internal/predicates.js";
|
|
4
|
+
import { matchesAnyClass } from "./internal/utils.js";
|
|
5
|
+
import { SlotNode } from "./slot.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
class GridNode extends WidgetNode {
|
|
8
|
+
static priority = 0;
|
|
9
|
+
static matches(_type, containerOrClass) {
|
|
10
|
+
return matchesAnyClass([Gtk.Grid], containerOrClass);
|
|
11
|
+
}
|
|
12
|
+
isGridChild(child) {
|
|
13
|
+
return child.typeName === "GridChild";
|
|
14
|
+
}
|
|
15
|
+
appendChild(child) {
|
|
16
|
+
if (child instanceof SlotNode) {
|
|
17
|
+
super.appendChild(child);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (isAttachable(child) && this.isGridChild(child)) {
|
|
21
|
+
child.attachTo(this);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Cannot append '${child.typeName}' to 'Grid': expected x.GridChild`);
|
|
25
|
+
}
|
|
26
|
+
insertBefore(child, _before) {
|
|
27
|
+
this.appendChild(child);
|
|
28
|
+
}
|
|
29
|
+
removeChild(child) {
|
|
30
|
+
if (child instanceof SlotNode) {
|
|
31
|
+
super.removeChild(child);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (isAttachable(child) && this.isGridChild(child)) {
|
|
35
|
+
child.detachFrom(this);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Cannot remove '${child.typeName}' from 'Grid': expected x.GridChild`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
registerNodeClass(GridNode);
|
package/dist/nodes/index.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import "./action-row-child.js";
|
|
2
1
|
import "./action-row.js";
|
|
2
|
+
import "./adjustable.js";
|
|
3
|
+
import "./animation/index.js";
|
|
4
|
+
import "./alert-dialog-response.js";
|
|
3
5
|
import "./application.js";
|
|
4
6
|
import "./autowrapped.js";
|
|
5
|
-
import "./calendar-mark.js";
|
|
6
7
|
import "./calendar.js";
|
|
8
|
+
import "./color-dialog-button.js";
|
|
7
9
|
import "./column-view-column.js";
|
|
8
10
|
import "./column-view.js";
|
|
11
|
+
import "./dialog.js";
|
|
9
12
|
import "./drawing-area.js";
|
|
10
|
-
import "./expander-row-child.js";
|
|
11
13
|
import "./expander-row.js";
|
|
12
14
|
import "./fixed-child.js";
|
|
15
|
+
import "./font-dialog-button.js";
|
|
16
|
+
import "./grid.js";
|
|
13
17
|
import "./grid-child.js";
|
|
14
|
-
import "./level-bar-offset.js";
|
|
15
18
|
import "./level-bar.js";
|
|
16
19
|
import "./list-item.js";
|
|
17
20
|
import "./list-view.js";
|
|
@@ -22,23 +25,25 @@ import "./notebook-page-tab.js";
|
|
|
22
25
|
import "./notebook-page.js";
|
|
23
26
|
import "./notebook.js";
|
|
24
27
|
import "./overlay-child.js";
|
|
25
|
-
import "./pack-child.js";
|
|
26
28
|
import "./pack.js";
|
|
27
29
|
import "./popover-menu.js";
|
|
28
|
-
import "./adjustment.js";
|
|
29
|
-
import "./scale-mark.js";
|
|
30
30
|
import "./scale.js";
|
|
31
31
|
import "./scrolled-window.js";
|
|
32
|
+
import "./search-bar.js";
|
|
32
33
|
import "./shortcut-controller.js";
|
|
33
34
|
import "./shortcut.js";
|
|
35
|
+
import "./event-controller.js";
|
|
34
36
|
import "./simple-list-item.js";
|
|
35
37
|
import "./simple-list-view.js";
|
|
36
38
|
import "./slot.js";
|
|
37
|
-
import "./source-buffer.js";
|
|
38
39
|
import "./source-view.js";
|
|
39
40
|
import "./stack-page.js";
|
|
40
41
|
import "./stack.js";
|
|
41
|
-
import "./text-
|
|
42
|
+
import "./text-anchor.js";
|
|
43
|
+
import "./text-content.js";
|
|
44
|
+
import "./text-paintable.js";
|
|
45
|
+
import "./text-segment.js";
|
|
46
|
+
import "./text-tag.js";
|
|
42
47
|
import "./text-view.js";
|
|
43
48
|
import "./toggle.js";
|
|
44
49
|
import "./toggle-group.js";
|
|
@@ -46,5 +51,8 @@ import "./toolbar-child.js";
|
|
|
46
51
|
import "./tree-list-item.js";
|
|
47
52
|
import "./tree-list-view.js";
|
|
48
53
|
import "./virtual.js";
|
|
54
|
+
import "./action-row-child.js";
|
|
55
|
+
import "./expander-row-child.js";
|
|
56
|
+
import "./pack-child.js";
|
|
49
57
|
import "./widget.js";
|
|
50
58
|
import "./window.js";
|
package/dist/nodes/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import "./action-row-child.js";
|
|
2
1
|
import "./action-row.js";
|
|
2
|
+
import "./adjustable.js";
|
|
3
|
+
import "./animation/index.js";
|
|
4
|
+
import "./alert-dialog-response.js";
|
|
3
5
|
import "./application.js";
|
|
4
6
|
import "./autowrapped.js";
|
|
5
|
-
import "./calendar-mark.js";
|
|
6
7
|
import "./calendar.js";
|
|
8
|
+
import "./color-dialog-button.js";
|
|
7
9
|
import "./column-view-column.js";
|
|
8
10
|
import "./column-view.js";
|
|
11
|
+
import "./dialog.js";
|
|
9
12
|
import "./drawing-area.js";
|
|
10
|
-
import "./expander-row-child.js";
|
|
11
13
|
import "./expander-row.js";
|
|
12
14
|
import "./fixed-child.js";
|
|
15
|
+
import "./font-dialog-button.js";
|
|
16
|
+
import "./grid.js";
|
|
13
17
|
import "./grid-child.js";
|
|
14
|
-
import "./level-bar-offset.js";
|
|
15
18
|
import "./level-bar.js";
|
|
16
19
|
import "./list-item.js";
|
|
17
20
|
import "./list-view.js";
|
|
@@ -22,23 +25,25 @@ import "./notebook-page-tab.js";
|
|
|
22
25
|
import "./notebook-page.js";
|
|
23
26
|
import "./notebook.js";
|
|
24
27
|
import "./overlay-child.js";
|
|
25
|
-
import "./pack-child.js";
|
|
26
28
|
import "./pack.js";
|
|
27
29
|
import "./popover-menu.js";
|
|
28
|
-
import "./adjustment.js";
|
|
29
|
-
import "./scale-mark.js";
|
|
30
30
|
import "./scale.js";
|
|
31
31
|
import "./scrolled-window.js";
|
|
32
|
+
import "./search-bar.js";
|
|
32
33
|
import "./shortcut-controller.js";
|
|
33
34
|
import "./shortcut.js";
|
|
35
|
+
import "./event-controller.js";
|
|
34
36
|
import "./simple-list-item.js";
|
|
35
37
|
import "./simple-list-view.js";
|
|
36
38
|
import "./slot.js";
|
|
37
|
-
import "./source-buffer.js";
|
|
38
39
|
import "./source-view.js";
|
|
39
40
|
import "./stack-page.js";
|
|
40
41
|
import "./stack.js";
|
|
41
|
-
import "./text-
|
|
42
|
+
import "./text-anchor.js";
|
|
43
|
+
import "./text-content.js";
|
|
44
|
+
import "./text-paintable.js";
|
|
45
|
+
import "./text-segment.js";
|
|
46
|
+
import "./text-tag.js";
|
|
42
47
|
import "./text-view.js";
|
|
43
48
|
import "./toggle.js";
|
|
44
49
|
import "./toggle-group.js";
|
|
@@ -46,5 +51,8 @@ import "./toolbar-child.js";
|
|
|
46
51
|
import "./tree-list-item.js";
|
|
47
52
|
import "./tree-list-view.js";
|
|
48
53
|
import "./virtual.js";
|
|
54
|
+
import "./action-row-child.js";
|
|
55
|
+
import "./expander-row-child.js";
|
|
56
|
+
import "./pack-child.js";
|
|
49
57
|
import "./widget.js";
|
|
50
58
|
import "./window.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type Reconciler from "react-reconciler";
|
|
4
|
+
import type { SignalStore } from "./signal-store.js";
|
|
5
|
+
export declare abstract class BaseItemRenderer<TStore = unknown> {
|
|
6
|
+
protected factory: Gtk.SignalListItemFactory;
|
|
7
|
+
protected fiberRoots: Map<number, any>;
|
|
8
|
+
protected tornDown: Set<number>;
|
|
9
|
+
protected estimatedItemHeight: number | null;
|
|
10
|
+
private store;
|
|
11
|
+
protected signalStore: SignalStore;
|
|
12
|
+
protected abstract getStoreTypeName(): string;
|
|
13
|
+
constructor(signalStore: SignalStore);
|
|
14
|
+
getFactory(): Gtk.SignalListItemFactory;
|
|
15
|
+
setEstimatedItemHeight(height: number | null): void;
|
|
16
|
+
setStore(store: TStore | null): void;
|
|
17
|
+
protected getStore(): TStore;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
protected abstract renderItem(ptr: number): ReactNode;
|
|
20
|
+
protected abstract getItemFromListItem(listItem: Gtk.ListItem): unknown;
|
|
21
|
+
protected abstract onSetup(listItem: Gtk.ListItem, ptr: number): Gtk.Widget;
|
|
22
|
+
protected abstract onBind(listItem: Gtk.ListItem, ptr: number, fiberRoot: Reconciler.FiberRoot): void;
|
|
23
|
+
protected abstract onUnbind(listItem: Gtk.ListItem): void;
|
|
24
|
+
protected abstract onTeardown(listItem: Gtk.ListItem, ptr: number): void;
|
|
25
|
+
protected onSetupComplete(_ptr: number): void;
|
|
26
|
+
protected createBox(): Gtk.Box;
|
|
27
|
+
protected clearBoxSizeRequest(box: Gtk.Widget): void;
|
|
28
|
+
private initializeFactory;
|
|
29
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { getNativeId } from "@gtkx/ffi";
|
|
2
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
+
import { createFiberRoot } from "../../fiber-root.js";
|
|
4
|
+
import { reconciler } from "../../reconciler.js";
|
|
5
|
+
export class BaseItemRenderer {
|
|
6
|
+
factory;
|
|
7
|
+
fiberRoots = new Map();
|
|
8
|
+
tornDown = new Set();
|
|
9
|
+
estimatedItemHeight = null;
|
|
10
|
+
store = null;
|
|
11
|
+
signalStore;
|
|
12
|
+
constructor(signalStore) {
|
|
13
|
+
this.signalStore = signalStore;
|
|
14
|
+
this.factory = new Gtk.SignalListItemFactory();
|
|
15
|
+
this.initializeFactory();
|
|
16
|
+
}
|
|
17
|
+
getFactory() {
|
|
18
|
+
return this.factory;
|
|
19
|
+
}
|
|
20
|
+
setEstimatedItemHeight(height) {
|
|
21
|
+
this.estimatedItemHeight = height;
|
|
22
|
+
}
|
|
23
|
+
setStore(store) {
|
|
24
|
+
this.store = store;
|
|
25
|
+
}
|
|
26
|
+
getStore() {
|
|
27
|
+
if (!this.store) {
|
|
28
|
+
throw new Error(`Expected ${this.getStoreTypeName()} to be set on ${this.constructor.name}`);
|
|
29
|
+
}
|
|
30
|
+
return this.store;
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this.signalStore.clear(this);
|
|
34
|
+
this.fiberRoots.clear();
|
|
35
|
+
this.tornDown.clear();
|
|
36
|
+
}
|
|
37
|
+
onSetupComplete(_ptr) { }
|
|
38
|
+
createBox() {
|
|
39
|
+
const box = new Gtk.Box(Gtk.Orientation.HORIZONTAL);
|
|
40
|
+
box.setValign(Gtk.Align.CENTER);
|
|
41
|
+
if (this.estimatedItemHeight !== null) {
|
|
42
|
+
box.setSizeRequest(-1, this.estimatedItemHeight);
|
|
43
|
+
}
|
|
44
|
+
return box;
|
|
45
|
+
}
|
|
46
|
+
clearBoxSizeRequest(box) {
|
|
47
|
+
if (box instanceof Gtk.Box) {
|
|
48
|
+
box.setSizeRequest(-1, -1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
initializeFactory() {
|
|
52
|
+
this.signalStore.set(this, this.factory, "setup", (listItem) => {
|
|
53
|
+
const ptr = getNativeId(listItem.handle);
|
|
54
|
+
const container = this.onSetup(listItem, ptr);
|
|
55
|
+
const fiberRoot = createFiberRoot(container);
|
|
56
|
+
this.fiberRoots.set(ptr, fiberRoot);
|
|
57
|
+
const element = this.renderItem(ptr);
|
|
58
|
+
reconciler.getInstance().updateContainer(element, fiberRoot, null, () => {
|
|
59
|
+
if (this.tornDown.has(ptr))
|
|
60
|
+
return;
|
|
61
|
+
this.onSetupComplete(ptr);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
this.signalStore.set(this, this.factory, "bind", (listItem) => {
|
|
65
|
+
const ptr = getNativeId(listItem.handle);
|
|
66
|
+
const fiberRoot = this.fiberRoots.get(ptr);
|
|
67
|
+
if (!fiberRoot)
|
|
68
|
+
return;
|
|
69
|
+
this.onBind(listItem, ptr, fiberRoot);
|
|
70
|
+
});
|
|
71
|
+
this.signalStore.set(this, this.factory, "unbind", (listItem) => {
|
|
72
|
+
this.onUnbind(listItem);
|
|
73
|
+
});
|
|
74
|
+
this.signalStore.set(this, this.factory, "teardown", (listItem) => {
|
|
75
|
+
const ptr = getNativeId(listItem.handle);
|
|
76
|
+
const fiberRoot = this.fiberRoots.get(ptr);
|
|
77
|
+
if (fiberRoot) {
|
|
78
|
+
this.tornDown.add(ptr);
|
|
79
|
+
this.onTeardown(listItem, ptr);
|
|
80
|
+
reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
|
|
81
|
+
queueMicrotask(() => {
|
|
82
|
+
this.fiberRoots.delete(ptr);
|
|
83
|
+
this.tornDown.delete(ptr);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare abstract class BaseStore<TItem = unknown> {
|
|
2
|
+
protected items: Map<string, TItem>;
|
|
3
|
+
private syncAction;
|
|
4
|
+
constructor();
|
|
5
|
+
getItem(id: string): TItem | undefined;
|
|
6
|
+
updateItem(id: string, item: TItem): void;
|
|
7
|
+
protected scheduleSync(): void;
|
|
8
|
+
protected abstract sync(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CommitPriority } from "../../scheduler.js";
|
|
2
|
+
import { DeferredAction } from "./deferred-action.js";
|
|
3
|
+
export class BaseStore {
|
|
4
|
+
items = new Map();
|
|
5
|
+
syncAction;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.syncAction = new DeferredAction(() => this.sync(), CommitPriority.LOW);
|
|
8
|
+
}
|
|
9
|
+
getItem(id) {
|
|
10
|
+
return this.items.get(id);
|
|
11
|
+
}
|
|
12
|
+
updateItem(id, item) {
|
|
13
|
+
if (this.items.has(id)) {
|
|
14
|
+
this.items.set(id, item);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
scheduleSync() {
|
|
18
|
+
this.syncAction.schedule();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
type AttachmentStrategy = {
|
|
3
|
+
type: "appendable";
|
|
4
|
+
container: Gtk.Widget & {
|
|
5
|
+
append(child: Gtk.Widget): void;
|
|
6
|
+
};
|
|
7
|
+
} | {
|
|
8
|
+
type: "addable";
|
|
9
|
+
container: Gtk.Widget & {
|
|
10
|
+
add(child: Gtk.Widget): void;
|
|
11
|
+
};
|
|
12
|
+
} | {
|
|
13
|
+
type: "content";
|
|
14
|
+
container: Gtk.Widget & {
|
|
15
|
+
setContent(content: Gtk.Widget | null): void;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
type: "singleChild";
|
|
19
|
+
container: Gtk.Widget & {
|
|
20
|
+
setChild(child: Gtk.Widget | null): void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const getAttachmentStrategy: (container: Gtk.Widget) => AttachmentStrategy | null;
|
|
24
|
+
export declare const attachChild: (child: Gtk.Widget, strategy: AttachmentStrategy) => void;
|
|
25
|
+
export declare const detachChild: (child: Gtk.Widget, strategy: AttachmentStrategy) => void;
|
|
26
|
+
export {};
|