@gtkx/react 0.16.0 → 0.17.2
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/dist/animation/css-builder.d.ts +3 -0
- package/dist/animation/css-builder.js +53 -0
- package/dist/animation/types.d.ts +120 -0
- package/dist/animation/types.js +1 -0
- package/dist/fiber-root.js +1 -1
- package/dist/generated/jsx.d.ts +354 -351
- package/dist/generated/jsx.js +2 -0
- package/dist/host-config.js +6 -11
- package/dist/jsx.d.ts +39 -10
- package/dist/jsx.js +7 -7
- package/dist/node.d.ts +1 -0
- package/dist/node.js +9 -0
- package/dist/nodes/abstract/virtual-container.d.ts +5 -1
- package/dist/nodes/abstract/virtual-container.js +9 -0
- package/dist/nodes/abstract/virtual-single-child.js +2 -1
- package/dist/nodes/action-row-child.js +8 -0
- package/dist/nodes/animation.d.ts +1 -0
- package/dist/nodes/animation.js +252 -0
- package/dist/nodes/event-controller.d.ts +22 -1
- package/dist/nodes/event-controller.js +2 -2
- package/dist/nodes/expander-row-child.js +8 -0
- package/dist/nodes/fixed-child.js +4 -0
- package/dist/nodes/grid-child.js +4 -0
- package/dist/nodes/index.d.ts +2 -4
- package/dist/nodes/index.js +2 -4
- package/dist/nodes/internal/deferred-action.d.ts +1 -0
- package/dist/nodes/internal/deferred-action.js +3 -0
- package/dist/nodes/internal/list-store.d.ts +4 -6
- package/dist/nodes/internal/list-store.js +26 -31
- package/dist/nodes/internal/selection-model.js +0 -4
- package/dist/nodes/internal/signal-store.d.ts +4 -1
- package/dist/nodes/internal/signal-store.js +6 -8
- package/dist/nodes/internal/text-buffer-controller.js +1 -1
- package/dist/nodes/internal/tree-store.d.ts +2 -6
- package/dist/nodes/internal/tree-store.js +58 -56
- package/dist/nodes/list-view.js +2 -1
- package/dist/nodes/models/tree-list.js +1 -1
- package/dist/nodes/overlay-child.js +7 -7
- package/dist/nodes/pack-child.js +8 -0
- package/dist/nodes/shortcut-controller.js +6 -61
- package/dist/nodes/slot.js +1 -1
- package/dist/nodes/text-paintable.d.ts +6 -0
- package/dist/nodes/toggle-group.js +1 -1
- package/dist/nodes/toolbar-child.js +22 -29
- package/dist/nodes/tree-list-view.js +2 -1
- package/dist/nodes/web-view.d.ts +1 -0
- package/dist/nodes/web-view.js +29 -0
- package/dist/render.js +1 -1
- package/package.json +4 -4
- package/dist/nodes/abstract/positional-parent.d.ts +0 -18
- package/dist/nodes/abstract/positional-parent.js +0 -48
- package/dist/nodes/action-row.d.ts +0 -6
- package/dist/nodes/action-row.js +0 -13
- package/dist/nodes/animation/animation-controller.d.ts +0 -17
- package/dist/nodes/animation/animation-controller.js +0 -107
- package/dist/nodes/animation/animation-factory.d.ts +0 -15
- package/dist/nodes/animation/animation-factory.js +0 -25
- package/dist/nodes/animation/animation-node.d.ts +0 -9
- package/dist/nodes/animation/animation-node.js +0 -126
- package/dist/nodes/animation/animation-style-sheet.d.ts +0 -16
- package/dist/nodes/animation/animation-style-sheet.js +0 -74
- package/dist/nodes/animation/index.d.ts +0 -4
- package/dist/nodes/animation/index.js +0 -1
- package/dist/nodes/animation/property-mapper.d.ts +0 -11
- package/dist/nodes/animation/property-mapper.js +0 -36
- package/dist/nodes/animation/transform-state.d.ts +0 -11
- package/dist/nodes/animation/transform-state.js +0 -57
- package/dist/nodes/animation/widget-registry.d.ts +0 -5
- package/dist/nodes/animation/widget-registry.js +0 -42
- package/dist/nodes/expander-row.d.ts +0 -6
- package/dist/nodes/expander-row.js +0 -18
- package/dist/nodes/internal/base-store.d.ts +0 -9
- package/dist/nodes/internal/base-store.js +0 -20
- package/dist/nodes/pack.d.ts +0 -6
- package/dist/nodes/pack.js +0 -13
package/dist/nodes/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "./action-row.js";
|
|
2
1
|
import "./adjustable.js";
|
|
3
|
-
import "./animation
|
|
2
|
+
import "./animation.js";
|
|
4
3
|
import "./alert-dialog-response.js";
|
|
5
4
|
import "./application.js";
|
|
6
5
|
import "./autowrapped.js";
|
|
@@ -10,7 +9,6 @@ import "./column-view-column.js";
|
|
|
10
9
|
import "./column-view.js";
|
|
11
10
|
import "./dialog.js";
|
|
12
11
|
import "./drawing-area.js";
|
|
13
|
-
import "./expander-row.js";
|
|
14
12
|
import "./fixed-child.js";
|
|
15
13
|
import "./font-dialog-button.js";
|
|
16
14
|
import "./grid.js";
|
|
@@ -25,7 +23,6 @@ import "./notebook-page-tab.js";
|
|
|
25
23
|
import "./notebook-page.js";
|
|
26
24
|
import "./notebook.js";
|
|
27
25
|
import "./overlay-child.js";
|
|
28
|
-
import "./pack.js";
|
|
29
26
|
import "./popover-menu.js";
|
|
30
27
|
import "./scale.js";
|
|
31
28
|
import "./scrolled-window.js";
|
|
@@ -51,6 +48,7 @@ import "./toolbar-child.js";
|
|
|
51
48
|
import "./tree-list-item.js";
|
|
52
49
|
import "./tree-list-view.js";
|
|
53
50
|
import "./virtual.js";
|
|
51
|
+
import "./web-view.js";
|
|
54
52
|
import "./action-row-child.js";
|
|
55
53
|
import "./expander-row-child.js";
|
|
56
54
|
import "./pack-child.js";
|
package/dist/nodes/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "./action-row.js";
|
|
2
1
|
import "./adjustable.js";
|
|
3
|
-
import "./animation
|
|
2
|
+
import "./animation.js";
|
|
4
3
|
import "./alert-dialog-response.js";
|
|
5
4
|
import "./application.js";
|
|
6
5
|
import "./autowrapped.js";
|
|
@@ -10,7 +9,6 @@ import "./column-view-column.js";
|
|
|
10
9
|
import "./column-view.js";
|
|
11
10
|
import "./dialog.js";
|
|
12
11
|
import "./drawing-area.js";
|
|
13
|
-
import "./expander-row.js";
|
|
14
12
|
import "./fixed-child.js";
|
|
15
13
|
import "./font-dialog-button.js";
|
|
16
14
|
import "./grid.js";
|
|
@@ -25,7 +23,6 @@ import "./notebook-page-tab.js";
|
|
|
25
23
|
import "./notebook-page.js";
|
|
26
24
|
import "./notebook.js";
|
|
27
25
|
import "./overlay-child.js";
|
|
28
|
-
import "./pack.js";
|
|
29
26
|
import "./popover-menu.js";
|
|
30
27
|
import "./scale.js";
|
|
31
28
|
import "./scrolled-window.js";
|
|
@@ -51,6 +48,7 @@ import "./toolbar-child.js";
|
|
|
51
48
|
import "./tree-list-item.js";
|
|
52
49
|
import "./tree-list-view.js";
|
|
53
50
|
import "./virtual.js";
|
|
51
|
+
import "./web-view.js";
|
|
54
52
|
import "./action-row-child.js";
|
|
55
53
|
import "./expander-row-child.js";
|
|
56
54
|
import "./pack-child.js";
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { BaseStore } from "./base-store.js";
|
|
3
2
|
export type ItemUpdatedCallback = (id: string) => void;
|
|
4
|
-
export declare class ListStore
|
|
3
|
+
export declare class ListStore {
|
|
5
4
|
private model;
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private sortedIds;
|
|
5
|
+
private ids;
|
|
6
|
+
private items;
|
|
9
7
|
private onItemUpdated;
|
|
10
8
|
setOnItemUpdated(callback: ItemUpdatedCallback | null): void;
|
|
11
9
|
addItem(id: string, item: unknown): void;
|
|
12
10
|
removeItem(id: string): void;
|
|
13
11
|
insertItemBefore(id: string, beforeId: string, item: unknown): void;
|
|
14
12
|
updateItem(id: string, item: unknown): void;
|
|
13
|
+
getItem(id: string): unknown;
|
|
15
14
|
getModel(): Gtk.StringList;
|
|
16
|
-
protected sync(): void;
|
|
17
15
|
}
|
|
@@ -1,48 +1,46 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
|
|
3
|
-
export class ListStore extends BaseStore {
|
|
2
|
+
export class ListStore {
|
|
4
3
|
model = new Gtk.StringList();
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
sortedIds = [];
|
|
4
|
+
ids = [];
|
|
5
|
+
items = new Map();
|
|
8
6
|
onItemUpdated = null;
|
|
9
7
|
setOnItemUpdated(callback) {
|
|
10
8
|
this.onItemUpdated = callback;
|
|
11
9
|
}
|
|
12
10
|
addItem(id, item) {
|
|
13
11
|
this.items.set(id, item);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.
|
|
12
|
+
const existingIndex = this.ids.indexOf(id);
|
|
13
|
+
if (existingIndex >= 0) {
|
|
14
|
+
this.model.remove(existingIndex);
|
|
15
|
+
this.ids.splice(existingIndex, 1);
|
|
17
16
|
}
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.scheduleSync();
|
|
17
|
+
this.ids.push(id);
|
|
18
|
+
this.model.append(id);
|
|
21
19
|
}
|
|
22
20
|
removeItem(id) {
|
|
23
|
-
|
|
21
|
+
const index = this.ids.indexOf(id);
|
|
22
|
+
if (index < 0)
|
|
24
23
|
return;
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this.newIdSet.delete(id);
|
|
24
|
+
this.model.remove(index);
|
|
25
|
+
this.ids.splice(index, 1);
|
|
28
26
|
this.items.delete(id);
|
|
29
|
-
this.scheduleSync();
|
|
30
27
|
}
|
|
31
28
|
insertItemBefore(id, beforeId, item) {
|
|
32
29
|
this.items.set(id, item);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
30
|
+
const existingIndex = this.ids.indexOf(id);
|
|
31
|
+
if (existingIndex >= 0) {
|
|
32
|
+
this.model.remove(existingIndex);
|
|
33
|
+
this.ids.splice(existingIndex, 1);
|
|
36
34
|
}
|
|
37
|
-
const beforeIndex = this.
|
|
38
|
-
if (beforeIndex
|
|
39
|
-
this.
|
|
35
|
+
const beforeIndex = this.ids.indexOf(beforeId);
|
|
36
|
+
if (beforeIndex < 0) {
|
|
37
|
+
this.ids.push(id);
|
|
38
|
+
this.model.append(id);
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
|
-
this.
|
|
41
|
+
this.ids.splice(beforeIndex, 0, id);
|
|
42
|
+
this.model.splice(beforeIndex, 0, [id]);
|
|
43
43
|
}
|
|
44
|
-
this.newIdSet.add(id);
|
|
45
|
-
this.scheduleSync();
|
|
46
44
|
}
|
|
47
45
|
updateItem(id, item) {
|
|
48
46
|
if (this.items.has(id)) {
|
|
@@ -53,13 +51,10 @@ export class ListStore extends BaseStore {
|
|
|
53
51
|
this.addItem(id, item);
|
|
54
52
|
}
|
|
55
53
|
}
|
|
54
|
+
getItem(id) {
|
|
55
|
+
return this.items.get(id);
|
|
56
|
+
}
|
|
56
57
|
getModel() {
|
|
57
58
|
return this.model;
|
|
58
59
|
}
|
|
59
|
-
sync() {
|
|
60
|
-
const newOrder = this.newSortedIds;
|
|
61
|
-
const oldLength = this.sortedIds.length;
|
|
62
|
-
this.model.splice(0, oldLength, newOrder.length > 0 ? newOrder : undefined);
|
|
63
|
-
this.sortedIds = [...newOrder];
|
|
64
|
-
}
|
|
65
60
|
}
|
|
@@ -73,10 +73,6 @@ export class SelectionModelManager {
|
|
|
73
73
|
applySelection() {
|
|
74
74
|
const ids = this.pendingSelection;
|
|
75
75
|
const nItems = this.getItemCount();
|
|
76
|
-
if (nItems === 0 && ids && ids.length > 0) {
|
|
77
|
-
this.setSelection(ids);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
76
|
this.pendingSelection = null;
|
|
81
77
|
const selected = ids ? this.resolveSelectionIndices(ids) : new Gtk.Bitset();
|
|
82
78
|
const mask = Gtk.Bitset.newRange(0, nItems);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
2
2
|
type SignalOwner = object;
|
|
3
3
|
export type SignalHandler = (...args: any[]) => any;
|
|
4
|
+
export interface SignalOptions {
|
|
5
|
+
blockable?: boolean;
|
|
6
|
+
}
|
|
4
7
|
export declare class SignalStore {
|
|
5
8
|
private ownerHandlers;
|
|
6
9
|
private blockDepth;
|
|
@@ -8,7 +11,7 @@ export declare class SignalStore {
|
|
|
8
11
|
private wrapHandler;
|
|
9
12
|
private disconnect;
|
|
10
13
|
private connect;
|
|
11
|
-
set(owner: SignalOwner, obj: GObject.
|
|
14
|
+
set(owner: SignalOwner, obj: GObject.Object, signal: string, handler?: SignalHandler | null, options?: SignalOptions): void;
|
|
12
15
|
clear(owner: SignalOwner): void;
|
|
13
16
|
blockAll(): void;
|
|
14
17
|
unblockAll(): void;
|
|
@@ -14,8 +14,6 @@ const LIFECYCLE_SIGNALS = new Set([
|
|
|
14
14
|
"bind",
|
|
15
15
|
"unbind",
|
|
16
16
|
"teardown",
|
|
17
|
-
"load-changed",
|
|
18
|
-
"notify",
|
|
19
17
|
]);
|
|
20
18
|
export class SignalStore {
|
|
21
19
|
ownerHandlers = new Map();
|
|
@@ -28,9 +26,9 @@ export class SignalStore {
|
|
|
28
26
|
}
|
|
29
27
|
return map;
|
|
30
28
|
}
|
|
31
|
-
wrapHandler(handler, signal) {
|
|
29
|
+
wrapHandler(handler, signal, blockable) {
|
|
32
30
|
return (...args) => {
|
|
33
|
-
if (this.blockDepth > 0 && !LIFECYCLE_SIGNALS.has(signal)) {
|
|
31
|
+
if (this.blockDepth > 0 && blockable && !LIFECYCLE_SIGNALS.has(signal)) {
|
|
34
32
|
return;
|
|
35
33
|
}
|
|
36
34
|
const [self, ...rest] = args;
|
|
@@ -47,17 +45,17 @@ export class SignalStore {
|
|
|
47
45
|
ownerMap?.delete(key);
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
connect(owner, obj, signal, handler) {
|
|
48
|
+
connect(owner, obj, signal, handler, blockable) {
|
|
51
49
|
const objectId = getNativeId(obj.handle);
|
|
52
50
|
const key = `${objectId}:${signal}`;
|
|
53
|
-
const wrappedHandler = this.wrapHandler(handler, signal);
|
|
51
|
+
const wrappedHandler = this.wrapHandler(handler, signal, blockable);
|
|
54
52
|
const handlerId = obj.connect(signal, wrappedHandler);
|
|
55
53
|
this.getOwnerMap(owner).set(key, { obj, handlerId });
|
|
56
54
|
}
|
|
57
|
-
set(owner, obj, signal, handler) {
|
|
55
|
+
set(owner, obj, signal, handler, options) {
|
|
58
56
|
this.disconnect(owner, obj, signal);
|
|
59
57
|
if (handler) {
|
|
60
|
-
this.connect(owner, obj, signal, handler);
|
|
58
|
+
this.connect(owner, obj, signal, handler, options?.blockable ?? true);
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
clear(owner) {
|
|
@@ -58,7 +58,7 @@ export class TextBufferController {
|
|
|
58
58
|
const { onBufferChanged, onTextInserted, onTextDeleted, onCanUndoChanged, onCanRedoChanged } = callbacks;
|
|
59
59
|
this.owner.signalStore.set(this.owner, buffer, "changed", onBufferChanged ? () => onBufferChanged(buffer) : null);
|
|
60
60
|
this.owner.signalStore.set(this.owner, buffer, "insert-text", onTextInserted
|
|
61
|
-
? (location, text
|
|
61
|
+
? (location, text) => onTextInserted(buffer, location.getOffset(), text)
|
|
62
62
|
: null);
|
|
63
63
|
this.owner.signalStore.set(this.owner, buffer, "delete-range", onTextDeleted
|
|
64
64
|
? (start, end) => onTextDeleted(buffer, start.getOffset(), end.getOffset())
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { BaseStore } from "./base-store.js";
|
|
3
2
|
export type TreeItemUpdatedCallback = (id: string) => void;
|
|
4
3
|
export type TreeItemData<T = unknown> = {
|
|
5
4
|
value: T;
|
|
@@ -7,15 +6,13 @@ export type TreeItemData<T = unknown> = {
|
|
|
7
6
|
indentForIcon?: boolean;
|
|
8
7
|
hideExpander?: boolean;
|
|
9
8
|
};
|
|
10
|
-
export declare class TreeStore
|
|
9
|
+
export declare class TreeStore {
|
|
11
10
|
private rootIds;
|
|
12
|
-
private newRootIds;
|
|
13
11
|
private children;
|
|
14
|
-
private newChildren;
|
|
15
12
|
private rootModel;
|
|
16
13
|
private childModels;
|
|
14
|
+
private items;
|
|
17
15
|
private onItemUpdated;
|
|
18
|
-
constructor();
|
|
19
16
|
setOnItemUpdated(callback: TreeItemUpdatedCallback | null): void;
|
|
20
17
|
updateItem(id: string, item: TreeItemData): void;
|
|
21
18
|
addItem(id: string, data: TreeItemData, parentId?: string): void;
|
|
@@ -25,5 +22,4 @@ export declare class TreeStore extends BaseStore<TreeItemData> {
|
|
|
25
22
|
getRootModel(): Gtk.StringList;
|
|
26
23
|
getChildrenModel(parentId: string): Gtk.StringList | null;
|
|
27
24
|
hasChildren(parentId: string): boolean;
|
|
28
|
-
protected sync(): void;
|
|
29
25
|
}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
|
|
3
|
-
export class TreeStore extends BaseStore {
|
|
2
|
+
export class TreeStore {
|
|
4
3
|
rootIds = [];
|
|
5
|
-
newRootIds = [];
|
|
6
4
|
children = new Map();
|
|
7
|
-
|
|
8
|
-
rootModel;
|
|
5
|
+
rootModel = new Gtk.StringList();
|
|
9
6
|
childModels = new Map();
|
|
7
|
+
items = new Map();
|
|
10
8
|
onItemUpdated = null;
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
this.rootModel = new Gtk.StringList();
|
|
14
|
-
}
|
|
15
9
|
setOnItemUpdated(callback) {
|
|
16
10
|
this.onItemUpdated = callback;
|
|
17
11
|
}
|
|
@@ -27,83 +21,109 @@ export class TreeStore extends BaseStore {
|
|
|
27
21
|
addItem(id, data, parentId) {
|
|
28
22
|
this.items.set(id, data);
|
|
29
23
|
if (parentId === undefined) {
|
|
30
|
-
const existingIndex = this.
|
|
31
|
-
if (existingIndex
|
|
32
|
-
this.
|
|
24
|
+
const existingIndex = this.rootIds.indexOf(id);
|
|
25
|
+
if (existingIndex >= 0) {
|
|
26
|
+
this.rootModel.remove(existingIndex);
|
|
27
|
+
this.rootIds.splice(existingIndex, 1);
|
|
33
28
|
}
|
|
34
|
-
this.
|
|
29
|
+
this.rootIds.push(id);
|
|
30
|
+
this.rootModel.append(id);
|
|
35
31
|
}
|
|
36
32
|
else {
|
|
37
|
-
let siblings = this.
|
|
33
|
+
let siblings = this.children.get(parentId);
|
|
38
34
|
if (!siblings) {
|
|
39
35
|
siblings = [];
|
|
40
|
-
this.
|
|
36
|
+
this.children.set(parentId, siblings);
|
|
41
37
|
}
|
|
42
38
|
const existingIndex = siblings.indexOf(id);
|
|
43
|
-
if (existingIndex
|
|
39
|
+
if (existingIndex >= 0) {
|
|
40
|
+
const model = this.childModels.get(parentId);
|
|
41
|
+
if (model) {
|
|
42
|
+
model.remove(existingIndex);
|
|
43
|
+
}
|
|
44
44
|
siblings.splice(existingIndex, 1);
|
|
45
45
|
}
|
|
46
46
|
siblings.push(id);
|
|
47
|
+
let model = this.childModels.get(parentId);
|
|
48
|
+
if (!model) {
|
|
49
|
+
model = new Gtk.StringList();
|
|
50
|
+
this.childModels.set(parentId, model);
|
|
51
|
+
}
|
|
52
|
+
model.append(id);
|
|
47
53
|
}
|
|
48
|
-
this.scheduleSync();
|
|
49
54
|
}
|
|
50
55
|
removeItem(id, parentId) {
|
|
51
56
|
this.items.delete(id);
|
|
52
|
-
this.
|
|
57
|
+
this.children.delete(id);
|
|
58
|
+
this.childModels.delete(id);
|
|
53
59
|
if (parentId === undefined) {
|
|
54
|
-
const index = this.
|
|
55
|
-
if (index
|
|
56
|
-
this.
|
|
60
|
+
const index = this.rootIds.indexOf(id);
|
|
61
|
+
if (index >= 0) {
|
|
62
|
+
this.rootIds.splice(index, 1);
|
|
63
|
+
this.rootModel.remove(index);
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
else {
|
|
60
|
-
const siblings = this.
|
|
67
|
+
const siblings = this.children.get(parentId);
|
|
61
68
|
if (siblings) {
|
|
62
69
|
const index = siblings.indexOf(id);
|
|
63
|
-
if (index
|
|
70
|
+
if (index >= 0) {
|
|
64
71
|
siblings.splice(index, 1);
|
|
72
|
+
const model = this.childModels.get(parentId);
|
|
73
|
+
if (model) {
|
|
74
|
+
model.remove(index);
|
|
75
|
+
}
|
|
65
76
|
}
|
|
66
77
|
if (siblings.length === 0) {
|
|
67
|
-
this.
|
|
78
|
+
this.children.delete(parentId);
|
|
68
79
|
}
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
|
-
this.scheduleSync();
|
|
72
82
|
}
|
|
73
83
|
insertItemBefore(id, beforeId, data, parentId) {
|
|
74
84
|
this.items.set(id, data);
|
|
75
85
|
if (parentId === undefined) {
|
|
76
|
-
const existingIndex = this.
|
|
77
|
-
if (existingIndex
|
|
78
|
-
this.
|
|
86
|
+
const existingIndex = this.rootIds.indexOf(id);
|
|
87
|
+
if (existingIndex >= 0) {
|
|
88
|
+
this.rootModel.remove(existingIndex);
|
|
89
|
+
this.rootIds.splice(existingIndex, 1);
|
|
79
90
|
}
|
|
80
|
-
const beforeIndex = this.
|
|
81
|
-
if (beforeIndex
|
|
82
|
-
this.
|
|
91
|
+
const beforeIndex = this.rootIds.indexOf(beforeId);
|
|
92
|
+
if (beforeIndex < 0) {
|
|
93
|
+
this.rootIds.push(id);
|
|
94
|
+
this.rootModel.append(id);
|
|
83
95
|
}
|
|
84
96
|
else {
|
|
85
|
-
this.
|
|
97
|
+
this.rootIds.splice(beforeIndex, 0, id);
|
|
98
|
+
this.rootModel.splice(beforeIndex, 0, [id]);
|
|
86
99
|
}
|
|
87
100
|
}
|
|
88
101
|
else {
|
|
89
|
-
let siblings = this.
|
|
102
|
+
let siblings = this.children.get(parentId);
|
|
90
103
|
if (!siblings) {
|
|
91
104
|
siblings = [];
|
|
92
|
-
this.
|
|
105
|
+
this.children.set(parentId, siblings);
|
|
106
|
+
}
|
|
107
|
+
let model = this.childModels.get(parentId);
|
|
108
|
+
if (!model) {
|
|
109
|
+
model = new Gtk.StringList();
|
|
110
|
+
this.childModels.set(parentId, model);
|
|
93
111
|
}
|
|
94
112
|
const existingIndex = siblings.indexOf(id);
|
|
95
|
-
if (existingIndex
|
|
113
|
+
if (existingIndex >= 0) {
|
|
114
|
+
model.remove(existingIndex);
|
|
96
115
|
siblings.splice(existingIndex, 1);
|
|
97
116
|
}
|
|
98
117
|
const beforeIndex = siblings.indexOf(beforeId);
|
|
99
|
-
if (beforeIndex
|
|
118
|
+
if (beforeIndex < 0) {
|
|
100
119
|
siblings.push(id);
|
|
120
|
+
model.append(id);
|
|
101
121
|
}
|
|
102
122
|
else {
|
|
103
123
|
siblings.splice(beforeIndex, 0, id);
|
|
124
|
+
model.splice(beforeIndex, 0, [id]);
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
|
-
this.scheduleSync();
|
|
107
127
|
}
|
|
108
128
|
getItem(id) {
|
|
109
129
|
return this.items.get(id);
|
|
@@ -112,7 +132,7 @@ export class TreeStore extends BaseStore {
|
|
|
112
132
|
return this.rootModel;
|
|
113
133
|
}
|
|
114
134
|
getChildrenModel(parentId) {
|
|
115
|
-
const childIds = this.children.get(parentId)
|
|
135
|
+
const childIds = this.children.get(parentId);
|
|
116
136
|
if (!childIds || childIds.length === 0) {
|
|
117
137
|
return null;
|
|
118
138
|
}
|
|
@@ -127,22 +147,4 @@ export class TreeStore extends BaseStore {
|
|
|
127
147
|
const childIds = this.children.get(parentId);
|
|
128
148
|
return childIds !== undefined && childIds.length > 0;
|
|
129
149
|
}
|
|
130
|
-
sync() {
|
|
131
|
-
const oldRootLength = this.rootIds.length;
|
|
132
|
-
this.rootModel.splice(0, oldRootLength, this.newRootIds.length > 0 ? this.newRootIds : undefined);
|
|
133
|
-
this.rootIds = [...this.newRootIds];
|
|
134
|
-
for (const [parentId, newChildIds] of this.newChildren) {
|
|
135
|
-
const model = this.childModels.get(parentId);
|
|
136
|
-
if (model) {
|
|
137
|
-
const oldLength = model.getNItems();
|
|
138
|
-
model.splice(0, oldLength, newChildIds.length > 0 ? newChildIds : undefined);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
for (const [parentId] of this.children) {
|
|
142
|
-
if (!this.newChildren.has(parentId)) {
|
|
143
|
-
this.childModels.delete(parentId);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
this.children = new Map(this.newChildren);
|
|
147
|
-
}
|
|
148
150
|
}
|
package/dist/nodes/list-view.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
1
2
|
import { LIST_WIDGET_CLASSES } from "../generated/internal.js";
|
|
2
3
|
import { registerNodeClass } from "../registry.js";
|
|
3
4
|
import { ListItemRenderer } from "./internal/list-item-renderer.js";
|
|
@@ -65,7 +66,7 @@ class ListViewNode extends WidgetNode {
|
|
|
65
66
|
const previousModel = this.list.getSelectionModel();
|
|
66
67
|
this.list.updateProps(oldProps, newProps);
|
|
67
68
|
const currentModel = this.list.getSelectionModel();
|
|
68
|
-
if (previousModel
|
|
69
|
+
if (!isObjectEqual(previousModel, currentModel)) {
|
|
69
70
|
this.container.setModel(currentModel);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -42,10 +42,10 @@ export class TreeList extends VirtualNode {
|
|
|
42
42
|
const id = node.props.id;
|
|
43
43
|
if (id === undefined)
|
|
44
44
|
return;
|
|
45
|
-
this.store.addItem(id, createTreeItemData(node.props), parentId);
|
|
46
45
|
for (const child of node.getChildNodes()) {
|
|
47
46
|
this.addItemWithChildren(child, id);
|
|
48
47
|
}
|
|
48
|
+
this.store.addItem(id, createTreeItemData(node.props), parentId);
|
|
49
49
|
}
|
|
50
50
|
insertBefore(child, before) {
|
|
51
51
|
if (!(child instanceof TreeListItemNode) || !(before instanceof TreeListItemNode)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObjectEqual } from "@gtkx/ffi";
|
|
1
|
+
import { getNativeId, isObjectEqual } from "@gtkx/ffi";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
3
|
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
4
|
import { VirtualNode } from "./virtual.js";
|
|
@@ -9,7 +9,7 @@ class OverlayChildNode extends VirtualNode {
|
|
|
9
9
|
return type === "OverlayChild";
|
|
10
10
|
}
|
|
11
11
|
parent = null;
|
|
12
|
-
children = new
|
|
12
|
+
children = new Map();
|
|
13
13
|
canBeChildOf(parent) {
|
|
14
14
|
return parent instanceof WidgetNode;
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ class OverlayChildNode extends VirtualNode {
|
|
|
22
22
|
unmount() {
|
|
23
23
|
if (this.parent && this.children.size > 0) {
|
|
24
24
|
const parent = this.parent;
|
|
25
|
-
const children = [...this.children];
|
|
25
|
+
const children = [...this.children.values()];
|
|
26
26
|
this.children.clear();
|
|
27
27
|
for (const child of children) {
|
|
28
28
|
const currentParent = child.getParent();
|
|
@@ -39,7 +39,7 @@ class OverlayChildNode extends VirtualNode {
|
|
|
39
39
|
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
40
40
|
}
|
|
41
41
|
const widget = child.container;
|
|
42
|
-
this.children.
|
|
42
|
+
this.children.set(getNativeId(widget.handle), widget);
|
|
43
43
|
scheduleAfterCommit(() => {
|
|
44
44
|
if (this.parent) {
|
|
45
45
|
this.attachChild(widget);
|
|
@@ -51,7 +51,7 @@ class OverlayChildNode extends VirtualNode {
|
|
|
51
51
|
throw new Error(`Cannot insert '${child.typeName}' into '${this.typeName}': expected Widget`);
|
|
52
52
|
}
|
|
53
53
|
const widget = child.container;
|
|
54
|
-
this.children.
|
|
54
|
+
this.children.set(getNativeId(widget.handle), widget);
|
|
55
55
|
scheduleAfterCommit(() => {
|
|
56
56
|
if (this.parent) {
|
|
57
57
|
this.attachChild(widget);
|
|
@@ -64,7 +64,7 @@ class OverlayChildNode extends VirtualNode {
|
|
|
64
64
|
}
|
|
65
65
|
const widget = child.container;
|
|
66
66
|
const parent = this.parent;
|
|
67
|
-
this.children.delete(widget);
|
|
67
|
+
this.children.delete(getNativeId(widget.handle));
|
|
68
68
|
scheduleAfterCommit(() => {
|
|
69
69
|
if (parent) {
|
|
70
70
|
const currentParent = widget.getParent();
|
|
@@ -83,7 +83,7 @@ class OverlayChildNode extends VirtualNode {
|
|
|
83
83
|
const clipOverlayChanged = oldProps?.clipOverlay !== newProps.clipOverlay;
|
|
84
84
|
if (measureChanged || clipOverlayChanged) {
|
|
85
85
|
const parent = this.parent;
|
|
86
|
-
for (const child of this.children) {
|
|
86
|
+
for (const child of this.children.values()) {
|
|
87
87
|
if (measureChanged) {
|
|
88
88
|
parent.setMeasureOverlay(child, newProps.measure ?? false);
|
|
89
89
|
}
|
package/dist/nodes/pack-child.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { PACK_INTERFACE_METHODS } from "../generated/internal.js";
|
|
1
2
|
import { registerNodeClass } from "../registry.js";
|
|
2
3
|
import { VirtualContainerNode } from "./abstract/virtual-container.js";
|
|
4
|
+
import { matchesInterface } from "./internal/utils.js";
|
|
3
5
|
class PackStartNode extends VirtualContainerNode {
|
|
4
6
|
static priority = 1;
|
|
5
7
|
static matches(type) {
|
|
6
8
|
return type === "PackStart";
|
|
7
9
|
}
|
|
10
|
+
canBeChildOf(parent) {
|
|
11
|
+
return matchesInterface(PACK_INTERFACE_METHODS, parent.container);
|
|
12
|
+
}
|
|
8
13
|
attachChild(parent, widget) {
|
|
9
14
|
parent.packStart(widget);
|
|
10
15
|
}
|
|
@@ -14,6 +19,9 @@ class PackEndNode extends VirtualContainerNode {
|
|
|
14
19
|
static matches(type) {
|
|
15
20
|
return type === "PackEnd";
|
|
16
21
|
}
|
|
22
|
+
canBeChildOf(parent) {
|
|
23
|
+
return matchesInterface(PACK_INTERFACE_METHODS, parent.container);
|
|
24
|
+
}
|
|
17
25
|
attachChild(parent, widget) {
|
|
18
26
|
parent.packEnd(widget);
|
|
19
27
|
}
|