Skip to content

Commit

Permalink
new widgets, ui redesign, png2disk tool
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalsom committed Nov 28, 2024
1 parent 638d69a commit aed821e
Show file tree
Hide file tree
Showing 56 changed files with 2,549 additions and 348 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ tests/images/sector_test/sector_test_360k.dmk
!tests/images/monster_disk
!tests/images/monster_disk/monster_disk*

# Ignore misc output files
# Ignore misc output and scratch files
*.png
*.webp
*.psd
*.jpg
*.csv
/plots/*
Expand Down
1 change: 1 addition & 0 deletions .idea/fluxfox.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ members = [
"examples/imginfo",
"examples/imgdump",
"examples/imgviz",
"crates/png2disk",
"crates/ffedit",
"crates/fftool",
"crates/ff_egui_app",
Expand Down
10 changes: 10 additions & 0 deletions crates/ff_egui_app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 0.1.1 (2024-11-24)

- Added Boot Sector display widget
- Displays Bios Parameter Blocks, Boot signature bytes
- Reorganized window layout
- Smaller widgets are now contained in a vertical gallery SidePanel
- Added head filter to Track List panel
- Added option to disable logo panel

## 0.1.0 (2024-11-24) Start of versioning
Empty file added crates/ff_egui_app/README.md
Empty file.
138 changes: 89 additions & 49 deletions crates/ff_egui_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ use std::{

use fluxfox::{file_system::fat::fat::FatFileSystem, DiskImage, DiskImageError, LoadingStatus};
use fluxfox_egui::{
widgets::{disk_info::DiskInfoWidget, filesystem::FileSystemWidget},
widgets::{
boot_sector::BootSectorWidget,
disk_info::DiskInfoWidget,
filesystem::FileSystemWidget,
header_group::HeaderGroup,
},
SectorSelection,
TrackListSelection,
UiEvent,
Expand Down Expand Up @@ -75,11 +80,15 @@ enum RunMode {
#[serde(default)]
pub struct AppUserOptions {
auto_show_viz: bool,
logo_panel: bool,
}

impl Default for AppUserOptions {
fn default() -> Self {
Self { auto_show_viz: true }
Self {
auto_show_viz: true,
logo_panel: true,
}
}
}

Expand All @@ -94,6 +103,7 @@ pub struct PersistentState {
pub struct AppWidgets {
hello: HelloWidget,
disk_info: DiskInfoWidget,
boot_sector: BootSectorWidget,
track_list: TrackListWidget,
file_system: FileSystemWidget,
}
Expand All @@ -106,6 +116,7 @@ impl AppWidgets {
);
let disk = disk_lock.read().unwrap();
self.disk_info.update(&disk, name);
self.boot_sector.update(&disk);
self.track_list.update(&disk);

drop(disk);
Expand Down Expand Up @@ -136,6 +147,7 @@ impl AppWidgets {

pub fn reset(&mut self) {
self.disk_info = DiskInfoWidget::default();
self.boot_sector = BootSectorWidget::default();
self.track_list = TrackListWidget::default();
self.file_system = FileSystemWidget::default();
}
Expand Down Expand Up @@ -271,71 +283,44 @@ impl eframe::App for App {
}

// Show windows
self.windows.viz_viewer.show(ctx);
if let Some(disk_image) = &self.disk_image {
self.windows.viz_viewer.show(ctx, disk_image.clone());
}

self.windows.sector_viewer.show(ctx);
self.windows.file_viewer.show(ctx);

egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:

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);
}
else {
//log::debug!("Running on web platform, showing Image menu");
ui.menu_button("Image", |ui| {
if ui.button("Load demo image...").clicked() {
let mut cursor = std::io::Cursor::new(DEMO_IMAGE);
DiskImage::load(&mut cursor, None, None, None)
.map(|disk| {
log::debug!("Disk image loaded successfully!");
self.disk_image = Some(Arc::new(RwLock::new(disk)));
self.disk_image_name = Some("demo.imz".to_string());
self.new_disk();
ctx.request_repaint();
self.events.push(AppEvent::ImageLoaded);
})
.unwrap_or_else(|e| {
log::error!("Error loading disk image: {:?}", e);
self.error_msg = Some(e.to_string());
});

ui.close_menu();
}
});
}
self.handle_menu(ctx, ui);

ui.menu_button("Windows", |ui| {
ui.checkbox(self.windows.viz_viewer.open_mut(), "Visualization");
});
// Done with menu bar.
if self.p_state.user_opts.logo_panel {
self.widgets.hello.show(ui, APP_NAME, &self.supported_extensions);
ui.add_space(8.0);
}
});

ui.menu_button("Options", |ui| {
ui.checkbox(&mut self.p_state.user_opts.auto_show_viz, "Auto-show Visualization");
egui::SidePanel::left("disk_info_gallery")
.exact_width(250.0)
.show(ctx, |ui| {
ui.with_layout(Layout::top_down(egui::Align::Center), |ui| {
ui.add_space(6.0);
self.handle_image_info(ui);
ui.add_space(6.0);
self.handle_bootsector_info(ui);
});
});
});

egui::CentralPanel::default().show(ctx, |ui| {
// The central panel the region left after adding TopPanels and SidePanels

self.widgets.hello.show(ui, APP_NAME, &self.supported_extensions);

ui.separator();

self.show_error(ui);

// Show dropped files (if any):
self.handle_dropped_files(ctx, None);
self.handle_loading_progress(ui);
self.handle_image_info(ui);

ui.with_layout(egui::Layout::top_down_justified(egui::Align::Center), |ui| {
ui.allocate_ui_with_layout(ui.available_size(), Layout::left_to_right(egui::Align::Min), |ui| {
Expand Down Expand Up @@ -411,6 +396,53 @@ impl App {
}
}

fn handle_menu(&mut self, ctx: &egui::Context, ui: &mut egui::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);
}
else {
//log::debug!("Running on web platform, showing Image menu");
ui.menu_button("Image", |ui| {
if ui.button("Load demo image...").clicked() {
let mut cursor = std::io::Cursor::new(DEMO_IMAGE);
DiskImage::load(&mut cursor, None, None, None)
.map(|disk| {
log::debug!("Disk image loaded successfully!");
self.disk_image = Some(Arc::new(RwLock::new(disk)));
self.disk_image_name = Some("demo.imz".to_string());
self.new_disk();
ctx.request_repaint();
self.events.push(AppEvent::ImageLoaded);
})
.unwrap_or_else(|e| {
log::error!("Error loading disk image: {:?}", e);
self.error_msg = Some(e.to_string());
});

ui.close_menu();
}
});
}

ui.menu_button("Windows", |ui| {
ui.checkbox(self.windows.viz_viewer.open_mut(), "Visualization");
});

ui.menu_button("Options", |ui| {
ui.checkbox(&mut self.p_state.user_opts.auto_show_viz, "Auto-show Visualization");
ui.checkbox(&mut self.p_state.user_opts.logo_panel, "Show fluxfox logo panel");
});
});
}

fn handle_events(&mut self) {
while let Some(event) = self.events.pop() {
match event {
Expand Down Expand Up @@ -472,12 +504,20 @@ impl App {

fn handle_image_info(&mut self, ui: &mut egui::Ui) {
if self.disk_image.is_some() {
ui.group(|ui| {
HeaderGroup::new("Disk Info").strong().expand().show(ui, |ui| {
self.widgets.disk_info.show(ui);
});
}
}

fn handle_bootsector_info(&mut self, ui: &mut egui::Ui) {
if self.disk_image.is_some() {
HeaderGroup::new("Boot Sector").strong().expand().show(ui, |ui| {
self.widgets.boot_sector.show(ui);
});
}
}

fn handle_track_info(&mut self, ui: &mut egui::Ui) {
if self.disk_image.is_some() {
ui.group(|ui| {
Expand Down
Loading

0 comments on commit aed821e

Please sign in to comment.