Rename from "Emigui" to "Egui"
Shorter to type (especially in code).
This commit is contained in:
parent
9f46d8f0be
commit
fd5ab736bb
59 changed files with 116 additions and 114 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -347,12 +347,7 @@ version = "1.1.1"
|
|||
source = "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]]
|
||||
name = "emigui"
|
||||
name = "egui"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ahash 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -364,22 +359,22 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "emigui_glium"
|
||||
name = "egui_glium"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"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)",
|
||||
"emigui 0.1.0",
|
||||
"egui 0.1.0",
|
||||
"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)",
|
||||
"webbrowser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "emigui_wasm"
|
||||
name = "egui_wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"emigui 0.1.0",
|
||||
"egui 0.1.0",
|
||||
"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_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)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "example_glium"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"emigui 0.1.0",
|
||||
"emigui_glium 0.1.0",
|
||||
"egui 0.1.0",
|
||||
"egui_glium 0.1.0",
|
||||
"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_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -403,8 +403,8 @@ dependencies = [
|
|||
name = "example_wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"emigui 0.1.0",
|
||||
"emigui_wasm 0.1.0",
|
||||
"egui 0.1.0",
|
||||
"egui_wasm 0.1.0",
|
||||
"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_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"emigui",
|
||||
"emigui_glium",
|
||||
"emigui_wasm",
|
||||
"egui",
|
||||
"egui_glium",
|
||||
"egui_wasm",
|
||||
"example_glium",
|
||||
"example_wasm",
|
||||
]
|
||||
|
|
22
README.md
22
README.md
|
@ -1,7 +1,5 @@
|
|||
# Emigui
|
||||
(Experimental, Modularized Immediate mode Graphical User Interface)
|
||||
|
||||
An immediate mode GUI library written in Rust. For web apps or native apps.
|
||||
# Egui
|
||||
An immediate mode GUI library written in Rust. Works anywhere you can draw textured triangles.
|
||||
|
||||
## Goals:
|
||||
* Lightweight
|
||||
|
@ -18,22 +16,21 @@ Loop:
|
|||
* Render with e.g. OpenGL
|
||||
|
||||
## 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 (emigui_wasm) for making a web app
|
||||
* WebAssembly (`egui_wasm`) for making a web app. [Click to run](https://emilk.github.io/emigui/index.html).
|
||||
* [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)
|
||||
|
||||
The same application code can thus be compiled to either into a native app or a web app.
|
||||
|
||||
## 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
|
||||
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:
|
||||
|
||||
|
@ -55,6 +52,11 @@ Features:
|
|||
## 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.
|
||||
|
||||
## 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
|
||||
Fonts:
|
||||
* Comfortaa: Open Font License, see OFT.txt
|
||||
|
|
|
@ -195,13 +195,13 @@ function _assertClass(instance, klass) {
|
|||
}
|
||||
/**
|
||||
* @param {State} state
|
||||
* @param {string} raw_input_json
|
||||
* @param {string} web_input_json
|
||||
* @returns {string}
|
||||
*/
|
||||
__exports.run_gui = function(state, raw_input_json) {
|
||||
__exports.run_gui = function(state, web_input_json) {
|
||||
try {
|
||||
_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;
|
||||
wasm.run_gui(8, state.ptr, ptr0, len0);
|
||||
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) {
|
||||
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) {
|
||||
var ret = getObject(arg0).call(getObject(arg1));
|
||||
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() {
|
||||
var ret = self.self;
|
||||
return addHeapObject(ret);
|
||||
|
@ -543,10 +547,6 @@ async function init(input) {
|
|||
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
||||
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) {
|
||||
var ret = getObject(arg0) instanceof WebAssembly.Memory;
|
||||
return ret;
|
||||
|
|
Binary file not shown.
|
@ -8,7 +8,7 @@
|
|||
<!-- TODO: read https://www.html5rocks.com/en/mobile/mobifying/#toc-meta-viewport -->
|
||||
|
||||
<head>
|
||||
<title>Emigui – An experimental immediate mode GUI written in Rust</title>
|
||||
<title>Egui – An experimental immediate mode GUI written in Rust</title>
|
||||
<style>
|
||||
html {
|
||||
/* Remove touch delay: */
|
||||
|
@ -61,7 +61,7 @@
|
|||
}
|
||||
|
||||
let input = {
|
||||
emigui: get_emigui_input(canvas),
|
||||
egui: get_egui_input(canvas),
|
||||
web: {
|
||||
location: window.location.toString(),
|
||||
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)));
|
||||
// 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}`);
|
||||
if (output.open_url) {
|
||||
window.open(output.open_url, "_self");
|
||||
}
|
||||
}
|
||||
|
||||
function from_emigui_cursor(cursor) {
|
||||
function from_egui_cursor(cursor) {
|
||||
if (cursor == "no_drop") { return "no-drop"; }
|
||||
else if (cursor == "not_allowed") { return "not-allowed"; }
|
||||
else if (cursor == "resize_horizontal") { return "ew-resize"; }
|
||||
|
@ -111,7 +111,7 @@
|
|||
canvas.height = window.innerHeight * pixels_per_point();
|
||||
}
|
||||
|
||||
function get_emigui_input(canvas) {
|
||||
function get_egui_input(canvas) {
|
||||
var input = {
|
||||
mouse_down: g_mouse_down,
|
||||
mouse_pos: g_mouse_pos,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "emigui"
|
||||
name = "egui"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
|
@ -1,5 +1,5 @@
|
|||
# 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:
|
||||
### Widgets
|
||||
|
@ -96,7 +96,7 @@ Add extremely quick animations for some things, maybe 2-3 frames. For instance:
|
|||
|
||||
### Names and structure
|
||||
* [ ] 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] Rename Region to Ui
|
||||
* [ ] Move Path and Triangles to own crate
|
|
@ -1,11 +1,11 @@
|
|||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let mut example_app = emigui::examples::ExampleApp::default();
|
||||
let mut ctx = emigui::Context::new(1.0);
|
||||
let mut example_app = egui::examples::ExampleApp::default();
|
||||
let mut ctx = egui::Context::new(1.0);
|
||||
|
||||
let raw_input = emigui::RawInput {
|
||||
screen_size: emigui::vec2(1280.0, 1024.0),
|
||||
let raw_input = egui::RawInput {
|
||||
screen_size: egui::vec2(1280.0, 1024.0),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -510,7 +510,7 @@ impl Context {
|
|||
|
||||
if ui
|
||||
.add(Button::new("Reset all"))
|
||||
.tooltip_text("Reset all Emigui state")
|
||||
.tooltip_text("Reset all Egui state")
|
||||
.clicked
|
||||
{
|
||||
*self.memory() = Default::default();
|
|
@ -94,7 +94,7 @@ struct OpenWindows {
|
|||
example_tree: bool,
|
||||
fractal_clock: bool,
|
||||
|
||||
// emigui stuff:
|
||||
// egui stuff:
|
||||
settings: bool,
|
||||
inspection: 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"));
|
||||
});
|
||||
menu::menu(ui, "About", |ui| {
|
||||
ui.add(label!("This is Emigui"));
|
||||
ui.add(Hyperlink::new("https://github.com/emilk/emigui/").text("Emigui home page"));
|
||||
ui.add(label!("This is Egui"));
|
||||
ui.add(Hyperlink::new("https://github.com/emilk/emigui/").text("Egui home page"));
|
||||
});
|
||||
|
||||
if let Some(time) = ui.input().seconds_since_midnight {
|
||||
|
@ -193,9 +193,9 @@ impl Default for ExampleWindow {
|
|||
|
||||
impl ExampleWindow {
|
||||
pub fn ui(&mut self, ui: &mut Ui) {
|
||||
ui.collapsing("About Emigui", |ui| {
|
||||
ui.collapsing("About Egui", |ui| {
|
||||
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| {
|
|
@ -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
|
||||
//! you move the mouse the same slider changes, even if the mouse has
|
||||
//! moved outside the slider.
|
|
@ -8,7 +8,7 @@ const MAX_CLICK_DIST: f32 = 6.0;
|
|||
const MAX_CLICK_DELAY: f64 = 0.3;
|
||||
|
||||
/// 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)]
|
||||
#[serde(default)]
|
||||
pub struct RawInput {
|
||||
|
@ -38,7 +38,7 @@ pub struct RawInput {
|
|||
pub events: Vec<Event>,
|
||||
}
|
||||
|
||||
/// What emigui maintains
|
||||
/// What egui maintains
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct InputState {
|
||||
/// The raw input we got this fraem
|
||||
|
@ -68,7 +68,7 @@ pub struct InputState {
|
|||
pub events: Vec<Event>,
|
||||
}
|
||||
|
||||
/// What emigui maintains
|
||||
/// What egui maintains
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MouseInput {
|
||||
/// Is the button currently down?
|
|
@ -1,4 +1,4 @@
|
|||
//! uis for emigui types.
|
||||
//! uis for egui types.
|
||||
use crate::{
|
||||
containers::show_tooltip,
|
||||
label,
|
|
@ -40,6 +40,7 @@ mod ui;
|
|||
pub mod widgets;
|
||||
|
||||
pub use {
|
||||
containers::*,
|
||||
context::Context,
|
||||
id::Id,
|
||||
input::*,
|
||||
|
@ -53,5 +54,4 @@ pub use {
|
|||
types::*,
|
||||
ui::Ui,
|
||||
widgets::*,
|
||||
containers::*,
|
||||
};
|
|
@ -644,8 +644,8 @@ impl Ui {
|
|||
///
|
||||
/// ``` ignore
|
||||
/// ui.columns(2, |columns| {
|
||||
/// columns[0].add(emigui::widgets::label!("First column"));
|
||||
/// columns[1].add(emigui::widgets::label!("Second column"));
|
||||
/// columns[0].add(egui::widgets::label!("First column"));
|
||||
/// columns[1].add(egui::widgets::label!("Second column"));
|
||||
/// });
|
||||
/// ```
|
||||
pub fn columns<F, R>(&mut self, num_columns: usize, add_contents: F) -> R
|
|
@ -1,12 +1,12 @@
|
|||
[package]
|
||||
name = "emigui_glium"
|
||||
name = "egui_glium"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
emigui = { path = "../emigui" }
|
||||
egui = { path = "../egui" }
|
||||
|
||||
chrono = { version = "0.4" }
|
||||
clipboard = "0.5"
|
|
@ -7,7 +7,7 @@ pub use painter::Painter;
|
|||
|
||||
use {
|
||||
clipboard::{ClipboardContext, ClipboardProvider},
|
||||
emigui::*,
|
||||
egui::*,
|
||||
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::*;
|
||||
|
||||
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 {
|
||||
CursorIcon::Default => glutin::MouseCursor::Default,
|
||||
CursorIcon::PointingHand => glutin::MouseCursor::Hand,
|
||||
|
@ -170,7 +170,7 @@ pub fn translate_cursor(cursor_icon: emigui::CursorIcon) -> glutin::MouseCursor
|
|||
}
|
||||
|
||||
pub fn handle_output(
|
||||
output: emigui::Output,
|
||||
output: egui::Output,
|
||||
display: &glium::backend::glutin::Display,
|
||||
clipboard: Option<&mut ClipboardContext>,
|
||||
) {
|
|
@ -1,7 +1,7 @@
|
|||
#![allow(deprecated)] // legacy implement_vertex macro
|
||||
|
||||
use {
|
||||
emigui::{
|
||||
egui::{
|
||||
paint::{PaintBatches, Triangles},
|
||||
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) {
|
||||
return; // No change
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ impl Painter {
|
|||
&mut self,
|
||||
display: &glium::Display,
|
||||
batches: PaintBatches,
|
||||
texture: &emigui::Texture,
|
||||
texture: &egui::Texture,
|
||||
) {
|
||||
self.upload_texture(display, texture);
|
||||
|
||||
|
@ -236,7 +236,7 @@ impl Painter {
|
|||
display: &glium::Display,
|
||||
clip_rect: Rect,
|
||||
triangles: &Triangles,
|
||||
texture: &emigui::Texture,
|
||||
texture: &egui::Texture,
|
||||
) {
|
||||
let vertex_buffer = {
|
||||
#[derive(Copy, Clone)]
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "emigui_wasm"
|
||||
name = "egui_wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
@ -14,7 +14,7 @@ serde = "1"
|
|||
serde_json = "1"
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
emigui = { path = "../emigui" }
|
||||
egui = { path = "../egui" }
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3"
|
|
@ -35,8 +35,8 @@ pub fn local_storage_remove(key: &str) {
|
|||
local_storage().map(|storage| storage.remove_item(key));
|
||||
}
|
||||
|
||||
pub fn load_memory(ctx: &emigui::Context) {
|
||||
if let Some(memory_string) = local_storage_get("emigui_memory_json") {
|
||||
pub fn load_memory(ctx: &egui::Context) {
|
||||
if let Some(memory_string) = local_storage_get("egui_memory_json") {
|
||||
match serde_json::from_str(&memory_string) {
|
||||
Ok(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()) {
|
||||
Ok(json) => {
|
||||
local_storage_set("emigui_memory_json", &json);
|
||||
local_storage_set("egui_memory_json", &json);
|
||||
}
|
||||
Err(err) => {
|
||||
console_log(format!(
|
|
@ -4,7 +4,7 @@ use {
|
|||
web_sys::{WebGlBuffer, WebGlProgram, WebGlRenderingContext, WebGlShader, WebGlTexture},
|
||||
};
|
||||
|
||||
use emigui::{
|
||||
use egui::{
|
||||
paint::{Color, PaintBatches, Texture, Triangles},
|
||||
vec2, Pos2,
|
||||
};
|
|
@ -6,8 +6,8 @@ license = "MIT OR Apache-2.0"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
emigui = { path = "../emigui" }
|
||||
emigui_glium = { path = "../emigui_glium" }
|
||||
egui = { path = "../egui" }
|
||||
egui_glium = { path = "../egui_glium" }
|
||||
serde = "1"
|
||||
serde_derive = "1"
|
||||
serde_json = "1"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
use {
|
||||
emigui::{examples::ExampleApp, paint::TextStyle, widgets::*, *},
|
||||
egui::{examples::ExampleApp, paint::TextStyle, widgets::*, *},
|
||||
glium::glutin,
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ where
|
|||
|
||||
fn main() {
|
||||
// TODO: combine
|
||||
let memory_path = "emigui.json";
|
||||
let memory_path = "egui.json";
|
||||
let settings_json_path: &str = "window.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 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 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 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: {
|
||||
let (width, height) = display.get_framebuffer_dimensions();
|
||||
vec2(width as f32, height as f32) / pixels_per_point
|
||||
|
@ -85,10 +85,10 @@ fn main() {
|
|||
let start_time = Instant::now();
|
||||
let mut running = true;
|
||||
let mut frame_start = Instant::now();
|
||||
let mut frame_times = emigui::MovementTracker::new(1000, 1.0);
|
||||
let mut clipboard = emigui_glium::init_clipboard();
|
||||
let mut frame_times = egui::MovementTracker::new(1000, 1.0);
|
||||
let mut clipboard = egui_glium::init_clipboard();
|
||||
|
||||
emigui_glium::read_memory(&ctx, memory_path);
|
||||
egui_glium::read_memory(&ctx, memory_path);
|
||||
|
||||
while running {
|
||||
{
|
||||
|
@ -102,21 +102,21 @@ fn main() {
|
|||
|
||||
{
|
||||
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.events.clear();
|
||||
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
|
||||
let mut ui = ctx.fullscreen_ui();
|
||||
example_app.ui(&mut ui, "");
|
||||
let mut ui = ui.centered_column(ui.available().width().min(480.0));
|
||||
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 {
|
||||
running = false;
|
||||
}
|
||||
|
@ -140,11 +140,11 @@ fn main() {
|
|||
|
||||
frame_times.add(
|
||||
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());
|
||||
emigui_glium::handle_output(output, &display, clipboard.as_mut());
|
||||
egui_glium::handle_output(output, &display, clipboard.as_mut());
|
||||
}
|
||||
|
||||
// Save state to disk:
|
||||
|
@ -157,8 +157,8 @@ fn main() {
|
|||
.get_inner_size()
|
||||
.map(|size| vec2(size.width as f32, size.height as f32));
|
||||
|
||||
if let Err(err) = emigui_glium::write_memory(&ctx, memory_path) {
|
||||
eprintln!("ERROR: Failed to save emigui state: {}", err);
|
||||
if let Err(err) = egui_glium::write_memory(&ctx, memory_path) {
|
||||
eprintln!("ERROR: Failed to save egui state: {}", err);
|
||||
}
|
||||
|
||||
serde_json::to_writer_pretty(std::fs::File::create(app_json_path).unwrap(), &example_app)
|
||||
|
|
|
@ -14,5 +14,5 @@ serde_derive = "1"
|
|||
serde_json = "1"
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
emigui = { path = "../emigui" }
|
||||
emigui_wasm = { path = "../emigui_wasm" }
|
||||
egui = { path = "../egui" }
|
||||
egui_wasm = { path = "../egui_wasm" }
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use {
|
||||
emigui::{
|
||||
egui::{
|
||||
color::srgba, examples::ExampleApp, label, widgets::Separator, Align, RawInput, TextStyle,
|
||||
*,
|
||||
},
|
||||
emigui_wasm::now_sec,
|
||||
egui_wasm::now_sec,
|
||||
};
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -16,7 +16,7 @@ use wasm_bindgen::prelude::*;
|
|||
#[derive(Clone, Debug, Default, serde_derive::Deserialize)]
|
||||
#[serde(default)]
|
||||
struct WebInput {
|
||||
emigui: RawInput,
|
||||
egui: RawInput,
|
||||
web: Web,
|
||||
}
|
||||
|
||||
|
@ -32,34 +32,34 @@ pub struct Web {
|
|||
pub struct State {
|
||||
example_app: ExampleApp,
|
||||
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 {
|
||||
fn new(canvas_id: &str, pixels_per_point: f32) -> Result<State, JsValue> {
|
||||
let ctx = Context::new(pixels_per_point);
|
||||
emigui_wasm::load_memory(&ctx);
|
||||
egui_wasm::load_memory(&ctx);
|
||||
Ok(State {
|
||||
example_app: Default::default(),
|
||||
ctx,
|
||||
webgl_painter: emigui_wasm::webgl::Painter::new(canvas_id)?,
|
||||
frame_times: emigui::MovementTracker::new(1000, 1.0),
|
||||
webgl_painter: egui_wasm::webgl::Painter::new(canvas_id)?,
|
||||
frame_times: egui::MovementTracker::new(1000, 1.0),
|
||||
})
|
||||
}
|
||||
|
||||
fn run(&mut self, web_input: WebInput) -> Result<Output, JsValue> {
|
||||
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();
|
||||
self.example_app.ui(&mut ui, &web_input.web.location_hash);
|
||||
let mut ui = ui.centered_column(ui.available().width().min(480.0));
|
||||
ui.set_layout(Layout::vertical(Align::Min));
|
||||
ui.add(label!("Emigui!").text_style(TextStyle::Heading));
|
||||
ui.label("Emigui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL.");
|
||||
ui.add(label!("Egui!").text_style(TextStyle::Heading));
|
||||
ui.label("Egui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL.");
|
||||
ui.label(
|
||||
"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(),
|
||||
)?;
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue