From e643b6b8f64b91d2997e3308aa8da47756546736 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Tue, 11 Jun 2024 22:42:24 -0400 Subject: [PATCH] may switch to iced because 50% gpu usage on mouse going flying is crazy --- client/src/app.rs | 96 ++++++++++++++++------------------------ client/src/components.rs | 0 client/src/lib.rs | 3 ++ client/src/main.rs | 2 +- client/src/types.rs | 0 server/Cargo.toml | 2 +- 6 files changed, 43 insertions(+), 60 deletions(-) create mode 100644 client/src/components.rs create mode 100644 client/src/types.rs diff --git a/client/src/app.rs b/client/src/app.rs index 0ba27e4..42b9bee 100644 --- a/client/src/app.rs +++ b/client/src/app.rs @@ -4,9 +4,10 @@ pub struct RealmApp { // Example stuff: label: String, + selected: bool, - #[serde(skip)] // This how you opt-out of serialization of a field - value: f32, + // #[serde(skip)] // This how you opt-out of serialization of a field + // value: f32, } impl Default for RealmApp { @@ -14,7 +15,7 @@ impl Default for RealmApp { Self { // Example stuff: label: "Hello World!".to_owned(), - value: 2.7, + selected: false } } } @@ -36,74 +37,53 @@ impl RealmApp { } impl eframe::App for RealmApp { - /// Called by the frame work to save state before shutdown. - fn save(&mut self, storage: &mut dyn eframe::Storage) { - eframe::set_value(storage, eframe::APP_KEY, self); - } - /// Called each time the UI needs repainting, which may be many times per second. fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { // Put your widgets into a `SidePanel`, `TopBottomPanel`, `CentralPanel`, `Window` or `Area`. // For inspiration and more examples, go to https://emilk.github.io/egui - egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { - // The top panel is often a good place for a menu bar: + // egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { + // egui::menu::bar(ui, |ui| { + // egui::widgets::global_dark_light_mode_buttons(ui); + // }); + // }); - egui::menu::bar(ui, |ui| { - // NOTE: no File->Quit on web pages! - let is_web = cfg!(target_arch = "wasm32"); - if !is_web { - ui.menu_button("File", |ui| { - if ui.button("Quit").clicked() { - ctx.send_viewport_cmd(egui::ViewportCommand::Close); - } - }); - ui.add_space(16.0); - } - - egui::widgets::global_dark_light_mode_buttons(ui); - }); + //Servers + egui::SidePanel::left("left_panel").show(ctx, |ui| { + ui.label("test"); + let response = ui.selectable_label(self.selected, "bruh"); + if response.clicked() { + self.selected = !self.selected; + } }); + //Channels + egui::SidePanel::left("inner_left_panel").show(ctx, |ui| { + ui.label("inner"); + }); + + //Conversation egui::CentralPanel::default().show(ctx, |ui| { - // The central panel the region left after adding TopPanel's and SidePanel's - ui.heading("eframe template"); + //TODO: Messages + + //Message Box + ui.with_layout(egui::Layout::bottom_up(egui::Align::BOTTOM).with_cross_justify(true), |ui| { + let response = ui.add(egui::TextEdit::multiline(&mut self.label).desired_rows(1)); + if response.changed() { + + } + ui.separator(); - ui.horizontal(|ui| { - ui.label("Write something: "); - ui.text_edit_singleline(&mut self.label); }); - ui.add(egui::Slider::new(&mut self.value, 0.0..=10.0).text("value")); - if ui.button("Increment").clicked() { - self.value += 1.0; - } - - ui.separator(); - - ui.add(egui::github_link_file!( - "https://github.com/emilk/eframe_template/blob/main/", - "Source code." - )); - - ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| { - powered_by_egui_and_eframe(ui); - egui::warn_if_debug_build(ui); - }); + // ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| { + // egui::warn_if_debug_build(ui); + // }); }); } -} -fn powered_by_egui_and_eframe(ui: &mut egui::Ui) { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 0.0; - ui.label("Powered by "); - ui.hyperlink_to("egui", "https://github.com/emilk/egui"); - ui.label(" and "); - ui.hyperlink_to( - "eframe", - "https://github.com/emilk/egui/tree/master/crates/eframe", - ); - ui.label("."); - }); + /// Called by the framework to save state before shutdown. + fn save(&mut self, storage: &mut dyn eframe::Storage) { + eframe::set_value(storage, eframe::APP_KEY, self); + } } \ No newline at end of file diff --git a/client/src/components.rs b/client/src/components.rs new file mode 100644 index 0000000..e69de29 diff --git a/client/src/lib.rs b/client/src/lib.rs index e9a1489..3b63385 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,4 +1,7 @@ #![warn(clippy::all, rust_2018_idioms)] mod app; +mod components; +mod types; + pub use app::RealmApp; \ No newline at end of file diff --git a/client/src/main.rs b/client/src/main.rs index ec32dc7..fbcc6dc 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -8,7 +8,7 @@ fn main() -> eframe::Result<()> { let native_options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() - .with_inner_size([400.0, 300.0]) + .with_inner_size([1280.0, 720.0]) .with_min_inner_size([300.0, 220.0]) .with_icon( // NOTE: Adding an icon is optional diff --git a/client/src/types.rs b/client/src/types.rs new file mode 100644 index 0000000..e69de29 diff --git a/server/Cargo.toml b/server/Cargo.toml index a35055c..cb3f706 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "server" +name = "realm_server" version = "0.1.0" edition = "2021"