From a5972f0eccea03cf341702ee0e606faf226e9236 Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sun, 12 Jan 2025 23:04:54 +0700 Subject: [PATCH] Fixes layout on CPU tab (#1244) --- gui/src/main.rs | 12 +--- gui/ui/main/cpu.slint | 117 +++++++++++++++++++++++--------------- gui/ui/main/display.slint | 3 +- gui/ui/main/tabs.slint | 6 +- 4 files changed, 77 insertions(+), 61 deletions(-) diff --git a/gui/src/main.rs b/gui/src/main.rs index 8e80d333f..70dca37a2 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -367,17 +367,7 @@ async fn run_launcher( let win = win.as_weak(); let exit = exit.clone(); - move |addr| { - let addr = match addr.parse() { - Ok(addr) => addr, - // TODO: Display error instead of panic. - Err(_e) => todo!(), - }; - - win.unwrap().hide().unwrap(); - - exit.set(Some(ExitAction::RunDebug(addr))); - } + move || todo!() }); // Set window properties. diff --git a/gui/ui/main/cpu.slint b/gui/ui/main/cpu.slint index dc5a22f92..528836536 100644 --- a/gui/ui/main/cpu.slint +++ b/gui/ui/main/cpu.slint @@ -1,70 +1,97 @@ -import { Button, Slider, LineEdit, HorizontalBox, VerticalBox } from "std-widgets.slint"; +import { Button, Slider, LineEdit, HorizontalBox, VerticalBox, GroupBox } from "std-widgets.slint"; -export component CpuTab { - property debug-address: "127.0.0.1:1234"; - - pure callback start-debug(string); +component CpuCount { + in-out property value; - HorizontalBox { + VerticalBox { padding: 0; + alignment: start; - VerticalBox { - alignment: start; + HorizontalBox { + padding: 0; - property cpus: 8; + Slider { + value: value; + minimum: 1; + maximum: 16; + changed(v) => { + value = Math.round(v); + } + } Text { - text: "Count"; + text: value; + width: 20px; } + } - HorizontalBox { - Slider { - value <=> cpus; - minimum: 1; - maximum: 16; - changed => { - cpus = Math.round(cpus); - } - } + Text { + text: "Changing this value to other than 8 may crash the game."; + wrap: word-wrap; + } + } +} - Text { - vertical-alignment: center; - text: cpus; - } +component DebugAddr { + in-out property value; + + pure callback start(); + + VerticalBox { + padding: 0; + alignment: LayoutAlignment.start; + + HorizontalBox { + padding: 0; + + LineEdit { + text <=> value; } - Text { - text: "Changing this value to other than 8 may crash the game."; + Button { + text: "Start"; + clicked => { + start(); + } } } - VerticalBox { - alignment: start; + Text { + text: "Specify a TCP address to listen for a debugger. The VMM will wait for a debugger to connect before start."; + wrap: word-wrap; + } + } +} - Text { - text: "Debug"; - } +export component CpuTab { + in-out property cpu-count: 8; + in-out property debug-address: "127.0.0.1:1234"; - HorizontalBox { - Text { - text: "Listen address"; - vertical-alignment: center; - } + pure callback start-debug(); - LineEdit { - text <=> debug-address; - } + VerticalBox { + padding: 0; + alignment: start; - Button { - text: "Start"; - clicked => { - start-debug(debug-address); - } + HorizontalBox { + padding: 0; + + GroupBox { + title: "Count"; + width: 50%; + CpuCount { + value <=> cpu-count; } } - Text { - text: "Specify a TCP address to listen for a debugger. The kernel will wait for a debugger to connect before start."; + GroupBox { + title: "GDB Server"; + DebugAddr { + value <=> debug-address; + start => { + start-debug(); + } + } } } } diff --git a/gui/ui/main/display.slint b/gui/ui/main/display.slint index bf182778f..3c8e84f5c 100644 --- a/gui/ui/main/display.slint +++ b/gui/ui/main/display.slint @@ -14,9 +14,9 @@ export component DisplayTab { GroupBox { title: "Device"; + width: 50%; ComboBox { model: devices; - preferred-width: 0; // Override content-based width. } } @@ -25,7 +25,6 @@ export component DisplayTab { ComboBox { model: resolutions; current-index <=> selected-resolution; - preferred-width: 0; // Same here. } } } diff --git a/gui/ui/main/tabs.slint b/gui/ui/main/tabs.slint index 2553aeeb7..29419a1e1 100644 --- a/gui/ui/main/tabs.slint +++ b/gui/ui/main/tabs.slint @@ -14,8 +14,8 @@ export component Tabs { in property <[string]> resolutions; in-out property selected-resolution; + pure callback start-debug(); pure callback report-issue(); - pure callback start-debug(string); private property tab: Tab.display; @@ -74,8 +74,8 @@ export component Tabs { if root.tab == Tab.cpu: CpuTab { vertical-stretch: 1; - start-debug(addr) => { - start-debug(addr); + start-debug => { + start-debug(); } } }