Skip to content

Add an image viewer editor with zoom to the internal browser bundle - #4558

Open
deepika-u wants to merge 1 commit into
eclipse-platform:masterfrom
deepika-u:image_viewer_click_zoom
Open

deepika-u wants to merge 1 commit into
eclipse-platform:masterfrom
deepika-u:image_viewer_click_zoom

Conversation

@deepika-u

@deepika-u deepika-u commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Add support for image zooming inside editor

Summary

Adds an Image Viewer (ImageViewerEditor) as the default editor for common image formats (png, jpg, jpeg, gif, bmp, ico, svg, tif, tiff). It provides interactive zoom/pan controls, trackpad pinch gestures, animated GIF playback, and graceful fallback to the browser editor when needed.


What's Changed

  • Interactive Zoom & Pan:

    • Left-click: Zoom in.
    • Ctrl/Cmd + Left-click: Zoom out.
    • Ctrl/Cmd + Mouse wheel or Trackpad pinch: Smooth continuous zoom (10% to 2000%).
    • The point under the mouse stays anchored during zooming.
    • Dynamic magnifier cursor automatically toggling between + and - with smooth alpha transparency across Windows, macOS, and Linux.
  • Context Menu Actions:

    • Fit to Window: Scales the image to fit entirely within the tab without scrollbars. Useful for an immediate full overview of large images or diagrams.
    • Actual Size (100%): Displays the image at exact 1:1 pixel resolution with scrollbars as needed. Useful for inspecting true sharpness and pixel details.
  • Format & Playback Support:

    • Plays animated GIFs respecting frame delays and repeat counts.
    • Chooses the highest-resolution frame for multi-image formats (ICO, TIFF).
    • Routes SVGs to the browser editor to preserve vector rendering.
  • Safe Background Loading:

    • Loads images in a background job so the UI remains responsive.
    • Automatically falls back to the browser editor if an image fails to load.

Before

Opening an image displays a static view with a standard arrow cursor and no zoom capabilities.
image

After

Opening an image shows a magnifier cursor ready to zoom:
image

Zooming in with clicks (magnifier shows +):
image

Zooming out with Ctrl+click (magnifier switches to -):
image


Verification

  • Added ImageZoomModelTest covering zoom steps, limits, and focal point calculations.
  • Added ImageViewerEditorTest covering valid images, invalid/empty files, null path resolution, and SVG redirection.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ±0     867 suites  ±0   1h 1m 7s ⏱️ + 6m 55s
 8 545 tests ±0   8 305 ✅ ±0  240 💤 ±0  0 ❌ ±0 
21 507 runs  ±0  20 834 ✅ ±0  673 💤 ±0  0 ❌ ±0 

Results for commit c94b015. ± Comparison against base commit ad7efa0.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved defects can close the viewer without opening a browser, steal focus, hide thin images, block the UI during path resolution, and leak a temporary image resource.

5 open issues
What changed in this PR

Adds a dedicated Image Viewer editor to Eclipse’s internal browser bundle, making image zooming available directly in editor tabs while retaining the browser as an alternative and fallback.

Changes:

  • Adds fit-to-window, click and wheel zoom, focal-point navigation, and animated GIF playback.
  • Introduces background image decoding, largest-frame selection for ICO/TIFF files, and browser routing for SVGs and loading failures.
  • Registers image associations, adds localized labels, and covers zoom arithmetic and editor loading with tests.
File Description
tests/​org.eclipse.ui.tests.browser/​src/​org/​eclipse/​ui/​tests/​browser/​internal/​ImageZoomModelTest.java Tests zoom levels, fit calculations, and focal-point arithmetic.
tests/​org.eclipse.ui.tests.browser/​src/​org/​eclipse/​ui/​tests/​browser/​internal/​ImageViewerEditorTestCase.java Tests image loading and browser fallback paths.
tests/​org.eclipse.ui.tests.browser/​src/​org/​eclipse/​ui/​tests/​browser/​internal/​AllTests.java Registers the new test classes.
bundles/​org.eclipse.ui.browser/​src/​org/​eclipse/​ui/​internal/​browser/​Messages.properties Adds localized viewer actions and loading/error messages.
bundles/​org.eclipse.ui.browser/​src/​org/​eclipse/​ui/​internal/​browser/​Messages.java Exposes the new localized message fields.
bundles/​org.eclipse.ui.browser/​src/​org/​eclipse/​ui/​internal/​browser/​ImageZoomModel.java Implements zoom state and coordinate calculations.
bundles/​org.eclipse.ui.browser/​src/​org/​eclipse/​ui/​internal/​browser/​ImageZoomCanvas.java Implements rendering, navigation, cursors, and GIF animation.
bundles/​org.eclipse.ui.browser/​src/​org/​eclipse/​ui/​internal/​browser/​ImageViewerEditor.java Manages asynchronous loading, editor lifecycle, and browser fallback.
bundles/​org.eclipse.ui.browser/​plugin.xml Registers the default image editor and expands image extensions.
bundles/​org.eclipse.ui.browser/​plugin.properties Adds the Image Viewer editor label.

Review effort: Balanced

@SougandhS SougandhS added the enhancement New feature or request label Nov 11, 2026
@deepika-u
deepika-u force-pushed the image_viewer_click_zoom branch from e70d95b to 6eacf02 Compare November 11, 2026 12:25
@deepika-u

Copy link
Copy Markdown
Contributor Author

All the comments are fixed now.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Fallback handling can close the image viewer without showing the image or a local error when the path is null or browser initialization fails, and the null-path test throws before reaching its assertion.

3 open issues
5 resolved since last review

Review effort: Balanced

@elsazac

elsazac commented Nov 12, 2026

Copy link
Copy Markdown
Member

The icon appears like this for me in Mac. Can you check this?

o11.mov

@elsazac

elsazac commented Nov 12, 2026

Copy link
Copy Markdown
Member

Also in Mac we can zoom in zoom out by placing two fingers on the trackpad and spreading them apart, which doesn't work in this scenario. Would it be possible to check that as well?

@deepika-u

Copy link
Copy Markdown
Contributor Author

Also in Mac we can zoom in zoom out by placing two fingers on the trackpad and spreading them apart, which doesn't work in this scenario. Would it be possible to check that as well?

Thanks alot @elsazac for checking on mac, let me check further.

@deepika-u
deepika-u force-pushed the image_viewer_click_zoom branch from 6eacf02 to e8ee5fb Compare November 13, 2026 05:13
@deepika-u

Copy link
Copy Markdown
Contributor Author

Also in Mac we can zoom in zoom out by placing two fingers on the trackpad and spreading them apart, which doesn't work in this scenario. Would it be possible to check that as well?

Added an SWT.Gesture listener. GESTURE_MAGNIFY zooms to the scale at gesture start times magnification, around the fingers.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The browser handover can close an unrelated tab or prematurely dispose the image viewer, causing the failure path to call setMessage() on a disposed canvas.

1 open issue
3 resolved since last review

Review effort: Balanced

@deepika-u
deepika-u force-pushed the image_viewer_click_zoom branch from e8ee5fb to c94b015 Compare November 16, 2026 12:20
@deepika-u

Copy link
Copy Markdown
Contributor Author

Hi, I've pushed an update addressing the recent feedback and platform-specific cursor improvements.
Could you please give this a test on your platforms (especially macOS and Linux) for the cursor appearance, zoom interactions, and pinch gesture? Looking forward to your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants