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,125 +1,140 @@
|
|
|
1
|
-
import { Observable } from '@dsf/lib/observable'
|
|
2
|
-
import { ButtonBuilder } from './button-builder'
|
|
3
|
-
import CheckBoxBuilder from './checkbox-builder'
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
1
|
+
import { Observable } from '@dsf/lib/observable'
|
|
2
|
+
import { ButtonBuilder } from './button-builder'
|
|
3
|
+
import CheckBoxBuilder from './checkbox-builder'
|
|
4
|
+
import ColorPickerBuilder from './color-picker-builder'
|
|
5
|
+
import { ComboBoxBuilder } from './combo-box-builder'
|
|
6
|
+
import { ComboEditBuilder } from './combo-edit-builder'
|
|
7
|
+
import GroupBoxBuilder from './groupbox-builder'
|
|
8
|
+
import LabelBuilder from './label-builder'
|
|
9
|
+
import LayoutBuilder, { LayoutOrientation } from './layout-builder'
|
|
10
|
+
import LineEditBuilder from './line-edit-builder'
|
|
11
|
+
import { ListBoxBuilder } from './list-box-builder'
|
|
12
|
+
import { ListViewBuilder } from './list-view-builder'
|
|
13
|
+
import { NodeSelectionComboBoxBuilder } from './node-selection-builder'
|
|
14
|
+
import { PopupMenuBuilder } from './popup-menu-builder'
|
|
15
|
+
import RadioButtonBuilder from './radio-builder'
|
|
16
|
+
import SliderBuilder from './slider-builder'
|
|
17
|
+
import { SplitterBuilder, SplitterBuilderContext } from './splitter-builder'
|
|
18
|
+
import { TabBuilder, TabBuilderContext } from './tab-builder'
|
|
19
|
+
import { createWidget } from './widget-builder'
|
|
20
|
+
|
|
21
|
+
export class WidgetBuilderContext {
|
|
22
|
+
layout: DzLayout | null
|
|
23
|
+
|
|
24
|
+
get parent(): DzWidget | DzLayout {
|
|
25
|
+
return this.layout ?? this.dialog
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor(public readonly dialog: DzBasicDialog) {
|
|
29
|
+
this.layout = new LayoutBuilder(this).build()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class WidgetsBuilder {
|
|
34
|
+
private readonly tabsContext: TabBuilderContext
|
|
35
|
+
private readonly splitterContext: SplitterBuilderContext
|
|
36
|
+
|
|
37
|
+
constructor(public readonly context: WidgetBuilderContext) {
|
|
38
|
+
this.tabsContext = new TabBuilderContext(this.context)
|
|
39
|
+
this.splitterContext = new SplitterBuilderContext(this.context)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
vertical(then: (layout: DzVBoxLayout) => void, orientation: LayoutOrientation = LayoutOrientation.LeftToRight): DzVBoxLayout {
|
|
43
|
+
return LayoutBuilder
|
|
44
|
+
.create(this.context)
|
|
45
|
+
.orientation(orientation)
|
|
46
|
+
.direction('vertical')
|
|
47
|
+
.build(then)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
horizontal(then: (layout: DzHBoxLayout) => void, orientation: LayoutOrientation = LayoutOrientation.LeftToRight): DzHBoxLayout {
|
|
51
|
+
return LayoutBuilder
|
|
52
|
+
.create(this.context)
|
|
53
|
+
.orientation(orientation)
|
|
54
|
+
.direction('horizontal')
|
|
55
|
+
.build(then)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
widget<T extends DzWidget>(type: { new(p0: any, p1?: any, p2?: any, p3?: any): T }, then?: (widget: T) => void): T {
|
|
59
|
+
return createWidget(this.context).build(type, then)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
label(text: string): LabelBuilder {
|
|
63
|
+
return new LabelBuilder(this.context).text(text)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
button(text?: string): ButtonBuilder {
|
|
67
|
+
return new ButtonBuilder(this.context).text(text)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
edit(): LineEditBuilder {
|
|
71
|
+
return new LineEditBuilder(this.context)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
checkbox(label?: string): CheckBoxBuilder {
|
|
75
|
+
return new CheckBoxBuilder(this.context).label(label)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
radio(label?: string): RadioButtonBuilder {
|
|
79
|
+
return new RadioButtonBuilder(this.context).label(label)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
group(title?: string | Observable<string>): GroupBoxBuilder {
|
|
83
|
+
return new GroupBoxBuilder(this.context).title(title)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
tab(title?: string): TabBuilder {
|
|
87
|
+
return TabBuilder.create(this.tabsContext).title(title)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
splitter(...items: DzWidget[]): SplitterBuilder {
|
|
91
|
+
return new SplitterBuilder(this.splitterContext).items(...items)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
contextMenu(): PopupMenuBuilder {
|
|
95
|
+
return new PopupMenuBuilder(this.context)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
combo(): ComboBoxBuilder {
|
|
99
|
+
return new ComboBoxBuilder(this.context)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
comboEdit(): ComboEditBuilder {
|
|
103
|
+
return new ComboEditBuilder(this.context)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// pathComboBox(checkBoxes: boolean = false): PathComboBoxBuilder {
|
|
107
|
+
// return new PathComboBoxBuilder(this.context, checkBoxes)
|
|
108
|
+
// }
|
|
109
|
+
|
|
110
|
+
slider(type: 'float' | 'integer' = 'float'): SliderBuilder {
|
|
111
|
+
return new SliderBuilder(this.context, type)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
color(): ColorPickerBuilder {
|
|
115
|
+
return new ColorPickerBuilder(this.context)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* @returns
|
|
121
|
+
* @deprecated use list
|
|
122
|
+
*/
|
|
123
|
+
listView<TItem, TData = TItem>(): ListViewBuilder<TItem, TData> {
|
|
124
|
+
return new ListViewBuilder(this.context)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get list(): {
|
|
128
|
+
view: <TItem, TData = TItem>() => ListViewBuilder<TItem, TData>
|
|
129
|
+
box: () => ListBoxBuilder
|
|
130
|
+
} {
|
|
131
|
+
return {
|
|
132
|
+
view: <TItem, TData = TItem>() => new ListViewBuilder<TItem, TData>(this.context),
|
|
133
|
+
box: () => new ListBoxBuilder(this.context)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
nodeSelection(): NodeSelectionComboBoxBuilder {
|
|
138
|
+
return new NodeSelectionComboBoxBuilder(this.context)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { Observable } from '@dsf/lib/observable';
|
|
2
|
-
import { BasicDialog } from './basic-dialog';
|
|
3
|
-
import { InputValidator } from './input-validator';
|
|
4
|
-
|
|
5
|
-
export class InputDialogModel {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { Observable } from '@dsf/lib/observable';
|
|
2
|
+
import { BasicDialog } from './basic-dialog';
|
|
3
|
+
import { InputValidator } from './input-validator';
|
|
4
|
+
|
|
5
|
+
export class InputDialogModel {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use `text$` instead
|
|
8
|
+
*/
|
|
9
|
+
value$: Observable<string> = new Observable()
|
|
10
|
+
get text$(): Observable<string> { return this.value$ }
|
|
11
|
+
|
|
12
|
+
validator: InputValidator | null = null
|
|
13
|
+
|
|
14
|
+
getNumericValue(): number {
|
|
15
|
+
return parseFloat(this.value$.value).valueOf()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor(validator: InputValidator | null = null) {
|
|
19
|
+
this.validator = validator
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class InputDialog extends BasicDialog {
|
|
24
|
+
constructor(title: string, private readonly model: InputDialogModel) {
|
|
25
|
+
super(title);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected build(): void {
|
|
29
|
+
this.add.edit().value(this.model.value$).validator(this.model.validator).focus()
|
|
30
|
+
}
|
|
28
31
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export enum InputValidator {
|
|
2
|
-
float,
|
|
3
|
-
int,
|
|
4
|
-
regexp,
|
|
5
|
-
subpath,
|
|
6
|
-
filename,
|
|
7
|
-
nodename,
|
|
8
|
-
nodelabel
|
|
1
|
+
export enum InputValidator {
|
|
2
|
+
float,
|
|
3
|
+
int,
|
|
4
|
+
regexp,
|
|
5
|
+
subpath,
|
|
6
|
+
filename,
|
|
7
|
+
nodename,
|
|
8
|
+
nodelabel
|
|
9
9
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BasicDialog } from './basic-dialog';
|
|
2
|
+
import { Direction } from './shared';
|
|
3
|
+
|
|
4
|
+
export class SelectionDialogModel {
|
|
5
|
+
options: string[] = [];
|
|
6
|
+
selectedOption: string | null = null;
|
|
7
|
+
selectedIndex: number = -1;
|
|
8
|
+
title: string = "Select an Option";
|
|
9
|
+
groupTitle: string = "";
|
|
10
|
+
orientation: Direction = 'horizontal';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class SelectionDialog extends BasicDialog {
|
|
14
|
+
constructor(private readonly model: SelectionDialogModel) {
|
|
15
|
+
super(model.title);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected build(): void {
|
|
19
|
+
this.dialog.showAcceptButton(true);
|
|
20
|
+
this.dialog.showCancelButton(false);
|
|
21
|
+
this.dialog.setAcceptButtonText("Cancel")
|
|
22
|
+
|
|
23
|
+
this.add.group(this.model.groupTitle).orientation(this.model.orientation).build((layout) => {
|
|
24
|
+
layout.spacing = 5;
|
|
25
|
+
this.model.options.forEach(option => {
|
|
26
|
+
this.add.button(option).clicked(() => {
|
|
27
|
+
this.model.selectedOption = option;
|
|
28
|
+
this.model.selectedIndex = this.model.options.indexOf(option);
|
|
29
|
+
this.close();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private buildForm(layout: DzLayout): void {
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ok(): boolean {
|
|
40
|
+
this.run();
|
|
41
|
+
return this.model.selectedOption !== null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
cancel(): boolean {
|
|
45
|
+
return this.ok() === false
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/dialog/shared.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export type Direction = 'vertical' | 'horizontal';
|
|
3
|
-
|
|
4
|
-
export class DialogProperties {
|
|
5
|
-
width?: number;
|
|
6
|
-
height?: number;
|
|
7
|
-
resizable?: boolean;
|
|
8
|
-
}
|
|
1
|
+
|
|
2
|
+
export type Direction = 'vertical' | 'horizontal';
|
|
3
|
+
|
|
4
|
+
export class DialogProperties {
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
resizable?: boolean;
|
|
8
|
+
}
|