window_of_opportunity 0.3.1

window_of_opportunity is attempting to make a native react style library
docs.rs failed to build window_of_opportunity-0.3.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: window_of_opportunity-0.1.0

Window_of_opportunity

A WIP, aiming to implement a react style library for creating native (as in, using the actual OS primitives) GUIs.

Currently targetting Macos with AppKit (using Cacao under the hood), but wanting to add some win32 waiting in the sidelines.

Features

  • Input boxes support internationalization because they are the native input boxes.
  • Small binaries - the todos example compiles to 1.3Mb in release.

Getting started

The simplest possible app would look like this:

use window_of_opportunity::{app::Application, component::Component, ui};

#[derive(Debug, Default)]
struct Window {}
impl Component for Window {
    fn render(
        &self,
        ctx: &window_of_opportunity::state::Ctx,
        _children: Vec<Box<window_of_opportunity::element::Element>>,
    ) -> Box<window_of_opportunity::element::Element> {
        ui! {
            Window width(600.) height(500) title("Hello World!") {
                { Div direction("column") gap(40.) padding(16.) {
                    { Div height(80.) background("blue") {} }
                    { Div direction("row") gap(10.) height(60.) {
                        { Button { Text "Hello, and this should mean a bigger button" } }
                        { Button { Text "Two" } }
                        { Div width(80.) background("red") {} }
                    } }
                    { Div height(40.) background("green") {} } 
                } }
            }
        }
    }
}

fn main() {
    let window = Box::new(Window {});
    let app = Application {};

    app.run(window, |_state, _message: ()| ())
}

Checkout the examples folder, there's at least one example in there which is doing not very much, but shows click event handlers.

Project Status

Note, hardly anything works, but creating a basic application is possible, and there are hooks for some state.

Feature Macos Win32 Gtk
Button ✅ ❌ ❌
Label ✅ ❌ ❌
Image (using BlitFrame) ✅ ❌ ❌
Input ✅ ❌ ❌
Window ✅ ❌ ❌
Window resizing ✅ ❌ ❌
Window title ✅ ❌ ❌
Layout ✅ ❌ ❌
List ✅ ❌ ❌
Test target ❌ ❌ ❌
  • Handle vec based lists
  • Add more elements - scrollviews, radiobuttons, comboboxes, selectboxes.
  • Add more properties - border, rounded corners, other events
  • Get working with win32
  • Get working with gtk.
  • Add a test target for writing automated tests against the virtual dom