GithubHelp home page GithubHelp logo

viewbuilder's Introduction

Viewbuilder

Crates.io version docs.rs docs CI status

A cross-platform user interface framework for Rust.

Viewbuilder is a moduler GUI library that can be used as an entire framework, or with individual parts.

use viewbuilder::{
    view,
    web::{self, html, Web},
    ControlFlow, Model, View,
};

enum Message {
    Increment,
    Decrement,
}

#[derive(Default)]
struct App {
    count: i32,
}

impl Model<Message> for App {
    fn handle(&mut self, msg: Message) -> ControlFlow {
        match msg {
            Message::Decrement => self.count -= 1,
            Message::Increment => self.count += 1,
        }
        ControlFlow::Rebuild
    }
}

fn view(model: &App) -> impl View<Web, Message> {
    (
        format!("High five count: {}", model.count),
        view::once(html::button(
            html::on_click(|| Message::Increment),
            "Up high!",
        )),
        view::once(html::button(
            html::on_click(|| Message::Decrement),
            "Down low!",
        )),
    )
}

fn main() {
    web::run(App::default(), view)
}

Getting started

Instatllation is simple with:

cargo add viewbuilder --features full

viewbuilder's People

Contributors

matthunz avatar bitfl0wer avatar

Stargazers

invisageable avatar Sebastien Menozzi avatar jacky liu avatar  avatar Hoang Phan avatar Stuart Gilliland  avatar rust avatar Bo-Wei Chen avatar Jeff Carpenter avatar Entice avatar garvin wang avatar  avatar 北夜 avatar DarkSky avatar chengwei avatar  avatar Borber avatar Don Yihtseu avatar rcoplo avatar 高庆丰 avatar null avatar Yue Chen avatar  avatar  avatar  avatar  avatar Andy Bao avatar Michael Cheng avatar  avatar  avatar Clayton Kehoe avatar  avatar Dustin Blackman avatar  avatar Maxime avatar Jerome Gravel-Niquet avatar Viktor Lazarev avatar Evan Almloff avatar Eumeryx avatar  avatar Sandalots avatar  avatar AZ Software avatar Shujaat Ali Khan avatar Andrejs Agejevs avatar Jessicazr86 avatar Jonathan Kelley avatar Fabian-Lars avatar Daniel  avatar Marc Espin avatar  avatar Samson Mok avatar  avatar  avatar fchengjin avatar  avatar lps avatar houseme avatar  avatar  avatar Piotr Wera avatar 张伯雨 avatar Jan Riemer avatar  avatar  avatar Ian Trudel avatar  avatar

Watchers

 avatar  avatar

viewbuilder's Issues

RSX view

We could wrap Dioxus' rsx! macro with our own that returns an Element

Add Taffy support

Similar to xilem, I'd like to allow for multiple layout systems. Currently this is being tested with LinearLayout but a FlexLayout or TaffyLayout element should exist to add more layout options.

Create windows while the event loop is running

Currently running Window::new or etc will create the window using the currently stored event loop. However, if the event loop is currently running these functions will panic.

I believe it's possible to just add a queue of pending windows and have them created after the current element code is finished (e.g. a click handler call)

Roadmap to v0.6

This crate went through a major update since v0.5 with a new focus on dioxus support. I'm looking to have v0.6 be a stable foundation for the road ahead. To this end I'd like to:

  • Implement tree updates
  • Add basic accesskit integration
  • Handle events (so far just looking at mouse inputs for clicks)
  • Implement more mutations in the VirtualTree

This should be a solid foundation but if it fits I'd also like to explore

  • Layered rendering with skia
  • Quadtree mapping for the layout tree (for event handling)
  • User-defined elements

Accesskit integration

The plan is to use accesskit for accessibility support. This should be fairly straightforward by adding the winit adapter and an Element::semantics or accessibility method.

Fix text layout

Currently Text will only request a size large enough for one line.

I'm not sure how to get the actual size of the rendered text from cosmic-text...

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.