Skip to content

Commit 4048049

Browse files
committed
HideHL: base implementation of HuiFilePicker
1 parent 13c191d commit 4048049

7 files changed

Lines changed: 70 additions & 8 deletions

File tree

hide/kit/File.hx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ class File extends Widget<String> {
2828

2929
return file.element[0];
3030
#elseif hui
31-
throw "implment";
31+
var f = new hrt.ui.HuiFilePicker();
32+
f.value = value;
33+
f.onValueChanged = () -> {
34+
value = f.value;
35+
broadcastValueChange(false);
36+
}
37+
return f;
3238
#else
3339
return null;
3440
#end

hide_hl/res/ui/style/common.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@color-foreground-muted: #878787;
1919
@color-accent: @color-blue;
2020

21-
@color-over: rgba(255,255,255,0.15);
21+
@color-over: rgba(255,255,255,0.25);
2222
@color-over-lighter: rgba(255,255,255,0.25);
2323

2424
@widget-base-height: 16;

hide_hl/res/ui/style/hui-category.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ hui-category {
2525
> #content {
2626
layout: vertical;
2727
fill-width: true;
28-
padding: 10;
28+
padding: 3;
2929
overflow: hidden;
3030
}
3131
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
hui-file-picker {
2+
min-height: @widget-base-height;
3+
min-width: @widget-base-height;
4+
fill-width: true;
5+
cursor: button;
6+
padding: 0 3 0 3;
7+
8+
> hui-text {
9+
valign: middle;
10+
margin-bottom: 2;
11+
}
12+
13+
background-type: hui;
14+
> hui-background {
15+
background: @widget-bg;
16+
border-radius: @base-corner-radius;
17+
outline: 1 @widget-border;
18+
}
19+
20+
&:hover {
21+
> hui-background {
22+
background: @color-over;
23+
}
24+
}
25+
}

hide_hl/res/ui/style/hui-slider.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
hui-slider {
2-
min-width: 50px;
2+
min-width: 30px;
33
fill-width: 1;
44
max-width: 200px;
55
height: @widget-base-height;

hrt/ui/HuiFilePicker.hx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package hrt.ui;
2+
3+
#if hui
4+
class HuiFilePicker extends HuiElement {
5+
static var SRC = <hui-file-picker>
6+
<hui-text id="path"/>
7+
</hui-file-picker>
8+
9+
public var value(default, set) : String;
10+
11+
public function new(?parent) {
12+
super(parent);
13+
initComponent();
14+
15+
this.onClick = (e: hxd.Event) -> {
16+
hxd.File.browse((select) -> {
17+
value = select.fileName;
18+
onValueChanged();
19+
}, {fileTypes: [{name: "prefab, l3d, fx", extensions: ["prefab", "l3d", "fx"]}]});
20+
}
21+
}
22+
23+
public function set_value(v: String) {
24+
path.text = v;
25+
return value = v;
26+
}
27+
28+
public dynamic function onValueChanged() {}
29+
}
30+
31+
#end

hrt/ui/HuiViewGym.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package hrt.ui;
33
#if hui
44

55
typedef TreeItem = {
6-
name: String,
7-
children: Array<TreeItem>,
8-
id: String,
9-
};
6+
name: String,
7+
children: Array<TreeItem>,
8+
id: String,
9+
};
1010

1111
class HuiViewGym extends HuiView<{}> {
1212
static var SRC =

0 commit comments

Comments
 (0)