mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
Select and Mask previews again after a document edit
The workspace keyed its pending preview on the request alone, so after HostedWorkspace::set_source the same request found the old job and no preview of the edited document started. The key carries WorkspaceCx::revision, as Vanishing Point and Wide Angle do.
This commit is contained in:
@@ -481,7 +481,13 @@ impl SelectMaskWorkspace {
|
||||
/// The events of the methods that ran between passes come first. A second pass of a frame reports only what its
|
||||
/// own input did, since the first pass took the frame's steps and commands. OK closes an open polygon first, so the
|
||||
/// result carries it.
|
||||
fn pass(&mut self, ui: &mut Ui, source: &dyn SelectMaskSource, open: Bind<'_, bool>) -> WorkspacePass<SelectMaskEvent, SelectMaskDone> {
|
||||
fn pass(
|
||||
&mut self,
|
||||
ui: &mut Ui,
|
||||
source: &dyn SelectMaskSource,
|
||||
revision: u64,
|
||||
open: Bind<'_, bool>,
|
||||
) -> WorkspacePass<SelectMaskEvent, SelectMaskDone> {
|
||||
// pc: crates/ui-egui/src/dialogs/select_mask_ui.rs:1812 `show`, :1375 `keys`, :870
|
||||
// `enter`, :881 `escape`.
|
||||
let env = Env::of(ui);
|
||||
@@ -511,7 +517,7 @@ impl SelectMaskWorkspace {
|
||||
.sides(|ui, cx| {
|
||||
let mut guard = this.borrow_mut();
|
||||
let work: &mut SelectMaskWorkspace = &mut guard;
|
||||
let status = cx.pending(key.clone(), || source.preview_job(&request)).clone();
|
||||
let status = cx.pending((revision, key.clone()), || source.preview_job(&request)).clone();
|
||||
*side_status.borrow_mut() = Some(status.clone());
|
||||
side_panel_open.set(None);
|
||||
*side_pick.borrow_mut() = None;
|
||||
@@ -910,8 +916,8 @@ impl FullWindowWorkspace for SelectMaskWorkspace {
|
||||
const KEY: &'static str = "select.selectAndMask";
|
||||
|
||||
fn show(&mut self, ui: &mut Ui, cx: WorkspaceCx<'_, Self::Source>) -> WorkspacePass<Self::Event, Self::Result> {
|
||||
let WorkspaceCx { source, open, .. } = cx;
|
||||
self.pass(ui, source, open)
|
||||
let WorkspaceCx { source, revision, open, .. } = cx;
|
||||
self.pass(ui, source, revision, open)
|
||||
}
|
||||
|
||||
/// The settings, and the bar's `tool`, `mode` (`"add"`, `"subtract"`), `size` (of the current tool), `hardness`,
|
||||
|
||||
@@ -129,7 +129,7 @@ fn press_label(fixture: &mut Fixture, label: &str) {
|
||||
|
||||
#[trial]
|
||||
fn select_mask_preview_is_asked_for_only_when_it_changes() {
|
||||
let (mut fixture, _, jobs) = open();
|
||||
let (mut fixture, app, jobs) = open();
|
||||
let first = jobs.load(Ordering::SeqCst);
|
||||
assert_eq!(first, 1, "one preview for the opening state");
|
||||
fixture.frame(vec![pointer::moved(canvas_point(&fixture, Vec2::ZERO))]);
|
||||
@@ -137,6 +137,11 @@ fn select_mask_preview_is_asked_for_only_when_it_changes() {
|
||||
assert_eq!(jobs.load(Ordering::SeqCst), first, "hovering changes nothing");
|
||||
press_label(&mut fixture, "Invert");
|
||||
assert_eq!(jobs.load(Ordering::SeqCst), first + 1, "an edit asks for a new preview");
|
||||
let size = PixelSize::new(DOCUMENT[0], DOCUMENT[1]);
|
||||
let edited: Arc<dyn SelectMaskSource> = Arc::new(Source { image: Solid { size }, jobs: Arc::clone(&jobs) });
|
||||
app.borrow_mut().host.get_mut::<HostedWorkspace<SelectMaskWorkspace>>().expect("the workspace is open").set_source(edited);
|
||||
fixture.settle();
|
||||
assert_eq!(jobs.load(Ordering::SeqCst), first + 2, "a document edit asks for a new preview of the same request");
|
||||
}
|
||||
|
||||
// The view keys work from inside the workspace with no help from the app: K picks Black & White, X held hides the
|
||||
|
||||
Reference in New Issue
Block a user