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 12m 23s ⏱️ + 19m 1s
 8 614 tests ±0   8 374 ✅ ±0  240 💤 ±0  0 ❌ ±0 
21 711 runs  ±0  21 038 ✅ ±0  673 💤 ±0  0 ❌ ±0 

Results for commit 2b38ed9. ± Comparison against base commit e33fada.

♻️ 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!

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 issues can block the UI when opening remote images, produce undersized cursors on fractional-DPI displays, and leak native image handles when cursor creation fails.

3 open issues
1 resolved since last review

Review effort: Balanced

@deepika-u
deepika-u force-pushed the image_viewer_click_zoom branch from c94b015 to 53f2d9a Compare December 3, 2026 12:30
@eclipse-platform-bot

eclipse-platform-bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 5ced4acb596bf449decbbcc13f56c1234075bb9b Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Thu, 3 Dec 2026 12:44:54 +0000
Subject: [PATCH] Version bump(s) for 4.43 stream


diff --git a/bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF
index 7deafe5b7a..5dff1ff9ad 100644
--- a/bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-SymbolicName: org.eclipse.ui.browser; singleton:=true
-Bundle-Version: 3.9.300.qualifier
+Bundle-Version: 3.9.400.qualifier
 Bundle-Activator: org.eclipse.ui.internal.browser.WebBrowserUIPlugin
 Bundle-Vendor: %Plugin.providerName
 Bundle-Localization: plugin
-- 
2.56.1

Further information are available in Common Build Issues - Missing version increments.

@deepika-u
deepika-u force-pushed the image_viewer_click_zoom branch from f49006e to ed6d79b Compare December 3, 2026 12:39
@deepika-u
deepika-u force-pushed the image_viewer_click_zoom branch from ed6d79b to 2b38ed9 Compare December 3, 2026 12:44
@deepika-u

Copy link
Copy Markdown
Contributor Author

Hi, 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

The null-path test incorrectly expects ErrorEditorPart even though initialization succeeds; it must wait for loading and verify that ImageViewerEditor remains open.

1 open issue
3 resolved since last review

Review effort: Balanced

Comment on lines +110 to +119
public void testInputWithNullPathShowsErrorPart() throws Exception {
// init() rejects the input: the workbench shows its error part instead
IEditorPart editor = page.openEditor(new PathInput(null), ImageViewerEditor.IMAGE_VIEWER_EDITOR_ID);
try {
assertEquals("org.eclipse.ui.internal.ErrorEditorPart", editor.getClass().getName());
} finally {
// the error part has a different input, so tearDown() cannot find it
page.closeEditor(editor, false);
}
}
@SougandhS
SougandhS requested a balanced review from Copilot December 4, 2026 06:13
@SougandhS
SougandhS removed the request for review from Copilot December 4, 2026 06:14
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.

5 participants