Skip to content

Commit

Permalink
update file dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Dec 14, 2023
1 parent 4995c64 commit ce95b4d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/re_data_source/src/data_loader/loader_external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub static EXTERNAL_LOADER_PATHS: Lazy<Vec<std::path::PathBuf>> = Lazy::new(|| {
executables.into_iter().collect()
});

/// Iterator over all registered [`DataLoader`]s.
/// Iterator over all registered external [`DataLoader`]s.

Check failure on line 47 in crates/re_data_source/src/data_loader/loader_external.rs

View workflow job for this annotation

GitHub Actions / Checks / Rust lints (fmt, check, cranky, tests, doc)

unresolved link to `DataLoader`
#[inline]
pub fn iter_external_loaders() -> impl ExactSizeIterator<Item = std::path::PathBuf> {
EXTERNAL_LOADER_PATHS.iter().cloned()
Expand Down
2 changes: 1 addition & 1 deletion crates/re_ui/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl UICommand {
"Save data for the current loop selection to a Rerun data file (.rrd)",
),

UICommand::Open => ("Open…", "Open a Rerun Data File (.rrd)"),
UICommand::Open => ("Open…", "Open any supported files (.rrd, images, meshes, …)"),

UICommand::CloseCurrentRecording => (
"Close current Recording",
Expand Down
34 changes: 22 additions & 12 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,18 +1269,28 @@ fn file_saver_progress_ui(egui_ctx: &egui::Context, background_tasks: &mut Backg
#[cfg(not(target_arch = "wasm32"))]
fn open_file_dialog_native() -> Vec<std::path::PathBuf> {
re_tracing::profile_function!();
let supported: Vec<_> = re_data_source::SUPPORTED_RERUN_EXTENSIONS
.iter()
.chain(re_data_source::SUPPORTED_IMAGE_EXTENSIONS)
.chain(re_data_source::SUPPORTED_MESH_EXTENSIONS)
.chain(re_data_source::SUPPORTED_POINT_CLOUD_EXTENSIONS)
.chain(re_data_source::SUPPORTED_TEXT_EXTENSIONS)
.copied()
.collect();
rfd::FileDialog::new()
.add_filter("Supported files", &supported)
.pick_files()
.unwrap_or_default()

let supported: Vec<_> = if re_data_source::iter_external_loaders().len() == 0 {
re_data_source::SUPPORTED_RERUN_EXTENSIONS
.iter()
.chain(re_data_source::SUPPORTED_IMAGE_EXTENSIONS)
.chain(re_data_source::SUPPORTED_MESH_EXTENSIONS)
.chain(re_data_source::SUPPORTED_POINT_CLOUD_EXTENSIONS)
.chain(re_data_source::SUPPORTED_TEXT_EXTENSIONS)
.copied()
.collect()
} else {
vec![]
};

let mut dialog = rfd::FileDialog::new();

// If there's at least one external loader registered, then literally anything goes!
if !supported.is_empty() {
dialog = dialog.add_filter("Supported files", &supported);
}

dialog.pick_files().unwrap_or_default()
}

#[cfg(target_arch = "wasm32")]
Expand Down

0 comments on commit ce95b4d

Please sign in to comment.