From 6063a541d525e04b268f6e23fffa7696994839b4 Mon Sep 17 00:00:00 2001 From: greysoh Date: Sun, 28 Apr 2024 15:20:18 -0400 Subject: [PATCH] chore: Adds hello world. --- gui/Cargo.toml | 2 ++ gui/src/main.rs | 31 ++++++++++++++++++++++++++++--- shell.nix | 11 ++++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gui/Cargo.toml b/gui/Cargo.toml index 1a15883..c0af2f4 100644 --- a/gui/Cargo.toml +++ b/gui/Cargo.toml @@ -6,3 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +eframe = "0.27.2" +egui = "0.27.2" diff --git a/gui/src/main.rs b/gui/src/main.rs index e7a11a9..647d29f 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -1,3 +1,28 @@ -fn main() { - println!("Hello, world!"); -} +use eframe::egui; + +fn main() -> Result<(), eframe::Error> { + let options = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]), + ..Default::default() + }; + + // Our application state: + let mut name = "Arthur".to_owned(); + let mut age = 42; + + eframe::run_simple_native("My egui App", options, move |ctx, _frame| { + egui::CentralPanel::default().show(ctx, |ui| { + ui.heading("My egui Application"); + ui.horizontal(|ui| { + let name_label = ui.label("Your name: "); + ui.text_edit_singleline(&mut name) + .labelled_by(name_label.id); + }); + ui.add(egui::Slider::new(&mut age, 0..=120).text("age")); + if ui.button("Increment").clicked() { + age += 1; + } + ui.label(format!("Hello '{name}', age {age}")); + }); + }) +} \ No newline at end of file diff --git a/shell.nix b/shell.nix index b354c84..9a10d05 100644 --- a/shell.nix +++ b/shell.nix @@ -11,13 +11,22 @@ openssl postgresql lsof - ]; + ]; shellHook = '' export PRISMA_QUERY_ENGINE_BINARY=${pkgs.prisma-engines}/bin/query-engine export PRISMA_QUERY_ENGINE_LIBRARY=${pkgs.prisma-engines}/lib/libquery_engine.node export PRISMA_SCHEMA_ENGINE_BINARY=${pkgs.prisma-engines}/bin/schema-engine + # egui patches! + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.wayland}/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.libxkbcommon}/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.xorg.libX11}/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.xorg.libXcursor}/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.xorg.libXrandr}/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.xorg.libXi}/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.libGL}/lib + source init.sh ''; } \ No newline at end of file