@@ -55,7 +55,6 @@ export component PropertyValueWidget inherits VerticalLayout {
55
55
56
56
if root .property-value.kind == PropertyValueKind.boolean: BooleanWidget {
57
57
enabled <=> root .enabled;
58
- property-name <=> root .property-name;
59
58
property-value <=> root .property-value;
60
59
61
60
set-bool-binding (value) => {
@@ -96,13 +95,6 @@ export component PropertyValueWidget inherits VerticalLayout {
96
95
root .update-display-string-impl (value);
97
96
}
98
97
99
- reset-action () => {
100
- root .reset-action ();
101
- }
102
- code-action () => {
103
- root .code-action ();
104
- }
105
-
106
98
init => {
107
99
// Floating editors need to know the current property details. Call the update if something changes.
108
100
if WindowManager.showing-color-picker && WindowManager.current-property-information.name == root .property-name {
@@ -114,7 +106,6 @@ export component PropertyValueWidget inherits VerticalLayout {
114
106
115
107
if root .property-value.kind == PropertyValueKind.code: CodeWidget {
116
108
enabled <=> root .enabled;
117
- property-name <=> root .property-name;
118
109
property-value <=> root .property-value;
119
110
120
111
update-display-string (value) => {
@@ -131,7 +122,6 @@ export component PropertyValueWidget inherits VerticalLayout {
131
122
132
123
if root .property-value.kind == PropertyValueKind.enum: EnumWidget {
133
124
enabled <=> root .enabled;
134
- property-name <=> root .property-name;
135
125
property-value <=> root .property-value;
136
126
137
127
set-enum-binding (text) => {
@@ -145,7 +135,6 @@ export component PropertyValueWidget inherits VerticalLayout {
145
135
146
136
if root .property-value.kind == PropertyValueKind.float: FloatWidget {
147
137
enabled <=> root .enabled;
148
- property-name <=> root .property-name;
149
138
property-value <=> root .property-value;
150
139
151
140
test-float-binding (text, unit) => {
@@ -162,7 +151,6 @@ export component PropertyValueWidget inherits VerticalLayout {
162
151
163
152
if root .property-value.kind == PropertyValueKind.integer: IntegerWidget {
164
153
enabled <=> root .enabled;
165
- property-name <=> root .property-name;
166
154
property-value <=> root .property-value;
167
155
168
156
test-integer-binding (text) => {
@@ -179,7 +167,6 @@ export component PropertyValueWidget inherits VerticalLayout {
179
167
180
168
if root .property-value.kind == PropertyValueKind.string: StringWidget {
181
169
enabled <=> root .enabled;
182
- property-name <=> root .property-name;
183
170
property-value : root .property-value;
184
171
185
172
has-code-action : root .has-code-action;
@@ -196,27 +183,26 @@ export component PropertyValueWidget inherits VerticalLayout {
196
183
update-display-string (value) => {
197
184
root .update-display-string-impl (value);
198
185
}
199
-
200
- reset-action () => {
201
- root .reset-action ();
202
- }
203
- code-action () => {
204
- root .code-action ();
205
- }
206
186
}
207
187
}
208
188
209
189
component IconButton inherits Rectangle {
210
190
in property <image > icon ;
211
191
in property <bool > checked : false ;
212
- TouchArea {
192
+ in property <bool > enabled : true ;
193
+ ta := TouchArea {
213
194
clicked => root .clicked ();
195
+ mouse-cursor: pointer;
196
+ enabled: root .enabled;
214
197
}
215
198
216
199
callback clicked();
217
200
Image {
218
201
height: 1rem ;
219
- colorize: checked ? Palette.accent-background : Palette.foreground.transparentize(0.5 );
202
+ colorize: !enabled ? Palette.foreground.transparentize(0.8 ) :
203
+ checked ? Palette.accent-background :
204
+ ta.has-hover ? Palette.accent-background.transparentize(0.2 ) :
205
+ Palette.foreground.transparentize(0.5 );
220
206
source: root .icon;
221
207
}
222
208
}
@@ -239,15 +225,37 @@ export component PropertyInformationWidget inherits TouchArea {
239
225
}
240
226
private property <PropertyWidgetMode> mode: kind == PropertyValueKind.code ? PropertyWidgetMode.expression : PropertyWidgetMode.value;
241
227
228
+ function code-action() {
229
+ Api.show-document-offset-range(
230
+ element-information.source-uri,
231
+ Api.property-declaration-ranges(property-information.name).defined-at.expression-range.start,
232
+ Api.property-declaration-ranges(property-information.name).defined-at.expression-range.start,
233
+ true ,
234
+ );
235
+ }
236
+ function reset-action() {
237
+ Api.set-code-binding(
238
+ element-information.source-uri,
239
+ element-information.source-version,
240
+ element-information.offset,
241
+ property-information.name,
242
+ "" ,
243
+ );
244
+ }
245
+
242
246
VerticalLayout {
243
247
padding-bottom: EditorSpaceSettings.default-padding;
244
248
padding-right: EditorSpaceSettings.default-padding * 2 ;
249
+ spacing: EditorSpaceSettings.default-spacing / 2 ;
245
250
246
251
HorizontalLayout {
247
252
alignment: LayoutAlignment.space-between;
248
253
NameLabel {
249
254
property-name: property-information.name;
250
255
property-value: property-information.value;
256
+ TouchArea {
257
+ double-clicked => { root .code-action(); }
258
+ }
251
259
}
252
260
253
261
HorizontalLayout {
@@ -261,6 +269,7 @@ export component PropertyInformationWidget inherits TouchArea {
261
269
IconButton {
262
270
icon: @image-url ("../assets/constant.svg" ) ;
263
271
checked: mode == PropertyWidgetMode.value;
272
+ enabled: kind != PropertyValueKind.code;
264
273
clicked => {
265
274
mode = PropertyWidgetMode.value;
266
275
}
@@ -276,32 +285,20 @@ export component PropertyInformationWidget inherits TouchArea {
276
285
277
286
IconButton {
278
287
icon: @image-url ("../assets/revert.svg" ) ;
288
+ enabled: property-information.value.code != "" ;
279
289
clicked => {
280
- Api.set-code-binding(
281
- element-information.source-uri,
282
- element-information.source-version,
283
- element-information.offset,
284
- property-information.name,
285
- "" ,
286
- );
290
+ root .reset-action();
287
291
}
288
292
}
289
293
}
290
294
}
291
295
292
-
293
296
if mode == PropertyWidgetMode.expression : HorizontalLayout {
297
+ alignment: LayoutAlignment.stretch;
294
298
spacing: 5px ;
295
299
IconButton {
296
300
icon: @image-url ("../assets/code.svg" ) ;
297
- clicked => {
298
- Api.show-document-offset-range(
299
- element-information.source-uri,
300
- Api.property-declaration-ranges(property-information.name).defined-at.expression-range.start,
301
- Api.property-declaration-ranges(property-information.name).defined-at.expression-range.start,
302
- true ,
303
- );
304
- }
301
+ clicked => { root .code-action(); }
305
302
}
306
303
ResettingLineEdit {
307
304
enabled: root .enabled;
@@ -331,8 +328,7 @@ export component PropertyInformationWidget inherits TouchArea {
331
328
332
329
if mode == PropertyWidgetMode.value : PropertyValueWidget {
333
330
property-value : root .property-information.value;
334
- // Because the name is given in the PropertyView already. FIXME: we should refactor this so that the PropertyValueWidget don't have the name
335
- property-name : "" ;
331
+ property-name : root .property-information.name;
336
332
enabled : root .enabled;
337
333
338
334
set-current-item () => {
@@ -400,21 +396,11 @@ export component PropertyInformationWidget inherits TouchArea {
400
396
}
401
397
402
398
reset-action () => {
403
- Api.set-code-binding (
404
- element-information.source-uri,
405
- element-information.source-version,
406
- element-information.offset,
407
- property-information.name,
408
- "" ,
409
- );
399
+ root .reset-action ();
410
400
}
401
+
411
402
code-action () => {
412
- Api.show-document-offset-range (
413
- element-information.source-uri,
414
- Api.property-declaration-ranges(property-information.name).defined-at.expression-range.start,
415
- Api.property-declaration-ranges (property-information.name).defined-at.expression-range.start,
416
- true ,
417
- );
403
+ root .code-action ();
418
404
}
419
405
}
420
406
}
@@ -453,6 +439,12 @@ export component PreviewDataPropertyValueWidget inherits VerticalLayout {
453
439
454
440
padding-bottom: EditorSpaceSettings.default-padding;
455
441
padding-right: EditorSpaceSettings.default-padding * 2 ;
442
+ spacing: EditorSpaceSettings.default-spacing / 2 ;
443
+
444
+ NameLabel {
445
+ property-name: root .preview-data.name;
446
+ property-value: root .value;
447
+ }
456
448
457
449
if root .preview-data.kind == PreviewDataKind.Value: PropertyValueWidget {
458
450
property-value <=> root .value;
@@ -516,7 +508,6 @@ export component PreviewDataPropertyValueWidget inherits VerticalLayout {
516
508
}
517
509
if root .preview-data.kind == PreviewDataKind.Json: JsonWidget {
518
510
enabled : root .preview-data.has-setter;
519
- property-name : root .preview-data.name;
520
511
property-value <=> root .value;
521
512
522
513
set-code-binding (text) => {
0 commit comments