From 190c59ac7aeb6ff60b9517239b80772e4486487e Mon Sep 17 00:00:00 2001 From: lunarydess Date: Tue, 18 Feb 2025 18:01:30 +0100 Subject: [PATCH] :sparkles: more ui stuff :3 --- Cargo.toml | 9 +++++---- src/app.rs | 36 +++++++++++++++++++++++++++++------- src/main.rs | 2 +- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3575626..3eb54fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,17 @@ [package] -name = "Application-Catnip" +name = "application_catnip" version = "0.0.0-develop" edition = "2024" [dependencies] egui = "0.31" eframe = { version = "0.31", default-features = false, features = [ - "accesskit", "default_fonts", - "glow", "persistence", - "wayland", + "accesskit", "default_fonts", + "glow", "persistence", + "wayland", "wgpu" ] } rfd = "0.15" env_logger = "0.11" serde = { version = "1", features = ["derive"] } egui_code_editor = { git = "https://github.com/lunarydess/Application-Catnip-Editor.git", version = "0.3.0-develop" } +egui-modal = { git = "https://github.com/mkrueger/egui-modal.git", branch = "mkrueger/egui0.31"} diff --git a/src/app.rs b/src/app.rs index d268342..57b6926 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,8 +1,8 @@ -use std::fs; use eframe::epaint::text::TextWrapMode; -use egui::{TextBuffer, ThemePreference}; +use egui::ThemePreference; use egui_code_editor::{CodeEditor, ColorTheme, Syntax, DEFAULT_THEMES}; -use std::option::Option; +use egui_modal::Modal; +use std::fs; #[derive(serde::Deserialize, serde::Serialize)] #[serde(default)] @@ -43,14 +43,36 @@ impl eframe::App for CatnipApp { // top bar egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { egui::menu::bar(ui, |ui| { + let modal = Modal::new(ctx, "open folder modal :3"); + modal.show(|ui| { + modal.title(ui, "Hello world!"); + modal.frame(ui, |ui| { + modal.body(ui, "This is a modal."); + }); + modal.buttons(ui, |ui| { + if modal.button(ui, "close").clicked() { + println!("Hello world!") + }; + }); + }); + let is_web = cfg!(target_arch = "wasm32"); if !is_web { ui.menu_button("File", |ui| { - if ui.button("Open …").clicked() { - if let Some(path) = rfd::FileDialog::new().pick_file() { - self.editor_text = fs::read_to_string(path.display().to_string()).unwrap(); + ui.menu_button("New …", |_| {}); + ui.menu_button("Open …", |ui| { + if ui.button("File").clicked() { + if let Some(path) = rfd::FileDialog::new().pick_file() { + self.editor_text = + fs::read_to_string(path.display().to_string()).unwrap(); + } } - } + if ui.button("Folder").clicked() { + if !modal.is_open() { + modal.open(); + } + } + }); if ui.button("Quit").clicked() { ctx.send_viewport_cmd(egui::ViewportCommand::Close); } diff --git a/src/main.rs b/src/main.rs index 9846aff..6970314 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use eframe::Renderer; -use Application_Catnip::CatnipApp; +use application_catnip::CatnipApp; fn main() { env_logger::init();