Skip to content

Commit 2866c7a

Browse files
committed
GUI refresh
1 parent b541150 commit 2866c7a

File tree

7 files changed

+197
-36
lines changed

7 files changed

+197
-36
lines changed

src/gui/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub fn run() {
396396
main_window_weak.unwrap().set_track_titles(slint::ModelRc::new(slint::VecModel::from(Vec::new())));
397397
main_window_weak.unwrap().set_selected_track_index(-1);
398398
main_window_weak.unwrap().set_selected_track_text("Select a track...".into());
399-
main_window_weak.unwrap().set_input_type(InputType::None);
399+
main_window_weak.unwrap().set_input_type(SongInputType::None);
400400
} else {
401401
debug_assert!(main_window_weak.unwrap().invoke_is_2x(), "Tried to set 2x SAV in non-2x mode");
402402

@@ -421,7 +421,7 @@ pub fn run() {
421421
display_error_dialog("Unsupported LSDj version! Please select a ROM that is v3.x or newer.");
422422
return;
423423
}
424-
main_window_weak.unwrap().set_input_type(InputType::LSDj);
424+
main_window_weak.unwrap().set_input_type(SongInputType::LSDj);
425425
main_window_weak.unwrap().set_input_valid(false);
426426
if !for_2x {
427427
if !main_window_weak.unwrap().invoke_is_2x() {
@@ -483,7 +483,7 @@ pub fn run() {
483483
main_window_weak.unwrap().set_track_titles(slint_string_arr(track_titles));
484484

485485
main_window_weak.unwrap().set_input_valid(true);
486-
main_window_weak.unwrap().set_input_type(InputType::GBS);
486+
main_window_weak.unwrap().set_input_type(SongInputType::GBS);
487487
options.borrow_mut().input = RenderInput::GBS(path.clone());
488488
return;
489489
}
@@ -499,7 +499,7 @@ pub fn run() {
499499
main_window_weak.unwrap().set_track_titles(slint_string_arr(vec![song_title]));
500500

501501
main_window_weak.unwrap().set_input_valid(true);
502-
main_window_weak.unwrap().set_input_type(InputType::VGM);
502+
main_window_weak.unwrap().set_input_type(SongInputType::VGM);
503503
main_window_weak.unwrap().set_vgm_engine_rate(60);
504504
main_window_weak.unwrap().set_vgm_tma_offset(0);
505505
options.borrow_mut().input = RenderInput::VGM(path.clone(), 60, 0);
@@ -561,7 +561,7 @@ pub fn run() {
561561

562562
match lsdj::get_track_titles_from_save(path.clone()) {
563563
Ok(track_titles) => {
564-
main_window_weak.unwrap().set_input_type(InputType::LSDj);
564+
main_window_weak.unwrap().set_input_type(SongInputType::LSDj);
565565
main_window_weak.unwrap().set_input_valid(true);
566566

567567
if !for_2x {
@@ -592,7 +592,7 @@ pub fn run() {
592592
}
593593
}
594594
Err(e) => {
595-
main_window_weak.unwrap().set_input_type(InputType::LSDj);
595+
main_window_weak.unwrap().set_input_type(SongInputType::LSDj);
596596
main_window_weak.unwrap().set_input_valid(false);
597597

598598
display_error_dialog(&e.to_string());
@@ -609,7 +609,7 @@ pub fn run() {
609609
let options = options.clone();
610610
main_window.on_set_lsdj_2x(move |is_2x| {
611611
match main_window_weak.unwrap().get_input_type() {
612-
InputType::LSDj => (),
612+
SongInputType::LSDj => (),
613613
_ => return false
614614
}
615615

@@ -736,7 +736,7 @@ pub fn run() {
736736
let render_input = options.borrow().input.clone();
737737
match stop_condition {
738738
StopCondition::Loops(loops) => {
739-
if main_window_weak.unwrap().get_input_type() == InputType::GBS {
739+
if main_window_weak.unwrap().get_input_type() == SongInputType::GBS {
740740
display_error_dialog("Loop detection is not supported for GBS files. Please select a different duration type.");
741741
return;
742742
} else if let RenderInput::VGM(vgm_path, engine_rate, _) = render_input {
@@ -757,7 +757,7 @@ pub fn run() {
757757
};
758758
options.borrow_mut().track_index = track_index;
759759

760-
if main_window_weak.unwrap().invoke_is_2x() && main_window_weak.unwrap().get_input_type() == InputType::LSDj {
760+
if main_window_weak.unwrap().invoke_is_2x() && main_window_weak.unwrap().get_input_type() == SongInputType::LSDj {
761761
let track_index_2x = match main_window_weak.unwrap().get_selected_track_index_2x() {
762762
-1 => {
763763
display_error_dialog("Please select a track to play on the 2x Game Boy.");

src/gui/slint/arrow-export.svg

Lines changed: 1 addition & 0 deletions
Loading

src/gui/slint/arrow-import.svg

Lines changed: 1 addition & 0 deletions
Loading

src/gui/slint/arrow-reset.svg

Lines changed: 1 addition & 0 deletions
Loading

src/gui/slint/chevron-down.svg

Lines changed: 3 additions & 0 deletions
Loading

src/gui/slint/main.slint

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { AboutSlint, Button, ComboBox, CheckBox, SpinBox, Switch, LineEdit, VerticalBox } from "std-widgets.slint";
22
import { ChannelConfigView, ChannelConfig } from "./channel-config.slint";
3+
import { ToolbarButton } from "./toolbar-button.slint";
34
import { ColorUtils } from "./color-picker.slint";
45
export { ColorUtils }
56

6-
export enum InputType {
7+
export enum SongInputType {
78
None, LSDj, GBS, VGM
89
}
910

@@ -31,7 +32,7 @@ export component MainWindow inherits Window {
3132
in property <string> sav-path-2x: "";
3233
in-out property <string> background-path: "";
3334
in property <bool> input-valid: false;
34-
in property <InputType> input-type: None;
35+
in property <SongInputType> input-type: None;
3536
in-out property <int> selected-track-index: -1;
3637
in-out property <string> selected-track-text: "Select a track...";
3738
in-out property <int> selected-track-index-2x: -1;
@@ -69,21 +70,26 @@ export component MainWindow inherits Window {
6970
in property <bool> progress-error: false;
7071
in property <bool> progress-indeterminate: false;
7172

73+
property <bool> configuration-open: true;
74+
7275
property<float> i-progress-anim-tick: -cos(180deg * mod(animation-tick() / 1.3s, 2) / 2) + 1;
7376
property<bool> lsdj-2x: false;
7477
in property<bool> vgm-2x: false;
7578

7679
public pure function is-2x() -> bool {
77-
(root.input-type == InputType.LSDj && root.lsdj-2x) || (root.input-type == InputType.VGM && root.vgm-2x)
80+
(root.input-type == SongInputType.LSDj && root.lsdj-2x) || (root.input-type == SongInputType.VGM && root.vgm-2x)
7881
}
7982

8083
title: "GBPresenter";
8184
icon: @image-url("gb-presenter-icon.png");
85+
height: self.min-height;
86+
width: self.min-width;
8287

8388
Rectangle {
84-
Button {
89+
ToolbarButton {
8590
icon: @image-url("info.svg");
86-
x: parent.width - self.width - 8px;
91+
tooltip: "About";
92+
x: parent.width - self.width - 16px;
8793
y: 16px;
8894
clicked => {
8995
i-about-popup.show()
@@ -165,7 +171,6 @@ export component MainWindow inherits Window {
165171
}
166172
}
167173
}
168-
169174
AboutSlint {
170175
preferred-height: 100px;
171176
}
@@ -182,6 +187,8 @@ export component MainWindow inherits Window {
182187
VerticalBox {
183188
alignment: start;
184189
spacing: 12px;
190+
z: -5;
191+
185192
Text {
186193
text: "GBPresenter";
187194
font-size: 32px;
@@ -208,7 +215,7 @@ export component MainWindow inherits Window {
208215
}
209216
}
210217
}
211-
if input-type == InputType.LSDj : HorizontalLayout {
218+
if input-type == SongInputType.LSDj : HorizontalLayout {
212219
alignment: stretch;
213220
spacing: 8px;
214221
Text {
@@ -228,7 +235,7 @@ export component MainWindow inherits Window {
228235
}
229236
}
230237
}
231-
if input-type == InputType.LSDj : HorizontalLayout {
238+
if input-type == SongInputType.LSDj : HorizontalLayout {
232239
alignment: stretch;
233240
spacing: 8px;
234241

@@ -241,7 +248,7 @@ export component MainWindow inherits Window {
241248
}
242249
}
243250
}
244-
if input-type == InputType.LSDj && lsdj-2x : HorizontalLayout {
251+
if input-type == SongInputType.LSDj && lsdj-2x : HorizontalLayout {
245252
alignment: stretch;
246253
spacing: 8px;
247254
Text {
@@ -261,7 +268,7 @@ export component MainWindow inherits Window {
261268
}
262269
}
263270
}
264-
if input-type == InputType.LSDj && lsdj-2x : HorizontalLayout {
271+
if input-type == SongInputType.LSDj && lsdj-2x : HorizontalLayout {
265272
alignment: stretch;
266273
spacing: 8px;
267274
Text {
@@ -285,7 +292,7 @@ export component MainWindow inherits Window {
285292
alignment: stretch;
286293
spacing: 8px;
287294
Text {
288-
text: (input-type == InputType.LSDj && lsdj-2x)
295+
text: (input-type == SongInputType.LSDj && lsdj-2x)
289296
? "Track 1:"
290297
: "Track:";
291298
vertical-alignment: center;
@@ -300,7 +307,7 @@ export component MainWindow inherits Window {
300307
}
301308
}
302309
}
303-
if input-type == InputType.LSDj && lsdj-2x : HorizontalLayout {
310+
if input-type == SongInputType.LSDj && lsdj-2x : HorizontalLayout {
304311
alignment: stretch;
305312
spacing: 8px;
306313
Text {
@@ -317,7 +324,7 @@ export component MainWindow inherits Window {
317324
}
318325
}
319326
}
320-
if input-type == InputType.VGM : HorizontalLayout {
327+
if input-type == SongInputType.VGM : HorizontalLayout {
321328
alignment: stretch;
322329
spacing: 8px;
323330

@@ -365,42 +372,73 @@ export component MainWindow inherits Window {
365372
}
366373
}
367374
}
368-
HorizontalLayout {
369-
alignment: end;
370-
spacing: 8px;
371-
Text {
372-
text: "Configuration:";
373-
vertical-alignment: center;
375+
TouchArea {
376+
mouse-cursor: pointer;
377+
clicked => {
378+
root.configuration-open = !root.configuration-open;
374379
}
375-
Button {
376-
text: "Import...";
380+
381+
HorizontalLayout {
382+
alignment: start;
383+
spacing: 8px;
384+
385+
Image {
386+
source: @image-url("chevron-down.svg");
387+
rotation-angle: root.configuration-open ? 0deg : -90deg;
388+
animate rotation-angle {
389+
duration: 100ms;
390+
easing: ease-in-out;
391+
}
392+
}
393+
Text {
394+
text: "Visualizer configuration";
395+
}
396+
}
397+
}
398+
if root.configuration-open: HorizontalLayout {
399+
alignment: stretch;
400+
spacing: 8px;
401+
402+
ToolbarButton {
403+
horizontal-stretch: 0.0;
404+
icon: @image-url("arrow-import.svg");
405+
text: "Import";
377406
enabled: !rendering;
378407
clicked => {
379408
root.import-config();
380409
}
381410
}
382-
Button {
383-
text: "Export...";
411+
ToolbarButton {
412+
horizontal-stretch: 0.0;
413+
icon: @image-url("arrow-export.svg");
414+
text: "Export";
384415
enabled: !rendering;
385416
clicked => {
386417
root.export-config();
387418
}
388419
}
389-
Button {
420+
Rectangle {
421+
horizontal-stretch: 1.0;
422+
}
423+
ToolbarButton {
424+
horizontal-stretch: 0.0;
425+
icon: @image-url("arrow-reset.svg");
390426
text: "Reset";
391427
enabled: !rendering;
428+
destructive: true;
392429
clicked => {
393430
root.reset-config();
394431
}
395432
}
396433
}
397-
ChannelConfigView {
434+
if root.configuration-open: ChannelConfigView {
398435
enabled: !rendering;
399436
active-chips: root.is-2x()
400437
? ["LR35902", "LR35902 (2x)"]
401438
: ["LR35902"];
402439
config-lr35902 <=> root.config-lr35902;
403440
config-lr35902-2x <=> root.config-lr35902-2x;
441+
z: -10;
404442
}
405443
HorizontalLayout {
406444
alignment: stretch;
@@ -444,8 +482,8 @@ export component MainWindow inherits Window {
444482
}
445483
}
446484
ComboBox {
447-
model: input-type == InputType.VGM ? ["seconds", "frames", "loops"]
448-
: input-type == InputType.LSDj ? ["seconds", "frames", "loops"]
485+
model: input-type == SongInputType.VGM ? ["seconds", "frames", "loops"]
486+
: input-type == SongInputType.LSDj ? ["seconds", "frames", "loops"]
449487
: ["seconds", "frames"];
450488
current-value <=> track-duration-type;
451489
enabled: !rendering;

0 commit comments

Comments
 (0)