morph_ui is a cross platform UI-Toolkit for embedded (no_std), desktop, mobile and web. Written in plain Rust.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Florian Blasius cb0a7e7dbd ci 5 days ago
morph_ui remove disabled widget from focusable list 1 month ago
morph_ui_orbclient implement copy paste cut for textfield 1 month ago
morph_ui_psp psp event handling 1 month ago
.gitignore update gitignore 7 months ago
.gitmodules Initial commit 7 months ago
.woodpecker.yml ci 5 days ago
Cargo.toml add widget base 1 month ago
LICENSE crates refactoring 8 months ago
README.md ci 5 days ago

README.md

morph_ui

morph_ui is a lightweight cross platform UI-Toolkit for embedded (no_std), desktop, mobile and web. Written in plain Rust.

Get it on Codeberg

Donate

CI morphUI.codeberg.page morphUI.codeberg.page MIT licensed

Platform notes

Embedded

On embedded (no_std) platforms morph_ui depends on alloc to make use of Box, Vec, String and BTreeMap. At the moment alloc is only available at Rust nightly. You can install Rust nightly with the following steps:

  • Make sure Rust toolchain is installed (install)
  • Run rustup toolchain install nightly

To run an application build with morph_ui you also need to declare an global allocator. You can find an example how to write your own global allocator at the Rust embedded book. But there are also some ready to use allocators on crates.io e.g. for cortex-m.

Desktop, Moible and Web

There is the second crate morph_ui_orbclient that provides all extra components to run an morph_ui application on desktop, mobile and web platforms.

Redox

To build an run an application on Redox check the Redox Book, please.

Linux, macOS and Window

morph_ui_orbclient depends on OrbClient which will build bundled with SDL2. To build it a Compiler is needed (like gcc, clang or MS's own compiler).

Mobile

morph_ui is tested on iOS but it should be also possible to run it on Android. A template project will following soon.

iOS

On iOS an up to date version of xcode is needed.

Web

On web the crate morph_ui_orbclient is also needed. For web it depends on web-sys. The following tools will be needed to run morph_ui on the web:

  • Rust standard toolchain rustup, rustc, cargo (install)
  • Rust web assembly toolchain wasm-pack (install)
  • JavaScript package manager npm (install)

Examples

Embedded

There is an example for a stm32 (cortex-m) board with a monochrome SH1106 display. The example is locates at morph_ui/examples/embedded/counter-sh1106.

Desktop

It is possible to run the desktop example from the root folder with cargo run --example EXAMPLE_NAME. The examples are located at morph_ui_orbclient/examples/.

Web

  • navigate to the folder morph_ui_orbclient/examples/web/orb_calculator
  • run npm install
  • run npm start
  • the calculator will open in your default web browser

Documentation

You can build and view the latest documentation by executing the following command:

cargo doc --no-deps --open

Debug flags

There are some debug helpers include in morph_ui. If you run your application in debug mode you can active the helpers by using Cmd + D on macOS and Ctrl + D on all other platforms. Debug helpers are not available in release mode. It is possible to configure the debug helpers by using the Debug flag enum:

Activation of debug flags on Shell struct

  • Active a raster that is drawn for the bounds of each widget also for the invisible widgets:
Shell::create().debug_flags(&[Debug::DrawRaster], Some(Rgb888::CSS_BLUE))
  • Active the pipeline output. Prints start of loop, event handling, rendering and layout with time measure:
Shell::create().debug_flags(&[Debug::PrintPipeline], None)
  • Active the output of the whole widget graph:
Shell::create().debug_flags(&[Debug::PrintGraph], None)

Activation of debug flags on Window struct (morph_ui_orbclient only)

  • Active a raster that is drawn for the bounds of each widget also for the invisible widgets:
Window::create().debug_flags(&[Debug::DrawRaster, Debug::PrintPipeline, Debug::PrintGraph], Some(Rgb888::CSS_BLUE))

Same flags are available for both structs!

Notable dependencies

Inspirations

  • OrbTk a cross platform Rust UI-Toolkit based on the Entity Component System pattern
  • druid a data-first Rust-native UI-Toolkit
  • flutter modern cross platform UI-Toolkit

Rusty alternatives

  • embedded-gui an experimental no-alloc Rust GUI toolkit built on top of embedded-graphics
  • OrbTk a cross platform Rust UI-Toolkit based on the Entity Component System pattern
  • druid a data-first Rust-native UI-Toolkit
  • iced a cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm
  • egui egui is a simple, fast, and highly portable immediate mode GUI library for Rust

Thanks to

  • Redox / OrbTk Community to help me learn Rust, feedback on UI topics, support
  • jackpot51 as mentor, as creator of awesome Redox OS
  • jamwaffles as creator of embedded-gui and support for embedded-gui
  • bugadani as sparrings partner by embedded UI topics