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 palette for the dark, in red

An observing planner as a demo: a star chart with zoom and pan next to a list of targets. The Milky Way is a shader that projects every pixel back onto the sky, so the band sits where the galactic plane is and moves with the chart. Bright stars glow and twinkle, the selected target pulses, and a frosted glass card describes it.

Its night vision mode fades everything to red, which keeps the eyes adapted to the dark.

The chart flies through five targets and switches to night vision half way. SWT recorded this video itself: swt-skia can store every repaint of a window as vector pictures and render them to video at any resolution, without screen capture.

Shadows, glow and frosted glass

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.

The glass panel glides over the cards and the animated shader, blurs what is behind it and casts a shadow that moves with it. The cards lift one after the other, and the text field glows while it has the focus.

// 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 }));

Using custom drawn widgets is supported

A synthesizer patch editor as a demo: knobs, an oscilloscope, level meters and an envelope whose points are dragged with the mouse. All of it is drawn on plain SWT canvases through Skia, and the scope and meters are animated at the frame rate.

The oscillator sweeps through sine, triangle, saw and square while the scope follows, the filter opens and closes, and the envelope points move. The note is held for 1.2 seconds and repeats, so the scope is flat in between.

Themes with animated states

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.

Hover and press fade over about 150 ms. The recordings switch the running application to dark and back without a restart. The second one is Snippet398 from the SWT snippets, with styles such as success, warning and danger on progress bars, labels and links.

An overlay layer above every control

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

The berth planner from the top of this page: an onboarding tour in four steps, a vessel dragged onto a berth with a drop highlight, then several switches between the light and the dark theme. The theme changes at runtime and every control restyles itself. Tour, badge and highlight are drawn above ordinary SWT controls, without extra windows.

A badge on a button, a drop highlight on the table, then the layout inspector with the 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.

Icons that stay vectors

SVG icons are drawn by Skia's SVG module at the size they are shown, so they stay sharp at any zoom.

Icons 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>

Six icons at three sizes. The theme changes every two seconds and the icons recolour, while the large one grows and shrinks and stays sharp.

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