Skip to content

Commit

Permalink
core,desktop: Update to winit v0.30.5 and latest egui from git
Browse files Browse the repository at this point in the history
  • Loading branch information
torokati44 committed Aug 22, 2024
1 parent 9f8b891 commit 5430378
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 162 deletions.
371 changes: 230 additions & 141 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
naga = { version = "22.1.0", features = ["wgsl-out"] }
wgpu = "22.1.0"
egui = { git = "https://github.com/emilk/egui.git", rev = "37b1e1504db14697c39ce1c3bb5e58f4f2b819bf" }
egui = { git = "https://github.com/emilk/egui.git", rev = "9a1e358a144b5d2af9d03a80257c34883f57cf0b" }
clap = { version = "4.5.16", features = ["derive"] }
anyhow = "1.0"
slotmap = "1.0.7"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ hashbrown = { version = "0.14.5", features = ["raw"] }
scopeguard = "1.2.0"
fluent-templates = "0.10.1"
egui = { workspace = true, optional = true }
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "37b1e1504db14697c39ce1c3bb5e58f4f2b819bf", default-features = false, optional = true }
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "9a1e358a144b5d2af9d03a80257c34883f57cf0b", default-features = false, optional = true }
png = { version = "0.17.13", optional = true }
flv-rs = { path = "../flv" }
async-channel = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ unknown-git = "deny"
# github.com organizations to allow git sources for
github = [
"ruffle-rs",
# TODO: Remove once a release with https://github.com/emilk/egui/pull/4847 in it is out.
# TODO: Remove once a release with https://github.com/emilk/egui/pull/4939 in it is out.
"emilk",
# TODO: Remove once a release with https://github.com/PolyMeilex/rfd/pull/209 in it is out.
"PolyMeilex",
Expand Down
8 changes: 4 additions & 4 deletions desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ workspace = true
clap = { workspace = true }
cpal = "0.15.3"
egui = { workspace = true }
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "37b1e1504db14697c39ce1c3bb5e58f4f2b819bf", default-features = false, features = ["image"] }
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "37b1e1504db14697c39ce1c3bb5e58f4f2b819bf", features = ["winit"] }
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "9a1e358a144b5d2af9d03a80257c34883f57cf0b", default-features = false, features = ["image"] }
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "9a1e358a144b5d2af9d03a80257c34883f57cf0b", features = ["winit"] }
image = { workspace = true, features = ["png"] }
egui-winit = { git = "https://github.com/emilk/egui.git", rev = "37b1e1504db14697c39ce1c3bb5e58f4f2b819bf" }
egui-winit = { git = "https://github.com/emilk/egui.git", rev = "9a1e358a144b5d2af9d03a80257c34883f57cf0b" }
fontdb = "0.21"
ruffle_core = { path = "../core", features = ["audio", "clap", "mp3", "nellymoser", "default_compatibility_rules", "egui"] }
ruffle_render = { path = "../render", features = ["clap"] }
Expand All @@ -28,7 +28,7 @@ ruffle_frontend_utils = { path = "../frontend-utils" }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-appender = "0.2.3"
winit = "0.29.15"
winit = "0.30.5"
webbrowser = "1.0.1"
url = { workspace = true }
dirs = "5.0"
Expand Down
19 changes: 11 additions & 8 deletions desktop/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use std::time::{Duration, Instant};
use url::Url;
use winit::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Size};
use winit::event::{ElementState, KeyEvent, Modifiers, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop, EventLoopBuilder};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::keyboard::{Key, NamedKey};
use winit::window::{Fullscreen, Icon, Window, WindowBuilder};
use winit::window::{Fullscreen, Icon, Window, WindowAttributes};

pub struct App {
preferences: GlobalPreferences,
Expand All @@ -43,22 +43,24 @@ impl App {
let icon =
Icon::from_rgba(icon_bytes.to_vec(), 32, 32).context("Couldn't load app icon")?;

let event_loop = EventLoopBuilder::with_user_event().build()?;
let event_loop = EventLoop::with_user_event().build()?;

let no_gui = preferences.cli.no_gui;
let min_window_size = (16, if no_gui { 16 } else { MENU_HEIGHT + 16 }).into();
let max_window_size = get_screen_size(&event_loop);
let preferred_width = preferences.cli.width;
let preferred_height = preferences.cli.height;
let start_fullscreen = preferences.cli.fullscreen;

let window = WindowBuilder::new()
let window_attributes = WindowAttributes::default()
.with_visible(false)
.with_title("Ruffle")
.with_window_icon(Some(icon))
.with_min_inner_size(min_window_size)
.with_max_inner_size(max_window_size)
.build(&event_loop)?;
.with_min_inner_size(min_window_size);

#[allow(deprecated)]
let window = event_loop.create_window(window_attributes)?;
let max_window_size = get_screen_size(&window);
window.set_max_inner_size(Some(max_window_size));
let window = Arc::new(window);

let mut font_database = fontdb::Database::default();
Expand Down Expand Up @@ -136,6 +138,7 @@ impl App {
// Poll UI events.
let event_loop = self.event_loop.take().expect("App already running");
let event_loop_proxy = event_loop.create_proxy();
#[allow(deprecated)]
event_loop.run(move |event, elwt| {
let mut check_redraw = false;
match event {
Expand Down
10 changes: 8 additions & 2 deletions desktop/src/gui/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ impl GuiController {

let theme_controller =
ThemeController::new(window.clone(), preferences.clone(), egui_ctx.clone()).await;
let mut egui_winit =
egui_winit::State::new(egui_ctx, ViewportId::ROOT, window.as_ref(), None, None);
let mut egui_winit = egui_winit::State::new(
egui_ctx,
ViewportId::ROOT,
window.as_ref(),
None,
None,
None,
);
egui_winit.set_max_texture_side(descriptors.limits.max_texture_dimension_2d as usize);

let movie_view_renderer = Arc::new(MovieViewRenderer::new(
Expand Down
7 changes: 3 additions & 4 deletions desktop/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::custom_event::RuffleEvent;
use anyhow::{anyhow, Error};
use gilrs::Button;
use rfd::AsyncFileDialog;
Expand All @@ -8,8 +7,8 @@ use url::Url;
use wgpu::rwh::{HasDisplayHandle, HasWindowHandle};
use winit::dpi::PhysicalSize;
use winit::event::{KeyEvent, Modifiers};
use winit::event_loop::EventLoop;
use winit::keyboard::{Key, KeyLocation, NamedKey};
use winit::window::Window;

/// Converts a winit event to a Ruffle `TextControlCode`.
/// Returns `None` if there is no match.
Expand Down Expand Up @@ -207,13 +206,13 @@ pub fn gilrs_button_to_gamepad_button(button: Button) -> Option<GamepadButton> {
}
}

pub fn get_screen_size(event_loop: &EventLoop<RuffleEvent>) -> PhysicalSize<u32> {
pub fn get_screen_size(window: &Window) -> PhysicalSize<u32> {
let mut min_x = 0;
let mut min_y = 0;
let mut max_x = 0;
let mut max_y = 0;

for monitor in event_loop.available_monitors() {
for monitor in window.available_monitors() {
let size = monitor.size();
let position = monitor.position();
min_x = min_x.min(position.x);
Expand Down

0 comments on commit 5430378

Please sign in to comment.