Skip to content

feat(image): add image viewer with pan and zoom#3

Closed
HelgeSverre wants to merge 15 commits intomainfrom
HelgeSverre/image-pan-zoom
Closed

feat(image): add image viewer with pan and zoom#3
HelgeSverre wants to merge 15 commits intomainfrom
HelgeSverre/image-pan-zoom

Conversation

@HelgeSverre
Copy link
Owner

Summary

  • Add full image viewer mode (ViewMode::Image) following existing CSV viewer patterns
  • Support PNG, JPEG, GIF, BMP, WebP formats via the image crate
  • Checkerboard background for transparency, nearest-neighbor scaling, CPU blitting
  • Mouse scroll to zoom (toward cursor), click-drag to pan
  • Keyboard shortcuts: Cmd+=/- (zoom), Cmd+0 (fit), Cmd+1 (actual size)
  • Status bar shows dimensions, zoom %, file size, format
  • Theme-configurable checkerboard colors and cell size across all 9 themes
  • Correct coordinate math for zoom-toward-cursor with content area offsets
  • Guards against zero-dimension images and u32 overflow for large images

Test Plan

  • All 1065+ test assertions pass (451 lib tests + integration tests)
  • Clippy clean (zero warnings with -D warnings)
  • Integration tests for ImageState, file detection, zoom, fit scale
  • Manual: open PNG/JPEG/GIF/BMP/WebP files
  • Manual: scroll to zoom, verify zoom anchors at cursor
  • Manual: click-drag to pan
  • Manual: keyboard shortcuts Cmd+=/-/0/1
  • Manual: resize window, verify auto-fit recomputes

The FromStr implementation for Command was missing ImageZoomIn,
ImageZoomOut, ImageFitToWindow, and ImageActualSize, causing
keymap YAML parsing to fail. Also adds image viewer integration tests
and updates Cargo.lock for the image crate dependency.
- Guard against zero-dimension images in compute_fit_scale
- Fix keyboard zoom anchoring at (0,0) by using last mouse position
- Convert window coords to content-area-local coords for zoom math
- Fix u32 overflow in pixel index computation for large images
- Recompute fit scale on window resize for image mode
- Add test for zero-dimension image edge case
@HelgeSverre
Copy link
Owner Author

Superseded by #4 (image-pan-zoom-v2)

@HelgeSverre HelgeSverre deleted the HelgeSverre/image-pan-zoom branch February 28, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant