Experimental Rust UI library for Audulus. "rui" is a temporary name.

Related tags

Command-line rui
Overview

rui

Experimental Rust UI library for Audulus. "rui" is a temporary name.

Looks like this:

    fn counter(start: usize) -> impl View {
        state(start, |count: State<usize>| {
            let count2 = count.clone();
            let value_string = format!("value: {:?}", *count.get());
            stack! {
                text(value_string.as_str());
                button("increment", move || {
                    *count.get() += 1;
                });
                button("decrement", move || {
                    *count2.get() -= 1;
                })
            }
        })
    }
  • Encode UI in types to ensure stable identity.
  • Use immediate mode initially, then optimize to reduce redraw later.
  • Use a forthcoming rust port of vger for rendering.

References

Towards principled reactive UI

Towards a unified theory of reactive UI

Flutter's Rendering Pipeline

Static Types in SwiftUI

Comments
  • Get error when running the example

    Get error when running the example

    I get an error when running the example:

    RUST_BACKTRACE=1 cargo run --example counter
    

    then

        Finished dev [unoptimized + debuginfo] target(s) in 0.12s
         Running `target/debug/examples/counter`
    Using Mesa Intel(R) UHD Graphics 630 (CFL GT2) (Gl)
    thread 'main' panicked at 'wgpu error: Validation Error
    
    Caused by:
        In a RenderPass
          note: encoder = `vger encoder`
        In a set_pipeline command
          note: render pipeline = `<RenderPipeline-(0, 1, Gl)>`
        Render pipeline targets are incompatible with render pass
        Incompatible color attachment: the renderpass expected [Some(Rgba8UnormSrgb)] but was given [Some(Bgra8UnormSrgb)]
    
    ', /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/wgpu-0.13.1/src/backend/direct.rs:2391:5
    stack backtrace:
       0: rust_begin_unwind
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
       1: core::panicking::panic_fmt
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
       2: wgpu::backend::direct::default_error_handler
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/wgpu-0.13.1/src/backend/direct.rs:2391:5
       3: core::ops::function::Fn::call
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:77:5
       4: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1954:9
       5: wgpu::backend::direct::ErrorSinkRaw::handle_error
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/wgpu-0.13.1/src/backend/direct.rs:2377:17
       6: wgpu::backend::direct::Context::handle_error
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/wgpu-0.13.1/src/backend/direct.rs:261:9
       7: <wgpu::backend::direct::Context as wgpu::Context>::command_encoder_end_render_pass
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/wgpu-0.13.1/src/backend/direct.rs:2087:13
       8: <wgpu::RenderPass as core::ops::drop::Drop>::drop
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/wgpu-0.13.1/src/lib.rs:3143:13
       9: core::ptr::drop_in_place<wgpu::RenderPass>
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ptr/mod.rs:487:1
      10: vger::Vger::encode
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/vger-0.2.4/src/lib.rs:293:9
      11: rui::context::Context::render
                 at ./src/context.rs:280:9
      12: rui::event_loop::rui::{{closure}}
                 at ./src/event_loop.rs:385:17
      13: winit::platform_impl::platform::sticky_exit_callback
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/winit-0.26.1/src/platform_impl/linux/mod.rs:753:5
      14: winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run_return
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/winit-0.26.1/src/platform_impl/linux/wayland/event_loop/mod.rs:394:21
      15: winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/winit-0.26.1/src/platform_impl/linux/wayland/event_loop/mod.rs:209:9
      16: winit::platform_impl::platform::EventLoop<T>::run
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/winit-0.26.1/src/platform_impl/linux/mod.rs:669:56
      17: winit::event_loop::EventLoop<T>::run
                 at /home/timpaikx/.cargo/registry/src/mirrors.bfsu.edu.cn-4c6e9dcaa6bd74e7/winit-0.26.1/src/event_loop.rs:154:9
      18: rui::event_loop::rui
                 at ./src/event_loop.rs:289:5
      19: counter::main
                 at ./examples/counter.rs:4:5
      20: core::ops::function::FnOnce::call_once
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    fish: Job 1, 'RUST_BACKTRACE=1 cargo run --ex…' terminated by signal SIGSEGV (Address boundary error)
    

    OS: Archlinux DE: GNOME 43 Wayland git commit: 15273d1f70ddeeba05c330411233659950d0150d

    If you need more information, I'm more than happy to provide it

    opened by Tim-Paik 6
  • wrong display in shapes example on Linux Xorg/Nvidia

    wrong display in shapes example on Linux Xorg/Nvidia

    excepted display a circle and rectangle but the display is confused

    image

    [w@ww rui]$ rustc --version
    rustc 1.59.0 (9d1b2106e 2022-02-23)
    [w@ww rui]$ screenfetch -n
     w@ww
     OS: Manjaro 21.2.4 Qonos
     Kernel: x86_64 Linux 5.10.102-1-MANJARO
     Uptime: 1d 1h 9m
     Packages: 1541
     Shell: bash 5.1.16
     Resolution: 1920x1080
     DE: KDE 5.91.0 / Plasma 5.24.2
     WM: KWin
     GTK Theme: Adwaita-dark [GTK2/3]
     Icon Theme: breeze-dark
     Disk: 247G / 489G (53%)
     CPU: AMD Ryzen 9 5900X 12-Core @ 24x 3.7GHz
     GPU: NVIDIA GeForce GT 1030
     RAM: 20197MiB / 64288MiB
    

    all example of rui not working on Linux with Nvidia graphic card

    opened by pymongo 4
  • Questions regarding this project

    Questions regarding this project

    Hey guys I have some questions regarding this project:

    1. Can this library be used to integrate into a game engine as easily as somehting like egui
    2. Are there any caching capabilities even though it is immediate?
    3. Does it compile for web as well?
    4. Does it lock you into some kind of framework like iced does?
    opened by Raj2032 3
  • Why not use AppKit/UIKit APIs for iOS/macOS targets?

    Why not use AppKit/UIKit APIs for iOS/macOS targets?

    It’s nice to see a UI toolkit inspired by SwiftUI, there’s a lot of things I really like about it, but I believe SwiftUI is just a VDOM-like frontend to UIKit/AppKit.

    Anyway with regards to this library, wouldn’t it make more sense to build upon UIKit/AppKit APIs for iOS and macOS targets?

    It’s all written in objective-c and therefore it’s viable to use from rust, and seems like you’d get much more mileage/utility from it.

    opened by colbyn 2
  • Wrong rendering of Gradient in Windows

    Wrong rendering of Gradient in Windows

    I tried running the gradient example from the readme in my Windows 10:

    use rui::*;
    
    fn main() {
        rui(canvas(|rect, vger| {
            vger.translate(rect.center() - LocalPoint::zero());
    
            let paint = vger.linear_gradient(
                [-100.0, -100.0],
                [100.0, 100.0],
                AZURE_HIGHLIGHT,
                RED_HIGHLIGHT,
                0.0,
            );
    
            let radius = 100.0;
            vger.fill_circle(LocalPoint::zero(), radius, paint);
        }));
    }
    

    And it looks like:

    image

    When it is supposed to look like ( image from the readme ):

    image

    bug 
    opened by marc2332 2
  • support for layout where things don't expand to the available space

    support for layout where things don't expand to the available space

    I'm working on a port of Flow to rui.

    One immediate issue is with layout: a node in a node graph doesn't expand to fit the available space.

    How can rui support that sort of layout?

    It seems that SwiftUI doesn't actually expand stacks like rui does. Here's a simple SwiftUI VStack:

    image

    Here's a rui vstack:

    image
    opened by wtholliday 1
  • Mouse button info for drag

    Mouse button info for drag

    Added MouseButton to drag view modifier. When mouse is pressed / released, a field in Context gets updated. Also adapted the gestures.rs example to print the pressed mouse button.

    opened by rsaccon 1
  • Key modifiers

    Key modifiers

    This PR makes Keyboard ModifiersState accessible from key, tap and drag View modifiers. ModifiersState is stored now in Context and not part of EventKind::Key anymore. I hope that makes sense. An example key_mods.rs is added. I modified the Button view so it does not pass ModifiersState to its closure and (and therefore works as before).

    opened by rsaccon 1
  • make rui more testable

    make rui more testable

    Currently rui would require a GPU for automated testing. If we could provide a text layout interface to layout (instead of vger) then we could do testing without a GPU (GitHub CI VMs don't have GPUs)

    opened by wtholliday 0
  • crate should have features to select winit, tao, or none

    crate should have features to select winit, tao, or none

    https://doc.rust-lang.org/cargo/reference/features.html

    In the "none" case, the user would supply their own rendering surface and events (e.g. when embedding an iOS app)

    enhancement good first issue 
    opened by wtholliday 0
  • how to add modifiers for views built through function composition

    how to add modifiers for views built through function composition

    For example, currently, sliders are built through composition of other views: https://github.com/audulus/rui/blob/566f1086dd67eb8ca56fa4f8bcc194292c0c0bc9/src/slider.rs#L7

    The view returned by hslider is an opaque type, so we can't add methods to it.

    How can methods be added to the result of hslider while still defining hslider mostly as a function (i.e. not having to define it entirely in terms of an implementation of View)?

    opened by wtholliday 0
  • Z-sorting components based on user interaction

    Z-sorting components based on user interaction

    I'd like to make some textboxes which are draggable. That means they'll be able to overlap, so I have to make the one that has been interacted with most recently float on top of the others.

    Can I do it with the current facilities (without implementing this manually with canvas)?

    opened by ruza-net 1
  • can we nest states using only references?

    can we nest states using only references?

    I was looking into using references instead of passing around a context, and it seems tricky. Just wanted to record somewhere how far I got.

    This is close, but doesn't quite work:

        struct State<F, V> {
            f: F,
            state: String,
            phantom: std::marker::PhantomData<V>,
        }
    
        impl<'a, V: View + 'a, F: Fn(&'a String) -> V + 'a> View for State<F, V> {
            fn draw(&self) {
                (self.f)(&self.state).draw();
            }
        }
    

    The problem is in F: Fn(&'a String) -> V + 'a. This says the entire closure cannot outlive the String passed in. That's not quite what we want. It's ok if the closure lives longer. What we want is for the return type (V) to live as long as the String passed in.

    What we want is something like F: for<'a> Fn(&'a String) -> V<'a> where V is a higher-kinded-type, but rust doesn't (yet) have this feature.

    opened by wtholliday 1
  • WIP: Documentation

    WIP: Documentation

    This is the branch containing my ongoing efforts to help document the library (https://github.com/audulus/rui/issues/10). Please do not merge them yet.

    If you have any problems with the docs, please tell me and/or edit the branch.

    opened by UARTman 1
  • text bounds should be typographic bounds, not geometric

    text bounds should be typographic bounds, not geometric

    Currently the bounding box for text is based on the geometry of the text, so "aaa" has a different bounding box than "AAA". This may require some digging down into vger.

    bug enhancement 
    opened by wtholliday 0
Owner
Audulus LLC
Audulus LLC
A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies

cargo-temp A CLI tool that allow you to create a new rust project in a temporary directory with already installed dependencies. Install Requires Rust

Yohan Boogaert 61 Oct 31, 2022
🦀 Temporary repository for the rewrite of Smoothie in Rust

Warning As with a lot of projects, this one is also a WIP, expect broken code ?? smoothie-rs Temporary repository hosting the code for Smoothie's futu

Couleur Tweak Tips 6 Jan 22, 2023
Temporary files and directories with UTF-8 paths.

camino-tempfile A secure, cross-platform, temporary file library for Rust with UTF-8 paths. This crate is a wrapper around tempfile that works with th

null 4 Apr 24, 2023
Temporary elevated access management as a self-hosted service

????☁️ S A T O U N K I Temporary elevated access management as a self-hosted service Overview Satounki is a self-hosted service which brings visibilit

جاد 31 Dec 17, 2023
Temporary repository for Kind2's refactor based on HVM2

Kind2 WIP Kind1 has been developed in JavaScript, which wasn't meant to be a long-term solution, but allowed us to explore self-types. Recently, we st

HigherOrderCO 11 Feb 24, 2024
A basic text editor, written in Rust (hence the name).

rut A basic text editor, written in Rust (hence the name). Why, though? I just wanted a basic TUI text editor (like Nano) that could: Be used with all

Lowell Thoerner 4 Feb 3, 2023
🧠 A command-line utility for switching git branches more easily. Switch branches interactively or use a fuzzy search to find that long-forgotten branch name.

git-smart-checkout A git command extension for switching git branches more efficiently. About Interactively switch branches or fuzzy search for that f

Cezar Craciun 51 Dec 29, 2022
A truly zero-dependency crate providing quick, easy, reliable, and scalable access to the name "jordin"

jordin Finally! A truly zero-dependency crate providing quick, easy, reliable, and scalable access to the name "jordin". Additionally, this one-of-a-k

jordin 2 Aug 4, 2022
Give me your APK, I will give you framework name

APK-FiD Give me your APK, I will give you framework name Usage ❯ apk-fid -h APK-FiD 1.0 Petruknisme <[email protected]> Give me your APK, I will giv

Aan 2 Aug 31, 2022
Like wee_alloc, but smaller since I used skinnier letters in the name.

lol_alloc A laughably simple wasm global_allocator. Like wee_alloc, but smaller since I used skinnier letters in the name. lol_alloc is a experimental

Craig 44 Dec 28, 2022
Run a program with a modified process name.

tagrun Run a program with a modified process name. You can add a tag for a process with tagrun, and use the tag to locate the process with ps, pgrep o

Li 2 Dec 21, 2022
An experimental GUI library for Rust 🦀

guee ?? Nothing to see here ?? ... But if you insist: This is an experimental UI library I'm working on for Blackjack. The idea is to find a very prag

null 12 Feb 1, 2023
auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, utilizing procedural macros.

Auto Rust auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, util

Minsky 6 May 14, 2023
An experimental real-time operating system (RTOS) written in Rust

An experimental real-time operating system (RTOS) written in Rust

null 0 Nov 14, 2022
Experimental language build in Rust to make it fast and robust

Reg-lang Experimental language build with Rust. Its aim is : To be simple to help learning programmation with, and in a second hand, to be robust enou

Gipson62 1 Dec 29, 2022
An experimental cross-platform UI framework in rust.

Cross-platform UI framework in Rust with Easy functional composasbles Flexible state management Desktop and mobile support Accessibility Native skia r

null 76 Feb 6, 2023
Cuprate, an upcoming experimental, modern & secure monero node. Written in Rust

Cuprate an upcoming experimental, modern & secure monero node. Written in Rust (there is nothing working at the moment, stay tuned if you want to see

Someone Else 16 Feb 20, 2023
Experimental OS, built with rust

You can support this night time project by hiring me for a day time job ! Fomos Experimental OS, built with Rust output.mp4 Fun fact: there are 3 apps

Thomas SIMON 818 Sep 7, 2023
🛠️ An experimental functional systems programming language, written in Rust and powered by LLVM as a backend.

An experimental functional systems programming language, written in Rust, and powered by LLVM as a backend. ?? Goal: The intent is to create a program

codex 3 Nov 15, 2023