@effindomv2/fui-as 0.1.46 → 0.1.48
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 +1 -1
- package/src/controls/NavLink.ts +31 -1
- package/src/controls/ProgressBar.ts +27 -4
package/package.json
CHANGED
package/src/controls/NavLink.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { navigateTo } from "../core/Navigation";
|
|
|
15
15
|
import { PointerEventArgs, PointerType } from "../core/Node";
|
|
16
16
|
import { hasPrimaryShortcutModifier } from "../core/Platform";
|
|
17
17
|
import { Theme, activeTheme } from "../core/Theme";
|
|
18
|
-
import { FlexBox } from "../nodes";
|
|
18
|
+
import { FlexBox, Text } from "../nodes";
|
|
19
19
|
|
|
20
20
|
export class NavigateEventArgs {
|
|
21
21
|
readonly path: string;
|
|
@@ -40,16 +40,28 @@ export class NavLink extends FlexBox {
|
|
|
40
40
|
private previewVisible: bool = false;
|
|
41
41
|
private previewPinnedForContextMenu: bool = false;
|
|
42
42
|
private disposed: bool = false;
|
|
43
|
+
private textColorValue: u32;
|
|
44
|
+
readonly labelNode: Text;
|
|
43
45
|
|
|
44
46
|
constructor(href: string, label: string = href, openInNewTab: bool = false) {
|
|
45
47
|
super();
|
|
48
|
+
const theme = activeTheme.value;
|
|
46
49
|
this.hrefValue = href;
|
|
47
50
|
this.openInNewTabValue = openInNewTab;
|
|
51
|
+
this.textColorValue = theme.colors.accent;
|
|
52
|
+
this.labelNode = new Text(label)
|
|
53
|
+
.fontFamily(theme.fonts.bodyFamily)
|
|
54
|
+
.fontSize(15.0)
|
|
55
|
+
.textColor(theme.colors.accent)
|
|
56
|
+
.selectable(false)
|
|
57
|
+
.cursor(CursorStyle.Pointer) as Text;
|
|
48
58
|
this.semanticRole(SemanticRole.Link);
|
|
49
59
|
this.semanticLabel(label);
|
|
50
60
|
this.cursor(CursorStyle.Pointer);
|
|
51
61
|
this.focusable(true);
|
|
62
|
+
this.child(this.labelNode);
|
|
52
63
|
this.track(activeTheme.addAction(new HandlerAction<NavLink, Theme>(this, (link: NavLink, _theme: Theme): void => {
|
|
64
|
+
link.syncVisualState();
|
|
53
65
|
link.syncFocusChrome();
|
|
54
66
|
})));
|
|
55
67
|
this.track(keyboardFocusVisible.addAction(new HandlerAction<NavLink, bool>(this, (link: NavLink, _visible: bool): void => {
|
|
@@ -75,6 +87,18 @@ export class NavLink extends FlexBox {
|
|
|
75
87
|
return this;
|
|
76
88
|
}
|
|
77
89
|
|
|
90
|
+
text(value: string): this {
|
|
91
|
+
this.semanticLabel(value);
|
|
92
|
+
this.labelNode.text(value);
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
textColor(color: u32): this {
|
|
97
|
+
this.textColorValue = color;
|
|
98
|
+
this.syncVisualState();
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
78
102
|
dispose(): void {
|
|
79
103
|
this.hidePreview();
|
|
80
104
|
if (!this.disposed) {
|
|
@@ -92,6 +116,7 @@ export class NavLink extends FlexBox {
|
|
|
92
116
|
super._handlePointerEvent(eventType, x, y, modifiers);
|
|
93
117
|
if (eventType == PointerEventType.Enter) {
|
|
94
118
|
this.hovered = true;
|
|
119
|
+
this.syncVisualState();
|
|
95
120
|
this.showPreview();
|
|
96
121
|
return;
|
|
97
122
|
}
|
|
@@ -99,6 +124,7 @@ export class NavLink extends FlexBox {
|
|
|
99
124
|
this.hovered = false;
|
|
100
125
|
this.pointerPressed = false;
|
|
101
126
|
this.pointerPressedOpenInNewTab = false;
|
|
127
|
+
this.syncVisualState();
|
|
102
128
|
if (!this.previewPinnedForContextMenu && !this.focused) {
|
|
103
129
|
this.hidePreview();
|
|
104
130
|
}
|
|
@@ -228,6 +254,10 @@ export class NavLink extends FlexBox {
|
|
|
228
254
|
FocusAdornerManager.hideOwner(this);
|
|
229
255
|
}
|
|
230
256
|
|
|
257
|
+
private syncVisualState(): void {
|
|
258
|
+
this.labelNode.textColor(this.hovered ? activeTheme.value.colors.accentHovered : this.textColorValue);
|
|
259
|
+
}
|
|
260
|
+
|
|
231
261
|
private track(disposable: Disposable): void {
|
|
232
262
|
this.disposables.push(disposable);
|
|
233
263
|
}
|
|
@@ -2,6 +2,7 @@ import { HandlerAction } from "../core/Action";
|
|
|
2
2
|
import { Disposable, disposeAll } from "../core/Disposable";
|
|
3
3
|
import { Theme, activeTheme } from "../core/Theme";
|
|
4
4
|
import { warn } from "../core/Logger";
|
|
5
|
+
import { FlexDirection, JustifyContent, Orientation } from "../core/ffi";
|
|
5
6
|
import { FlexBox } from "../nodes";
|
|
6
7
|
|
|
7
8
|
function clamp(value: f32, min: f32, max: f32): f32 {
|
|
@@ -23,6 +24,7 @@ export class ProgressBar extends FlexBox {
|
|
|
23
24
|
private currentValue: f32 = 0.0;
|
|
24
25
|
private lengthValue: f32 = 220.0;
|
|
25
26
|
private thicknessValue: f32 = 14.0;
|
|
27
|
+
private orientationValue: Orientation = Orientation.Horizontal;
|
|
26
28
|
private trackColorValue: u32 = 0;
|
|
27
29
|
private fillColorValue: u32 = 0;
|
|
28
30
|
private trackColorOverridden: bool = false;
|
|
@@ -33,6 +35,7 @@ export class ProgressBar extends FlexBox {
|
|
|
33
35
|
super();
|
|
34
36
|
this.fillNode = new FlexBox();
|
|
35
37
|
this.child(this.fillNode);
|
|
38
|
+
this.semanticOrientation(Orientation.Horizontal);
|
|
36
39
|
this.track(activeTheme.addAction(new HandlerAction<ProgressBar, Theme>(this, (bar: ProgressBar, _theme: Theme): void => {
|
|
37
40
|
bar.handleThemeChanged();
|
|
38
41
|
})));
|
|
@@ -89,6 +92,15 @@ export class ProgressBar extends FlexBox {
|
|
|
89
92
|
return this;
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
orientation(value: Orientation): this {
|
|
96
|
+
this.orientationValue = value == Orientation.Vertical
|
|
97
|
+
? Orientation.Vertical
|
|
98
|
+
: Orientation.Horizontal;
|
|
99
|
+
this.semanticOrientation(this.orientationValue);
|
|
100
|
+
this.syncGeometry();
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
92
104
|
trackColor(color: u32): this {
|
|
93
105
|
this.trackColorOverridden = true;
|
|
94
106
|
this.trackColorValue = color;
|
|
@@ -128,10 +140,21 @@ export class ProgressBar extends FlexBox {
|
|
|
128
140
|
const range = this.maxValue - this.minValue;
|
|
129
141
|
const fraction = range > 0.0 ? clamp((this.currentValue - this.minValue) / range, 0.0, 1.0) : 0.0;
|
|
130
142
|
const fillLength = this.lengthValue * fraction;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
if (this.orientationValue == Orientation.Vertical) {
|
|
144
|
+
this.flexDirection(FlexDirection.Column);
|
|
145
|
+
this.justifyContent(JustifyContent.End);
|
|
146
|
+
this.width(this.thicknessValue);
|
|
147
|
+
this.height(this.lengthValue);
|
|
148
|
+
this.fillNode.width(this.thicknessValue);
|
|
149
|
+
this.fillNode.height(fillLength);
|
|
150
|
+
} else {
|
|
151
|
+
this.flexDirection(FlexDirection.Row);
|
|
152
|
+
this.justifyContent(JustifyContent.Start);
|
|
153
|
+
this.width(this.lengthValue);
|
|
154
|
+
this.height(this.thicknessValue);
|
|
155
|
+
this.fillNode.width(fillLength);
|
|
156
|
+
this.fillNode.height(this.thicknessValue);
|
|
157
|
+
}
|
|
135
158
|
this.semanticValueRange(this.currentValue, this.minValue, this.maxValue);
|
|
136
159
|
this.syncSemanticLabel();
|
|
137
160
|
}
|