* claim: #1801 * Insert SVG: the file picker opens on SVG files (#1801) Every Open went through one host picker whose filters start with designs, CAD files and meshes, so Insert SVG (and Insert DXF) in a sketch opened on STEP, IGES and meshes, and the SVG file had to be found under another filter. The host's pick_open now takes the extensions the command reads and offers them as the picker's first, default filter. Insert SVG and Insert DXF pass their type; every other Open passes none and keeps the list it had. The browser host ignores them (it shows its own file panel). --------- Co-authored-by: MateuszSychXpl <151755914+MateuszSychXpl@users.noreply.github.com>
26 lines
898 B
Rust
26 lines
898 B
Rust
//! Controlled host futures shared by Render and library picker regressions.
|
|
use crate::{SolveApp, file_picker::FilePickerFuture};
|
|
use std::{
|
|
cell::RefCell,
|
|
future::Future,
|
|
pin::Pin,
|
|
rc::Rc,
|
|
task::{Context, Poll},
|
|
};
|
|
pub type Slot = Rc<RefCell<Option<Option<String>>>>;
|
|
struct Manual(Slot);
|
|
impl Future for Manual {
|
|
type Output = Option<String>;
|
|
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
|
|
self.0.borrow_mut().take().map_or(Poll::Pending, Poll::Ready)
|
|
}
|
|
}
|
|
pub fn save(app: &mut SolveApp, slot: &Slot) {
|
|
let slot = slot.clone();
|
|
app.services.pick_save = Some(Box::new(move |_, _| Box::pin(Manual(slot.clone())) as FilePickerFuture));
|
|
}
|
|
pub fn open(app: &mut SolveApp, slot: &Slot) {
|
|
let slot = slot.clone();
|
|
app.services.pick_open = Some(Box::new(move |_| Box::pin(Manual(slot.clone())) as FilePickerFuture));
|
|
}
|