diff --git a/.gitignore b/.gitignore index ab951f8..cd34ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,9 @@ Cargo.lock # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +test/ + +# Added by cargo + +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7ac894f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "chocobar" +description = "An experiment to create a topbar for X11 using Rust and Slint" +version = "0.1.0" +edition = "2024" +authors = ["candifloss "] +readme = "README.md" + +[dependencies] +raw-window-handle = "0.6.2" +slint = { version = "1.14.1", features = ["raw-window-handle-06", "renderer-software"] } +winit = { version = "0.30.12", features = ["x11rb"] } +x11rb = "0.13.2" + +[build-dependencies] +slint-build = "1.14.1" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..99576fc --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + slint_build::compile("ui/topbar.slint").unwrap(); +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d629a6a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,18 @@ +use slint::{LogicalPosition, LogicalSize}; + +slint::include_modules!(); + +fn main() -> Result<(), Box> { + let bar_height = 25; + let bar_width = 1366; + + let ui = TopBar::new()?; + ui.set_bar_width(bar_width); + ui.set_bar_height(bar_height); + ui.window() + .set_size(LogicalSize::new(bar_width as f32, bar_height as f32)); + ui.window().set_position(LogicalPosition::new(0.0, 0.0)); + ui.run()?; + + Ok(()) +} diff --git a/ui/topbar.slint b/ui/topbar.slint new file mode 100644 index 0000000..6fa9b4d --- /dev/null +++ b/ui/topbar.slint @@ -0,0 +1,42 @@ +export component TopBar inherits Window { + + in property bar_width; + in property bar_height; + + title: "chocobar"; + width: bar_width *1px; + height: bar_height *1px; + always-on-top: true; + no-frame: true; + //background: #999898a6; + x: 0px; + y: 0px; + + Rectangle { + x: 0px; + y: 0px; + width: 100%; + height: 100%; + background: #999898a6; + border-radius: 0px; + + HorizontalLayout { + x: 0px; + y: 0px; + width: 100%; + height: 100%; + + Rectangle { + background: #79a9af7b; + } + + Rectangle { + background: #779e5c7a; + } + + Rectangle { + background: #c2779a7a; + } + } + } +} \ No newline at end of file