• This repository has been archived on 15/Jul/2024
  • Stars
    star
    209
  • Rank 188,325 (Top 4 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Deprecated Rust Window Creation Library

glazier

Xi Zulip dependency status Apache 2.0 Build Status

Glazier is an operating system integration layer infrastructure layer intended for high quality GUI toolkits in Rust. It is agnostic to the choice of drawing, so the client must provide that, but the goal is to abstract over most of the other integration points with the underlying operating system.

Primary platforms are Windows, macOS, and Linux. Web is a secondary platform. Other ports may happen if they are contributed.

This library is currently work in progress and should be considered experimental. Contributions are welcome, see CONTRIBUTING for more details.

Community

Xi Zulip

Discussion of Xilem development happens in the Xi Zulip, specifically the #glazier stream. All public content can be read without logging in

Scope

The following tasks are in scope. Mostly they are implemented, but as always there is more refinement to be done.

  • Window creation, including subwindows (useful for context menus and the like).

  • System menus. These are especially important on macOS.

  • Keyboard events.

  • Input Method Editor. On macOS, correct handling of dead keys is through the IME, and an application built on Glazier is expected to handle IME.

  • Mouse and pointer (touch and pen) events. Mouse events are currently supported, pointers are a hoped-for feature.

  • Cursors (mouse pointer indicator on the screen), including custom images.

  • Providing DPI scaling information to the application.

  • Clipboard.

  • File dialog.

The general philosophy is that a task is in scope if it requires deep integration with the platform and is not easy to separate out as a separate library that layers on top of Glazier.

Hooks provided

Glazier does not provide drawing primitives and is intended to be agnostic to the drawing infrastructure. It uses raw-window-handle to provide an attachment point for the drawing code, a widely used abstraction in the Rust ecosystem. A top priority will be integrating with the wgpu ecosystem. In addition, we would gladly accept integration work to make Piet run on top of Glazier, but this is not a core priority.

We hope to integrate with AccessKit for accessibility.

While Glazier currently has primitive support for scheduling repaint cycles, ultimately we would like to support frame pacing. Doing the actual decision of when to repaint is probably out of scope, but providing portable infrastructure (CVDisplayLink on macOS, presentation statistics, scheduling based on high resolution timers) is in scope.

Out of scope

We have no solution to interfacing with the system compositor. This is necessary to handle embedded video content properly, and is also a good way to stitch together other embedded content such as web views.

Like drawing, most font and text issues are out of scope. Localization and internationalization are expected to be handled by the layer above, though platform hooks would be in scope (for example, querying the locale preference).

Glazier does not provide a solution for packaging and distribution of applications. Work on this is needed, and we would gladly cooperate with such efforts.

Design

The code in Glazier can be divided into roughly two categories: the platform agnostic code and types, which are exposed directly, and the platform-specific implementations of these types, which live in per-backend directories in src/backend. The backend-specific code for the current backend is reexported as glazier::backend.

Glazier does not generally expose backend types directly. Instead, we expose wrapper structs that define the common interface, and then call corresponding methods on the concrete type for the current backend.

Unsafe

Interacting with system APIs is inherently unsafe. One of the goals of Glazier is to handle almost all interaction with these APIs, exposing a safe interface to the UI toolkit. The exception is drawing, which will generally require at least some additional unsafe code for integration.

Similar libraries

  • winit. This is by far the most commonly used window creation crate. As discussed in the links below, the scope is defined quite differently. In general, winit is probably more suitable for games and game-like applications, while Glazier is intended to provide more of the full desktop GUI experience, including system menus and support for IME.

  • baseview. Another window creation abstraction, motivated mostly by the audio plugin use case where the module is not in control of its own UI runloop.

Dependencies

Glazier requires a recent rust toolchain to build; it does not (yet) have an explicit minimum supported rust version, but the latest stable version should work.

On Linux and BSD, Glazier also requires pkg-config and clang, and the development packages of wayland, libxkbcommon and libxcb, to be installed. Some of the examples require vulkan-loader.

Most distributions have pkg-config installed by default. To install the remaining packages on Fedora, run

sudo dnf install clang wayland-devel libxkbcommon-x11-devel libxcb-devel vulkan-loader-devel

To install them on Debian or Ubuntu, run

sudo apt-get install pkg-config clang libwayland-dev libxkbcommon-x11-dev libvulkan-dev

Further reading

License

Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)

Contribution

Contributions are welcome by pull request. The Rust code of conduct applies.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

More Repositories

1

druid

A data-first Rust-native UI design toolkit.
Rust
9,543
star
2

xilem

An experimental Rust native UI framework
Rust
3,444
star
3

vello

A GPU compute-centric 2D renderer.
Rust
2,315
star
4

piet

An abstraction for 2D graphics.
Rust
1,251
star
5

runebender

A font editor written in Rust.
Rust
762
star
6

kurbo

A Rust library for manipulating curves
Rust
698
star
7

masonry

Rust UI design toolkit - moved.
Rust
405
star
8

skribo

A Rust library for low-level text layout.
Rust
325
star
9

parley

Rich text layout library
Rust
197
star
10

piet-metal

Experimental Metal-based GPU renderer for piet 2D graphics.
Rust
140
star
11

bevy_vello

An integration to render with Vello in Bevy game engine.
Rust
117
star
12

spline

A spline for interactive 2D curve design
Rust
112
star
13

druid-widget-nursery

A place where Druid widgets come to mature before moving to the Druid repo.
Rust
87
star
14

velato

An integration to parse and render Lottie with Vello.
Rust
71
star
15

norad

Rust crate for working with Unified Font Object files
Rust
43
star
16

rbf-interp

An implementation of Radial Basis Function multidimensional interpolation
Rust
35
star
17

gpu-stroke-expansion-paper

Rust
35
star
18

2d.graphics

Repo for an ideational book on 2D graphics, plus tools to make images
26
star
19

peniko

Primitive types for styling vector graphics.
Rust
22
star
20

vello_svg

An integration to render SVG files with Vello.
Rust
15
star
21

wiki

Wiki and documentation for 2D graphics projects
9
star
22

android_trace

Support for Android NDK Tracing in Rust
Rust
6
star
23

rfcs

Suggestions for major changes to the linebender ecosystem
6
star
24

linebender.github.io

Main webpage for linebender org
SCSS
5
star
25

interpoli

Rust
3
star
26

runebender.app

Ruby
2
star
27

piet-snapshots

Data for snapshot testing of piet backends
2
star