eclipsercp.de

SWT, drawn
by Skia.

swt-skia implements the SWT API with every widget painted in Java through Skia. Your application keeps the SWT API it already uses and gains themes, a dark mode, animated states and vector icons.

For GTK, Cocoa and Win32. Developed and licensed by vogella GmbH.

HarborDemoSWT on Skia

A demo application written against the SWT API: tree, buttons, progress bar and the berth plan are all drawn by Skia, and SWT recorded this video itself. Switch the page to Dark in the menu and the application follows.

Run Eclipse RCP and IDE unmodified

swt-skia keeps the public API of SWT. Existing SWT and RCP code runs on it unchanged: shells, layouts and listeners stay as they are, and what changes is who paints the pixels.

Because the toolkit draws each control itself, the look of an application is no longer fixed by the operating system.

// Plain SWT, as you wrote it years ago
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());

Button save = new Button(shell, SWT.PUSH);
save.setText("Save changes");

// The one new line: pick a theme
VogellaTheme.create(display, dark).apply(display);

shell.open();

What swt-skia adds to SWT.

A berth planner on Eclipse 4 RCP

Harbor plans the berths of a container port. It is an Eclipse 4 RCP application written against the SWT API, and on swt-skia every part of it is drawn by Skia. Dragged vessels lift with a shadow and dock into their berth, themes crossfade, the night shift spreads from the pointer as a circular wipe, and the water is an SkSL shader.

The theme switch between Native, vogella Light and vogella Dark and the swap of SVG icon sets are plain e4 and work with stock SWT too. The crossfades, layout morphs, shaders, shadows and the zoom of the whole window come from swt-skia.

A guided tour with coach marks, a vessel dragged onto its berth, three themes, Focus Plan morphing the layout until the berth plan fills the window, the night shift, the animated water and a zoom of the whole window in which the SVG icons stay sharp.

A palette for the dark, in red

NightSky plans one night of observing, also as an Eclipse 4 RCP application on swt-skia. Eyepiece views and the Milky Way are SkSL shaders, and every target gets its meteors and an altitude curve.

Night vision spreads over the window as a circular wipe, switches to a red theme and to a second, red SVG icon set, which keeps the eyes adapted to the dark. Focus Chart lets the star chart fill the window with a layout morph.

Eyepiece views and the shader Milky Way, the wipe to night vision with its red icons, Focus Chart, meteors and altitude curves, then the wipe back to day colours.

Shadows, glass, shaders and animation

Because Skia draws the controls, effects that native SWT cannot draw are available in plain Java SWT code: soft drop shadows and glows that reach outside a control, frosted glass that blurs what is drawn behind a panel, and SkSL shaders as fills. A shadow follows its control when it moves, resizes or hides.

Lottie animations, animated GIFs and WebP images play in the same window, with play, pause and speed controls.

The aurora is a shader drawn on every frame. The glass panel blurs whatever moves behind it, the cards lift with real drop shadows, and the Lottie, GIF and WebP animations are paused and change speed.

// A shadow under a control
new DropShadow(card).setElevation(4);

// Frosted glass and a shader fill, in a paint listener
Effects.blurBehind(gc, 0, 0, width, height, 20, 24);
Effects.fillShader(gc, 0, 0, width, height, 0, sksl,
    Map.of("time", new float[] { t }));

Themes and icons that follow them

A theme is a set of renderers, one per kind of control. It defines styles such as primary, secondary, danger, flat and pill, in a light and a dark variant, and the running application switches between themes without a restart. Hover and press fade over about 150 ms.

SVG icons are drawn by Skia's SVG module at the size they are shown, so they stay sharp at any zoom. They can style themselves with CSS: a style block with currentColor and custom properties such as var(--accent), whose values come from the theme at paint time. One file per icon follows every theme and accent colour, without being reloaded.

<style>
  .badge { fill: var(--accent, #3d6bff) }
</style>

Light to dark as a circular wipe, SVG icons recoloured by the theme, the vogella theme and a sample theme next to plain SWT controls, and a crossfade back to the native look.

Custom drawing and an overlay layer

Custom drawn widgets are supported: the synthesizer panel draws its knobs, oscilloscope, level meters and envelope on plain SWT canvases through Skia, animated at the frame rate, and the envelope points are dragged with the mouse.

Each shell also has a layer that is drawn on top of all its controls. It carries badges, drop highlights and coach marks for onboarding tours, and a layout inspector for developers, without extra windows.

The synthesizer panel plays a note while the scope and meters follow, then badges, a drop-target highlight and coach marks appear above the mail view, and the layout inspector shows bounds, preferred size and layout data of the control under the pointer.

Zoom the whole window

Like the zoom of a web browser, a shell can be zoomed at runtime: the layout reflows into the window and every control, icon and drawing is painted again at the new size, so nothing turns blurry. Ctrl+Plus and Ctrl+Minus do it from the keyboard, which helps in presentations, in training and for accessibility.

An order form zooms from 100 to 150 %, to 115 %, to 85 % and back, and form and table reflow at every step.

ShellZoom.setZoom(shell, 150);
ShellZoom.installShortcuts(display);

The Eclipse IDE runs on it

The Eclipse SDK runs on swt-skia, here on Linux. Workbench, toolbars, Package Explorer, the Java editor with its syntax colours, the Outline and content assist are all drawn by Skia.

Switching editors, scrolling, expanding a class in the Package Explorer and opening content assist.

The SWT graphics example runs on it

GraphicsExample is the reference application for drawing with SWT. The stock example runs on swt-skia as it is: transparency, clipping, transforms, curves and full-frame animations all come out of Skia. The recording shows four of its animated tabs.

Twirl, a voxel landscape, water ripples and a lake reflection of two rocky islands, each computed per pixel in plain SWT code.

Screenshot tests without a screen

A control paints offscreen into a Skia picture, and the result is compared with a baseline image. No display is read back, so the tests run headless on a build server.

shell.setSize(300, 200);
shell.open();

// Compares with snapshots/<test class>/login-dialog.png
assertMatchesSnapshot(shell, "login-dialog");

// One control at 200 % zoom, with a tolerance
assertMatchesSnapshot(Snapshot.of(button).zoom(200),
    "login-button@2x", Tolerance.of(2, 10));

An SWT window in the browser

Since every pixel comes from Skia draw commands, those commands can be sent somewhere else. A running SWT application, here the berth planner, is streamed to a browser and driven from it: every click on the right happens in Chrome.

The first full frame of this 1180 by 800 window was about 300 KB. After that only the changed areas travel, typically 5 to 80 KB per update.

Left: the SWT window. Right: the same application in Chrome, where every click comes from.

Where it runs.

swt-skia runs on all three SWT platforms: GTK (GTK3 and GTK4) on Linux, Cocoa on macOS and Win32 on Windows.

It builds with Maven and Tycho and needs JDK 25. Skia is reached through its Java bindings, Skija.

Licensed by vogella.

swt-skia is available under a written license agreement with vogella GmbH. It is not open source and it is not a project of the Eclipse Foundation.

See it on your application

Tell us which SWT or RCP application you maintain and on which platforms it runs. We usually answer within one business day.

Or write to info@vogella.com.

Looking for the Eclipse RCP portal?

Platform news, Eclipse downloads, the patched Eclipse SDK, update sites, tutorials and the open pull requests of the Eclipse Platform now live on their own page.

Open the Eclipse RCP portal