dazscript-framework 0.1.14 → 0.1.16
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 +365 -93
- package/babel.config.js +33 -33
- package/dist/babel/trace-babel-plugin.js +243 -243
- package/dist/babel/trace-log-babel-plugin.js +164 -164
- package/dist/scripts/install-generator.js +185 -185
- package/package.json +72 -70
- package/src/common/dz-dump.ts +120 -120
- package/src/common/log.ts +56 -57
- package/src/common/trace.ts +26 -26
- package/src/core/action-decorator.ts +15 -15
- package/src/core/base-script.ts +30 -30
- package/src/core/custom-action.ts +11 -11
- package/src/core/global.ts +4 -4
- package/src/dialog/basic-dialog.ts +40 -32
- package/src/dialog/builders/button-builder.ts +52 -52
- package/src/dialog/builders/checkbox-builder.ts +29 -29
- package/src/dialog/builders/color-picker-builder.ts +36 -0
- package/src/dialog/builders/combo-box-builder.ts +38 -35
- package/src/dialog/builders/combo-edit-builder.ts +35 -35
- package/src/dialog/builders/dialog-builder.ts +49 -49
- package/src/dialog/builders/groupbox-builder.ts +121 -73
- package/src/dialog/builders/label-builder.ts +33 -29
- package/src/dialog/builders/layout-builder.ts +59 -59
- package/src/dialog/builders/line-edit-builder.ts +124 -119
- package/src/dialog/builders/list-box-builder.ts +103 -0
- package/src/dialog/builders/list-view-builder.ts +396 -328
- package/src/dialog/builders/node-selection-builder.ts +55 -55
- package/src/dialog/builders/path-combo-box-builder.ts +24 -24
- package/src/dialog/builders/popup-menu-builder.ts +46 -46
- package/src/dialog/builders/radio-builder.ts +42 -42
- package/src/dialog/builders/slider-builder.ts +40 -0
- package/src/dialog/builders/splitter-builder.ts +88 -88
- package/src/dialog/builders/tab-builder.ts +120 -106
- package/src/dialog/builders/widget-builder.ts +136 -124
- package/src/dialog/builders/widgets-builder.ts +140 -125
- package/src/dialog/input-dialog.ts +30 -27
- package/src/dialog/input-validator.ts +8 -8
- package/src/dialog/selection-dialog.ts +47 -0
- package/src/dialog/shared.ts +8 -8
- package/src/helpers/action-helper.ts +214 -81
- package/src/helpers/array-helper.ts +170 -145
- package/src/helpers/camera-helper.ts +12 -12
- package/src/helpers/custom-action-helper.ts +176 -176
- package/src/helpers/directory-helper.ts +14 -0
- package/src/helpers/file-helper.ts +90 -90
- package/src/helpers/http-helper.ts +186 -0
- package/src/helpers/input-helper.ts +18 -18
- package/src/helpers/list-view-helper.ts +105 -89
- package/src/helpers/menu-helper.ts +28 -28
- package/src/helpers/message-box-helper.ts +25 -15
- package/src/helpers/node-helper.ts +461 -236
- package/src/helpers/number-helper.ts +10 -10
- package/src/helpers/numeric-property-helper.ts +91 -91
- package/src/helpers/object-helper.ts +2 -2
- package/src/helpers/pane-helper.ts +28 -20
- package/src/helpers/progress-helper.ts +51 -33
- package/src/helpers/property-helper.ts +61 -52
- package/src/helpers/record-helper.ts +16 -16
- package/src/helpers/scene-helper.ts +144 -95
- package/src/helpers/script-helper.ts +15 -15
- package/src/helpers/skeleton-helper.ts +26 -26
- package/src/helpers/splitter-helper.ts +8 -8
- package/src/helpers/string-helper.ts +39 -31
- package/src/helpers/surface-helper.ts +5 -5
- package/src/helpers/undo-helper.ts +8 -7
- package/src/helpers/viewport-helper.ts +21 -8
- package/src/lib/delayed.ts +38 -38
- package/src/lib/dictionary.ts +3 -0
- package/src/lib/frame-keys.ts +67 -67
- package/src/lib/guid.ts +2 -2
- package/src/lib/menu-item.ts +10 -9
- package/src/lib/observable.ts +147 -94
- package/src/lib/set.ts +50 -25
- package/src/lib/settings.ts +112 -104
- package/src/lib/tree-node.ts +149 -145
- package/src/samples/config.ts +2 -2
- package/src/samples/hello-world.dsa.ts +12 -12
- package/src/samples/sample-dialog.dsa.ts +51 -51
- package/src/samples/sample-dialog.ts +48 -48
- package/src/shared/set-keyboard-shortcut.ts +146 -102
- package/tsconfig.json +116 -116
- package/webpack.config.js +70 -70
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { Observable } from '@dsf/lib/observable';
|
|
2
|
-
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
3
|
-
import { WidgetBuilderContext } from './widgets-builder';
|
|
4
|
-
|
|
5
|
-
export class NodeSelectionComboBoxBuilder extends WidgetBuilderBase<DzNodeSelectionComboBox> {
|
|
6
|
-
constructor(context: WidgetBuilderContext) {
|
|
7
|
-
super(createWidget(context).withArgs(['DzNode', true]).build(DzNodeSelectionComboBox))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
node(node: Observable<DzNode>): this {
|
|
11
|
-
this.widget.setNode(node.value)
|
|
12
|
-
node.connect((node) => {
|
|
13
|
-
this.widget.setNode(node)
|
|
14
|
-
})
|
|
15
|
-
return this
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
nodes(nodes: Observable<DzNode[]>): this {
|
|
19
|
-
this.widget.setNodes(nodes.value)
|
|
20
|
-
nodes.connect((nodes) => {
|
|
21
|
-
this.widget.setNodes(nodes)
|
|
22
|
-
})
|
|
23
|
-
return this
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
selected(node: Observable<DzNode>): this {
|
|
27
|
-
this.widget.setSelectedNode(node.value)
|
|
28
|
-
node.connect((node) => {
|
|
29
|
-
this.widget.setSelectedNode(node)
|
|
30
|
-
})
|
|
31
|
-
return this
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
value(node: Observable<DzNode>): this {
|
|
35
|
-
this.widget.nodeSelectionChanged.scriptConnect(() => {
|
|
36
|
-
node.value = this.widget.getSelectedNode()
|
|
37
|
-
})
|
|
38
|
-
this.selected(node)
|
|
39
|
-
return this
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
changed(then: (node: DzNode) => void): this {
|
|
43
|
-
this.widget.nodeSelectionChanged.scriptConnect(() => {
|
|
44
|
-
then(this.widget.getSelectedNode())
|
|
45
|
-
})
|
|
46
|
-
return this
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
refresh(): void {
|
|
50
|
-
this.widget.update()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
build(then?: (comboBox: DzNodeSelectionComboBox) => void): DzNodeSelectionComboBox {
|
|
54
|
-
return super.build()
|
|
55
|
-
}
|
|
1
|
+
import { Observable } from '@dsf/lib/observable';
|
|
2
|
+
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
3
|
+
import { WidgetBuilderContext } from './widgets-builder';
|
|
4
|
+
|
|
5
|
+
export class NodeSelectionComboBoxBuilder extends WidgetBuilderBase<DzNodeSelectionComboBox> {
|
|
6
|
+
constructor(context: WidgetBuilderContext) {
|
|
7
|
+
super(createWidget(context).withArgs(['DzNode', true]).build(DzNodeSelectionComboBox))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
node(node: Observable<DzNode>): this {
|
|
11
|
+
this.widget.setNode(node.value)
|
|
12
|
+
node.connect((node) => {
|
|
13
|
+
this.widget.setNode(node)
|
|
14
|
+
})
|
|
15
|
+
return this
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
nodes(nodes: Observable<DzNode[]>): this {
|
|
19
|
+
this.widget.setNodes(nodes.value)
|
|
20
|
+
nodes.connect((nodes) => {
|
|
21
|
+
this.widget.setNodes(nodes)
|
|
22
|
+
})
|
|
23
|
+
return this
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
selected(node: Observable<DzNode>): this {
|
|
27
|
+
this.widget.setSelectedNode(node.value)
|
|
28
|
+
node.connect((node) => {
|
|
29
|
+
this.widget.setSelectedNode(node)
|
|
30
|
+
})
|
|
31
|
+
return this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
value(node: Observable<DzNode>): this {
|
|
35
|
+
this.widget.nodeSelectionChanged.scriptConnect(() => {
|
|
36
|
+
node.value = this.widget.getSelectedNode()
|
|
37
|
+
})
|
|
38
|
+
this.selected(node)
|
|
39
|
+
return this
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
changed(then: (node: DzNode) => void): this {
|
|
43
|
+
this.widget.nodeSelectionChanged.scriptConnect(() => {
|
|
44
|
+
then(this.widget.getSelectedNode())
|
|
45
|
+
})
|
|
46
|
+
return this
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
refresh(): void {
|
|
50
|
+
this.widget.update()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
build(then?: (comboBox: DzNodeSelectionComboBox) => void): DzNodeSelectionComboBox {
|
|
54
|
+
return super.build()
|
|
55
|
+
}
|
|
56
56
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { Observable } from '@dsf/lib/observable';
|
|
2
|
-
import { createWidget, WidgetBuilderBase } from './widget-builder';
|
|
3
|
-
import { WidgetBuilderContext } from './widgets-builder';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export class PathComboBoxBuilder extends WidgetBuilderBase<DzPathComboBox> {
|
|
7
|
-
constructor(context: WidgetBuilderContext, checkBoxes: boolean = false) {
|
|
8
|
-
super(createWidget(context).withArgs([checkBoxes]).build(DzPathComboBox))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
items(items: string[] | Observable<string[]>): this {
|
|
12
|
-
if (items instanceof Array) {
|
|
13
|
-
this.widget.setTypes(items)
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
this.widget.setTypes(items.value)
|
|
17
|
-
items.connect((items) => {
|
|
18
|
-
this.widget.setTypes(items)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return this
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
import { Observable } from '@dsf/lib/observable';
|
|
2
|
+
import { createWidget, WidgetBuilderBase } from './widget-builder';
|
|
3
|
+
import { WidgetBuilderContext } from './widgets-builder';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class PathComboBoxBuilder extends WidgetBuilderBase<DzPathComboBox> {
|
|
7
|
+
constructor(context: WidgetBuilderContext, checkBoxes: boolean = false) {
|
|
8
|
+
super(createWidget(context).withArgs([checkBoxes]).build(DzPathComboBox))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
items(items: string[] | Observable<string[]>): this {
|
|
12
|
+
if (items instanceof Array) {
|
|
13
|
+
this.widget.setTypes(items)
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this.widget.setTypes(items.value)
|
|
17
|
+
items.connect((items) => {
|
|
18
|
+
this.widget.setTypes(items)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
2
|
-
import { WidgetBuilderContext } from './widgets-builder';
|
|
3
|
-
|
|
4
|
-
export class PopupMenuItem {
|
|
5
|
-
id?: number
|
|
6
|
-
text?: string
|
|
7
|
-
checkbox?: boolean
|
|
8
|
-
activated?: (id?: number) => void
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class PopupMenuBuilder extends WidgetBuilderBase<DzPopupMenu> {
|
|
12
|
-
constructor(context: WidgetBuilderContext) {
|
|
13
|
-
super(createWidget(context).build(DzPopupMenu));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
parent(parent: DzWidget): this {
|
|
17
|
-
this.widget.reparent(parent
|
|
18
|
-
return this
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
items(...items: PopupMenuItem[]): this {
|
|
22
|
-
items?.forEach((item, idx) => {
|
|
23
|
-
if (!item.text) {
|
|
24
|
-
this.widget.insertSeparator(idx)
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.widget.insertTextItem(item.text, item.id ?? idx, idx)
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (item.activated) this.widget.connectItem(item.id ?? idx, null, item.activated)
|
|
32
|
-
})
|
|
33
|
-
return this
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
selected(fn: (idx: number) => void): this {
|
|
37
|
-
this.widget.activated.scriptConnect((idx) => {
|
|
38
|
-
fn(idx)
|
|
39
|
-
})
|
|
40
|
-
return this
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
build(then?: (popupMenu: DzPopupMenu) => void): DzPopupMenu {
|
|
44
|
-
then?.(this.widget)
|
|
45
|
-
return this.widget
|
|
46
|
-
}
|
|
1
|
+
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
2
|
+
import { WidgetBuilderContext } from './widgets-builder';
|
|
3
|
+
|
|
4
|
+
export class PopupMenuItem {
|
|
5
|
+
id?: number
|
|
6
|
+
text?: string
|
|
7
|
+
checkbox?: boolean
|
|
8
|
+
activated?: (id?: number) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class PopupMenuBuilder extends WidgetBuilderBase<DzPopupMenu> {
|
|
12
|
+
constructor(context: WidgetBuilderContext) {
|
|
13
|
+
super(createWidget(context).build(DzPopupMenu));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
parent(parent: DzWidget): this {
|
|
17
|
+
this.widget.reparent(parent)
|
|
18
|
+
return this
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
items(...items: PopupMenuItem[]): this {
|
|
22
|
+
items?.forEach((item, idx) => {
|
|
23
|
+
if (!item.text) {
|
|
24
|
+
this.widget.insertSeparator(idx)
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.widget.insertTextItem(item.text, item.id ?? idx, idx)
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (item.activated) this.widget.connectItem(item.id ?? idx, null, item.activated)
|
|
32
|
+
})
|
|
33
|
+
return this
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
selected(fn: (idx: number) => void): this {
|
|
37
|
+
this.widget.activated.scriptConnect((idx) => {
|
|
38
|
+
fn(idx)
|
|
39
|
+
})
|
|
40
|
+
return this
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
build(then?: (popupMenu: DzPopupMenu) => void): DzPopupMenu {
|
|
44
|
+
then?.(this.widget)
|
|
45
|
+
return this.widget
|
|
46
|
+
}
|
|
47
47
|
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { Observable } from '@dsf/lib/observable';
|
|
2
|
-
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
3
|
-
import { WidgetBuilderContext } from './widgets-builder';
|
|
4
|
-
|
|
5
|
-
export default class RadioButtonBuilder extends WidgetBuilderBase<DzRadioButton> {
|
|
6
|
-
constructor(context: WidgetBuilderContext) {
|
|
7
|
-
super(createWidget(context).build(DzRadioButton))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
label(text: string): this {
|
|
11
|
-
this.widget.text = text ?? ''
|
|
12
|
-
return this
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
value(source: boolean | Observable<boolean>): this {
|
|
16
|
-
if (typeof source === 'boolean') {
|
|
17
|
-
this.widget.checked = source
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
this.widget.checked = source.value
|
|
21
|
-
source.connect((value) => {
|
|
22
|
-
this.widget.checked = value
|
|
23
|
-
})
|
|
24
|
-
this.widget.toggled.scriptConnect((value) => {
|
|
25
|
-
source.value = value
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
return this
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
toggled(fn: (value: boolean) => void): this {
|
|
32
|
-
this.widget.toggled.scriptConnect((value) => {
|
|
33
|
-
fn(value)
|
|
34
|
-
})
|
|
35
|
-
return this
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
build(checkbox?: (checkbox: DzRadioButton) => void): DzRadioButton {
|
|
39
|
-
checkbox?.(this.widget)
|
|
40
|
-
return this.widget
|
|
41
|
-
}
|
|
42
|
-
|
|
1
|
+
import { Observable } from '@dsf/lib/observable';
|
|
2
|
+
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
3
|
+
import { WidgetBuilderContext } from './widgets-builder';
|
|
4
|
+
|
|
5
|
+
export default class RadioButtonBuilder extends WidgetBuilderBase<DzRadioButton> {
|
|
6
|
+
constructor(context: WidgetBuilderContext) {
|
|
7
|
+
super(createWidget(context).build(DzRadioButton))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
label(text: string): this {
|
|
11
|
+
this.widget.text = text ?? ''
|
|
12
|
+
return this
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
value(source: boolean | Observable<boolean>): this {
|
|
16
|
+
if (typeof source === 'boolean') {
|
|
17
|
+
this.widget.checked = source
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.widget.checked = source.value
|
|
21
|
+
source.connect((value) => {
|
|
22
|
+
this.widget.checked = value
|
|
23
|
+
})
|
|
24
|
+
this.widget.toggled.scriptConnect((value) => {
|
|
25
|
+
source.value = value
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
return this
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toggled(fn: (value: boolean) => void): this {
|
|
32
|
+
this.widget.toggled.scriptConnect((value) => {
|
|
33
|
+
fn(value)
|
|
34
|
+
})
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
build(checkbox?: (checkbox: DzRadioButton) => void): DzRadioButton {
|
|
39
|
+
checkbox?.(this.widget)
|
|
40
|
+
return this.widget
|
|
41
|
+
}
|
|
42
|
+
|
|
43
43
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Observable } from '@dsf/lib/observable'
|
|
2
|
+
import { WidgetBuilderBase, createWidget } from './widget-builder'
|
|
3
|
+
import { WidgetBuilderContext } from './widgets-builder'
|
|
4
|
+
|
|
5
|
+
export default class SliderBuilder extends WidgetBuilderBase<DzFloatSlider | DzIntSlider> {
|
|
6
|
+
constructor(context: WidgetBuilderContext, readonly type: 'float' | 'integer') {
|
|
7
|
+
super(createWidget(context).build(type === 'float' ? DzFloatSlider : DzIntSlider))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
value(value$: number | Observable<number>): this {
|
|
11
|
+
if (typeof value$ === 'number') {
|
|
12
|
+
this.widget.value = value$
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.widget.value = value$.value
|
|
16
|
+
value$.connect((value) => {
|
|
17
|
+
this.widget.value = value
|
|
18
|
+
});
|
|
19
|
+
(this.widget.valueChanged as unknown as ISignalT<number>).scriptConnect((value) => {
|
|
20
|
+
value$.value = value
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
return this
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
min(min: number): this {
|
|
27
|
+
this.widget.min = min
|
|
28
|
+
return this
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
max(max: number): this {
|
|
32
|
+
this.widget.max = max
|
|
33
|
+
return this
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
clamped(yesNo: boolean): this {
|
|
37
|
+
this.widget.clamped = yesNo
|
|
38
|
+
return this
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { getState, restoreState } from '@dsf/helpers/splitter-helper';
|
|
2
|
-
import { Observable } from '@dsf/lib/observable';
|
|
3
|
-
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
4
|
-
import { WidgetBuilderContext } from './widgets-builder';
|
|
5
|
-
|
|
6
|
-
export class SplitterBuilder extends WidgetBuilderBase<DzSplitter> {
|
|
7
|
-
private _items: DzWidget[] = []
|
|
8
|
-
|
|
9
|
-
constructor(private context: SplitterBuilderContext) {
|
|
10
|
-
super(createWidget(context.widgetContext).build(DzSplitter))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
vertical(): this {
|
|
14
|
-
this.context.orientation = DzSplitter.Vertical
|
|
15
|
-
return this
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
horizontal(): this {
|
|
19
|
-
this.context.orientation = DzSplitter.Horizontal
|
|
20
|
-
return this
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
items(...items: DzWidget[]): this {
|
|
24
|
-
this._items = items
|
|
25
|
-
return this
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
collapsible(...collapsible: boolean[]): this {
|
|
29
|
-
this.context.collapsible = collapsible
|
|
30
|
-
return this
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
strech(...strech: number[]): this {
|
|
34
|
-
this.context.strech = strech
|
|
35
|
-
return this
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
state(bind: Observable<string>): this {
|
|
39
|
-
this.context.state = bind
|
|
40
|
-
return this
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
build(then?: (splitter: DzSplitter) => void): DzSplitter {
|
|
44
|
-
let splitter = createWidget(this.context.widgetContext).build(DzSplitter)
|
|
45
|
-
splitter.orientation = this.context.orientation
|
|
46
|
-
|
|
47
|
-
this._items?.forEach((widget, index) => {
|
|
48
|
-
splitter.addWidget(widget)
|
|
49
|
-
splitter.setCollapsible(index, this.context.collapsible[index] ?? this.context.collapsible[0] ?? false)
|
|
50
|
-
splitter.setStretchFactor(index, this.context.strech[index] ?? this.context.strech[0] ?? 0)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
restoreState(splitter, this.context.state?.value);
|
|
54
|
-
(splitter.getWidget() as QSplitter).splitterMoved.scriptConnect(() => {
|
|
55
|
-
this.context.state.value = getState(splitter)
|
|
56
|
-
})
|
|
57
|
-
this.context.state.connect((state) => {
|
|
58
|
-
restoreState(splitter, state)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
this.context.add(splitter, (splitter) => {
|
|
62
|
-
then?.(splitter)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
return splitter
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export class SplitterBuilderContext {
|
|
70
|
-
private _current: DzSplitter
|
|
71
|
-
|
|
72
|
-
orientation: number = DzSplitter.Vertical
|
|
73
|
-
collapsible: boolean[] = []
|
|
74
|
-
strech: number[] = []
|
|
75
|
-
state = new Observable<string>()
|
|
76
|
-
|
|
77
|
-
get current(): DzSplitter | null {
|
|
78
|
-
return this._current
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
constructor(public readonly widgetContext: WidgetBuilderContext) { }
|
|
82
|
-
|
|
83
|
-
add(splitter: DzSplitter, content: (splitterWidget: DzSplitter) => void): DzSplitter {
|
|
84
|
-
this._current = splitter
|
|
85
|
-
content(splitter)
|
|
86
|
-
this._current = null
|
|
87
|
-
return splitter
|
|
88
|
-
}
|
|
1
|
+
import { getState, restoreState } from '@dsf/helpers/splitter-helper';
|
|
2
|
+
import { Observable } from '@dsf/lib/observable';
|
|
3
|
+
import { WidgetBuilderBase, createWidget } from './widget-builder';
|
|
4
|
+
import { WidgetBuilderContext } from './widgets-builder';
|
|
5
|
+
|
|
6
|
+
export class SplitterBuilder extends WidgetBuilderBase<DzSplitter> {
|
|
7
|
+
private _items: DzWidget[] = []
|
|
8
|
+
|
|
9
|
+
constructor(private context: SplitterBuilderContext) {
|
|
10
|
+
super(createWidget(context.widgetContext).build(DzSplitter))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
vertical(): this {
|
|
14
|
+
this.context.orientation = DzSplitter.Vertical
|
|
15
|
+
return this
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
horizontal(): this {
|
|
19
|
+
this.context.orientation = DzSplitter.Horizontal
|
|
20
|
+
return this
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
items(...items: DzWidget[]): this {
|
|
24
|
+
this._items = items
|
|
25
|
+
return this
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
collapsible(...collapsible: boolean[]): this {
|
|
29
|
+
this.context.collapsible = collapsible
|
|
30
|
+
return this
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
strech(...strech: number[]): this {
|
|
34
|
+
this.context.strech = strech
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
state(bind: Observable<string>): this {
|
|
39
|
+
this.context.state = bind
|
|
40
|
+
return this
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
build(then?: (splitter: DzSplitter) => void): DzSplitter {
|
|
44
|
+
let splitter = createWidget(this.context.widgetContext).build(DzSplitter)
|
|
45
|
+
splitter.orientation = this.context.orientation
|
|
46
|
+
|
|
47
|
+
this._items?.forEach((widget, index) => {
|
|
48
|
+
splitter.addWidget(widget)
|
|
49
|
+
splitter.setCollapsible(index, this.context.collapsible[index] ?? this.context.collapsible[0] ?? false)
|
|
50
|
+
splitter.setStretchFactor(index, this.context.strech[index] ?? this.context.strech[0] ?? 0)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
restoreState(splitter, this.context.state?.value);
|
|
54
|
+
(splitter.getWidget() as QSplitter).splitterMoved.scriptConnect(() => {
|
|
55
|
+
this.context.state.value = getState(splitter)
|
|
56
|
+
})
|
|
57
|
+
this.context.state.connect((state) => {
|
|
58
|
+
restoreState(splitter, state)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
this.context.add(splitter, (splitter) => {
|
|
62
|
+
then?.(splitter)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return splitter
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class SplitterBuilderContext {
|
|
70
|
+
private _current: DzSplitter
|
|
71
|
+
|
|
72
|
+
orientation: number = DzSplitter.Vertical
|
|
73
|
+
collapsible: boolean[] = []
|
|
74
|
+
strech: number[] = []
|
|
75
|
+
state = new Observable<string>()
|
|
76
|
+
|
|
77
|
+
get current(): DzSplitter | null {
|
|
78
|
+
return this._current
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
constructor(public readonly widgetContext: WidgetBuilderContext) { }
|
|
82
|
+
|
|
83
|
+
add(splitter: DzSplitter, content: (splitterWidget: DzSplitter) => void): DzSplitter {
|
|
84
|
+
this._current = splitter
|
|
85
|
+
content(splitter)
|
|
86
|
+
this._current = null
|
|
87
|
+
return splitter
|
|
88
|
+
}
|
|
89
89
|
}
|