GithubHelp home page GithubHelp logo

derin's Introduction

Derin - Derivable User Interface

Crates.io Docs

A UI library for Rust that makes creating a GUI as simple as declaring a struct.

Setting up

[dependencies]

# The core library and APIs, used for creating and displaying widgets.
derin = "0.1"

# Adds #[derive(WidgetContainer)]. Is used to help create widget trees.
derin_macros = "0.1"

Examples

Beyond looking at the API docs, you're encouraged to look at one of the provided examples, to see more complex examples of how to use Derin. Those can be found in the derin/examples directory.

// A simple application that shows a click-able button to the user.
extern crate derin;

use derin::{Window, WindowConfig, LoopFlow};
use derin::widgets::{Button, Contents};
use derin::geometry::DimsBox;

fn main() {
    let print_string = "Prints to the console.";

    // Create a new window that displays a GUI on the desktop.
    let mut window = unsafe{ Window::new(
        // Set the attributes with which we'll create the window.
        WindowConfig {
            dimensions: Some(DimsBox::new2(400, 50)),
            title: "Derin's Hello World".to_string(),
            ..WindowConfig::default()
        },
        // Create a button that displays "Hello World" to the user, and passes `print_string`
        // to the UI's action loop.
        Button::new(Contents::Text("Hello, World!".to_string()), Some(print_string)),
        // Set the theme to the default theme.
        derin::theme::Theme::default()
    ).unwrap() };

    let _: Option<()> = window.run_forever(
        // Whenever an action is recieved from a widget, this function is called.
        |print_string, _, _| {
            // Print out strings passed to the action function.
            println!("{}", print_string);
            LoopFlow::Continue
        },
        |_, _| None
    );
}

License

Derin is made available under the Mozilla Public License, 2.0, viewable in this repository or on the Mozilla Website.

Contribution

Unless explicitly stated otherwise, any contributions intentionally submitted for inclusion within Derin will be licensed under the MPL-2.0 license, without any additional terms or conditions.

derin's People

Contributors

osspial 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.