Coder Social home page Coder Social logo

libui-rs's Introduction

libui Crates.io Build Status License: MIT License: Apache

The native cross-platform UI toolkit for Rust

libui is a simple, small and easy to distribute GUI library. It provides a native UI for your platform by utilising your systems API instead of implementing yet another mismatched looking renderer. Thus all libui apps are lightweight, have a native look and feel and start from a highly performant base which is well integrated with the ecosystem on each platform. Because it implements only the common subset of these platform APIs, your apps will work on all platforms and won't have significant behavioral inconsistencies, with no additional effort on your part. If you only plan to support one platform however, a specialized crate will provide a better experience.

Technically, libui is a "rustification" wrapper over the C library libui-ng, which actually abstracts the native GUI framework. That is the Win32 API on Windows, Cocoa on Mac OS X, and GTK3 for Linux and others.

Example

Add libui to your dependency list in cargo.toml with:

libui = "0.3.0"

or use the latest version from the repository:

libui = { git = "https://github.com/libui-rs/libui" }

Next we suggest to have a look at the example applications or start with the minimal example printed here:

#![cfg_attr(not(test), windows_subsystem = "windows")]
#![cfg_attr(test, windows_subsystem = "console")]

extern crate libui;
use libui::controls::*;
use libui::prelude::*;

fn main() {
    let ui = UI::init()
        .expect("Couldn't initialize UI library");
    
    let mut win = Window::new(&ui, "Example", 300, 200, 
        WindowType::NoMenubar);
    let layout = VerticalBox::new();

    // add controls to your layout here

    win.set_child(layout);
    win.show();
    ui.main();
}

We also have documentation on docs.rs for all released versions.

Screenshots

On the left see a libui application running on a GNOME desktop with GTK 3. On the right under Windows 10 with its native user interface.

Example application running under Linux and Windows

For more screenshots, see here.

Compatibility

libui 0.2.0 works down to edition 2018 and was successfully tested on:

  • Windows 7 SP1
  • Windows 10 22H2
  • Debian 12 w/ GNOME 43 & GTK 3.24
  • macOS Big Sur 11.6

libui 0.3.0 works down to edition 2021 and was successfully tested on:

  • Debian 12 w/ GNOME 43 & GTK 3.24
  • Windows 10 22H2

Prerequisits & Building

To build the underlying libui-ng your system must have certain tools installed in addition to your rust toolchain. I am trying to cut down on the inconveniences as far as possible.

Linux:

  • libgtk-3-dev (debian package) - for compiling libui-ng
  • libclang (debian package) - for generating the libui-ng bindings

Windows:

  • MSVC (via Windows SDK or Visual Studio)
  • LLVM - for generating the libui-ng bindings

Note: MinGW-64 does compile and link, but the application won't start due to MinGW missing TaskDialog(). Reportedly, with versions >= 5.X, the function is available.

Acknowledgments

Entity Acknowledgement Further Information
@pcwalton Initial author. Largely shaped this library. pcwalton/libui-rs
@NoraCodes and others Further development and maintenance. rust-native-ui/libui-rs
@tobia libui::layout! macro for easier UI description. tobia/iui-builder
@andlabs Author of the C library libui. andlabs/libui
@szanni and @cody271 Maintainers of libui-ng. The underlying library to this wrapper. libui-ng/libui-ng

libui-rs's People

Contributors

noracodes avatar nptr avatar masche842 avatar barzamin avatar pcwalton avatar xobs avatar huangjj27 avatar coolreader18 avatar lord avatar jamesmunns avatar killercup avatar mitchhentges avatar mjhanninen avatar mglolenstine avatar ivanceras avatar lucaciucci avatar seercat3160 avatar zakcodes avatar antler5 avatar dependabot-support avatar nyanpasu64 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.