Rename from "Emigui" to "Egui"

Shorter to type (especially in code).
This commit is contained in:
Emil Ernerfeldt 2020-05-30 10:22:35 +02:00
parent 9f46d8f0be
commit fd5ab736bb
59 changed files with 116 additions and 114 deletions

28
Cargo.lock generated
View file

@ -347,12 +347,7 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "either" name = "egui"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "emigui"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ahash 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "ahash 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -364,22 +359,22 @@ dependencies = [
] ]
[[package]] [[package]]
name = "emigui_glium" name = "egui_glium"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"emigui 0.1.0", "egui 0.1.0",
"glium 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", "glium 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
"webbrowser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "webbrowser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "emigui_wasm" name = "egui_wasm"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"emigui 0.1.0", "egui 0.1.0",
"js-sys 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
@ -387,12 +382,17 @@ dependencies = [
"web-sys 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)", "web-sys 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "either"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "example_glium" name = "example_glium"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"emigui 0.1.0", "egui 0.1.0",
"emigui_glium 0.1.0", "egui_glium 0.1.0",
"glium 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", "glium 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
@ -403,8 +403,8 @@ dependencies = [
name = "example_wasm" name = "example_wasm"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"emigui 0.1.0", "egui 0.1.0",
"emigui_wasm 0.1.0", "egui_wasm 0.1.0",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -1,8 +1,8 @@
[workspace] [workspace]
members = [ members = [
"emigui", "egui",
"emigui_glium", "egui_glium",
"emigui_wasm", "egui_wasm",
"example_glium", "example_glium",
"example_wasm", "example_wasm",
] ]

View file

@ -1,7 +1,5 @@
# Emigui # Egui
(Experimental, Modularized Immediate mode Graphical User Interface) An immediate mode GUI library written in Rust. Works anywhere you can draw textured triangles.
An immediate mode GUI library written in Rust. For web apps or native apps.
## Goals: ## Goals:
* Lightweight * Lightweight
@ -18,22 +16,21 @@ Loop:
* Render with e.g. OpenGL * Render with e.g. OpenGL
## Available backends: ## Available backends:
Wherever you can render textured triangles you can use Emigui. Wherever you can render textured triangles you can use Egui.
Currently two backends have been tested: * WebAssembly (`egui_wasm`) for making a web app. [Click to run](https://emilk.github.io/emigui/index.html).
* WebAssembly (emigui_wasm) for making a web app
* [Glium](https://github.com/glium/glium) for native apps (see example_glium). * [Glium](https://github.com/glium/glium) for native apps (see example_glium).
* [miniquad](https://github.com/not-fl3/emigui-miniquad) [web demo](https://not-fl3.github.io/miniquad-samples/emigui.html) [demo source](https://github.com/not-fl3/good-web-game/blob/master/examples/emigui.rs) * [miniquad](https://github.com/not-fl3/emigui-miniquad) [web demo](https://not-fl3.github.io/miniquad-samples/emigui.html) [demo source](https://github.com/not-fl3/good-web-game/blob/master/examples/emigui.rs)
The same application code can thus be compiled to either into a native app or a web app. The same application code can thus be compiled to either into a native app or a web app.
## Demos ## Demos
[Emigui feature demo](https://emilk.github.io/emigui/index.html), (partial) source: https://github.com/emilk/emigui/blob/master/emigui/src/examples/app.rs [Egui feature demo](https://emilk.github.io/emigui/index.html), (partial) source: https://github.com/emilk/emigui/blob/master/egui/src/examples/app.rs
[Hobogo: A small game using Emigui](https://emilk.github.io/hobogo/index.html), source: https://github.com/emilk/hobogo [Hobogo: A small game using Egui](https://emilk.github.io/hobogo/index.html), source: https://github.com/emilk/hobogo
## State ## State
Mostly a tech demo at this point. I hope to find time to work more on this in the future. Alpha state. It works, but is somewhat incomplete.
Features: Features:
@ -55,6 +52,11 @@ Features:
## Inspiration ## Inspiration
The one and only [Dear ImGui](https://github.com/ocornut/imgui) is a great Immediate Mode GUI for C++ which works with many backends. That library revolutionized how I think about GUI code from something I hated to do to something I now like to do. The one and only [Dear ImGui](https://github.com/ocornut/imgui) is a great Immediate Mode GUI for C++ which works with many backends. That library revolutionized how I think about GUI code from something I hated to do to something I now like to do.
## Name
The name of the gui library is "Egui", written like that in text and as `egui` in code and pronounced as "e-gooey".
The library used to be called `Emigui`, which is why it is still hosted at [github.com/emilk/emigui](https://github.com/emilk/emigui). If you like, `emigui` is the collection of helper crates that surrounds `egui`, while `egui` is the actual GUI library.
## Credits / Licenses ## Credits / Licenses
Fonts: Fonts:
* Comfortaa: Open Font License, see OFT.txt * Comfortaa: Open Font License, see OFT.txt

View file

@ -195,13 +195,13 @@ function _assertClass(instance, klass) {
} }
/** /**
* @param {State} state * @param {State} state
* @param {string} raw_input_json * @param {string} web_input_json
* @returns {string} * @returns {string}
*/ */
__exports.run_gui = function(state, raw_input_json) { __exports.run_gui = function(state, web_input_json) {
try { try {
_assertClass(state, State); _assertClass(state, State);
var ptr0 = passStringToWasm0(raw_input_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); var ptr0 = passStringToWasm0(web_input_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN; var len0 = WASM_VECTOR_LEN;
wasm.run_gui(8, state.ptr, ptr0, len0); wasm.run_gui(8, state.ptr, ptr0, len0);
var r0 = getInt32Memory0()[8 / 4 + 0]; var r0 = getInt32Memory0()[8 / 4 + 0];
@ -479,14 +479,18 @@ async function init(input) {
imports.wbg.__wbg_setItem_535f63295c5e7cec = handleError(function(arg0, arg1, arg2, arg3, arg4) { imports.wbg.__wbg_setItem_535f63295c5e7cec = handleError(function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).setItem(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); getObject(arg0).setItem(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
}); });
imports.wbg.__wbg_newnoargs_8aad4a6554f38345 = function(arg0, arg1) {
var ret = new Function(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_call_1f85aaa5836dfb23 = handleError(function(arg0, arg1) { imports.wbg.__wbg_call_1f85aaa5836dfb23 = handleError(function(arg0, arg1) {
var ret = getObject(arg0).call(getObject(arg1)); var ret = getObject(arg0).call(getObject(arg1));
return addHeapObject(ret); return addHeapObject(ret);
}); });
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_newnoargs_8aad4a6554f38345 = function(arg0, arg1) {
var ret = new Function(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_self_c0d3a5923e013647 = handleError(function() { imports.wbg.__wbg_self_c0d3a5923e013647 = handleError(function() {
var ret = self.self; var ret = self.self;
return addHeapObject(ret); return addHeapObject(ret);
@ -543,10 +547,6 @@ async function init(input) {
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret); return addHeapObject(ret);
}; };
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Memory_ce2336191e545514 = function(arg0) { imports.wbg.__wbg_instanceof_Memory_ce2336191e545514 = function(arg0) {
var ret = getObject(arg0) instanceof WebAssembly.Memory; var ret = getObject(arg0) instanceof WebAssembly.Memory;
return ret; return ret;

Binary file not shown.

View file

@ -8,7 +8,7 @@
<!-- TODO: read https://www.html5rocks.com/en/mobile/mobifying/#toc-meta-viewport --> <!-- TODO: read https://www.html5rocks.com/en/mobile/mobifying/#toc-meta-viewport -->
<head> <head>
<title>Emigui An experimental immediate mode GUI written in Rust</title> <title>Egui An experimental immediate mode GUI written in Rust</title>
<style> <style>
html { html {
/* Remove touch delay: */ /* Remove touch delay: */
@ -61,7 +61,7 @@
} }
let input = { let input = {
emigui: get_emigui_input(canvas), egui: get_egui_input(canvas),
web: { web: {
location: window.location.toString(), location: window.location.toString(),
location_hash: window.location.hash.toString(), // i.e. #fragment location_hash: window.location.hash.toString(), // i.e. #fragment
@ -70,14 +70,14 @@
let output = JSON.parse(wasm_bindgen.run_gui(g_wasm_app, JSON.stringify(input))); let output = JSON.parse(wasm_bindgen.run_gui(g_wasm_app, JSON.stringify(input)));
// console.log(`output: ${JSON.stringify(output)}`); // console.log(`output: ${JSON.stringify(output)}`);
document.body.style.cursor = from_emigui_cursor(output.cursor_icon); document.body.style.cursor = from_egui_cursor(output.cursor_icon);
// console.log(`Translated ${output.cursor_icon} to ${document.body.style.cursor}`); // console.log(`Translated ${output.cursor_icon} to ${document.body.style.cursor}`);
if (output.open_url) { if (output.open_url) {
window.open(output.open_url, "_self"); window.open(output.open_url, "_self");
} }
} }
function from_emigui_cursor(cursor) { function from_egui_cursor(cursor) {
if (cursor == "no_drop") { return "no-drop"; } if (cursor == "no_drop") { return "no-drop"; }
else if (cursor == "not_allowed") { return "not-allowed"; } else if (cursor == "not_allowed") { return "not-allowed"; }
else if (cursor == "resize_horizontal") { return "ew-resize"; } else if (cursor == "resize_horizontal") { return "ew-resize"; }
@ -111,7 +111,7 @@
canvas.height = window.innerHeight * pixels_per_point(); canvas.height = window.innerHeight * pixels_per_point();
} }
function get_emigui_input(canvas) { function get_egui_input(canvas) {
var input = { var input = {
mouse_down: g_mouse_down, mouse_down: g_mouse_down,
mouse_pos: g_mouse_pos, mouse_pos: g_mouse_pos,

View file

@ -1,5 +1,5 @@
[package] [package]
name = "emigui" name = "egui"
version = "0.1.0" version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -1,5 +1,5 @@
# GUI implementation # GUI implementation
This is the core library crate Emigui. It is fully platform independent without any backend. You give the Emigui library input each frame (mouse pos etc), and it outputs a triangle mesh for you to paint. This is the core library crate Egui. It is fully platform independent without any backend. You give the Egui library input each frame (mouse pos etc), and it outputs a triangle mesh for you to paint.
## TODO: ## TODO:
### Widgets ### Widgets
@ -96,7 +96,7 @@ Add extremely quick animations for some things, maybe 2-3 frames. For instance:
### Names and structure ### Names and structure
* [ ] Rename things to be more consistent with Dear ImGui * [ ] Rename things to be more consistent with Dear ImGui
* [x] Combine Emigui and Context? * [x] Combine Egui and Context?
* [x] Solve which parts of Context are behind a mutex * [x] Solve which parts of Context are behind a mutex
* [x] Rename Region to Ui * [x] Rename Region to Ui
* [ ] Move Path and Triangles to own crate * [ ] Move Path and Triangles to own crate

View file

@ -1,11 +1,11 @@
use criterion::{criterion_group, criterion_main, Criterion}; use criterion::{criterion_group, criterion_main, Criterion};
pub fn criterion_benchmark(c: &mut Criterion) { pub fn criterion_benchmark(c: &mut Criterion) {
let mut example_app = emigui::examples::ExampleApp::default(); let mut example_app = egui::examples::ExampleApp::default();
let mut ctx = emigui::Context::new(1.0); let mut ctx = egui::Context::new(1.0);
let raw_input = emigui::RawInput { let raw_input = egui::RawInput {
screen_size: emigui::vec2(1280.0, 1024.0), screen_size: egui::vec2(1280.0, 1024.0),
..Default::default() ..Default::default()
}; };

View file

@ -510,7 +510,7 @@ impl Context {
if ui if ui
.add(Button::new("Reset all")) .add(Button::new("Reset all"))
.tooltip_text("Reset all Emigui state") .tooltip_text("Reset all Egui state")
.clicked .clicked
{ {
*self.memory() = Default::default(); *self.memory() = Default::default();

View file

@ -94,7 +94,7 @@ struct OpenWindows {
example_tree: bool, example_tree: bool,
fractal_clock: bool, fractal_clock: bool,
// emigui stuff: // egui stuff:
settings: bool, settings: bool,
inspection: bool, inspection: bool,
memory: bool, memory: bool,
@ -139,8 +139,8 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows) {
ui.add(Checkbox::new(&mut windows.memory, "Memory")); ui.add(Checkbox::new(&mut windows.memory, "Memory"));
}); });
menu::menu(ui, "About", |ui| { menu::menu(ui, "About", |ui| {
ui.add(label!("This is Emigui")); ui.add(label!("This is Egui"));
ui.add(Hyperlink::new("https://github.com/emilk/emigui/").text("Emigui home page")); ui.add(Hyperlink::new("https://github.com/emilk/emigui/").text("Egui home page"));
}); });
if let Some(time) = ui.input().seconds_since_midnight { if let Some(time) = ui.input().seconds_since_midnight {
@ -193,9 +193,9 @@ impl Default for ExampleWindow {
impl ExampleWindow { impl ExampleWindow {
pub fn ui(&mut self, ui: &mut Ui) { pub fn ui(&mut self, ui: &mut Ui) {
ui.collapsing("About Emigui", |ui| { ui.collapsing("About Egui", |ui| {
ui.add(label!( ui.add(label!(
"Emigui is an experimental immediate mode GUI written in Rust." "Egui is an experimental immediate mode GUI written in Rust."
)); ));
ui.horizontal(|ui| { ui.horizontal(|ui| {

View file

@ -1,6 +1,6 @@
//! Emigui tracks widgets frame-to-frame using `Id`s. //! Egui tracks widgets frame-to-frame using `Id`s.
//! //!
//! For instance, if you start dragging a slider one frame, emigui stores //! For instance, if you start dragging a slider one frame, egui stores
//! the sldiers Id as the current `interact_id` so that next frame when //! the sldiers Id as the current `interact_id` so that next frame when
//! you move the mouse the same slider changes, even if the mouse has //! you move the mouse the same slider changes, even if the mouse has
//! moved outside the slider. //! moved outside the slider.

View file

@ -8,7 +8,7 @@ const MAX_CLICK_DIST: f32 = 6.0;
const MAX_CLICK_DELAY: f64 = 0.3; const MAX_CLICK_DELAY: f64 = 0.3;
/// What the integration gives to the gui. /// What the integration gives to the gui.
/// All coordinates in emigui is in point/logical coordinates. /// All coordinates in egui is in point/logical coordinates.
#[derive(Clone, Debug, Default, Deserialize)] #[derive(Clone, Debug, Default, Deserialize)]
#[serde(default)] #[serde(default)]
pub struct RawInput { pub struct RawInput {
@ -38,7 +38,7 @@ pub struct RawInput {
pub events: Vec<Event>, pub events: Vec<Event>,
} }
/// What emigui maintains /// What egui maintains
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct InputState { pub struct InputState {
/// The raw input we got this fraem /// The raw input we got this fraem
@ -68,7 +68,7 @@ pub struct InputState {
pub events: Vec<Event>, pub events: Vec<Event>,
} }
/// What emigui maintains /// What egui maintains
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MouseInput { pub struct MouseInput {
/// Is the button currently down? /// Is the button currently down?

View file

@ -1,4 +1,4 @@
//! uis for emigui types. //! uis for egui types.
use crate::{ use crate::{
containers::show_tooltip, containers::show_tooltip,
label, label,

View file

@ -40,6 +40,7 @@ mod ui;
pub mod widgets; pub mod widgets;
pub use { pub use {
containers::*,
context::Context, context::Context,
id::Id, id::Id,
input::*, input::*,
@ -53,5 +54,4 @@ pub use {
types::*, types::*,
ui::Ui, ui::Ui,
widgets::*, widgets::*,
containers::*,
}; };

View file

@ -644,8 +644,8 @@ impl Ui {
/// ///
/// ``` ignore /// ``` ignore
/// ui.columns(2, |columns| { /// ui.columns(2, |columns| {
/// columns[0].add(emigui::widgets::label!("First column")); /// columns[0].add(egui::widgets::label!("First column"));
/// columns[1].add(emigui::widgets::label!("Second column")); /// columns[1].add(egui::widgets::label!("Second column"));
/// }); /// });
/// ``` /// ```
pub fn columns<F, R>(&mut self, num_columns: usize, add_contents: F) -> R pub fn columns<F, R>(&mut self, num_columns: usize, add_contents: F) -> R

View file

@ -1,12 +1,12 @@
[package] [package]
name = "emigui_glium" name = "egui_glium"
version = "0.1.0" version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
emigui = { path = "../emigui" } egui = { path = "../egui" }
chrono = { version = "0.4" } chrono = { version = "0.4" }
clipboard = "0.5" clipboard = "0.5"

View file

@ -7,7 +7,7 @@ pub use painter::Painter;
use { use {
clipboard::{ClipboardContext, ClipboardProvider}, clipboard::{ClipboardContext, ClipboardProvider},
emigui::*, egui::*,
glium::glutin::{self, VirtualKeyCode}, glium::glutin::{self, VirtualKeyCode},
}; };
@ -126,7 +126,7 @@ fn should_ignore_char(chr: char) -> bool {
} }
} }
pub fn translate_virtual_key_code(key: glutin::VirtualKeyCode) -> Option<emigui::Key> { pub fn translate_virtual_key_code(key: glutin::VirtualKeyCode) -> Option<egui::Key> {
use VirtualKeyCode::*; use VirtualKeyCode::*;
Some(match key { Some(match key {
@ -157,7 +157,7 @@ pub fn translate_virtual_key_code(key: glutin::VirtualKeyCode) -> Option<emigui:
}) })
} }
pub fn translate_cursor(cursor_icon: emigui::CursorIcon) -> glutin::MouseCursor { pub fn translate_cursor(cursor_icon: egui::CursorIcon) -> glutin::MouseCursor {
match cursor_icon { match cursor_icon {
CursorIcon::Default => glutin::MouseCursor::Default, CursorIcon::Default => glutin::MouseCursor::Default,
CursorIcon::PointingHand => glutin::MouseCursor::Hand, CursorIcon::PointingHand => glutin::MouseCursor::Hand,
@ -170,7 +170,7 @@ pub fn translate_cursor(cursor_icon: emigui::CursorIcon) -> glutin::MouseCursor
} }
pub fn handle_output( pub fn handle_output(
output: emigui::Output, output: egui::Output,
display: &glium::backend::glutin::Display, display: &glium::backend::glutin::Display,
clipboard: Option<&mut ClipboardContext>, clipboard: Option<&mut ClipboardContext>,
) { ) {

View file

@ -1,7 +1,7 @@
#![allow(deprecated)] // legacy implement_vertex macro #![allow(deprecated)] // legacy implement_vertex macro
use { use {
emigui::{ egui::{
paint::{PaintBatches, Triangles}, paint::{PaintBatches, Triangles},
Rect, Rect,
}, },
@ -195,7 +195,7 @@ impl Painter {
} }
} }
fn upload_texture(&mut self, facade: &dyn glium::backend::Facade, texture: &emigui::Texture) { fn upload_texture(&mut self, facade: &dyn glium::backend::Facade, texture: &egui::Texture) {
if self.current_texture_id == Some(texture.id) { if self.current_texture_id == Some(texture.id) {
return; // No change return; // No change
} }
@ -217,7 +217,7 @@ impl Painter {
&mut self, &mut self,
display: &glium::Display, display: &glium::Display,
batches: PaintBatches, batches: PaintBatches,
texture: &emigui::Texture, texture: &egui::Texture,
) { ) {
self.upload_texture(display, texture); self.upload_texture(display, texture);
@ -236,7 +236,7 @@ impl Painter {
display: &glium::Display, display: &glium::Display,
clip_rect: Rect, clip_rect: Rect,
triangles: &Triangles, triangles: &Triangles,
texture: &emigui::Texture, texture: &egui::Texture,
) { ) {
let vertex_buffer = { let vertex_buffer = {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View file

@ -1,5 +1,5 @@
[package] [package]
name = "emigui_wasm" name = "egui_wasm"
version = "0.1.0" version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
@ -14,7 +14,7 @@ serde = "1"
serde_json = "1" serde_json = "1"
wasm-bindgen = "0.2" wasm-bindgen = "0.2"
emigui = { path = "../emigui" } egui = { path = "../egui" }
[dependencies.web-sys] [dependencies.web-sys]
version = "0.3" version = "0.3"

View file

@ -35,8 +35,8 @@ pub fn local_storage_remove(key: &str) {
local_storage().map(|storage| storage.remove_item(key)); local_storage().map(|storage| storage.remove_item(key));
} }
pub fn load_memory(ctx: &emigui::Context) { pub fn load_memory(ctx: &egui::Context) {
if let Some(memory_string) = local_storage_get("emigui_memory_json") { if let Some(memory_string) = local_storage_get("egui_memory_json") {
match serde_json::from_str(&memory_string) { match serde_json::from_str(&memory_string) {
Ok(memory) => { Ok(memory) => {
*ctx.memory() = memory; *ctx.memory() = memory;
@ -48,10 +48,10 @@ pub fn load_memory(ctx: &emigui::Context) {
} }
} }
pub fn save_memory(ctx: &emigui::Context) { pub fn save_memory(ctx: &egui::Context) {
match serde_json::to_string(&*ctx.memory()) { match serde_json::to_string(&*ctx.memory()) {
Ok(json) => { Ok(json) => {
local_storage_set("emigui_memory_json", &json); local_storage_set("egui_memory_json", &json);
} }
Err(err) => { Err(err) => {
console_log(format!( console_log(format!(

View file

@ -4,7 +4,7 @@ use {
web_sys::{WebGlBuffer, WebGlProgram, WebGlRenderingContext, WebGlShader, WebGlTexture}, web_sys::{WebGlBuffer, WebGlProgram, WebGlRenderingContext, WebGlShader, WebGlTexture},
}; };
use emigui::{ use egui::{
paint::{Color, PaintBatches, Texture, Triangles}, paint::{Color, PaintBatches, Texture, Triangles},
vec2, Pos2, vec2, Pos2,
}; };

View file

@ -6,8 +6,8 @@ license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
emigui = { path = "../emigui" } egui = { path = "../egui" }
emigui_glium = { path = "../emigui_glium" } egui_glium = { path = "../egui_glium" }
serde = "1" serde = "1"
serde_derive = "1" serde_derive = "1"
serde_json = "1" serde_json = "1"

View file

@ -4,7 +4,7 @@
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use { use {
emigui::{examples::ExampleApp, paint::TextStyle, widgets::*, *}, egui::{examples::ExampleApp, paint::TextStyle, widgets::*, *},
glium::glutin, glium::glutin,
}; };
@ -38,7 +38,7 @@ where
fn main() { fn main() {
// TODO: combine // TODO: combine
let memory_path = "emigui.json"; let memory_path = "egui.json";
let settings_json_path: &str = "window.json"; let settings_json_path: &str = "window.json";
let app_json_path: &str = "example_app.json"; let app_json_path: &str = "example_app.json";
@ -46,7 +46,7 @@ fn main() {
let mut window_settings: Window = read_json(settings_json_path).unwrap_or_default(); let mut window_settings: Window = read_json(settings_json_path).unwrap_or_default();
let mut events_loop = glutin::EventsLoop::new(); let mut events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new().with_title("Emigui example"); let window = glutin::WindowBuilder::new().with_title("Egui example");
let context = glutin::ContextBuilder::new(); let context = glutin::ContextBuilder::new();
let display = glium::Display::new(window, context, &events_loop).unwrap(); let display = glium::Display::new(window, context, &events_loop).unwrap();
@ -69,10 +69,10 @@ fn main() {
let mut ctx = profile("initializing emilib", || Context::new(pixels_per_point)); let mut ctx = profile("initializing emilib", || Context::new(pixels_per_point));
let mut painter = profile("initializing painter", || { let mut painter = profile("initializing painter", || {
emigui_glium::Painter::new(&display) egui_glium::Painter::new(&display)
}); });
let mut raw_input = emigui::RawInput { let mut raw_input = egui::RawInput {
screen_size: { screen_size: {
let (width, height) = display.get_framebuffer_dimensions(); let (width, height) = display.get_framebuffer_dimensions();
vec2(width as f32, height as f32) / pixels_per_point vec2(width as f32, height as f32) / pixels_per_point
@ -85,10 +85,10 @@ fn main() {
let start_time = Instant::now(); let start_time = Instant::now();
let mut running = true; let mut running = true;
let mut frame_start = Instant::now(); let mut frame_start = Instant::now();
let mut frame_times = emigui::MovementTracker::new(1000, 1.0); let mut frame_times = egui::MovementTracker::new(1000, 1.0);
let mut clipboard = emigui_glium::init_clipboard(); let mut clipboard = egui_glium::init_clipboard();
emigui_glium::read_memory(&ctx, memory_path); egui_glium::read_memory(&ctx, memory_path);
while running { while running {
{ {
@ -102,21 +102,21 @@ fn main() {
{ {
raw_input.time = start_time.elapsed().as_nanos() as f64 * 1e-9; raw_input.time = start_time.elapsed().as_nanos() as f64 * 1e-9;
raw_input.seconds_since_midnight = Some(emigui_glium::local_time_of_day()); raw_input.seconds_since_midnight = Some(egui_glium::local_time_of_day());
raw_input.scroll_delta = vec2(0.0, 0.0); raw_input.scroll_delta = vec2(0.0, 0.0);
raw_input.events.clear(); raw_input.events.clear();
events_loop.poll_events(|event| { events_loop.poll_events(|event| {
emigui_glium::input_event(event, clipboard.as_mut(), &mut raw_input, &mut running) egui_glium::input_event(event, clipboard.as_mut(), &mut raw_input, &mut running)
}); });
} }
let emigui_start = Instant::now(); let egui_start = Instant::now();
ctx.begin_frame(raw_input.clone()); // TODO: avoid clone ctx.begin_frame(raw_input.clone()); // TODO: avoid clone
let mut ui = ctx.fullscreen_ui(); let mut ui = ctx.fullscreen_ui();
example_app.ui(&mut ui, ""); example_app.ui(&mut ui, "");
let mut ui = ui.centered_column(ui.available().width().min(480.0)); let mut ui = ui.centered_column(ui.available().width().min(480.0));
ui.set_layout(Layout::vertical(Align::Min)); ui.set_layout(Layout::vertical(Align::Min));
ui.add(label!("Emigui running inside of Glium").text_style(TextStyle::Heading)); ui.add(label!("Egui running inside of Glium").text_style(TextStyle::Heading));
if ui.add(Button::new("Quit")).clicked { if ui.add(Button::new("Quit")).clicked {
running = false; running = false;
} }
@ -140,11 +140,11 @@ fn main() {
frame_times.add( frame_times.add(
raw_input.time, raw_input.time,
(Instant::now() - emigui_start).as_secs_f64() as f32, (Instant::now() - egui_start).as_secs_f64() as f32,
); );
painter.paint_batches(&display, paint_batches, ctx.texture()); painter.paint_batches(&display, paint_batches, ctx.texture());
emigui_glium::handle_output(output, &display, clipboard.as_mut()); egui_glium::handle_output(output, &display, clipboard.as_mut());
} }
// Save state to disk: // Save state to disk:
@ -157,8 +157,8 @@ fn main() {
.get_inner_size() .get_inner_size()
.map(|size| vec2(size.width as f32, size.height as f32)); .map(|size| vec2(size.width as f32, size.height as f32));
if let Err(err) = emigui_glium::write_memory(&ctx, memory_path) { if let Err(err) = egui_glium::write_memory(&ctx, memory_path) {
eprintln!("ERROR: Failed to save emigui state: {}", err); eprintln!("ERROR: Failed to save egui state: {}", err);
} }
serde_json::to_writer_pretty(std::fs::File::create(app_json_path).unwrap(), &example_app) serde_json::to_writer_pretty(std::fs::File::create(app_json_path).unwrap(), &example_app)

View file

@ -14,5 +14,5 @@ serde_derive = "1"
serde_json = "1" serde_json = "1"
wasm-bindgen = "0.2" wasm-bindgen = "0.2"
emigui = { path = "../emigui" } egui = { path = "../egui" }
emigui_wasm = { path = "../emigui_wasm" } egui_wasm = { path = "../egui_wasm" }

View file

@ -4,11 +4,11 @@
use std::sync::Arc; use std::sync::Arc;
use { use {
emigui::{ egui::{
color::srgba, examples::ExampleApp, label, widgets::Separator, Align, RawInput, TextStyle, color::srgba, examples::ExampleApp, label, widgets::Separator, Align, RawInput, TextStyle,
*, *,
}, },
emigui_wasm::now_sec, egui_wasm::now_sec,
}; };
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
@ -16,7 +16,7 @@ use wasm_bindgen::prelude::*;
#[derive(Clone, Debug, Default, serde_derive::Deserialize)] #[derive(Clone, Debug, Default, serde_derive::Deserialize)]
#[serde(default)] #[serde(default)]
struct WebInput { struct WebInput {
emigui: RawInput, egui: RawInput,
web: Web, web: Web,
} }
@ -32,34 +32,34 @@ pub struct Web {
pub struct State { pub struct State {
example_app: ExampleApp, example_app: ExampleApp,
ctx: Arc<Context>, ctx: Arc<Context>,
webgl_painter: emigui_wasm::webgl::Painter, webgl_painter: egui_wasm::webgl::Painter,
frame_times: emigui::MovementTracker<f32>, frame_times: egui::MovementTracker<f32>,
} }
impl State { impl State {
fn new(canvas_id: &str, pixels_per_point: f32) -> Result<State, JsValue> { fn new(canvas_id: &str, pixels_per_point: f32) -> Result<State, JsValue> {
let ctx = Context::new(pixels_per_point); let ctx = Context::new(pixels_per_point);
emigui_wasm::load_memory(&ctx); egui_wasm::load_memory(&ctx);
Ok(State { Ok(State {
example_app: Default::default(), example_app: Default::default(),
ctx, ctx,
webgl_painter: emigui_wasm::webgl::Painter::new(canvas_id)?, webgl_painter: egui_wasm::webgl::Painter::new(canvas_id)?,
frame_times: emigui::MovementTracker::new(1000, 1.0), frame_times: egui::MovementTracker::new(1000, 1.0),
}) })
} }
fn run(&mut self, web_input: WebInput) -> Result<Output, JsValue> { fn run(&mut self, web_input: WebInput) -> Result<Output, JsValue> {
let everything_start = now_sec(); let everything_start = now_sec();
self.ctx.begin_frame(web_input.emigui); self.ctx.begin_frame(web_input.egui);
let mut ui = self.ctx.fullscreen_ui(); let mut ui = self.ctx.fullscreen_ui();
self.example_app.ui(&mut ui, &web_input.web.location_hash); self.example_app.ui(&mut ui, &web_input.web.location_hash);
let mut ui = ui.centered_column(ui.available().width().min(480.0)); let mut ui = ui.centered_column(ui.available().width().min(480.0));
ui.set_layout(Layout::vertical(Align::Min)); ui.set_layout(Layout::vertical(Align::Min));
ui.add(label!("Emigui!").text_style(TextStyle::Heading)); ui.add(label!("Egui!").text_style(TextStyle::Heading));
ui.label("Emigui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL."); ui.label("Egui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL.");
ui.label( ui.label(
"Everything you see is rendered as textured triangles. There is no DOM. There are no HTML elements." "Everything you see is rendered as textured triangles. There is no DOM. There are no HTML elements."
); );
@ -104,7 +104,7 @@ impl State {
self.ctx.pixels_per_point(), self.ctx.pixels_per_point(),
)?; )?;
emigui_wasm::save_memory(&self.ctx); // TODO: don't save every frame egui_wasm::save_memory(&self.ctx); // TODO: don't save every frame
Ok(output) Ok(output)
} }