From c6db34516aadbe0860e7683cfdd64073f4515941 Mon Sep 17 00:00:00 2001 From: accusys Date: Sun, 29 Mar 2026 16:29:38 +0800 Subject: [PATCH] Use native Slint MenuBar (macOS compatible - menu at top of screen) --- Cargo.toml | 2 +- ui/main_window.slint | 108 ++++++++++++------------------------------- 2 files changed, 30 insertions(+), 80 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5e8a53f..881bc13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["lib", "cdylib", "staticlib"] path = "src/lib.rs" [dependencies] -slint = "1.7" +slint = "1.15" tokio = { version = "1.42", features = ["full"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/ui/main_window.slint b/ui/main_window.slint index e1336ed..ded8b2a 100644 --- a/ui/main_window.slint +++ b/ui/main_window.slint @@ -7,6 +7,35 @@ export component AppWindow inherits Window { height: 700px; background: #ece9d8; + // Native menu bar (macOS compatible - appears at top of screen) + MenuBar { + Menu { + title: "File"; + MenuItem { title: "Load Controller List"; } + MenuSeparator { } + MenuItem { title: "Exit"; } + } + Menu { + title: "Controller"; + MenuItem { title: "Add Controller"; } + } + Menu { + title: "Tools"; + MenuItem { title: "Update Firmware"; } + MenuItem { title: "Dump Controller Log"; } + MenuSeparator { } + MenuItem { title: "Email Settings"; } + MenuItem { title: "Preferences"; } + } + Menu { + title: "Help"; + MenuItem { title: "Local Help Center"; } + MenuItem { title: "Play Tutorial"; } + MenuSeparator { } + MenuItem { title: "About"; } + } + } + // Callbacks callback connect_server(); callback refresh_data(); @@ -14,12 +43,6 @@ export component AppWindow inherits Window { callback menu_exit(); callback menu_add_controller(); - // Menu bar properties for callbacks - in-out property menu_file_open: false; - in-out property menu_ctrl_open: false; - in-out property menu_tools_open: false; - in-out property menu_help_open: false; - in-out property connected: false; in-out property is_loading: false; in-out property status_text: "Disconnected"; @@ -105,79 +128,6 @@ export component AppWindow inherits Window { VerticalLayout { spacing: 0; - // Menu Bar - matches Java Swing JMenuBar - Rectangle { - height: 22px; - background: #d4d0c8; - HorizontalLayout { - spacing: 0; - - // File menu - Rectangle { - width: 55px; - height: 22px; - background: menu_file_open ? #c0c0c0 : #d4d0c8; - Text { - text: "File"; - font_size: 12px; - horizontal-alignment: center; - vertical-alignment: center; - } - TouchArea { - clicked => { menu_file_open = !menu_file_open; } - } - } - - // Controller menu - Rectangle { - width: 85px; - height: 22px; - background: menu_ctrl_open ? #c0c0c0 : #d4d0c8; - Text { - text: "Controller"; - font_size: 12px; - horizontal-alignment: center; - vertical-alignment: center; - } - TouchArea { - clicked => { menu_ctrl_open = !menu_ctrl_open; } - } - } - - // Tools menu - Rectangle { - width: 55px; - height: 22px; - background: menu_tools_open ? #c0c0c0 : #d4d0c8; - Text { - text: "Tools"; - font_size: 12px; - horizontal-alignment: center; - vertical-alignment: center; - } - TouchArea { - clicked => { menu_tools_open = !menu_tools_open; } - } - } - - // Help menu - Rectangle { - width: 55px; - height: 22px; - background: menu_help_open ? #c0c0c0 : #d4d0c8; - Text { - text: "Help"; - font_size: 12px; - horizontal-alignment: center; - vertical-alignment: center; - } - TouchArea { - clicked => { menu_help_open = !menu_help_open; } - } - } - } - } - // Toolbar - matches Java JToolBar (750x65) Rectangle { height: 65px;