Skip to content

Commit

Permalink
Add left panel ui
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxxcode committed Jan 13, 2024
1 parent 3335d50 commit 45f29e0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions examples/sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ edition = "2021"
[dependencies]
eframe = { version = "0.25.0", default-features = false, features = ["glow"] }
egui-file-explorer = { version = "0.1.0", path = "../../"}

# Enable image loading
egui_extras = { version = "0.25.0", default-features = false, features = ["all_loaders"]}
6 changes: 4 additions & 2 deletions examples/sandbox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ struct MyApp {
}

impl MyApp {
pub fn new() -> Self {
pub fn new(cc: &eframe::CreationContext) -> Self {
egui_extras::install_image_loaders(&cc.egui_ctx);

Self {
file_explorer: FileExplorer::new()
}
Expand All @@ -32,6 +34,6 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"My egui application",
options,
Box::new(|_| Box::new(MyApp::new()))
Box::new(|ctx| Box::new(MyApp::new(ctx)))
)
}
33 changes: 30 additions & 3 deletions src/file_explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl FileExplorer {
.default_width(150.0)
.width_range(80.0..=300.0)
.show_inside(ui, |ui| {
self.update_left_panel(ui);
self.update_left_panel(ctx, ui);
});

egui::TopBottomPanel::bottom("fe_bottom_panel")
Expand Down Expand Up @@ -76,13 +76,40 @@ impl FileExplorer {
});
});
})

// TODO: Search bar
});

ui.add_space(ctx.style().spacing.item_spacing.y);
}

fn update_left_panel(&mut self, ui: &mut egui::Ui) {
ui.label("This is the left panel!");
fn update_left_panel(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) {
ui.label("Drives:");

// NOTE: These are currently only hardcoded test values!
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0), egui::Button::new("(C:)"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0), egui::Button::new("Toshiba(D:)"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0),
egui::Button::new("Samsung 980..(E:)"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0), egui::Button::new("(F:)"));

ui.add_space(ctx.style().spacing.item_spacing.y * 4.0);

ui.label("User:");

let folder_icon = egui::include_image!("../data/folder_icon.png");

// NOTE: These are currently only hardcoded test values!
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0),
egui::Button::image_and_text(folder_icon.clone(), "Desktop"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0),
egui::Button::image_and_text(folder_icon.clone(), "Documents"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0),
egui::Button::image_and_text(folder_icon.clone(), "Downloads"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0),
egui::Button::image_and_text(folder_icon.clone(), "Music"));
ui.add_sized(egui::Vec2::new(ui.available_width(), 0.0),
egui::Button::image_and_text(folder_icon.clone(), "Pictures"));
}

fn update_bottom_panel(&mut self, ui: &mut egui::Ui) {
Expand Down

0 comments on commit 45f29e0

Please sign in to comment.