dazscript-framework 1.0.22 → 1.0.23
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/package.json
CHANGED
|
@@ -42,12 +42,18 @@ export class DialogBuilder extends WidgetsBuilder {
|
|
|
42
42
|
let dialogWidget = this.context.dialog.getWidget();
|
|
43
43
|
let sizeHint = dialogWidget.minimumSizeHint;
|
|
44
44
|
let maxHeight = this.properties.maxHeight;
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
let hasExplicitHeight = this.properties.height !== undefined;
|
|
46
|
+
let height = this.properties.height;
|
|
47
|
+
if (height !== undefined && maxHeight !== undefined && height > maxHeight) height = maxHeight;
|
|
48
|
+
|
|
49
|
+
if (maxHeight !== undefined) {
|
|
50
|
+
this.context.dialog.minHeight = Math.min(sizeHint.height, maxHeight);
|
|
51
|
+
}
|
|
52
|
+
else if (height !== undefined) {
|
|
53
|
+
this.context.dialog.minHeight = height;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (height !== undefined) this.context.dialog.height = height;
|
|
51
57
|
|
|
52
58
|
if (this.properties.width) this.context.dialog.width = this.properties.width;
|
|
53
59
|
if (this.properties.maxWidth !== undefined) this.context.dialog.maxWidth = this.properties.maxWidth;
|
|
@@ -59,7 +65,8 @@ export class DialogBuilder extends WidgetsBuilder {
|
|
|
59
65
|
else {
|
|
60
66
|
if (this.properties.width)
|
|
61
67
|
this.context.dialog.setFixedWidth(this.properties.width);
|
|
62
|
-
|
|
68
|
+
if (hasExplicitHeight && height !== undefined)
|
|
69
|
+
this.context.dialog.setFixedHeight(height);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
|
|
@@ -15,6 +15,16 @@ class HeaderDialog extends BasicDialog {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
class NonResizableDefaultSizeDialog extends BasicDialog {
|
|
19
|
+
protected build(): void { }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class ExplicitFixedHeightDialog extends BasicDialog {
|
|
23
|
+
protected build(): void {
|
|
24
|
+
this.builder.options({ height: 35 })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
describe('dialog geometry trace', () => {
|
|
19
29
|
beforeEach(() => {
|
|
20
30
|
; (globalThis as any).App = {
|
|
@@ -29,7 +39,11 @@ describe('dialog geometry trace', () => {
|
|
|
29
39
|
width = 300
|
|
30
40
|
height = 200
|
|
31
41
|
minHeight = 0
|
|
42
|
+
maxHeight = 0
|
|
43
|
+
maxWidth = 0
|
|
32
44
|
sizeGripEnabled = false
|
|
45
|
+
fixedHeight: number | undefined
|
|
46
|
+
fixedWidth: number | undefined
|
|
33
47
|
private widget = {
|
|
34
48
|
objectName: '',
|
|
35
49
|
x: 10,
|
|
@@ -50,12 +64,31 @@ describe('dialog geometry trace', () => {
|
|
|
50
64
|
addLayout() { }
|
|
51
65
|
|
|
52
66
|
exec() {
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
if (this.sizeGripEnabled) {
|
|
68
|
+
this.width = 640
|
|
69
|
+
this.height = 480
|
|
70
|
+
this.widget.width = 640
|
|
71
|
+
this.widget.height = 480
|
|
72
|
+
return true
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.widget.minimumSizeHint = { width: 196, height: 76 }
|
|
76
|
+
this.width = this.fixedWidth ?? this.widget.minimumSizeHint.width
|
|
77
|
+
this.height = this.fixedHeight ?? this.widget.minimumSizeHint.height
|
|
78
|
+
this.widget.width = this.width
|
|
79
|
+
this.widget.height = this.height
|
|
57
80
|
return true
|
|
58
81
|
}
|
|
82
|
+
|
|
83
|
+
setFixedHeight(value: number) {
|
|
84
|
+
this.fixedHeight = value
|
|
85
|
+
this.height = value
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setFixedWidth(value: number) {
|
|
89
|
+
this.fixedWidth = value
|
|
90
|
+
this.width = value
|
|
91
|
+
}
|
|
59
92
|
}
|
|
60
93
|
const Layout = class {
|
|
61
94
|
direction = 0
|
|
@@ -145,4 +178,30 @@ describe('dialog geometry trace', () => {
|
|
|
145
178
|
message.includes('objectName="Vholf3DPowerMenu-ActiveToolDlg"')
|
|
146
179
|
)).toBe(true)
|
|
147
180
|
})
|
|
181
|
+
|
|
182
|
+
it('does not freeze a non-resizable dialog to an early implicit size hint', () => {
|
|
183
|
+
new NonResizableDefaultSizeDialog('Store Active Camera').run()
|
|
184
|
+
|
|
185
|
+
const messages = (globalThis as any).App.debug.mock.calls.map((call: unknown[]) => String(call[0]))
|
|
186
|
+
|
|
187
|
+
expect(messages.some((message: string) =>
|
|
188
|
+
message.includes('event=dialog.geometry phase=afterExec') &&
|
|
189
|
+
message.includes('objectName="StoreActiveCameraDlg"') &&
|
|
190
|
+
message.includes('dialogHeight=76') &&
|
|
191
|
+
message.includes('sizeHintHeight=76')
|
|
192
|
+
)).toBe(true)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('keeps explicit non-resizable dialog height fixed', () => {
|
|
196
|
+
new ExplicitFixedHeightDialog('Explicit Height').run()
|
|
197
|
+
|
|
198
|
+
const messages = (globalThis as any).App.debug.mock.calls.map((call: unknown[]) => String(call[0]))
|
|
199
|
+
|
|
200
|
+
expect(messages.some((message: string) =>
|
|
201
|
+
message.includes('event=dialog.geometry phase=afterExec') &&
|
|
202
|
+
message.includes('objectName="ExplicitHeightDlg"') &&
|
|
203
|
+
message.includes('dialogHeight=35') &&
|
|
204
|
+
message.includes('sizeHintHeight=76')
|
|
205
|
+
)).toBe(true)
|
|
206
|
+
})
|
|
148
207
|
})
|