dazscript-framework 0.1.15 → 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.
Files changed (82) hide show
  1. package/README.md +365 -93
  2. package/babel.config.js +33 -33
  3. package/dist/babel/trace-babel-plugin.js +243 -243
  4. package/dist/babel/trace-log-babel-plugin.js +164 -164
  5. package/dist/scripts/install-generator.js +185 -185
  6. package/package.json +72 -70
  7. package/src/common/dz-dump.ts +120 -120
  8. package/src/common/log.ts +56 -56
  9. package/src/common/trace.ts +26 -26
  10. package/src/core/action-decorator.ts +15 -15
  11. package/src/core/base-script.ts +30 -30
  12. package/src/core/custom-action.ts +11 -11
  13. package/src/core/global.ts +4 -4
  14. package/src/dialog/basic-dialog.ts +40 -32
  15. package/src/dialog/builders/button-builder.ts +52 -52
  16. package/src/dialog/builders/checkbox-builder.ts +29 -29
  17. package/src/dialog/builders/color-picker-builder.ts +35 -35
  18. package/src/dialog/builders/combo-box-builder.ts +38 -35
  19. package/src/dialog/builders/combo-edit-builder.ts +35 -35
  20. package/src/dialog/builders/dialog-builder.ts +49 -49
  21. package/src/dialog/builders/groupbox-builder.ts +121 -82
  22. package/src/dialog/builders/label-builder.ts +33 -28
  23. package/src/dialog/builders/layout-builder.ts +59 -59
  24. package/src/dialog/builders/line-edit-builder.ts +124 -119
  25. package/src/dialog/builders/list-box-builder.ts +103 -0
  26. package/src/dialog/builders/list-view-builder.ts +396 -328
  27. package/src/dialog/builders/node-selection-builder.ts +55 -55
  28. package/src/dialog/builders/path-combo-box-builder.ts +24 -24
  29. package/src/dialog/builders/popup-menu-builder.ts +46 -46
  30. package/src/dialog/builders/radio-builder.ts +42 -42
  31. package/src/dialog/builders/slider-builder.ts +39 -22
  32. package/src/dialog/builders/splitter-builder.ts +88 -88
  33. package/src/dialog/builders/tab-builder.ts +120 -106
  34. package/src/dialog/builders/widget-builder.ts +136 -124
  35. package/src/dialog/builders/widgets-builder.ts +140 -135
  36. package/src/dialog/input-dialog.ts +30 -27
  37. package/src/dialog/input-validator.ts +8 -8
  38. package/src/dialog/selection-dialog.ts +47 -0
  39. package/src/dialog/shared.ts +8 -8
  40. package/src/helpers/action-helper.ts +214 -81
  41. package/src/helpers/array-helper.ts +170 -145
  42. package/src/helpers/camera-helper.ts +12 -12
  43. package/src/helpers/custom-action-helper.ts +176 -176
  44. package/src/helpers/directory-helper.ts +14 -0
  45. package/src/helpers/file-helper.ts +90 -90
  46. package/src/helpers/http-helper.ts +186 -0
  47. package/src/helpers/input-helper.ts +18 -18
  48. package/src/helpers/list-view-helper.ts +105 -89
  49. package/src/helpers/menu-helper.ts +28 -28
  50. package/src/helpers/message-box-helper.ts +25 -15
  51. package/src/helpers/node-helper.ts +461 -236
  52. package/src/helpers/number-helper.ts +10 -10
  53. package/src/helpers/numeric-property-helper.ts +91 -91
  54. package/src/helpers/object-helper.ts +2 -2
  55. package/src/helpers/pane-helper.ts +28 -20
  56. package/src/helpers/progress-helper.ts +51 -33
  57. package/src/helpers/property-helper.ts +61 -52
  58. package/src/helpers/record-helper.ts +16 -16
  59. package/src/helpers/scene-helper.ts +144 -94
  60. package/src/helpers/script-helper.ts +15 -15
  61. package/src/helpers/skeleton-helper.ts +26 -26
  62. package/src/helpers/splitter-helper.ts +8 -8
  63. package/src/helpers/string-helper.ts +39 -31
  64. package/src/helpers/surface-helper.ts +5 -5
  65. package/src/helpers/undo-helper.ts +8 -8
  66. package/src/helpers/viewport-helper.ts +21 -8
  67. package/src/lib/delayed.ts +38 -38
  68. package/src/lib/dictionary.ts +3 -0
  69. package/src/lib/frame-keys.ts +67 -67
  70. package/src/lib/guid.ts +2 -2
  71. package/src/lib/menu-item.ts +10 -9
  72. package/src/lib/observable.ts +147 -94
  73. package/src/lib/set.ts +50 -25
  74. package/src/lib/settings.ts +112 -104
  75. package/src/lib/tree-node.ts +149 -145
  76. package/src/samples/config.ts +2 -2
  77. package/src/samples/hello-world.dsa.ts +12 -12
  78. package/src/samples/sample-dialog.dsa.ts +51 -51
  79. package/src/samples/sample-dialog.ts +48 -48
  80. package/src/shared/set-keyboard-shortcut.ts +146 -102
  81. package/tsconfig.json +116 -116
  82. package/webpack.config.js +70 -70
@@ -1,82 +1,121 @@
1
- import { Observable } from '@dsf/lib/observable';
2
- import { Direction } from '../shared';
3
- import LayoutBuilder from './layout-builder';
4
- import { IWidgetBuilder, createWidget } from './widget-builder';
5
- import { WidgetBuilderContext } from './widgets-builder';
6
-
7
- export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
8
- private _title: Observable<string>
9
- private _direction: Direction = 'vertical'
10
- private _style: { flat?: boolean }
11
- private _visible: Observable<boolean>
12
- private _columns: number = 1
13
-
14
- constructor(private context: WidgetBuilderContext) {
15
- }
16
-
17
- title(text: string | Observable<string>): this {
18
- this._title = typeof text === 'string'
19
- ? new Observable(text)
20
- : text
21
- return this
22
- }
23
-
24
- vertical(): this {
25
- this._direction = 'vertical'
26
- return this
27
- }
28
-
29
- horizontal(): this {
30
- this._direction = 'horizontal'
31
- return this
32
- }
33
-
34
- style(options: { flat?: boolean }): this {
35
- this._style = options
36
- return this
37
- }
38
-
39
- visible(value: boolean | Observable<boolean>): this {
40
- this._visible = typeof value === 'boolean'
41
- ? new Observable(value)
42
- : value
43
- return this
44
- }
45
-
46
- columns(value: number): this {
47
- this._columns = value
48
- return this
49
- }
50
-
51
- build(then?: (layout: DzVBoxLayout | DzHBoxLayout, groupBox: DzGroupBox) => void): DzGroupBox {
52
- let groupBox = createWidget(this.context).build(DzGroupBox)
53
-
54
- groupBox.title = this._title?.value
55
- groupBox.flat = this._style?.flat
56
- groupBox.columns = this._columns
57
-
58
- this._title?.connect((text) => {
59
- groupBox.title = text
60
- })
61
-
62
- new LayoutBuilder(this.context)
63
- .parent(groupBox)
64
- .direction(this._direction)
65
- .build((layout) => {
66
- then?.(layout, groupBox)
67
- })
68
-
69
- if (this._visible) {
70
- if (this._visible.value === false)
71
- groupBox.hide()
72
- this._visible.connect((visible) => {
73
- if (visible)
74
- groupBox.show()
75
- else
76
- groupBox.hide()
77
- })
78
- }
79
-
80
- return groupBox
81
- }
82
- }
1
+ import { Observable } from '@dsf/lib/observable';
2
+ import { Direction } from '../shared';
3
+ import LayoutBuilder from './layout-builder';
4
+ import { IWidgetBuilder, createWidget } from './widget-builder';
5
+ import { WidgetBuilderContext } from './widgets-builder';
6
+
7
+ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
8
+ private _title: Observable<string>
9
+ private _direction: Direction = 'vertical'
10
+ private _style: { flat?: boolean }
11
+ private _visible: Observable<boolean>
12
+ private _enabled: Observable<boolean>
13
+ private _columns: number = 1
14
+ private _height: number | null = null
15
+ private _minHeight: number | null = null
16
+
17
+ constructor(private context: WidgetBuilderContext) {
18
+ }
19
+
20
+ title(text: string | Observable<string>): this {
21
+ this._title = typeof text === 'string'
22
+ ? new Observable(text)
23
+ : text
24
+ return this
25
+ }
26
+
27
+ vertical(): this {
28
+ this._direction = 'vertical'
29
+ return this
30
+ }
31
+
32
+ horizontal(): this {
33
+ this._direction = 'horizontal'
34
+ return this
35
+ }
36
+
37
+ orientation(direction: Direction): this {
38
+ this._direction = direction
39
+ return this
40
+ }
41
+
42
+ style(options: { flat?: boolean }): this {
43
+ this._style = options
44
+ return this
45
+ }
46
+
47
+ flat(): this {
48
+ this._style = { flat: true }
49
+ return this
50
+ }
51
+
52
+ visible(value: boolean | Observable<boolean>): this {
53
+ this._visible = typeof value === 'boolean'
54
+ ? new Observable(value)
55
+ : value
56
+ return this
57
+ }
58
+
59
+ enabled(value: boolean | Observable<boolean>): this {
60
+ this._enabled = typeof value === 'boolean'
61
+ ? new Observable(value)
62
+ : value
63
+ return this
64
+ }
65
+
66
+ height(value: number): this {
67
+ this._height = value
68
+ return this
69
+ }
70
+
71
+ minHeight(value: number): this {
72
+ this._minHeight = value
73
+ return this
74
+ }
75
+
76
+ columns(value: number): this {
77
+ this._columns = value
78
+ return this
79
+ }
80
+
81
+ build(then?: (layout: DzVBoxLayout | DzHBoxLayout, groupBox: DzGroupBox) => void): DzGroupBox {
82
+ let groupBox = createWidget(this.context).build(DzGroupBox)
83
+
84
+ groupBox.title = this._title?.value
85
+ groupBox.flat = this._style?.flat
86
+ groupBox.columns = this._columns
87
+ if (this._height !== null) groupBox.height = this._height
88
+ if (this._minHeight !== null) groupBox.minHeight = this._minHeight
89
+
90
+ this._title?.connect((text) => {
91
+ groupBox.title = text
92
+ })
93
+
94
+ new LayoutBuilder(this.context)
95
+ .parent(groupBox)
96
+ .direction(this._direction)
97
+ .build((layout) => {
98
+ then?.(layout, groupBox)
99
+ })
100
+
101
+ if (this._visible) {
102
+ if (this._visible.value === false)
103
+ groupBox.hide()
104
+ this._visible.connect((visible) => {
105
+ if (visible)
106
+ groupBox.show()
107
+ else
108
+ groupBox.hide()
109
+ })
110
+ }
111
+
112
+ if (this._enabled) {
113
+ groupBox.enabled = this._enabled.value
114
+ this._enabled.connect((enabled) => {
115
+ groupBox.enabled = enabled
116
+ })
117
+ }
118
+
119
+ return groupBox
120
+ }
121
+ }
@@ -1,28 +1,33 @@
1
- import { WidgetBuilderBase, createWidget } from './widget-builder';
2
- import { WidgetBuilderContext } from './widgets-builder';
3
-
4
- export default class LabelBuilder extends WidgetBuilderBase<DzLabel> {
5
- constructor(context: WidgetBuilderContext) {
6
- super(createWidget(context).build(DzLabel));
7
-
8
- }
9
-
10
- text(text: string): this {
11
- this.widget.text = text;
12
- return this;
13
- }
14
-
15
- minWidth(width: number): this {
16
- this.widget.minWidth = width
17
- return this;
18
- }
19
-
20
- align(alignment: AlignmentFlags): this {
21
- this.widget.alignment = alignment
22
- return this;
23
- }
24
-
25
- build(): DzLabel {
26
- return this.widget;
27
- }
28
- }
1
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
2
+ import { WidgetBuilderContext } from './widgets-builder';
3
+
4
+ export default class LabelBuilder extends WidgetBuilderBase<DzLabel> {
5
+ constructor(context: WidgetBuilderContext) {
6
+ super(createWidget(context).build(DzLabel));
7
+
8
+ }
9
+
10
+ text(text: string): this {
11
+ this.widget.text = text;
12
+ return this;
13
+ }
14
+
15
+ wordWrap(enabled: boolean = true): this {
16
+ this.widget.wordWrap = enabled
17
+ return this
18
+ }
19
+
20
+ minWidth(width: number): this {
21
+ this.widget.minWidth = width
22
+ return this;
23
+ }
24
+
25
+ align(alignment: AlignmentFlags): this {
26
+ this.widget.alignment = alignment
27
+ return this;
28
+ }
29
+
30
+ build(): DzLabel {
31
+ return this.widget;
32
+ }
33
+ }
@@ -1,59 +1,59 @@
1
- import { Direction } from '@dsf/dialog/shared';
2
- import { WidgetBuilderContext } from './widgets-builder';
3
-
4
- export enum LayoutOrientation {
5
- LeftToRight = 0,
6
- RightToLeft = 1,
7
- TopToBottom = 2,
8
- BottomToTop = 3
9
- }
10
-
11
- export default class LayoutBuilder {
12
- private widgetParent: DzWidget | DzLayout | null;
13
- private _direction: Direction = 'vertical';
14
- private _orientation?: LayoutOrientation;
15
-
16
- constructor(protected context: WidgetBuilderContext) { }
17
-
18
- static create(context: WidgetBuilderContext): LayoutBuilder {
19
- return new LayoutBuilder(context)
20
- }
21
-
22
- orientation(orientation: LayoutOrientation): this {
23
- this._orientation = orientation;
24
- return this
25
- }
26
-
27
- direction(direction: Direction): this {
28
- this._direction = direction;
29
- return this;
30
- }
31
-
32
- parent(parent: DzWidget | DzLayout): this {
33
- this.widgetParent = parent;
34
- return this;
35
- }
36
-
37
- build(then?: (layout: DzVBoxLayout | DzHBoxLayout) => void): DzVBoxLayout | DzHBoxLayout {
38
- let parent = this.widgetParent ?? this.context.parent;
39
- let type = this.getLayoutFor(this._direction);
40
- let layout = new type(parent);
41
- if (this._orientation) layout.direction = this._orientation;
42
-
43
- let currentLayout = this.context.layout;
44
- this.context.layout = layout;
45
-
46
- if (parent.inherits("DzWidget") && (parent as any).addLayout)
47
- (parent as DzBasicDialog).addLayout(layout);
48
-
49
- then?.(layout);
50
-
51
- this.context.layout = currentLayout;
52
- return layout;
53
- }
54
-
55
- private getLayoutFor(direction: string): new (arg: any) => DzVBoxLayout | DzHBoxLayout {
56
- return direction === 'horizontal' ? DzHBoxLayout : DzVBoxLayout;
57
- }
58
- }
59
-
1
+ import { Direction } from '@dsf/dialog/shared';
2
+ import { WidgetBuilderContext } from './widgets-builder';
3
+
4
+ export enum LayoutOrientation {
5
+ LeftToRight = 0,
6
+ RightToLeft = 1,
7
+ TopToBottom = 2,
8
+ BottomToTop = 3
9
+ }
10
+
11
+ export default class LayoutBuilder {
12
+ private widgetParent: DzWidget | DzLayout | null;
13
+ private _direction: Direction = 'vertical';
14
+ private _orientation?: LayoutOrientation;
15
+
16
+ constructor(protected context: WidgetBuilderContext) { }
17
+
18
+ static create(context: WidgetBuilderContext): LayoutBuilder {
19
+ return new LayoutBuilder(context)
20
+ }
21
+
22
+ orientation(orientation: LayoutOrientation): this {
23
+ this._orientation = orientation;
24
+ return this
25
+ }
26
+
27
+ direction(direction: Direction): this {
28
+ this._direction = direction;
29
+ return this;
30
+ }
31
+
32
+ parent(parent: DzWidget | DzLayout): this {
33
+ this.widgetParent = parent;
34
+ return this;
35
+ }
36
+
37
+ build(then?: (layout: DzVBoxLayout | DzHBoxLayout) => void): DzVBoxLayout | DzHBoxLayout {
38
+ let parent = this.widgetParent ?? this.context.parent;
39
+ let type = this.getLayoutFor(this._direction);
40
+ let layout = new type(parent);
41
+ if (this._orientation) layout.direction = this._orientation;
42
+
43
+ let currentLayout = this.context.layout;
44
+ this.context.layout = layout;
45
+
46
+ if (parent.inherits("DzWidget") && (parent as any).addLayout)
47
+ (parent as DzBasicDialog).addLayout(layout);
48
+
49
+ then?.(layout);
50
+
51
+ this.context.layout = currentLayout;
52
+ return layout;
53
+ }
54
+
55
+ private getLayoutFor(direction: string): new (arg: any) => DzVBoxLayout | DzHBoxLayout {
56
+ return direction === 'horizontal' ? DzHBoxLayout : DzVBoxLayout;
57
+ }
58
+ }
59
+
@@ -1,119 +1,124 @@
1
- import { Observable } from '@dsf/lib/observable';
2
- import { InputValidator } from '../input-validator';
3
- import { WidgetBuilderBase, createWidget } from './widget-builder';
4
- import { WidgetBuilderContext } from './widgets-builder';
5
-
6
- export default class LineEditBuilder extends WidgetBuilderBase<DzLineEdit> {
7
- private inputValidator: InputValidator
8
- private minValue?: number
9
- private maxValue?: number
10
-
11
- constructor(context: WidgetBuilderContext) {
12
- super(createWidget(context).build(DzLineEdit))
13
- }
14
-
15
- placeholder(text: string): this {
16
- this.widget.placeholderText = text
17
- return this
18
- }
19
-
20
- focus(): this {
21
- this.widget.getWidget().setFocus()
22
- return this
23
- }
24
-
25
- validator(validator: InputValidator | null): this {
26
- if (validator === null) return this
27
- this.inputValidator = validator
28
- let settings = new DzSettings()
29
- settings.setStringValue("validator", InputValidator[validator]);
30
- this.widget.setValidator(settings)
31
- return this
32
- }
33
-
34
- /**
35
- * Sets the min value of the input when validator is set to in or float
36
- * @param minValue
37
- * @returns
38
- */
39
- min(minValue: number): this {
40
- this.minValue = minValue
41
- return this
42
- }
43
-
44
- /**
45
- * Sets the max value of the input when validator is set to in or float
46
- * @param maxValue
47
- * @returns
48
- */
49
- max(maxValue: number): this {
50
- this.maxValue = maxValue
51
- return this
52
- }
53
-
54
- /**
55
- * Clamps the input to min and max values. Only works when validator is set to int or float
56
- * @param min
57
- * @param max
58
- * @returns
59
- */
60
- clamp(min: number, max: number): this {
61
- return this.min(min).max(max)
62
- }
63
-
64
- readOnly(onOff?: Observable<boolean> | null): this {
65
- if (onOff == null) {
66
- this.widget.readOnly = true
67
- return this
68
- }
69
- else {
70
- this.widget.readOnly = onOff.value
71
- onOff.connect((value) => {
72
- this.widget.readOnly = value
73
- })
74
- }
75
- return this
76
- }
77
-
78
- value(text_: string | Observable<string>): this {
79
- if (typeof text_ === 'string') {
80
- this.widget.text = text_
81
- }
82
- else if (text_ instanceof Observable) {
83
- this.widget.text = text_.value;
84
- this.widget.textChanged.scriptConnect((text: string) => {
85
- text_.value = this.clampValue(text);
86
- });
87
- text_.connect((text: string) => {
88
- this.widget.text = text;
89
- });
90
- }
91
-
92
- return this;
93
- }
94
-
95
- private clampValue(text: string): string {
96
- if (this.inputValidator === InputValidator.int || this.inputValidator === InputValidator.float) {
97
- let value = Number(text);
98
- if (!isNaN(value)) {
99
- if (this.minValue !== undefined) {
100
- value = Math.max(value, this.minValue);
101
- }
102
- if (this.maxValue !== undefined) {
103
- value = Math.min(value, this.maxValue);
104
- }
105
- return String(value);
106
- }
107
- }
108
- else if (this.maxValue && text.length > this.maxValue)
109
- text = text[this.maxValue]
110
-
111
- return text;
112
- }
113
-
114
-
115
- build(then?: (lineEdit: DzLineEdit) => void): DzLineEdit {
116
- then?.(this.widget);
117
- return this.widget;
118
- }
119
- }
1
+ import { Observable } from '@dsf/lib/observable';
2
+ import { InputValidator } from '../input-validator';
3
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
4
+ import { WidgetBuilderContext } from './widgets-builder';
5
+
6
+ export default class LineEditBuilder extends WidgetBuilderBase<DzLineEdit> {
7
+ private inputValidator: InputValidator
8
+ private minValue?: number
9
+ private maxValue?: number
10
+
11
+ constructor(context: WidgetBuilderContext) {
12
+ super(createWidget(context).build(DzLineEdit))
13
+ }
14
+
15
+ password(): this {
16
+ this.widget.echoMode = (DzLineEdit as any).Password ?? 2
17
+ return this
18
+ }
19
+
20
+ placeholder(text: string): this {
21
+ this.widget.placeholderText = text
22
+ return this
23
+ }
24
+
25
+ focus(): this {
26
+ this.widget.getWidget().setFocus()
27
+ return this
28
+ }
29
+
30
+ validator(validator: InputValidator | null): this {
31
+ if (validator === null) return this
32
+ this.inputValidator = validator
33
+ let settings = new DzSettings()
34
+ settings.setStringValue("validator", InputValidator[validator]);
35
+ this.widget.setValidator(settings)
36
+ return this
37
+ }
38
+
39
+ /**
40
+ * Sets the min value of the input when validator is set to in or float
41
+ * @param minValue
42
+ * @returns
43
+ */
44
+ min(minValue: number): this {
45
+ this.minValue = minValue
46
+ return this
47
+ }
48
+
49
+ /**
50
+ * Sets the max value of the input when validator is set to in or float
51
+ * @param maxValue
52
+ * @returns
53
+ */
54
+ max(maxValue: number): this {
55
+ this.maxValue = maxValue
56
+ return this
57
+ }
58
+
59
+ /**
60
+ * Clamps the input to min and max values. Only works when validator is set to int or float
61
+ * @param min
62
+ * @param max
63
+ * @returns
64
+ */
65
+ clamp(min: number, max: number): this {
66
+ return this.min(min).max(max)
67
+ }
68
+
69
+ readOnly(onOff?: Observable<boolean> | null): this {
70
+ if (onOff == null) {
71
+ this.widget.readOnly = true
72
+ return this
73
+ }
74
+ else {
75
+ this.widget.readOnly = onOff.value
76
+ onOff.connect((value) => {
77
+ this.widget.readOnly = value
78
+ })
79
+ }
80
+ return this
81
+ }
82
+
83
+ value(text_: string | Observable<string>): this {
84
+ if (typeof text_ === 'string') {
85
+ this.widget.text = text_
86
+ }
87
+ else if (text_ instanceof Observable) {
88
+ this.widget.text = text_.value;
89
+ this.widget.textChanged.scriptConnect((text: string) => {
90
+ text_.value = this.clampValue(text);
91
+ });
92
+ text_.connect((text: string) => {
93
+ this.widget.text = text;
94
+ });
95
+ }
96
+
97
+ return this;
98
+ }
99
+
100
+ private clampValue(text: string): string {
101
+ if (this.inputValidator === InputValidator.int || this.inputValidator === InputValidator.float) {
102
+ let value = Number(text);
103
+ if (!isNaN(value)) {
104
+ if (this.minValue !== undefined) {
105
+ value = Math.max(value, this.minValue);
106
+ }
107
+ if (this.maxValue !== undefined) {
108
+ value = Math.min(value, this.maxValue);
109
+ }
110
+ return String(value);
111
+ }
112
+ }
113
+ else if (this.maxValue && text.length > this.maxValue)
114
+ text = text[this.maxValue]
115
+
116
+ return text;
117
+ }
118
+
119
+
120
+ build(then?: (lineEdit: DzLineEdit) => void): DzLineEdit {
121
+ then?.(this.widget);
122
+ return this.widget;
123
+ }
124
+ }