Coder Social home page Coder Social logo

kas's Introduction

KAS GUI

Test Status kas-text Docs Minimum rustc version

KAS, (historically the toolKit Abstraction System), is a general-purpose GUI toolkit. KAS's design provides:

  • retained mode (library stores state), inspired by Qt (classic)
  • concise, partially declarative specification of widgets
  • type-safe, widget-local event handlers
  • simple ownership with no retained pointers into widget state
  • widgets embed state and handlers (easy reuse of complex components)
  • scalability to millions of widgets

Examples

For details, see the Examples README.

Gallery Splitter Mandlebrot

Features

  • Automatic window size and layout: just specify row/column/grid layout and let KAS do the rest (with correct HiDPI scaling)
  • Themes (sizing and rendering control) and colour schemes with run-time switching
  • Accessibility/input: full keyboard control as well as touchscreen and mouse
  • Bidirectional and rich text support via KAS-text with complex glyph shaping via HarfBuzz
  • Accelerated graphics via WebGPU
  • Embedded accelerated graphics via custom pipelines

Missing features

These aren't here yet!

  • Raster graphics
  • Flow-box layouts (but rows, columns and grids are enough for most stuff)
  • CPU-based fallback renderer
  • Desktop UI integration
  • And much more, see the ROADMAP.

Learn

Installation and dependencies

Rust

KAS requires [Rust] version 1.45 or greater. All examples are compatible with the stable channel, but using the nightly channel does have a couple of advantages:

  • Proceedural macros emit better diagnostics. In some cases, diagnostics are missed without nightly rustc, hence nightly is recommended for development.
  • Documentation generated via cargo doc requires nightly for links
  • A few minor option things: see Feature flags below.

WebGPU

Currently, KAS's only drawing method is WebGPU which requires DirectX 11/12, Vulkan or Metal. In the future, there may be support for OpenGL and software rendering.

HarfBuzz (optional)

This is only needed if the shaping feature is enabled. On my system, the following libraries are used: libharfbuzz.so.0, libglib-2.0.so.0, libgraphite2.so.3 and libpcre.so.1.

Quick-start

Install dependencies:

# For Ubuntu:
sudo apt-get install build-essential git libxcb-shape0-dev libxcb-xfixes0-dev libharfbuzz-dev

# For Fedora:
# glslc is optional; see kas-wgpu/README.md
sudo dnf install libxcb-devel harfbuzz-devel glslc

Next, clone the repository and run the examples as follows:

git clone https://github.com/kas-gui/kas.git
cd kas
cargo test
cd kas-wgpu
cargo build --examples
cargo run --example gallery
cargo run --example layout
cargo run --example mandlebrot

To build docs locally:

RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --features markdown --no-deps --all --open

Crates

  • kas: the core of the GUI library, providing most interfaces and logic along with a selection of common widgets
  • kas-macros: a helper crate for proc macros (do not use directly)
  • KAS-text: font loading, text layout, text navigation
  • kas-theme: theming support for KAS (API plus two themes; organisation may change)
  • kas-wgpu: provides windowing via winit and rendering via WebGPU

A user depends on kas to write their complete UI specification, selects a theme from kas-theme, instances a kas_wgpu::Toolkit, adds the window(s), and runs the UI.

Feature flags

The kas crate has the following feature flags:

  • shaping: enables complex glyph forming for languages such as Arabic. This requires that the HarfBuzz library is installed.
  • markdown: enables Markdown parsing for rich-text
  • serde: adds (de)serialisation support to various types
  • json: adds config (de)serialisation using JSON (implies serde)
  • yaml: adds config (de)serialisation using YAML (implies serde)
  • winit: adds compatibility code for winit's event and geometry types. This is currently the only functional windowing/event library.
  • stack_dst: some compatibility impls (see kas-theme's documentation)
  • internal_doc: turns on some extra documentation intended for internal usage but not for end users. (This only affects generated documentation.)

Configuration

Formats are not yet stabilised, hence reading/writing configuration is disabled by default. Ensure that the yaml and/or json feature flag is enabled, then configure with environment variables:

# Set the config path:
export KAS_CONFIG=kas-config.yaml
# Use write-mode to write out default config:
KAS_CONFIG_MODE=writedefault cargo run --example gallery
# Now just edit the config and run like normal:
cargo run --example gallery

Copyright and Licence

The COPYRIGHT file includes a list of contributors who claim copyright on this project. This list may be incomplete; new contributors may optionally add themselves to this list.

The KAS library is published under the terms of the Apache License, Version 2.0. You may obtain a copy of this licence from the LICENSE file or on the following webpage: https://www.apache.org/licenses/LICENSE-2.0

kas's People

Contributors

dhardy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.