✨ more ui stuff :3
This commit is contained in:
@@ -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"}
|
||||
|
||||
36
src/app.rs
36
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);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use eframe::Renderer;
|
||||
use Application_Catnip::CatnipApp;
|
||||
use application_catnip::CatnipApp;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
Reference in New Issue
Block a user