From efa6d358648fc0cb4e40e8d06e6465fa019c971d Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 28 May 2026 15:48:50 +0200 Subject: [PATCH] Phase 5: Keyboard shortcuts and editor polish - Tool shortcuts (editor active): B=Pen, E=Eraser, L=Line, R=Rect, C=Circle, I=Color Pick - Brush size: [/] keys decrease/increase by 2 - Zoom: 0=reset, +=zoom in, -=zoom out - Ctrl+Z=undo, Ctrl+S=commit (save edit) - A=toggle adjustments panel - Skip global hotkeys (Ctrl+B sidebar, number nav) when editor active - All 156 tests pass. --- odin/src/gui/runtime.odin | 53 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/odin/src/gui/runtime.odin b/odin/src/gui/runtime.odin index b5b239a..6c2086a 100644 --- a/odin/src/gui/runtime.odin +++ b/odin/src/gui/runtime.odin @@ -266,10 +266,61 @@ run_gui_app :: proc(state: ^core.Comic_State) -> shared.App_Error { } } + if app.editor.active && !interaction_locked { + if rl.IsKeyPressed(.B) && !rl.IsKeyDown(.LEFT_CONTROL) && !rl.IsKeyDown(.RIGHT_CONTROL) { + app.editor.current_tool = .Pen + } + if rl.IsKeyPressed(.E) { + app.editor.current_tool = .Eraser + } + if rl.IsKeyPressed(.L) { + app.editor.current_tool = .Line + } + if rl.IsKeyPressed(.R) { + app.editor.current_tool = .Rectangle + } + if rl.IsKeyPressed(.C) && !rl.IsKeyDown(.LEFT_CONTROL) && !rl.IsKeyDown(.RIGHT_CONTROL) { + app.editor.current_tool = .Circle + } + if rl.IsKeyPressed(.I) { + app.editor.current_tool = .Color_Pick + } + if rl.IsKeyPressed(.LEFT_BRACKET) { + app.editor.brush_size = max(app.editor.brush_size - 2, 1) + } + if rl.IsKeyPressed(.RIGHT_BRACKET) { + app.editor.brush_size = min(app.editor.brush_size + 2, 80) + } + if rl.IsKeyPressed(.ZERO) { + app.editor.zoom = 1.0 + app.editor.pan_offset = rl.Vector2{} + app.editor.needs_redraw = true + } + if rl.IsKeyPressed(.EQUAL) || rl.IsKeyPressed(.KP_ADD) { + app.editor.zoom = min(app.editor.zoom + 0.25, 8.0) + app.editor.needs_redraw = true + } + if rl.IsKeyPressed(.MINUS) || rl.IsKeyPressed(.KP_SUBTRACT) { + app.editor.zoom = max(app.editor.zoom - 0.25, 0.25) + app.editor.needs_redraw = true + } + if rl.IsKeyDown(.LEFT_CONTROL) || rl.IsKeyDown(.RIGHT_CONTROL) { + if rl.IsKeyPressed(.Z) { + editor_undo(&app.editor) + } + if rl.IsKeyPressed(.S) { + push_status(&app.status_msg, &app.action_log, editor_commit(&app)) + } + } + if rl.IsKeyPressed(.A) && !rl.IsKeyDown(.LEFT_CONTROL) && !rl.IsKeyDown(.RIGHT_CONTROL) { + app.editor.show_adjust_panel = !app.editor.show_adjust_panel + } + } + // Compact mode forces the sidebar collapsed if bp == .Compact { app.sidebar_collapsed = true } - if !interaction_locked { + if !interaction_locked && !app.editor.active { if rl.IsKeyPressed(.B) && (rl.IsKeyDown(.LEFT_CONTROL) || rl.IsKeyDown(.RIGHT_CONTROL)) { app.sidebar_collapsed = !app.sidebar_collapsed status := "Sidebar expanded"