Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update egui to 0.24 #75

Merged
merged 5 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
315 changes: 85 additions & 230 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ categories = ["games"]

# Shared dependencies
[workspace.dependencies]
egui = "0.23.0"
egui_extras = { version = "0.23.0", features = ["svg", "image"] }
epaint = "0.23.0"
egui = "0.24.1"
egui_extras = { version = "0.24.1", features = ["svg", "image"] }
epaint = "0.24.1"

luminol-eframe = { version = "0.23.0", path = "crates/eframe/", features = [
luminol-eframe = { version = "0.4.0", path = "crates/eframe/", features = [
"wgpu",
"accesskit",
"persistence",
"default_fonts",
"x11",
"wayland",
], default-features = false }
luminol-egui-wgpu = { version = "0.23.0", path = "crates/egui-wgpu/" }
egui_glow = "0.23.0"
egui-winit = "0.23.0"
luminol-egui-wgpu = { version = "0.4.0", path = "crates/egui-wgpu/" }
egui_glow = "0.24.1"
egui-winit = "0.24.1"

wgpu = { version = "0.18.0", features = ["naga"] }
glam = { version = "0.24.2", features = ["bytemuck"] }
Expand All @@ -96,9 +96,11 @@ tracing = "0.1.37"

strum = { version = "0.25.0", features = ["derive"] }
paste = "1.0.14"
thiserror = "1.0"
thiserror = "1.0.37"
bitflags = "2.4.0"
anyhow = "1.0"
puffin = "0.18"
raw-window-handle = "0.5.0"

parking_lot = { version = "0.12.1", features = ["deadlock_detection"] }
once_cell = "1.18.0"
Expand Down
7 changes: 3 additions & 4 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ workspace = true

[dependencies]
egui.workspace = true
luminol-eframe.workspace = true

egui_dock = "0.8.2"
egui-notify = "0.10.0"
egui-modal = "0.2.5"
egui_dock = "0.9.0"
egui-notify = "0.11.0"
egui-modal = "0.3.1"

parking_lot.workspace = true
poll-promise.workspace = true
Expand Down
9 changes: 6 additions & 3 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// it with Steamworks API by Valve Corporation, containing parts covered by
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.
#![feature(trait_alias)]

use std::sync::Arc;

Expand All @@ -45,6 +44,8 @@ pub mod project_manager;
pub use project_manager::ProjectManager;

pub struct UpdateState<'res> {
pub ctx: &'res egui::Context,

#[cfg(not(target_arch = "wasm32"))]
pub audio: &'res mut luminol_audio::Audio,
#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -131,6 +132,7 @@ impl<'res> UpdateState<'res> {
edit_windows: &'this mut window::EditWindows,
) -> UpdateState<'this> {
UpdateState {
ctx: self.ctx,
audio: self.audio,
graphics: self.graphics.clone(),
filesystem: self.filesystem,
Expand All @@ -152,6 +154,7 @@ impl<'res> UpdateState<'res> {
edit_tabs: &'this mut tab::EditTabs,
) -> UpdateState<'this> {
UpdateState {
ctx: self.ctx,
audio: self.audio,
graphics: self.graphics.clone(),
filesystem: self.filesystem,
Expand All @@ -168,7 +171,7 @@ impl<'res> UpdateState<'res> {
}
}

pub fn manage_projects(&mut self, frame: &mut luminol_eframe::Frame, show_modal: bool) {
pub fn manage_projects(&mut self, show_modal: bool) {
let mut should_close = false;
let mut should_save = false;
let mut should_run_closure = false;
Expand Down Expand Up @@ -238,7 +241,7 @@ impl<'res> UpdateState<'res> {

if should_run_closure {
if let Some(closure) = self.project_manager.closure.take() {
closure(self, frame);
closure(self);
}
}

Expand Down
18 changes: 10 additions & 8 deletions crates/core/src/project_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

pub struct ProjectManager {
pub(crate) modal: egui_modal::Modal,
pub(crate) closure: Option<Box<dyn ProjectManagerClosure>>,
pub(crate) closure: Option<Box<ProjectManagerClosure>>,

pub create_project_promise: Option<poll_promise::Promise<CreateProjectPromiseResult>>,
pub load_filesystem_promise: Option<poll_promise::Promise<FileSystemPromiseResult>>,
Expand All @@ -37,7 +37,7 @@ pub struct CreateProjectResult {
pub host_fs: luminol_filesystem::host::FileSystem,
}

pub trait ProjectManagerClosure = FnOnce(&mut crate::UpdateState<'_>, &mut luminol_eframe::Frame);
type ProjectManagerClosure = dyn FnOnce(&mut crate::UpdateState<'_>);
pub type CreateProjectPromiseResult = anyhow::Result<CreateProjectResult>;
pub type FileSystemPromiseResult = luminol_filesystem::Result<luminol_filesystem::host::FileSystem>;
pub type FileSystemOpenResult = luminol_filesystem::Result<luminol_filesystem::project::LoadResult>;
Expand Down Expand Up @@ -66,24 +66,26 @@ impl ProjectManager {
}

/// Runs a closure after asking the user to save unsaved changes.
pub fn run_custom(&mut self, closure: impl ProjectManagerClosure + 'static) {
pub fn run_custom(&mut self, closure: impl FnOnce(&mut crate::UpdateState<'_>) + 'static) {
self.closure = Some(Box::new(closure));
}

#[cfg(not(target_arch = "wasm32"))]
/// Closes the application after asking the user to save unsaved changes.
pub fn quit(&mut self) {
self.run_custom(|update_state, frame| {
self.run_custom(|update_state| {
// Disable the modified flag so `luminol_eframe::App::on_close_event` doesn't recurse
update_state.modified.set(false);

frame.close();
update_state
.ctx
.send_viewport_cmd(egui::ViewportCommand::Close);
});
}

/// Opens a project picker after asking the user to save unsaved changes.
pub fn open_project_picker(&mut self) {
self.run_custom(|update_state, _frame| {
self.run_custom(|update_state| {
// maybe worthwhile to make an extension trait to select spawn_async or spawn_local based on the target?
#[cfg(not(target_arch = "wasm32"))]
{
Expand All @@ -107,7 +109,7 @@ impl ProjectManager {
/// On native, `key` should be the absolute path to the project folder.
/// On web, `key` should be the IndexedDB key of the project folder.
pub fn load_recent_project(&mut self, key: String) {
self.run_custom(|update_state, _frame| {
self.run_custom(|update_state| {
#[cfg(not(target_arch = "wasm32"))]
{
update_state.close_project();
Expand All @@ -131,7 +133,7 @@ impl ProjectManager {

/// Closes the current project after asking the user to save unsaved changes.
pub fn close_project(&mut self) {
self.run_custom(|update_state, _frame| {
self.run_custom(|update_state| {
update_state.close_project();
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Tabs {

fn add_boxed_tab(&mut self, tab: Box<dyn Tab>) {
// FIXME O(n)
for node in self.dock_state.iter_nodes() {
for (_, node) in self.dock_state.iter_all_nodes() {
if let egui_dock::Node::Leaf { tabs, .. } = node {
if tabs.iter().any(|t| t.id() == tab.id()) {
return;
Expand Down
65 changes: 64 additions & 1 deletion crates/eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,70 @@ All notable changes to the `eframe` crate.
NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/CHANGELOG.md), [`egui_glow`](../egui_glow/CHANGELOG.md),and [`egui-wgpu`](../egui-wgpu/CHANGELOG.md) have their own changelogs!

This file is updated upon each release.
Changes since the last release can be found by running the `scripts/generate_changelog.py` script.
Changes since the last release can be found at <https://github.com/emilk/egui/compare/latest...HEAD> or by running the `scripts/generate_changelog.py` script.


## 0.24.1 - 2023-11-30
#### Desktop/Native:
* Fix window flashing white on launch [#3631](https://github.com/emilk/egui/pull/3631) (thanks [@zeozeozeo](https://github.com/zeozeozeo)!)
* Fix windowing problems when using the `x11` feature on Linux [#3643](https://github.com/emilk/egui/pull/3643)
* Fix bugs when there are multiple monitors with different scales [#3663](https://github.com/emilk/egui/pull/3663)
* `glow` backend: clear framebuffer color before calling `App::update` [#3665](https://github.com/emilk/egui/pull/3665)

#### Web:
* Fix click-to-copy on Safari [#3621](https://github.com/emilk/egui/pull/3621)
* Don't throw away frames on click/copy/cut [#3623](https://github.com/emilk/egui/pull/3623)
* Remove dependency on `tts` [#3651](https://github.com/emilk/egui/pull/3651)


## 0.24.0 - 2023-11-23
* Multiple viewports/windows [#3172](https://github.com/emilk/egui/pull/3172) (thanks [@konkitoman](https://github.com/konkitoman)!)
* Replace `eframe::Frame` commands and `WindowInfo` with egui [#3564](https://github.com/emilk/egui/pull/3564)
* Use `egui::ViewportBuilder` in `eframe::NativeOptions` [#3572](https://github.com/emilk/egui/pull/3572)
* Remove warm-starting [#3574](https://github.com/emilk/egui/pull/3574)
* Fix copy and cut on Safari [#3513](https://github.com/emilk/egui/pull/3513) (thanks [@lunixbochs](https://github.com/lunixbochs)!)
* Update puffin to 0.18 [#3600](https://github.com/emilk/egui/pull/3600)
* Update MSRV to Rust 1.72 [#3595](https://github.com/emilk/egui/pull/3595)

### Breaking changes:
Most settings in `NativeOptions` have been moved to `NativeOptions::viewport`, which uses the new `egui::ViewportBuilder`:

```diff
let native_options = eframe::nativeOptions {
- initial_window_size: Some(egui::vec2(320.0, 240.0)),
- drag_and_drop_support: true,
+ viewport: egui::ViewportBuilder::default()
+ .with_inner_size([320.0, 240.0])
+ .with_drag_and_drop(true),
..Default::default()
};
```

`NativeOptions::fullsize_content` has been replaced with four settings: `ViewportBuilder::with_fullsize_content_view`, `with_title_shown`, `with_titlebar_shown`, `with_titlebar_buttons_shown`

`frame.info().window_info` is gone, replaced with `ctx.input(|i| i.viewport())`.

`frame.info().native_pixels_per_point` is replaced with `ctx.input(|i| i.raw.native_pixels_per_point)`.

Most commands in `eframe::Frame` has been replaced with `egui::ViewportCommand`, so So `frame.close()` becomes `ctx.send_viewport_cmd(ViewportCommand::Close)`, etc.

`App::on_close_event` has been replaced with `ctx.input(|i| i.viewport().close_requested())` and `ctx.send_viewport_cmd(ViewportCommand::CancelClose)`.

`eframe::IconData` is now `egui::IconData`.

`eframe::IconData::try_from_png_bytes` is now `eframe::icon_data::from_png_bytes`.

`App::post_rendering` is gone. Screenshots are taken with `ctx.send_viewport_cmd(ViewportCommand::Screenshots)` and are returned in `egui::Event` which you can check with:
``` rust
ui.input(|i| {
for event in &i.raw.events {
if let egui::Event::Screenshot { viewport_id, image } = event {
// handle it here
}
}
});
```


## 0.23.0 - 2023-09-27
* Update MSRV to Rust 1.70.0 [#3310](https://github.com/emilk/egui/pull/3310)
Expand Down
25 changes: 17 additions & 8 deletions crates/eframe/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "luminol-eframe"
version = "0.23.0"
version.workspace = true
authors = ["Emil Ernerfeldt <[email protected]>"]
description = "egui framework - write GUI apps that compiles to web and/or natively"
edition.workspace = true
Expand Down Expand Up @@ -32,6 +32,7 @@ default = [
"default_fonts",
"wgpu",
"wayland",
"web_screen_reader",
"winit/default",
"x11",
]
Expand Down Expand Up @@ -70,15 +71,24 @@ persistence = [
## `eframe` will call `puffin::GlobalProfiler::lock().new_frame()` for you
##
## Only enabled on native, because of the low resolution (1ms) of clocks in browsers.
puffin = ["dep:puffin", "egui/puffin", "egui_glow?/puffin", "luminol-egui-wgpu?/puffin"]
puffin = [
"dep:puffin",
"egui/puffin",
"egui_glow?/puffin",
"luminol-egui-wgpu?/puffin",
"egui-winit/puffin",
]

## Enables wayland support and fixes clipboard issue.
wayland = ["egui-winit/wayland"]

## Enable screen reader support (requires `ctx.options_mut(|o| o.screen_reader = true);`) on web.
##
## For other platforms, use the `accesskit` feature instead.
web_screen_reader = ["tts"]
web_screen_reader = [
"web-sys/SpeechSynthesis",
"web-sys/SpeechSynthesisUtterance",
]

## Use [`wgpu`](https://docs.rs/wgpu) for painting (via [`egui-wgpu`](https://github.com/emilk/egui/tree/master/crates/egui-wgpu)).
## This overrides the `glow` feature.
Expand Down Expand Up @@ -120,7 +130,7 @@ egui-winit = { workspace = true, features = [
image = { version = "0.24", default-features = false, features = [
"png",
] } # Needed for app icon
raw-window-handle = { version = "0.5.0" }
raw-window-handle.workspace = true
winit = { version = "0.28.1", default-features = false }

# optional native:
Expand All @@ -134,7 +144,7 @@ pollster = { version = "0.3", optional = true } # needed for wgpu
# this can be done at the same time we expose x11/wayland features of winit crate.
glutin = { version = "0.30", optional = true }
glutin-winit = { version = "0.3.0", optional = true }
puffin = { version = "0.16", optional = true }
puffin = { workspace = true, optional = true }
wgpu = { workspace = true, optional = true }

# mac:
Expand All @@ -152,7 +162,7 @@ winapi = "0.3.9"
bytemuck = "1.7"
js-sys = "0.3"
percent-encoding = "2.1"
wasm-bindgen = "0.2.87"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3.58", features = [
"BinaryType",
Expand Down Expand Up @@ -216,6 +226,5 @@ luminol-web = { version = "0.4.0", path = "../web/" }

# optional web:
luminol-egui-wgpu = { workspace = true, optional = true } # if wgpu is used, use it without (!) winit
raw-window-handle = { version = "0.5.2", optional = true }
tts = { version = "0.25", optional = true, default-features = false }
raw-window-handle = { workspace = true, optional = true }
wgpu = { workspace = true, optional = true }
2 changes: 1 addition & 1 deletion crates/eframe/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
> [!IMPORTANT]
> luminol-eframe is currently based on emilk/egui@0.23.0
> luminol-eframe is currently based on emilk/egui@0.24.1

> [!NOTE]
> This is Luminol's modified version of eframe. The original version is dual-licensed under MIT and Apache 2.0.
Expand Down
Loading
Loading