Skip to content

Commit

Permalink
add tidy up button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Kharel committed May 8, 2024
1 parent ec21365 commit fdb54e9
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 77 deletions.
13 changes: 13 additions & 0 deletions src/custom_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ pub fn footer(ui: &mut egui::Ui) {
});
}

pub fn organize_items(ui: &mut egui::Ui) {
// ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui
.add(
egui::Button::new("Tidy up")
)
.clicked()
{
ui.ctx().memory_mut(|mem| mem.reset_areas());
ui.close_menu();
}
// });
}
71 changes: 0 additions & 71 deletions src/pages/app.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/blog.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
use include_dir::{include_dir, Dir};

use crate::custom_widgets::{powered_by_egui_and_eframe, footer};
use crate::custom_widgets::{powered_by_egui_and_eframe, footer, organize_items};

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Blogs {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ pub use resume::ResumePage;
mod blog;
pub use blog::BlogPage;

mod app;
pub use app::TemplateApp;
// mod app;
// pub use app::TemplateApp;

mod playground;
pub use playground::Playground;
19 changes: 19 additions & 0 deletions src/pages/playground.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#[derive(serde::Deserialize, serde::Serialize)]
pub struct Playground;

impl Default for Playground {
fn default() -> Self {
Self
}
}

impl eframe::App for Playground {
fn update(&mut self, _ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(_ctx, |ui| {
ui.heading("Playground");
ui.label("This is a playground page.");
});
}

fn save(&mut self, _storage: &mut dyn eframe::Storage) {}
}
6 changes: 3 additions & 3 deletions src/pages/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod interests;
pub use self::links::Links;
mod links;

pub use crate::custom_widgets::powered_by_egui_and_eframe;
pub use crate::custom_widgets::{powered_by_egui_and_eframe, footer, organize_items};

#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct Resume {
Expand Down Expand Up @@ -177,9 +177,9 @@ impl eframe::App for ResumePage {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {

egui::CentralPanel::default().show(ctx, |ui| {
footer(ui);
powered_by_egui_and_eframe(ui);
// insert everything inside drag and drop


egui::Window::new(format!(
"{} | {}",
self.resume.header.name, self.resume.header.current_title
Expand Down
26 changes: 26 additions & 0 deletions src/wrap_pages.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::fmt;
use crate::custom_widgets::organize_items;

#[derive(Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct State {
resume_page: crate::pages::ResumePage,
blog_page: crate::pages::BlogPage,
playground_page: crate::pages::Playground,

selected_anchor: Anchor,
}
Expand All @@ -15,6 +17,7 @@ pub struct State {
enum Anchor {
Blog,
Resume,
Playground
// Clear,
}

Expand All @@ -24,6 +27,19 @@ enum Command {
Nothing,
}




//██████╗ ██╗ █████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ███╗ ██╗ ██████╗
//██╔══██╗ ██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔════╝ ██╔══██╗ ██╔═══██╗ ██║ ██║ ████╗ ██║ ██╔══██╗
//██████╔╝ ██║ ███████║ ╚████╔╝ ██║ ███╗ ██████╔╝ ██║ ██║ ██║ ██║ ██╔██╗ ██║ ██║ ██║
//██╔═══╝ ██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██╔══██╗ ██║ ██║ ██║ ██║ ██║╚██╗██║ ██║ ██║
//██║ ███████╗ ██║ ██║ ██║ ╚██████╔╝ ██║ ██║ ╚██████╔╝ ╚██████╔╝ ██║ ╚████║ ██████╔╝
//╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝




impl Anchor {
#[cfg(target_arch = "wasm32")]
fn all() -> Vec<Self> {
Expand Down Expand Up @@ -82,6 +98,11 @@ impl WrapPages {
Anchor::Resume,
&mut self.state.resume_page as &mut dyn eframe::App,
),
(
"Playground",
Anchor::Playground,
&mut self.state.playground_page as &mut dyn eframe::App,
),
];

vec.into_iter()
Expand Down Expand Up @@ -114,6 +135,10 @@ impl WrapPages {
}
}
}

ui.separator();

organize_items(ui);
self.state.selected_anchor = selected_anchor;
}
}
Expand All @@ -122,6 +147,7 @@ impl eframe::App for WrapPages {
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, eframe::APP_KEY, &self.state.blog_page);
eframe::set_value(storage, eframe::APP_KEY, &self.state.resume_page);
eframe::set_value(storage, eframe::APP_KEY, &self.state.playground_page);
}

fn clear_color(&self, visuals: &egui::Visuals) -> [f32; 4] {
Expand Down

0 comments on commit fdb54e9

Please sign in to comment.