GitXplorerGitXplorer
D

egui_wings

public
5 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
4dc7a38c485f3b300b9ff381cd8380029ab30dfe

Bump versions and lock egui at 0.30.0

DDouglasDwyer committed a month ago
Verified
953e5407c367be72293421594c93a6c140b35b71

Merge pull request #3 from geolehmann/master

DDouglasDwyer committed a month ago
Unverified
a5b8fa815b579b4a2fe73695b685eca4ec8904a7

Update cargo.toml

committed a month ago
Unverified
5e26a9069e9b8baa878423b9ca4ffe688f073e33

cargo fmt

committed a month ago
Unverified
3d271c140556e634714a9a68334608184e5180a1

v0.30.0

committed a month ago
Unverified
5c5f85acfd9cae6d10d7d2e092ff9129ab1c459a

Update crate versions

DDouglasDwyer committed 2 months ago

README

The README file for this repository.

egui_wings

Crates.io Docs.rs

This crate facilitates sharing an egui::Context between a host and multiple guest WASM modules. This allows WASM plugins to draw UI and easily display it via the host.


Usage

The following code snippet shows how to use egui_wings from a WASM plugin (the complete example may be found in the egui_wings_example folder). It defines a WingsSystem which will store the WASM plugin's state. Each frame, the draw_ui method is invoked. It accesses the host egui::Context via a system dependency and then makes normal egui calls to draw a UI.

use egui_wings::*;
use example_host::*;
use wings::*;

instantiate_systems!(ExampleHost, [PluginSystem]);

/// An object that will be instantiated inside a WASM plugin.
#[export_system]
pub struct PluginSystem {
    /// A handle for accessing system dependencies.
    ctx: WingsContextHandle<Self>,
}

impl PluginSystem {
    /// Submits the `egui` commands to draw the debug windows.
    fn draw_ui(&mut self, _: &example_host::on::Render) {
        let egui = self.ctx.get::<dyn Egui>();
        Window::new("webassembly says hello!")
            .resizable(true)
            .vscroll(true)
            .default_open(false)
        .show(&egui.context(), |ui| {
            ui.label("Hello there!");
        });
    }
}

impl WingsSystem for PluginSystem {
    const DEPENDENCIES: Dependencies = dependencies().with::<dyn Egui>();

    const EVENT_HANDLERS: EventHandlers<Self> = event_handlers().with(Self::draw_ui);

    fn new(ctx: WingsContextHandle<Self>) -> Self {
        Self { ctx }
    }
}