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 bf93d9e commit 788acd1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
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 788acd1

Please sign in to comment.