diff --git a/crates/keymap/src/chord.rs b/crates/keymap/src/chord.rs index 535216da5..eec5c3781 100644 --- a/crates/keymap/src/chord.rs +++ b/crates/keymap/src/chord.rs @@ -823,9 +823,9 @@ impl Trigger { /// `one`, the chord's text, as this kind of press writes it. fn written(&self, one: String) -> String { match self.press { - Press::Single => one, - Press::Double => format!("{one} {one}"), - Press::Hold => format!("Hold {one}"), + PressKind::Single => one, + PressKind::Double => format!("{one} {one}"), + PressKind::Hold => format!("Hold {one}"), } } } diff --git a/crates/keymap/src/import.rs b/crates/keymap/src/import.rs index 15c1c7cb4..96b310f07 100644 --- a/crates/keymap/src/import.rs +++ b/crates/keymap/src/import.rs @@ -14,7 +14,7 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use serde::{Deserialize, Serialize}; -use crate::chord::{Chord, Press, Trigger}; +use crate::chord::{Chord, PressKind, Trigger}; use crate::chord::foreign::{Flavor, ForeignError, ReadNote, read_foreign}; use crate::command::CommandRef; use crate::keymap::{Binding, CommandDef, CommandKind, Keymap, MAX_BINDINGS, Policy}; @@ -968,7 +968,7 @@ fn key_codes(k: &ForeignKey) -> Vec<(String, bool)> { /// The first unscoped single-press default of command `i` as (modifiers text, key text), the forms codes decode to. fn default_parts(keymap: &Keymap, i: usize) -> Option<(String, String)> { let command = &keymap.catalog().get(i)?.command; - let chord = keymap.default_bindings(command).into_iter().find(|b| b.scope.is_none() && b.trigger.press == Press::Single)?.trigger.chord; + let chord = keymap.default_bindings(command).into_iter().find(|b| b.scope.is_none() && b.trigger.press == PressKind::Single)?.trigger.chord; let (key, full) = (chord.key.name(), chord.to_string()); let mods = full.strip_suffix(key).unwrap_or_default().trim_end_matches('+'); Some((mods.to_string(), key.to_string())) diff --git a/crates/keymap/src/import/kys.rs b/crates/keymap/src/import/kys.rs index 4921f8bea..176c00249 100644 --- a/crates/keymap/src/import/kys.rs +++ b/crates/keymap/src/import/kys.rs @@ -177,7 +177,7 @@ pub fn read(text: &str) -> Result { let mut key = ForeignKey::read(None, key, flavor); // Photoshop's tool shortcuts are single keys: one with modifiers is reported as // unreadable and binds nothing, and the tool keeps the key it has. - if row.tool && key.trigger.as_ref().is_ok_and(|t| !t.chord.mods.is_none() || t.press != crate::chord::Press::Single) { + if row.tool && key.trigger.as_ref().is_ok_and(|t| !t.chord.mods.is_none() || t.press != crate::chord::PressKind::Single) { key.trigger = Err(ForeignError::UnsupportedModifier(key.text.clone())); } entry = entry.with_key(key); @@ -226,7 +226,7 @@ pub fn write(name: &str, keymap: &Keymap) -> String { for tools in [false, true] { for b in keymap.catalog().iter().filter(|b| matches!(b.kind, CommandKind::Tool { .. }) == tools) { let keys: Vec = - keymap.bindings(&b.command).iter().filter(|k| k.scope.is_none() && k.trigger.press == crate::chord::Press::Single).map(|k| photoshop_key(&k.trigger)).collect(); + keymap.bindings(&b.command).iter().filter(|k| k.scope.is_none() && k.trigger.press == crate::chord::PressKind::Single).map(|k| photoshop_key(&k.trigger)).collect(); let Some(first) = keys.first() else { continue }; let label = escape(&b.label.replace('…', "...")); let id = escape(&b.command.key()); diff --git a/crates/keymap/src/keymap.rs b/crates/keymap/src/keymap.rs index d057fe33b..89b20bfa5 100644 --- a/crates/keymap/src/keymap.rs +++ b/crates/keymap/src/keymap.rs @@ -422,7 +422,7 @@ impl Keymap { /// The command a hold of `chord` runs where it applies, ranked as the other lookups rank. pub fn hold_of(&self, chord: &Chord, active: &Active<'_>) -> Option { - match self.winners(Trigger { chord: chord.effective(self.platform), press: Press::Hold }, active, &[]) { + match self.winners(Trigger { chord: chord.effective(self.platform), press: PressKind::Hold }, active, &[]) { Winners::None => None, Winners::Run(i) => Some(self.catalog[i].command.clone()), Winners::Cycle(cycle) => cycle.first().map(|&i| self.catalog[i].command.clone()), @@ -499,7 +499,7 @@ impl Keymap { /// [`shown_chord`](Self::shown_chord) of the command at catalog position `i`, from the bindings. fn shown_of(&self, i: usize) -> Option { let home = &self.catalog[i].scope; - let single = || self.current[i].iter().filter(|(trigger, _)| trigger.press == Press::Single); + let single = || self.current[i].iter().filter(|(trigger, _)| trigger.press == PressKind::Single); let runs = |(trigger, scope): &&Bound| { let name = [scope.as_str()]; let active = match self.scopes.kind(scope) { @@ -507,7 +507,7 @@ impl Keymap { ScopeKind::Panel => Active::panel(name[0]), ScopeKind::Context => Active { panel: None, contexts: &name, typing: false }, }; - match self.winners(Trigger { chord: trigger.chord.effective(self.platform), press: Press::Single }, &active, &[]) { + match self.winners(Trigger { chord: trigger.chord.effective(self.platform), press: PressKind::Single }, &active, &[]) { Winners::None => false, Winners::Run(j) => j == i, Winners::Cycle(cycle) => cycle.contains(&i), @@ -531,7 +531,7 @@ impl Keymap { Lookup::Cycle(cycle) => return cycle.into_iter().next(), Lookup::None => {} } - let want = Trigger { chord: chord.effective(self.platform), press: Press::Single }; + let want = Trigger { chord: chord.effective(self.platform), press: PressKind::Single }; self.by_trigger.get(&want)?.iter().find(|&&(i, k)| self.at(i, k).is_some()).map(|&(i, _)| self.catalog[i].command.clone()) } diff --git a/crates/ui-contract/icons/phosphor/arrow-down.svg b/crates/ui-contract/icons/phosphor/arrow-down.svg index e1bf0f35f..0e7629b6d 100644 --- a/crates/ui-contract/icons/phosphor/arrow-down.svg +++ b/crates/ui-contract/icons/phosphor/arrow-down.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/crates/ui-contract/icons/phosphor/arrow-up.svg b/crates/ui-contract/icons/phosphor/arrow-up.svg index 5710ca8d4..a8ba45ec7 100644 --- a/crates/ui-contract/icons/phosphor/arrow-up.svg +++ b/crates/ui-contract/icons/phosphor/arrow-up.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/crates/ui-contract/src/contract/items/lead.rs b/crates/ui-contract/src/contract/items/lead.rs index 2a800a77c..4c81dbf98 100644 --- a/crates/ui-contract/src/contract/items/lead.rs +++ b/crates/ui-contract/src/contract/items/lead.rs @@ -3,9 +3,11 @@ use super::{ItemsHooks, Placement, members}; use crate::contract::collection::{CollectionEvent, LeadOnOpen, LeadSource, ListDrag, SelectMode}; use crate::contract::{Collection, Cx}; +use crate::runtime::memory::sub; +use crate::runtime::{drag, pointer}; use craft_behavior::{Flow, ItemLayout, PointerEvent, SelectionChange, SelectionModel}; use craft_keymap::Mods; -use egui::{Pos2, Rect, Vec2}; +use egui::{Context, Id, Pos2, Rect, Vec2}; use std::any::TypeId; /// What made a selection change, reported with it (`CollectionEvent::Selection`): a key, or a pointer pick with the @@ -16,6 +18,13 @@ pub(super) enum PickBy { Pointer(Mods), } +/// What the rest timer of `drag_select` last saw: the drag's pointer and the row it is timing. +#[derive(Clone, Copy, Default)] +struct DragRest { + pointer: Option, + row: Option, +} + impl<'s, 'r, C: Collection> ItemsHooks<'s, 'r, C> { pub(super) fn select_mode(comp: &C) -> SelectMode { comp.items().select diff --git a/crates/ui-widgets/src/display/kbd.rs b/crates/ui-widgets/src/display/kbd.rs index 3f4f8a85d..5a6cafbe3 100644 --- a/crates/ui-widgets/src/display/kbd.rs +++ b/crates/ui-widgets/src/display/kbd.rs @@ -129,9 +129,9 @@ impl Kbd { None => one, }; match trigger.press { - craft_keymap::chord::Press::Single => one, - craft_keymap::chord::Press::Double => format!("{one} {one}"), - craft_keymap::chord::Press::Hold => words.kbd_hold.fill(&[("chord", one.as_str())]), + craft_keymap::chord::PressKind::Single => one, + craft_keymap::chord::PressKind::Double => format!("{one} {one}"), + craft_keymap::chord::PressKind::Hold => words.kbd_hold.fill(&[("chord", one.as_str())]), } }