feat(iced): add keyboard shortcuts for selection operations

This commit is contained in:
2026-07-15 03:31:13 +03:00
parent 611a6655da
commit 12ccbf2688
@@ -379,6 +379,9 @@ pub enum Message {
SelectionDragStart(f32, f32),
SelectionDragMove(f32, f32),
SelectionDragEnd,
SelectAll,
Deselect,
SelectInverse,
// ── Selection transform ─────────────────────────────
TransformDragStart(f32, f32),
@@ -1975,6 +1978,19 @@ impl HcieIcedApp {
}
}
}
Message::SelectAll => {
let w = self.documents[self.active_doc].engine.canvas_width() as f32;
let h = self.documents[self.active_doc].engine.canvas_height() as f32;
self.documents[self.active_doc].selection_rect = Some((0.0, 0.0, w, h));
}
Message::Deselect => {
self.documents[self.active_doc].selection_rect = None;
}
Message::SelectInverse => {
self.documents[self.active_doc].engine.selection_invert();
self.refresh_composite_if_needed();
return Task::perform(async {}, |_| Message::CompositeRefresh);
}
// ── Selection transform ────────────────────────
Message::TransformDragStart(x, y) => {
@@ -3000,6 +3016,10 @@ impl HcieIcedApp {
/// - Ctrl+O: Open
/// - Ctrl+C: Copy
/// - Ctrl+V: Paste
/// - Ctrl+X: Cut
/// - Ctrl+A: Select All
/// - Ctrl+D: Deselect
/// - Ctrl+Shift+I: Inverse Selection
/// - Escape: Close dialog
pub fn subscription(&self) -> iced::Subscription<Message> {
let keyboard = iced::keyboard::on_key_press(|key, modifiers| {
@@ -3042,6 +3062,18 @@ impl HcieIcedApp {
iced::keyboard::Key::Character(ref c) if c.as_str() == "x" && ctrl && !shift => {
Some(Message::CopyImage) // TODO: cut
}
// Ctrl+A = Select All
iced::keyboard::Key::Character(ref c) if c.as_str() == "a" && ctrl && !shift => {
Some(Message::SelectAll)
}
// Ctrl+D = Deselect
iced::keyboard::Key::Character(ref c) if c.as_str() == "d" && ctrl && !shift => {
Some(Message::Deselect)
}
// Ctrl+Shift+I = Inverse Selection
iced::keyboard::Key::Character(ref c) if c.as_str() == "i" && ctrl && shift => {
Some(Message::SelectInverse)
}
// Escape = close menu, cancel dialog, deselect, or cancel crop
iced::keyboard::Key::Named(iced::keyboard::key::Named::Escape) => {
Some(Message::MenuClose) // Crop cancel handled in update()