Use native Slint MenuBar (macOS compatible - menu at top of screen)
This commit is contained in:
@@ -11,7 +11,7 @@ crate-type = ["lib", "cdylib", "staticlib"]
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint = "1.7"
|
slint = "1.15"
|
||||||
tokio = { version = "1.42", features = ["full"] }
|
tokio = { version = "1.42", features = ["full"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|||||||
@@ -7,6 +7,35 @@ export component AppWindow inherits Window {
|
|||||||
height: 700px;
|
height: 700px;
|
||||||
background: #ece9d8;
|
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
|
// Callbacks
|
||||||
callback connect_server();
|
callback connect_server();
|
||||||
callback refresh_data();
|
callback refresh_data();
|
||||||
@@ -14,12 +43,6 @@ export component AppWindow inherits Window {
|
|||||||
callback menu_exit();
|
callback menu_exit();
|
||||||
callback menu_add_controller();
|
callback menu_add_controller();
|
||||||
|
|
||||||
// Menu bar properties for callbacks
|
|
||||||
in-out property<bool> menu_file_open: false;
|
|
||||||
in-out property<bool> menu_ctrl_open: false;
|
|
||||||
in-out property<bool> menu_tools_open: false;
|
|
||||||
in-out property<bool> menu_help_open: false;
|
|
||||||
|
|
||||||
in-out property<bool> connected: false;
|
in-out property<bool> connected: false;
|
||||||
in-out property<bool> is_loading: false;
|
in-out property<bool> is_loading: false;
|
||||||
in-out property<string> status_text: "Disconnected";
|
in-out property<string> status_text: "Disconnected";
|
||||||
@@ -105,79 +128,6 @@ export component AppWindow inherits Window {
|
|||||||
VerticalLayout {
|
VerticalLayout {
|
||||||
spacing: 0;
|
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)
|
// Toolbar - matches Java JToolBar (750x65)
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: 65px;
|
height: 65px;
|
||||||
|
|||||||
Reference in New Issue
Block a user