|
|
|
@@ -50,40 +50,37 @@ use crate::{AppWindow, CollectionRow};
|
|
|
|
|
struct PressUndo {
|
|
|
|
|
selection: BTreeSet<ImageId>,
|
|
|
|
|
anchor: Option<usize>,
|
|
|
|
|
previous_anchor: Option<usize>,
|
|
|
|
|
cursor: Option<usize>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PressUndo {
|
|
|
|
|
/// Everything [`press_remembering_anchor`] is about to change.
|
|
|
|
|
/// Everything [`select_row`] is about to change.
|
|
|
|
|
///
|
|
|
|
|
/// The four are the whole of what a press touches, which is the property
|
|
|
|
|
/// the restore depends on and the reason it is worth a test of its own: an
|
|
|
|
|
/// press that grew a fifth piece of state would leave that piece behind
|
|
|
|
|
/// The three are the whole of what a press touches, which is the property
|
|
|
|
|
/// the restore depends on and the reason it is worth a test of its own: a
|
|
|
|
|
/// press that grew a fourth piece of state would leave that piece behind
|
|
|
|
|
/// after a cancel, silently.
|
|
|
|
|
fn capture(
|
|
|
|
|
selection: &BTreeSet<ImageId>,
|
|
|
|
|
anchor: Option<usize>,
|
|
|
|
|
previous_anchor: Option<usize>,
|
|
|
|
|
cursor: Option<usize>,
|
|
|
|
|
) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
selection: selection.clone(),
|
|
|
|
|
anchor,
|
|
|
|
|
previous_anchor,
|
|
|
|
|
cursor,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Put it all back. Returns the two the caller holds in `Cell`s.
|
|
|
|
|
/// Put it all back. Returns the one the caller holds in a `Cell`.
|
|
|
|
|
fn restore(
|
|
|
|
|
self,
|
|
|
|
|
selection: &mut BTreeSet<ImageId>,
|
|
|
|
|
anchor: &mut Option<usize>,
|
|
|
|
|
) -> (Option<usize>, Option<usize>) {
|
|
|
|
|
) -> Option<usize> {
|
|
|
|
|
*selection = self.selection;
|
|
|
|
|
*anchor = self.anchor;
|
|
|
|
|
(self.previous_anchor, self.cursor)
|
|
|
|
|
self.cursor
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -117,18 +114,15 @@ pub struct CollectionsController {
|
|
|
|
|
/// same argument applied to the one index that has to survive a move.
|
|
|
|
|
anchor: RefCell<Option<usize>>,
|
|
|
|
|
/// TRACES: FR-UI-2 | FR-UI-4
|
|
|
|
|
/// Where the anchor was *before* the press that moved it.
|
|
|
|
|
/// TRACES: FR-CAT-7 | FR-UI-4
|
|
|
|
|
/// A photograph the most recent press asked to take *out* of the
|
|
|
|
|
/// selection, held until the release says the press was a tap.
|
|
|
|
|
///
|
|
|
|
|
/// The touch equivalent of shift-click needs this. A double tap is two
|
|
|
|
|
/// presses, and both of them move the anchor onto the cell being tapped —
|
|
|
|
|
/// so by the time the double tap is reported, "the range from the anchor to
|
|
|
|
|
/// here" describes a single cell. This remembers the cell the user actually
|
|
|
|
|
/// started from, which is the one they mean.
|
|
|
|
|
///
|
|
|
|
|
/// Updated only when a press *moves* the anchor, so the second tap of a
|
|
|
|
|
/// double tap — which lands on the cell that is already the anchor — leaves
|
|
|
|
|
/// it pointing where the first tap left it.
|
|
|
|
|
previous_anchor: std::cell::Cell<Option<usize>>,
|
|
|
|
|
/// See [`Press::Deferred`] for why removal cannot happen on the press:
|
|
|
|
|
/// this is the whole of what stops a drag of forty photographs carrying
|
|
|
|
|
/// one. Overwritten by the next press and dropped by the drag that
|
|
|
|
|
/// consumes it, so at most one is ever pending.
|
|
|
|
|
pending_toggle: std::cell::Cell<Option<ImageId>>,
|
|
|
|
|
/// TRACES: FR-UI-4
|
|
|
|
|
/// What the selection was immediately before the most recent press, so a
|
|
|
|
|
/// gesture that turns out not to have been a press can put it back.
|
|
|
|
@@ -368,22 +362,57 @@ impl CollectionsController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TRACES: FR-CAT-7 | FR-UI-4
|
|
|
|
|
/// What a press did, and what is left for the release to do.
|
|
|
|
|
///
|
|
|
|
|
/// Only one press has anything left over, and it is the one every multi-image
|
|
|
|
|
/// drag depends on — see [`Press::Deferred`].
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub enum Press {
|
|
|
|
|
/// The selection is already what this press means. Nothing to finish.
|
|
|
|
|
Applied,
|
|
|
|
|
/// **Taking a photograph out of the selection waits for the release.**
|
|
|
|
|
///
|
|
|
|
|
/// Putting one *in* has to happen on the press: the drag that may follow
|
|
|
|
|
/// reads the selection to decide what it carries, and by the time the
|
|
|
|
|
/// finger lifts it is over the sidebar. Taking one out is the opposite —
|
|
|
|
|
/// nothing between the press and the release needs the image gone, and one
|
|
|
|
|
/// thing very much needs it to stay.
|
|
|
|
|
///
|
|
|
|
|
/// A plain press has said so since selection was written: pressing an
|
|
|
|
|
/// already-selected cell leaves the selection alone. Ctrl did not, and on a
|
|
|
|
|
/// tablet *every* press is a ctrl-press — that is what selection mode is.
|
|
|
|
|
/// So grabbing one of forty selected photographs deselected it on the way
|
|
|
|
|
/// down; the drag that followed found the cell under the finger no longer
|
|
|
|
|
/// in the selection, took that to mean an unselected image was being
|
|
|
|
|
/// dragged, and carried it alone. Forty photographs became one, and the
|
|
|
|
|
/// only clue was the grabbed cell's ring blinking out.
|
|
|
|
|
///
|
|
|
|
|
/// So the removal is handed back for the *click* to apply, and a click
|
|
|
|
|
/// fires only for a press that stayed put — never for one that became a
|
|
|
|
|
/// drag. See `tap-slop` in `library.slint`.
|
|
|
|
|
Deferred(ImageId),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Apply a press to the selection.
|
|
|
|
|
///
|
|
|
|
|
/// Split from the callback so the policy is testable without a window: this is
|
|
|
|
|
/// the part a user notices being wrong.
|
|
|
|
|
///
|
|
|
|
|
/// - **plain** — replace the selection with this one image
|
|
|
|
|
/// - **ctrl** — toggle this image, keeping the rest, and move the anchor here
|
|
|
|
|
/// - **ctrl** — add this image to the selection, keeping the rest, and move the
|
|
|
|
|
/// anchor here; taking one *out* is [deferred](Press::Deferred) to the release
|
|
|
|
|
/// - **shift** — select the range from the anchor to here, *replacing* what was
|
|
|
|
|
/// selected; the anchor stays put, so an overshoot is corrected by
|
|
|
|
|
/// shift-clicking the right cell rather than starting again
|
|
|
|
|
/// - **ctrl+shift** — the same range, *added* to the selection, for picking up a
|
|
|
|
|
/// second run without losing the first
|
|
|
|
|
///
|
|
|
|
|
/// A plain press on an image that is *already* selected leaves the selection
|
|
|
|
|
/// alone. That is what makes dragging a multi-selection possible at all — the
|
|
|
|
|
/// press that begins the drag would otherwise collapse the selection to one.
|
|
|
|
|
/// A press on an image that is *already* selected never removes it here —
|
|
|
|
|
/// plainly or with ctrl. That is what makes dragging a multi-selection possible
|
|
|
|
|
/// at all: the press that begins the drag would otherwise take the grabbed
|
|
|
|
|
/// photograph out from under it.
|
|
|
|
|
///
|
|
|
|
|
/// `ids` is the **loaded window**, `offset` where it starts in the library and
|
|
|
|
|
/// `row` a position within it; the anchor is kept as `offset + row`, an
|
|
|
|
@@ -402,8 +431,10 @@ pub fn apply_press(
|
|
|
|
|
ctrl: bool,
|
|
|
|
|
shift: bool,
|
|
|
|
|
span: &dyn Fn(usize, usize) -> Vec<ImageId>,
|
|
|
|
|
) {
|
|
|
|
|
let Some(&id) = ids.get(row) else { return };
|
|
|
|
|
) -> Press {
|
|
|
|
|
let Some(&id) = ids.get(row) else {
|
|
|
|
|
return Press::Applied;
|
|
|
|
|
};
|
|
|
|
|
let here = offset + row;
|
|
|
|
|
|
|
|
|
|
if shift {
|
|
|
|
@@ -413,7 +444,7 @@ pub fn apply_press(
|
|
|
|
|
selection.clear();
|
|
|
|
|
selection.insert(id);
|
|
|
|
|
*anchor = Some(here);
|
|
|
|
|
return;
|
|
|
|
|
return Press::Applied;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// The anchor deliberately does **not** move. Shift-clicking again
|
|
|
|
@@ -459,15 +490,19 @@ pub fn apply_press(
|
|
|
|
|
run = ids[lo_row..=hi_row].to_vec();
|
|
|
|
|
}
|
|
|
|
|
selection.extend(run);
|
|
|
|
|
return;
|
|
|
|
|
return Press::Applied;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ctrl {
|
|
|
|
|
if !selection.remove(&id) {
|
|
|
|
|
selection.insert(id);
|
|
|
|
|
}
|
|
|
|
|
*anchor = Some(here);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Taking one out waits for the release — see [`Press::Deferred`].
|
|
|
|
|
if selection.contains(&id) {
|
|
|
|
|
return Press::Deferred(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selection.insert(id);
|
|
|
|
|
return Press::Applied;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Plain press on something already selected: leave it. The drag that may
|
|
|
|
@@ -475,41 +510,13 @@ pub fn apply_press(
|
|
|
|
|
// multi-image drag impossible to start.
|
|
|
|
|
if selection.contains(&id) {
|
|
|
|
|
*anchor = Some(here);
|
|
|
|
|
return;
|
|
|
|
|
return Press::Applied;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selection.clear();
|
|
|
|
|
selection.insert(id);
|
|
|
|
|
*anchor = Some(here);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TRACES: FR-UI-2 | FR-UI-4
|
|
|
|
|
/// Apply a press, and remember where the anchor was before it moved.
|
|
|
|
|
///
|
|
|
|
|
/// The bookkeeping a double tap depends on, split out from the callback so the
|
|
|
|
|
/// touch sequence — hold one cell, double-tap another, get the run between —
|
|
|
|
|
/// can be tested without a window. See [`CollectionsController::previous_anchor`]
|
|
|
|
|
/// for why the *previous* anchor is the one a double tap means.
|
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
|
pub fn press_remembering_anchor(
|
|
|
|
|
selection: &mut BTreeSet<ImageId>,
|
|
|
|
|
anchor: &mut Option<usize>,
|
|
|
|
|
previous: &mut Option<usize>,
|
|
|
|
|
ids: &[ImageId],
|
|
|
|
|
offset: usize,
|
|
|
|
|
row: usize,
|
|
|
|
|
ctrl: bool,
|
|
|
|
|
shift: bool,
|
|
|
|
|
span: &dyn Fn(usize, usize) -> Vec<ImageId>,
|
|
|
|
|
) {
|
|
|
|
|
let before = *anchor;
|
|
|
|
|
apply_press(selection, anchor, ids, offset, row, ctrl, shift, span);
|
|
|
|
|
// Only a press that *moved* the anchor updates this. The second tap of a
|
|
|
|
|
// double tap lands on the cell the first tap made the anchor, so it changes
|
|
|
|
|
// nothing and the origin survives to be extended from.
|
|
|
|
|
if *anchor != before {
|
|
|
|
|
*previous = before;
|
|
|
|
|
}
|
|
|
|
|
Press::Applied
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Apply a press and push the result into the grid — the whole of what a
|
|
|
|
@@ -533,23 +540,25 @@ pub fn select_row(
|
|
|
|
|
*ctl.press_undo.borrow_mut() = Some(PressUndo::capture(
|
|
|
|
|
&ctl.selection.borrow(),
|
|
|
|
|
*ctl.anchor.borrow(),
|
|
|
|
|
ctl.previous_anchor.get(),
|
|
|
|
|
ctl.cursor(),
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
let mut previous = ctl.previous_anchor.get();
|
|
|
|
|
press_remembering_anchor(
|
|
|
|
|
// Whatever the last press left pending is answered by this one: two
|
|
|
|
|
// presses without a click in between means the first never was a tap.
|
|
|
|
|
ctl.pending_toggle.set(None);
|
|
|
|
|
|
|
|
|
|
if let Press::Deferred(id) = apply_press(
|
|
|
|
|
&mut ctl.selection.borrow_mut(),
|
|
|
|
|
&mut ctl.anchor.borrow_mut(),
|
|
|
|
|
&mut previous,
|
|
|
|
|
ids,
|
|
|
|
|
offset,
|
|
|
|
|
row,
|
|
|
|
|
ctrl,
|
|
|
|
|
shift,
|
|
|
|
|
&|first, last| ctl.span(first, last),
|
|
|
|
|
);
|
|
|
|
|
ctl.previous_anchor.set(previous);
|
|
|
|
|
) {
|
|
|
|
|
ctl.pending_toggle.set(Some(id));
|
|
|
|
|
}
|
|
|
|
|
// The cursor follows the press, so an arrow key after a click continues
|
|
|
|
|
// from the cell that was clicked rather than from wherever the keyboard
|
|
|
|
|
// was last.
|
|
|
|
@@ -557,6 +566,26 @@ pub fn select_row(
|
|
|
|
|
sync_selection(window, ctl, ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TRACES: FR-CAT-7 | FR-UI-4
|
|
|
|
|
/// Finish a press that turned out to be a tap.
|
|
|
|
|
///
|
|
|
|
|
/// The other half of [`Press::Deferred`]: a ctrl-press on an already-selected
|
|
|
|
|
/// photograph leaves it in, because the drag that may follow has to be able to
|
|
|
|
|
/// carry it, and this takes it out again once the release has proved there was
|
|
|
|
|
/// no drag.
|
|
|
|
|
///
|
|
|
|
|
/// Called from the click, which Slint reports only for a press that stayed
|
|
|
|
|
/// within `tap-slop` of where it landed — so a press that became a drag never
|
|
|
|
|
/// reaches here, and a press taken over by the Flickable never reaches here
|
|
|
|
|
/// either. Both leave the pending removal to be dropped by the next press.
|
|
|
|
|
pub fn commit_press(window: &AppWindow, ctl: &Rc<CollectionsController>, ids: &[ImageId]) {
|
|
|
|
|
let Some(id) = ctl.pending_toggle.take() else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
ctl.selection.borrow_mut().remove(&id);
|
|
|
|
|
sync_selection(window, ctl, ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TRACES: FR-UI-4
|
|
|
|
|
/// Put the selection back as it was before the most recent press.
|
|
|
|
|
///
|
|
|
|
@@ -568,14 +597,22 @@ pub fn select_row(
|
|
|
|
|
/// Idempotent, and a no-op when there is nothing to undo, so it is safe to
|
|
|
|
|
/// call on every gesture start rather than only on the ones that need it.
|
|
|
|
|
pub fn cancel_press(window: &AppWindow, ctl: &Rc<CollectionsController>, ids: &[ImageId]) {
|
|
|
|
|
// The press is being unmade, so what it left for the release to finish is
|
|
|
|
|
// unmade with it. Cleared before the early return: a press that changed
|
|
|
|
|
// nothing to undo can still have deferred a removal — and a finger that
|
|
|
|
|
// held long enough to pick a photograph up before the second one landed
|
|
|
|
|
// has to put it back down, or the ring stays open around a cell nobody is
|
|
|
|
|
// touching and the grid stays frozen with it.
|
|
|
|
|
ctl.pending_toggle.set(None);
|
|
|
|
|
window.set_library_held_row(-1);
|
|
|
|
|
|
|
|
|
|
let Some(undo) = ctl.press_undo.borrow_mut().take() else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let (previous_anchor, cursor) = undo.restore(
|
|
|
|
|
let cursor = undo.restore(
|
|
|
|
|
&mut ctl.selection.borrow_mut(),
|
|
|
|
|
&mut ctl.anchor.borrow_mut(),
|
|
|
|
|
);
|
|
|
|
|
ctl.previous_anchor.set(previous_anchor);
|
|
|
|
|
ctl.set_cursor(cursor);
|
|
|
|
|
sync_selection(window, ctl, ids);
|
|
|
|
|
}
|
|
|
|
@@ -1022,7 +1059,7 @@ pub(crate) const HOLD_DELAY_MS: u64 = 450;
|
|
|
|
|
/// press that armed it has *already* selected the cell under the finger, so
|
|
|
|
|
/// what firing adds is the mode: from here taps toggle rather than open, and
|
|
|
|
|
/// the header's buttons appear to act on what has been gathered.
|
|
|
|
|
fn arm_hold(window: &AppWindow, ctl: &Rc<CollectionsController>) {
|
|
|
|
|
fn arm_hold(window: &AppWindow, ctl: &Rc<CollectionsController>, row: i32) {
|
|
|
|
|
let timer = slint::Timer::default();
|
|
|
|
|
let weak = window.as_weak();
|
|
|
|
|
let ctl_cb = ctl.clone();
|
|
|
|
@@ -1032,8 +1069,22 @@ fn arm_hold(window: &AppWindow, ctl: &Rc<CollectionsController>) {
|
|
|
|
|
std::time::Duration::from_millis(HOLD_DELAY_MS),
|
|
|
|
|
move || {
|
|
|
|
|
let Some(w) = weak.upgrade() else { return };
|
|
|
|
|
ctl_cb.select_mode.set(true);
|
|
|
|
|
w.set_library_select_mode(true);
|
|
|
|
|
|
|
|
|
|
// TRACES: FR-CAT-7
|
|
|
|
|
// The photograph is in the user's hand: the grid draws a ring
|
|
|
|
|
// opening around it and stops scrolling underneath it, so the drag
|
|
|
|
|
// that may follow cannot be lost to a flick. See `held-row` in
|
|
|
|
|
// `library.slint`.
|
|
|
|
|
//
|
|
|
|
|
// This half happens whether or not selection mode was already on —
|
|
|
|
|
// it is the half a *drag* needs, and a drag out of a selection of
|
|
|
|
|
// forty starts in a mode that is already on.
|
|
|
|
|
w.set_library_held_row(row);
|
|
|
|
|
|
|
|
|
|
if !ctl_cb.select_mode.get() {
|
|
|
|
|
ctl_cb.select_mode.set(true);
|
|
|
|
|
w.set_library_select_mode(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The release that follows this hold must not also open the image:
|
|
|
|
|
// the user asked for a selection and would land in develop instead.
|
|
|
|
@@ -1498,17 +1549,20 @@ pub fn wire<S, R, P, C>(
|
|
|
|
|
let offset = w.get_library_offset().max(0) as usize;
|
|
|
|
|
select_row(&w, &ctl, &ids, offset, row as usize, ctrl_held, shift_held);
|
|
|
|
|
|
|
|
|
|
// TRACES: FR-UI-2 | FR-UI-4
|
|
|
|
|
// TRACES: FR-UI-2 | FR-UI-4 | FR-CAT-7
|
|
|
|
|
// And start counting, in case this press is a hold. The press has
|
|
|
|
|
// already selected this one cell; what the hold adds is the *mode*,
|
|
|
|
|
// so the taps that follow go on selecting instead of opening the
|
|
|
|
|
// next photograph the user touches.
|
|
|
|
|
// next photograph the user touches — and the *pick-up*, which is
|
|
|
|
|
// what makes the drag reliable.
|
|
|
|
|
//
|
|
|
|
|
// Not started when the mode is already on: it is on, and a second
|
|
|
|
|
// hold would have nothing to do but suppress the tap that ends it.
|
|
|
|
|
if !ctl.select_mode.get() {
|
|
|
|
|
arm_hold(&w, &ctl);
|
|
|
|
|
}
|
|
|
|
|
// Armed even when the mode is already on, which it did not used to
|
|
|
|
|
// be: there was nothing left for the hold to switch on, so it was
|
|
|
|
|
// skipped. But the mode being on is exactly the state a
|
|
|
|
|
// multi-image drag starts from, and skipping the hold left that
|
|
|
|
|
// drag with no pick-up and no cue — the one gesture that most
|
|
|
|
|
// needed both. See `arm_hold`.
|
|
|
|
|
arm_hold(&w, &ctl, row);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1856,16 +1910,33 @@ pub fn wire<S, R, P, C>(
|
|
|
|
|
// Slint owns the gesture (see the preamble). What is left here is the
|
|
|
|
|
// payload — the image ids the drop will act on — and the spring.
|
|
|
|
|
|
|
|
|
|
// The payload is built when the drag starts, so it is the selection as it
|
|
|
|
|
// stands at that moment rather than whatever it becomes mid-flight.
|
|
|
|
|
// TRACES: FR-CAT-7
|
|
|
|
|
// **What arms the drag, not what it carries.**
|
|
|
|
|
//
|
|
|
|
|
// `DragArea` declines to start a drag while its `data` is empty, and it
|
|
|
|
|
// tests that on every pointer event that reaches it — the first one
|
|
|
|
|
// included, which arrives long before any drag. The binding in
|
|
|
|
|
// `library.slint` calls this callback, and a binding that calls a callback
|
|
|
|
|
// has nothing Slint can invalidate it on: it is evaluated once, when a
|
|
|
|
|
// finger first lands on that cell, and cached. `dragging` is empty at that
|
|
|
|
|
// moment and stays empty until `drag-started` fires.
|
|
|
|
|
//
|
|
|
|
|
// So this is answered at the wrong time, and always will be. That is
|
|
|
|
|
// harmless only because **`set_user_data` is called unconditionally**: an
|
|
|
|
|
// empty `Vec` is still user data, so the transfer is never `is_empty()` and
|
|
|
|
|
// the `DragArea` stays armed. Skipping the call for an empty selection —
|
|
|
|
|
// which looks like an obvious tidy-up — would disarm every cell a finger
|
|
|
|
|
// had ever touched outside a drag, and dragging would simply stop working
|
|
|
|
|
// with nothing to see.
|
|
|
|
|
//
|
|
|
|
|
// What the drop actually reads is `dragging`, set by `drag-started` and
|
|
|
|
|
// read back by `dropped-on`. `user_data` rather than plain text so that
|
|
|
|
|
// nothing outside the application can interpret it as a paste.
|
|
|
|
|
{
|
|
|
|
|
let ctl = ctl.clone();
|
|
|
|
|
window.on_library_drag_payload(move || {
|
|
|
|
|
let carried = ctl.dragging.borrow().clone();
|
|
|
|
|
let mut data = slint::DataTransfer::default();
|
|
|
|
|
// `user_data` rather than plain text: these are catalog ids for our
|
|
|
|
|
// own drop handler, not something another application should be
|
|
|
|
|
// able to interpret as a paste.
|
|
|
|
|
data.set_user_data(Rc::new(carried));
|
|
|
|
|
data
|
|
|
|
|
});
|
|
|
|
@@ -1899,6 +1970,15 @@ pub fn wire<S, R, P, C>(
|
|
|
|
|
// meant. The pinch already cancels for exactly this reason.
|
|
|
|
|
*ctl.hold_timer.borrow_mut() = None;
|
|
|
|
|
|
|
|
|
|
// TRACES: FR-CAT-7
|
|
|
|
|
// And this press was not a tap, so it never gets to take anything
|
|
|
|
|
// out of the selection — see [`Press::Deferred`]. Dropped here as
|
|
|
|
|
// well as on the next press because the drag reads the selection
|
|
|
|
|
// one line below, and a removal still pending would be a
|
|
|
|
|
// photograph the user can see is selected and the drop would not
|
|
|
|
|
// carry.
|
|
|
|
|
ctl.pending_toggle.set(None);
|
|
|
|
|
|
|
|
|
|
// Dragging an *unselected* cell carries only that one, and makes it
|
|
|
|
|
// the selection — otherwise the images that travel are not the ones
|
|
|
|
|
// the user grabbed. Dragging a selected cell carries the whole
|
|
|
|
@@ -2062,6 +2142,10 @@ pub fn wire<S, R, P, C>(
|
|
|
|
|
let landed = ctl.dropped_on.borrow_mut().take();
|
|
|
|
|
let to_trash = ctl.trash_requested.borrow_mut().take();
|
|
|
|
|
ctl.dragging.borrow_mut().clear();
|
|
|
|
|
// The grid clears this itself on the cancel that starts a drag;
|
|
|
|
|
// this is for the endings that reach no cell — a drop, or a drag
|
|
|
|
|
// abandoned over nothing.
|
|
|
|
|
w.set_library_held_row(-1);
|
|
|
|
|
*ctl.hover_id.borrow_mut() = None;
|
|
|
|
|
*ctl.spring_timer.borrow_mut() = None;
|
|
|
|
|
|
|
|
|
@@ -2657,6 +2741,30 @@ fn unique_name(conn: &rusqlite::Connection, parent: Option<CollectionId>) -> Str
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
|
|
/// A press and the release that follows it — which is what a click is.
|
|
|
|
|
///
|
|
|
|
|
/// These tests are about what a *user* sees, and a user only ever presses
|
|
|
|
|
/// and lets go. Calling [`apply_press`] alone would drop the half of the
|
|
|
|
|
/// policy that waits for the release ([`Press::Deferred`]) and quietly
|
|
|
|
|
/// assert the wrong thing about ctrl.
|
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
|
fn click(
|
|
|
|
|
selection: &mut BTreeSet<ImageId>,
|
|
|
|
|
anchor: &mut Option<usize>,
|
|
|
|
|
ids: &[ImageId],
|
|
|
|
|
offset: usize,
|
|
|
|
|
row: usize,
|
|
|
|
|
ctrl: bool,
|
|
|
|
|
shift: bool,
|
|
|
|
|
span: &dyn Fn(usize, usize) -> Vec<ImageId>,
|
|
|
|
|
) {
|
|
|
|
|
if let Press::Deferred(id) =
|
|
|
|
|
apply_press(selection, anchor, ids, offset, row, ctrl, shift, span)
|
|
|
|
|
{
|
|
|
|
|
selection.remove(&id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
fn ids(n: u64) -> Vec<ImageId> {
|
|
|
|
@@ -2730,8 +2838,8 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 2, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 2, false, false, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(sel.iter().copied().collect::<Vec<_>>(), vec![ImageId(3)]);
|
|
|
|
|
}
|
|
|
|
@@ -2743,12 +2851,12 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
assert_eq!(sel.len(), 2);
|
|
|
|
|
|
|
|
|
|
// Toggling: a second ctrl-press on the same cell takes it out again.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
assert_eq!(sel.iter().copied().collect::<Vec<_>>(), vec![ImageId(1)]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2759,8 +2867,8 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 2, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 6, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 2, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 6, false, true, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(sel.len(), 5, "rows 2..=6 inclusive");
|
|
|
|
|
assert!(sel.contains(&ImageId(3)) && sel.contains(&ImageId(7)));
|
|
|
|
@@ -2773,8 +2881,8 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 6, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 2, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 6, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 2, false, true, &span);
|
|
|
|
|
assert_eq!(sel.len(), 5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2788,12 +2896,12 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 5, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 15, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 5, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 15, false, true, &span);
|
|
|
|
|
assert_eq!(sel.len(), 11, "rows 5..=15");
|
|
|
|
|
|
|
|
|
|
// Corrected to a shorter range from the same anchor.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 8, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 8, false, true, &span);
|
|
|
|
|
assert_eq!(sel.len(), 4, "rows 5..=8, and nothing from the first range");
|
|
|
|
|
assert!(!sel.contains(&ImageId(16)), "row 15 is no longer selected");
|
|
|
|
|
}
|
|
|
|
@@ -2807,9 +2915,9 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 10, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 14, false, true, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 12, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 10, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 14, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 12, false, true, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(anchor, Some(10));
|
|
|
|
|
assert_eq!(sel.len(), 3, "rows 10..=12");
|
|
|
|
@@ -2830,25 +2938,14 @@ mod tests {
|
|
|
|
|
let span = library(&all);
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
let mut previous = None;
|
|
|
|
|
|
|
|
|
|
// Selecting began somewhere else, so a range gesture would have had an
|
|
|
|
|
// anchor to sweep from.
|
|
|
|
|
press_remembering_anchor(
|
|
|
|
|
&mut sel,
|
|
|
|
|
&mut anchor,
|
|
|
|
|
&mut previous,
|
|
|
|
|
&all,
|
|
|
|
|
0,
|
|
|
|
|
4,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
&span,
|
|
|
|
|
);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 4, false, false, &span);
|
|
|
|
|
assert_eq!(sel.len(), 1);
|
|
|
|
|
|
|
|
|
|
tap(&mut sel, &mut anchor, &mut previous, &all, 11);
|
|
|
|
|
tap(&mut sel, &mut anchor, &mut previous, &all, 11);
|
|
|
|
|
tap(&mut sel, &mut anchor, &all, 11);
|
|
|
|
|
tap(&mut sel, &mut anchor, &all, 11);
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
sel.iter().copied().collect::<Vec<_>>(),
|
|
|
|
@@ -2859,24 +2956,86 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
/// One tap in selection mode: a press reported as ctrl-held, which is what
|
|
|
|
|
/// `library.slint` sends while the mode is on.
|
|
|
|
|
fn tap(
|
|
|
|
|
sel: &mut BTreeSet<ImageId>,
|
|
|
|
|
anchor: &mut Option<usize>,
|
|
|
|
|
previous: &mut Option<usize>,
|
|
|
|
|
all: &[ImageId],
|
|
|
|
|
row: usize,
|
|
|
|
|
) {
|
|
|
|
|
press_remembering_anchor(
|
|
|
|
|
sel,
|
|
|
|
|
anchor,
|
|
|
|
|
previous,
|
|
|
|
|
all,
|
|
|
|
|
0,
|
|
|
|
|
row,
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
&library(all),
|
|
|
|
|
fn tap(sel: &mut BTreeSet<ImageId>, anchor: &mut Option<usize>, all: &[ImageId], row: usize) {
|
|
|
|
|
click(sel, anchor, all, 0, row, true, false, &library(all));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TRACES: FR-CAT-7 | FR-UI-4
|
|
|
|
|
/// The bug that made a forty-image drag file one photograph.
|
|
|
|
|
///
|
|
|
|
|
/// In selection mode every press arrives as a ctrl-press, so grabbing one
|
|
|
|
|
/// of the selected cells to drag them all used to *deselect* the cell being
|
|
|
|
|
/// grabbed. `drag-started` then saw a press on an image that was not in the
|
|
|
|
|
/// selection, concluded that was the gesture, and carried it alone.
|
|
|
|
|
#[test]
|
|
|
|
|
fn grabbing_a_selected_cell_leaves_the_whole_selection_to_drag() {
|
|
|
|
|
let all = ids(20);
|
|
|
|
|
let span = library(&all);
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
// Three photographs picked in selection mode, which reports ctrl.
|
|
|
|
|
for row in [2, 5, 9] {
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, row, true, false, &span);
|
|
|
|
|
}
|
|
|
|
|
assert_eq!(sel.len(), 3);
|
|
|
|
|
|
|
|
|
|
// The press that begins the drag, on one of the three.
|
|
|
|
|
let outcome = apply_press(&mut sel, &mut anchor, &all, 0, 5, true, false, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
outcome,
|
|
|
|
|
Press::Deferred(ImageId(6)),
|
|
|
|
|
"the removal has to be handed back, not performed"
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
sel.len(),
|
|
|
|
|
3,
|
|
|
|
|
"the drag reads the selection next, and all three have to still be in it"
|
|
|
|
|
);
|
|
|
|
|
assert!(sel.contains(&ImageId(6)), "least of all the one being held");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// And the other half: with no drag, the release still takes it out.
|
|
|
|
|
///
|
|
|
|
|
/// A tap in selection mode has to toggle, or there is no way to correct a
|
|
|
|
|
/// mis-tap short of leaving the mode.
|
|
|
|
|
#[test]
|
|
|
|
|
fn a_tap_on_a_selected_cell_still_takes_it_out() {
|
|
|
|
|
let all = ids(20);
|
|
|
|
|
let span = library(&all);
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
for row in [2, 5, 9] {
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, row, true, false, &span);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 5, true, false, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
sel.iter().copied().collect::<Vec<_>>(),
|
|
|
|
|
vec![ImageId(3), ImageId(10)],
|
|
|
|
|
"the tapped photograph is out and the other two stayed"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The anchor moves on the press whether or not the removal does.
|
|
|
|
|
///
|
|
|
|
|
/// "Select to…" measures from the anchor, and a run taken after tapping a
|
|
|
|
|
/// selected cell has to start where the user last touched — otherwise the
|
|
|
|
|
/// gesture sweeps from wherever the anchor happened to be left.
|
|
|
|
|
#[test]
|
|
|
|
|
fn a_deferred_press_still_moves_the_anchor() {
|
|
|
|
|
let all = ids(20);
|
|
|
|
|
let span = library(&all);
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
let _ = apply_press(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(anchor, Some(3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
@@ -2888,13 +3047,13 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 2, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 2, false, true, &span);
|
|
|
|
|
assert_eq!(sel.len(), 3);
|
|
|
|
|
|
|
|
|
|
// A new anchor by ctrl-click, then a ctrl+shift range from it.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 10, true, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 12, true, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 10, true, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 12, true, true, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(sel.len(), 6, "rows 0..=2 and 10..=12");
|
|
|
|
|
assert!(sel.contains(&ImageId(1)) && sel.contains(&ImageId(13)));
|
|
|
|
@@ -2909,13 +3068,13 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 1, true, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 2, true, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 0, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 1, true, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 2, true, false, &span);
|
|
|
|
|
assert_eq!(sel.len(), 3);
|
|
|
|
|
|
|
|
|
|
// Pressing one of the three to begin a drag.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 1, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 1, false, false, &span);
|
|
|
|
|
assert_eq!(sel.len(), 3, "the selection survived the press");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2932,23 +3091,22 @@ mod tests {
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
// A selection built the ordinary way, and the state it leaves behind.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 1, false, false, &span);
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 1, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 3, true, false, &span);
|
|
|
|
|
let before = (sel.clone(), anchor);
|
|
|
|
|
|
|
|
|
|
// The finger that opens a pinch.
|
|
|
|
|
let undo = PressUndo::capture(&sel, anchor, Some(1), Some(3));
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 5, false, false, &span);
|
|
|
|
|
let undo = PressUndo::capture(&sel, anchor, Some(3));
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 5, false, false, &span);
|
|
|
|
|
assert_ne!(
|
|
|
|
|
(sel.clone(), anchor),
|
|
|
|
|
before,
|
|
|
|
|
"the press has to change something, or this proves nothing"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let (previous_anchor, cursor) = undo.restore(&mut sel, &mut anchor);
|
|
|
|
|
let cursor = undo.restore(&mut sel, &mut anchor);
|
|
|
|
|
|
|
|
|
|
assert_eq!((sel, anchor), before, "selection and anchor are back");
|
|
|
|
|
assert_eq!(previous_anchor, Some(1), "and so is the shift-click origin");
|
|
|
|
|
assert_eq!(cursor, Some(3), "and the keyboard cursor");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2960,7 +3118,7 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 99, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 99, false, false, &span);
|
|
|
|
|
assert!(sel.is_empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2980,12 +3138,12 @@ mod tests {
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
// Anchor on the sixth image, in a window starting at the beginning.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &first, 0, 5, false, false, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &first, 0, 5, false, false, &span);
|
|
|
|
|
assert_eq!(anchor, Some(5), "the anchor is an ordinal, not a row");
|
|
|
|
|
|
|
|
|
|
// The user scrolls — the window now starts four images in — and
|
|
|
|
|
// shift-clicks the image at ordinal 10.
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &later, 4, 6, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &later, 4, 6, false, true, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(sel.len(), 6, "ordinals 5..=10");
|
|
|
|
|
assert!(sel.contains(&ImageId(6)), "the anchored image is still in");
|
|
|
|
@@ -3007,7 +3165,7 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = Some(0);
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &window, 10, 3, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &window, 10, 3, false, true, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(sel.len(), 14, "ordinals 0..=13, loaded or not");
|
|
|
|
|
assert!(
|
|
|
|
@@ -3030,7 +3188,7 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = Some(25);
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &window, 0, 2, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &window, 0, 2, false, true, &span);
|
|
|
|
|
|
|
|
|
|
assert_eq!(sel.len(), 24, "ordinals 2..=25");
|
|
|
|
|
assert!(sel.contains(&ImageId(3)) && sel.contains(&ImageId(26)));
|
|
|
|
@@ -3051,7 +3209,7 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = Some(0);
|
|
|
|
|
|
|
|
|
|
apply_press(
|
|
|
|
|
click(
|
|
|
|
|
&mut sel,
|
|
|
|
|
&mut anchor,
|
|
|
|
|
&window,
|
|
|
|
@@ -3073,7 +3231,7 @@ mod tests {
|
|
|
|
|
let mut sel = BTreeSet::new();
|
|
|
|
|
let mut anchor = None;
|
|
|
|
|
|
|
|
|
|
apply_press(&mut sel, &mut anchor, &all, 0, 3, false, true, &span);
|
|
|
|
|
click(&mut sel, &mut anchor, &all, 0, 3, false, true, &span);
|
|
|
|
|
assert_eq!(sel.iter().copied().collect::<Vec<_>>(), vec![ImageId(4)]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|