mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 09:08:11 +00:00
Guides: a keyboard Delete clears the guide selection instead of moving it to the next guide
This commit is contained in:
@@ -125,7 +125,7 @@ struct PendingKey(Option<GuideKey>);
|
||||
/// modifiers (Ctrl turns snapping off).
|
||||
/// - The guides are one Tab stop. Page Up and Page Down select the previous or next guide (vertical guides left to
|
||||
/// right, then horizontal ones top to bottom), the arrow keys nudge the selected one across its axis (Shift moves
|
||||
/// it by the large step) and Delete or Backspace removes it. With the canvas focused, Delete or Backspace removes
|
||||
/// it by the large step) and Delete or Backspace removes it and clears the selection. With the canvas focused, Delete or Backspace removes
|
||||
/// the selected guide unless it is locked, before the canvas's tool and the app's shortcuts.
|
||||
/// - A press on a guide selects it, so [`GuidesOutput::select`] reports the key. A press on the canvas background
|
||||
/// (one that reaches the canvas's tool) clears the selection, reported as `Some(None)`.
|
||||
@@ -386,12 +386,8 @@ impl<'a> Guides<'a> {
|
||||
let forward = cx.intents().take_exact(&Intent::delete(true, Granularity::Unit));
|
||||
let backward = cx.intents().take_exact(&Intent::delete(false, Granularity::Unit));
|
||||
if forward || backward {
|
||||
let next = place::after_removal(guides, &place::keyboard_order(guides), guide.key);
|
||||
cx.set(place::removed(guides, guide.key));
|
||||
self.report.select = Some(next);
|
||||
if let Some(next) = next {
|
||||
cx.focus_part(next.part(GUIDE));
|
||||
}
|
||||
self.report.select = Some(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,3 @@ pub(super) fn with_guide(guides: &[Guide], guide: Guide) -> Vec<Guide> {
|
||||
pub(super) fn fresh_key(guides: &[Guide]) -> GuideKey {
|
||||
GuideKey::new(guides.iter().map(|guide| guide.key.get() + 1).max().unwrap_or(0))
|
||||
}
|
||||
|
||||
/// The guide that holds the place of `key` once it is gone: the next in `order`, else the one before it.
|
||||
pub(super) fn after_removal(guides: &[Guide], order: &[usize], key: GuideKey) -> Option<GuideKey> {
|
||||
let at = order.iter().position(|&index| guides[index].key == key)?;
|
||||
order.get(at + 1).or_else(|| at.checked_sub(1).and_then(|before| order.get(before))).map(|&index| guides[index].key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user