kas 0.17.0

A pure-Rust GUI toolkit with stateful widgets
Documentation
KAS GUI
=======

[![Test Status](https://github.com/kas-gui/kas/workflows/Tests/badge.svg)](https://github.com/kas-gui/kas/actions)
[![Crates.io](https://img.shields.io/crates/v/kas.svg)](https://crates.io/crates/kas)
[![kas-text](https://img.shields.io/badge/GitHub-kas--text-blueviolet)](https://github.com/kas-gui/kas-text/)
[![Docs](https://docs.rs/kas/badge.svg)](https://docs.rs/kas)

Links: [Tutorials](https://kas-gui.github.io/tutorials/) — [Wiki](https://github.com/kas-gui/kas/wiki/Getting-started) — [Examples](examples) — [7GUIs](https://github.com/kas-gui/7guis/) — [Blog](https://kas-gui.github.io/blog/) — [Design](https://github.com/kas-gui/design)


About Kas
---------

The Kas GUI system strives to be both fast and follow Alan Kay's slogan:

> Simple things should be simple, complex things should be possible.

An excerpt from examples/hello.rs:
```rust
let hello_ui = column![
    "Hello, world!",
    Button::label("&Close").with(|cx, _| cx.exit())
];
```

An excerpt from examples/counter.rs:
```rust
#[derive(Clone, Debug)]
struct Increment(i32);

fn counter() -> impl Widget<Data = ()> {
    let tree = column![
        format_label!("{}").align(AlignHints::CENTER),
        row![
            Button::label_msg("−", Increment(-1)),
            Button::label_msg("+", Increment(1)),
        ]
        .map_any(),
    ];

    tree.with_state(0)
        .on_message(|_, count, Increment(add)| *count += add)
}
```

On the more complex end, custom widgets can be fairly complex; check the Kas
widget library (including source code) for examples.

### Capabilities

- [x] Fully keyboard-accessible
- [x] Screen reader support (partial: kas-gui/kas#509)
- [x] IME support (partial: kas-gui/kas#508)
- [ ] Integrated i18n support (not yet started;  kas-gui/kas#7)
- [x] Complex text support: use system fonts with glyph fallbacks, BiDi, common text effects (kas-gui/kas#13)
- [x] Automatic margins and layout with pixel-perfect scaling
- [x] Support for custom themes including theme-driven animations and sizing
- [x] Virtual scrolling (list or grid), including support for async data access

### Goals

Kas is designed to:

-   Support stateful user-defined widgets with high-ish level of code
-   Support the best user-interaction possible
-   Support automatic layout and pixel-perfect scaling at any scale factor (i.e. margins and element sizes should be consistent, raster icons should have pixel-perfect rendering; layout is allowed to change as content is scaled).
-   Support extremely fast, monolithic Rust binaries

### Limitations

Every approach has its limitations. Ours are:

-   Stateful widgets imply invalid-state bugs are possible. There are some (dev-mode) guards against bad-initialisation order, but fundamentally this class of bugs cannot be prevented.
-   Custom widgets have a lot of flexibility over management of child widgets; this comes with some expectations. Violating these expectations will result in a panic in debug builds.
-   Custom widget definitions use macro-enhanced Rust (not a custom DSL), allowing the full power of Rust code but running the risk of confusing other tooling (both `rustfmt` and `rust-analyzer` have some issues here).

### Status

In development. Interfaces are not currently stable.

Enough functionality should be present to develop complex GUIs, however some features are still missing (see [the Roadmap](https://github.com/kas-gui/kas/blob/master/ROADMAP.md#future-work).


Crates and features
-------------------

Crates in this repository:

-   [kas-core]https://docs.rs/kas-core: the core library
-   kas-macros: proc-macro crate (see `kas-core` documentation)
-   [kas-widgets]https://docs.rs/kas-widgets: the main widget library
-   [kas-view]https://docs.rs/kas-view: view widgets supporting virtual scrolling
-   [kas-image]https://docs.rs/kas-image: scalable and raster image widgets and utilities
-   [kas-wgpu]https://docs.rs/kas-wgpu: rendering backend over [wgpu]
-   [kas-soft]https://docs.rs/kas-soft: basic CPU rendering backend over [softbuffer]
-   [kas-dylib]https://crates.io/crates/kas-dylib: helper crate to support dynamic linking
-   [kas]: a meta-package plus convenient driver covering most of the above

Significant external dependencies:

-   [winit]https://github.com/rust-windowing/winit: platform window integration
-   [wgpu]https://github.com/gfx-rs/wgpu: modern accelerated graphics API
-   [AccessKit]https://accesskit.dev/: Accessibility infrastructure for UI toolkits
-   [kas-text]https://crates.io/crates/kas-text: complex text support
-   [rustybuzz]https://crates.io/crates/rustybuzz: a complete harfbuzz's shaping algorithm port to Rust
-   [fontique]https://crates.io/crates/fontique: Font enumeration and fallback
-   [resvg]https://crates.io/crates/resvg: an SVG rendering library
-   [tiny-skia]https://crates.io/crates/tiny-skia: a tiny Skia subset ported to Rust
-   [Image]https://crates.io/crates/image: An Image Processing Library
-   [impl-tools]https://crates.io/crates/impl-tools: `autoimpl` and `impl_scope` (extensible) macros
-   [easy-cast]https://crates.io/crates/easy-cast: Type conversion, success expected

### Feature flags

The `kas` crate enables a selection of important features by default while attempting to support most platforms. Other crates do not enable any features by default.
See [documentation in Cargo.toml](https://github.com/kas-gui/kas/blob/master/Cargo.toml#L29).

[kas]: https://docs.rs/kas
[wgpu]: https://github.com/gfx-rs/wgpu
[softbuffer]: https://github.com/rust-windowing/softbuffer


Copyright and Licence
---------------------

The [COPYRIGHT](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](LICENSE) file or on
the following webpage: <https://www.apache.org/licenses/LICENSE-2.0>