@effindomv2/fui-as 0.1.13 → 0.1.15
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
|
@@ -111,14 +111,14 @@ class DefaultDropdownFieldPresenter extends DropdownFieldPresenter {
|
|
|
111
111
|
constructor(metrics: DropdownFieldMetrics = DEFAULT_DROPDOWN_FIELD_METRICS) {
|
|
112
112
|
const valueNode = new Text("")
|
|
113
113
|
.selectable(false)
|
|
114
|
-
.
|
|
114
|
+
.fillSize()
|
|
115
115
|
.maxLines(1)
|
|
116
116
|
.wrapping(false) as Text;
|
|
117
117
|
valueNode
|
|
118
118
|
.overflowFade(true, false)
|
|
119
119
|
.verticalAlign(TextVerticalAlign.Center);
|
|
120
120
|
const valueHost = new FlexBox()
|
|
121
|
-
.
|
|
121
|
+
.fillSize()
|
|
122
122
|
.child(valueNode) as FlexBox;
|
|
123
123
|
const chevronHost = new FlexBox()
|
|
124
124
|
.width(metrics.chevronBoxSize, Unit.Pixel)
|
|
@@ -144,7 +144,8 @@ class DefaultDropdownFieldPresenter extends DropdownFieldPresenter {
|
|
|
144
144
|
.padding(metrics.paddingLeft, metrics.paddingTop, metrics.paddingRight, metrics.paddingBottom)
|
|
145
145
|
.bgColor(state.pressed && state.enabled ? theme.colors.background : theme.colors.surface);
|
|
146
146
|
this.valueHost
|
|
147
|
-
.fillWidth()
|
|
147
|
+
.fillWidth()
|
|
148
|
+
.fillHeight();
|
|
148
149
|
this.valueNode
|
|
149
150
|
.font(theme.fonts.body, metrics.fontSize)
|
|
150
151
|
.textColor(state.enabled ? theme.colors.textPrimary : theme.colors.textMuted);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlignItems, TextVerticalAlign
|
|
1
|
+
import { AlignItems, TextVerticalAlign } from "../../core/ffi";
|
|
2
2
|
import { Theme } from "../../core/Theme";
|
|
3
3
|
import { FlexBox, Text } from "../../nodes";
|
|
4
4
|
import { DropdownSizing } from "../ControlSizing";
|
|
@@ -7,14 +7,12 @@ export class DropdownOptionRowMetrics {
|
|
|
7
7
|
constructor(
|
|
8
8
|
readonly height: f32,
|
|
9
9
|
readonly paddingLeft: f32 = 10.0,
|
|
10
|
-
readonly paddingTop: f32 = 6.0,
|
|
11
10
|
readonly paddingRight: f32 = 10.0,
|
|
12
|
-
readonly paddingBottom: f32 = 6.0,
|
|
13
11
|
readonly fontSize: f32 = 16.0,
|
|
14
12
|
) {}
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
const DEFAULT_DROPDOWN_OPTION_ROW_METRICS = new DropdownOptionRowMetrics(34.0);
|
|
15
|
+
const DEFAULT_DROPDOWN_OPTION_ROW_METRICS = new DropdownOptionRowMetrics(34.0, 10.0, 10.0, 16.0);
|
|
18
16
|
|
|
19
17
|
function resolveOptionRowMetrics(sizing: DropdownSizing | null): DropdownOptionRowMetrics {
|
|
20
18
|
if (sizing === null || (!sizing.hasOptionHeight && !sizing.hasOptionFontSize)) {
|
|
@@ -22,13 +20,10 @@ function resolveOptionRowMetrics(sizing: DropdownSizing | null): DropdownOptionR
|
|
|
22
20
|
}
|
|
23
21
|
const fontSize = sizing.hasOptionFontSize ? sizing.optionFontSizePx : DEFAULT_DROPDOWN_OPTION_ROW_METRICS.fontSize;
|
|
24
22
|
const height = sizing.hasOptionHeight ? sizing.optionHeightPx : DEFAULT_DROPDOWN_OPTION_ROW_METRICS.height;
|
|
25
|
-
const verticalPadding = height > fontSize ? (height - fontSize) * 0.5 : 0.0;
|
|
26
23
|
return new DropdownOptionRowMetrics(
|
|
27
24
|
height,
|
|
28
25
|
DEFAULT_DROPDOWN_OPTION_ROW_METRICS.paddingLeft,
|
|
29
|
-
verticalPadding,
|
|
30
26
|
DEFAULT_DROPDOWN_OPTION_ROW_METRICS.paddingRight,
|
|
31
|
-
verticalPadding,
|
|
32
27
|
fontSize,
|
|
33
28
|
);
|
|
34
29
|
}
|
|
@@ -71,7 +66,7 @@ class DefaultDropdownOptionRowPresenter extends DropdownOptionRowPresenter {
|
|
|
71
66
|
constructor(metrics: DropdownOptionRowMetrics = DEFAULT_DROPDOWN_OPTION_ROW_METRICS) {
|
|
72
67
|
const labelNode = new Text("")
|
|
73
68
|
.selectable(false)
|
|
74
|
-
.
|
|
69
|
+
.fillSize()
|
|
75
70
|
.maxLines(1)
|
|
76
71
|
.wrapping(false) as Text;
|
|
77
72
|
labelNode
|
|
@@ -87,7 +82,7 @@ class DefaultDropdownOptionRowPresenter extends DropdownOptionRowPresenter {
|
|
|
87
82
|
apply(theme: Theme, state: DropdownOptionRowVisualState): void {
|
|
88
83
|
const metrics = this.metrics;
|
|
89
84
|
this.root
|
|
90
|
-
.padding(metrics.paddingLeft,
|
|
85
|
+
.padding(metrics.paddingLeft, 0.0, metrics.paddingRight, 0.0)
|
|
91
86
|
.cornerRadius(theme.spacing.xs)
|
|
92
87
|
.bgColor(state.highlighted ? theme.contextMenu.item.hoverBackground : 0x00000000);
|
|
93
88
|
this.labelNode
|
package/src/nodes/Text.ts
CHANGED
|
@@ -15,9 +15,15 @@ export class Text extends TextCore {
|
|
|
15
15
|
if (props.hasWidth) {
|
|
16
16
|
text.width(props.widthValue, props.widthUnit);
|
|
17
17
|
}
|
|
18
|
+
if (props.hasFillWidth) {
|
|
19
|
+
text.fillWidth();
|
|
20
|
+
}
|
|
18
21
|
if (props.hasHeight) {
|
|
19
22
|
text.height(props.heightValue, props.heightUnit);
|
|
20
23
|
}
|
|
24
|
+
if (props.hasFillHeight) {
|
|
25
|
+
text.fillHeight();
|
|
26
|
+
}
|
|
21
27
|
if (props.hasFontFamily) {
|
|
22
28
|
const family = props.fontFamilyValue;
|
|
23
29
|
if (family !== null) {
|
package/src/nodes/TextCore.ts
CHANGED
|
@@ -20,9 +20,11 @@ export class TextProps {
|
|
|
20
20
|
widthValue: f32 = 0.0;
|
|
21
21
|
widthUnit: Unit = Unit.Pixel;
|
|
22
22
|
hasWidth: bool = false;
|
|
23
|
+
hasFillWidth: bool = false;
|
|
23
24
|
heightValue: f32 = 0.0;
|
|
24
25
|
heightUnit: Unit = Unit.Pixel;
|
|
25
26
|
hasHeight: bool = false;
|
|
27
|
+
hasFillHeight: bool = false;
|
|
26
28
|
fontId: u32 = 0;
|
|
27
29
|
fontSize: f32 = 0.0;
|
|
28
30
|
hasFont: bool = false;
|
|
@@ -66,9 +68,11 @@ export class TextCore extends Node {
|
|
|
66
68
|
private widthValue: f32 = 0.0;
|
|
67
69
|
private widthUnit: Unit = Unit.Pixel;
|
|
68
70
|
private hasWidth: bool = false;
|
|
71
|
+
private hasFillWidth: bool = false;
|
|
69
72
|
private heightValue: f32 = 0.0;
|
|
70
73
|
private heightUnit: Unit = Unit.Pixel;
|
|
71
74
|
private hasHeight: bool = false;
|
|
75
|
+
private hasFillHeight: bool = false;
|
|
72
76
|
private fontId: u32 = 0;
|
|
73
77
|
private fontSizeValue: f32 = 0.0;
|
|
74
78
|
private hasFont: bool = false;
|
|
@@ -147,6 +151,7 @@ export class TextCore extends Node {
|
|
|
147
151
|
this.widthValue = value;
|
|
148
152
|
this.widthUnit = unit;
|
|
149
153
|
this.hasWidth = true;
|
|
154
|
+
this.hasFillWidth = false;
|
|
150
155
|
if (this.hasBuiltHandle()) {
|
|
151
156
|
ui.setWidth(this.handle, value, <u32>unit);
|
|
152
157
|
this.notifyRetainedLayoutMutation();
|
|
@@ -158,6 +163,7 @@ export class TextCore extends Node {
|
|
|
158
163
|
this.heightValue = value;
|
|
159
164
|
this.heightUnit = unit;
|
|
160
165
|
this.hasHeight = true;
|
|
166
|
+
this.hasFillHeight = false;
|
|
161
167
|
if (this.hasBuiltHandle()) {
|
|
162
168
|
ui.setHeight(this.handle, value, <u32>unit);
|
|
163
169
|
this.notifyRetainedLayoutMutation();
|
|
@@ -165,6 +171,30 @@ export class TextCore extends Node {
|
|
|
165
171
|
return this;
|
|
166
172
|
}
|
|
167
173
|
|
|
174
|
+
fillWidth(): this {
|
|
175
|
+
this.hasFillWidth = true;
|
|
176
|
+
if (this.hasBuiltHandle()) {
|
|
177
|
+
ui.setFillWidth(this.handle, true);
|
|
178
|
+
this.notifyRetainedLayoutMutation();
|
|
179
|
+
}
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
fillHeight(): this {
|
|
184
|
+
this.hasFillHeight = true;
|
|
185
|
+
if (this.hasBuiltHandle()) {
|
|
186
|
+
ui.setFillHeight(this.handle, true);
|
|
187
|
+
this.notifyRetainedLayoutMutation();
|
|
188
|
+
}
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fillSize(): this {
|
|
193
|
+
this.fillWidth();
|
|
194
|
+
this.fillHeight();
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
168
198
|
text(content: string): this {
|
|
169
199
|
this.contentValue = content;
|
|
170
200
|
if (this.hasBuiltHandle()) {
|
|
@@ -423,9 +453,15 @@ export class TextCore extends Node {
|
|
|
423
453
|
if (this.hasWidth) {
|
|
424
454
|
ui.setWidth(this.handle, this.widthValue, <u32>this.widthUnit);
|
|
425
455
|
}
|
|
456
|
+
if (this.hasFillWidth) {
|
|
457
|
+
ui.setFillWidth(this.handle, true);
|
|
458
|
+
}
|
|
426
459
|
if (this.hasHeight) {
|
|
427
460
|
ui.setHeight(this.handle, this.heightValue, <u32>this.heightUnit);
|
|
428
461
|
}
|
|
462
|
+
if (this.hasFillHeight) {
|
|
463
|
+
ui.setFillHeight(this.handle, true);
|
|
464
|
+
}
|
|
429
465
|
ui.setText(this.handle, this.contentValue);
|
|
430
466
|
if (this.textStyleRunsWords !== null) {
|
|
431
467
|
ui.setTextStyleRuns(this.handle, changetype<Uint32Array>(this.textStyleRunsWords));
|