From 525f0f6969a0c3f157f56d07cf184eb590bc7ddc Mon Sep 17 00:00:00 2001 From: RobDavenport Date: Wed, 24 Apr 2024 02:10:08 +0900 Subject: [PATCH] use eframe 0.27 --- Cargo.lock | 383 ++---------------- gamercade_editor/Cargo.toml | 3 +- gamercade_editor/src/main.rs | 6 +- .../ui/audio/instrument_editor/fm_editor.rs | 5 +- .../ui/audio/instrument_editor/piano_roll.rs | 26 +- .../audio/instrument_editor/sampler_editor.rs | 7 +- .../instrument_editor/wavetable_editor.rs | 9 +- gamercade_editor/src/ui/audio/oscilloscope.rs | 7 +- .../src/ui/graphics/graphics_editor.rs | 42 +- gamercade_editor/src/ui/graphics/mod.rs | 4 +- .../palette_editor_tab/color_editor.rs | 20 +- .../src/ui/graphics/palette_editor_tab/mod.rs | 20 +- .../palette_editor_tab/palette_list.rs | 6 +- .../palette_editor_tab/palette_viewer.rs | 20 +- .../palette_editor_tab/sprite_preview.rs | 11 +- .../graphics/sprite_sheet_editor_tab/mod.rs | 6 +- .../palette_preview.rs | 10 +- .../sprite_sheet_editor_tab/sheet_editor.rs | 16 +- 18 files changed, 156 insertions(+), 445 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6871d7e..42b4ef03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,12 +18,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" -[[package]] -name = "accesskit" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8" - [[package]] name = "accesskit" version = "0.12.3" @@ -34,34 +28,13 @@ dependencies = [ "serde", ] -[[package]] -name = "accesskit_consumer" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bb4d9e4772fe0d47df57d0d5dbe5d85dd05e2f37ae1ddb6b105e76be58fb00" -dependencies = [ - "accesskit 0.11.2", -] - [[package]] name = "accesskit_consumer" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c17cca53c09fbd7288667b22a201274b9becaa27f0b91bf52a526db95de45e6" dependencies = [ - "accesskit 0.12.3", -] - -[[package]] -name = "accesskit_macos" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d0acf6acb667c89d3332999b1a5df4edbc8d6113910f392ebb73f2b03bb56" -dependencies = [ - "accesskit 0.11.2", - "accesskit_consumer 0.15.2", - "objc2 0.3.0-beta.3.patch-leaks.3", - "once_cell", + "accesskit", ] [[package]] @@ -70,95 +43,53 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd3b6ae1eabbfbced10e840fd3fce8a93ae84f174b3e4ba892ab7bcb42e477a7" dependencies = [ - "accesskit 0.12.3", - "accesskit_consumer 0.16.1", + "accesskit", + "accesskit_consumer", "objc2 0.3.0-beta.3.patch-leaks.3", "once_cell", ] -[[package]] -name = "accesskit_unix" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e084cb5168790c0c112626175412dc5ad127083441a8248ae49ddf6725519e83" -dependencies = [ - "accesskit 0.11.2", - "accesskit_consumer 0.15.2", - "async-channel 1.9.0", - "atspi 0.10.1", - "futures-lite 1.13.0", - "serde", - "zbus 3.15.1", -] - [[package]] name = "accesskit_unix" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09f46c18d99ba61ad7123dd13eeb0c104436ab6af1df6a1cd8c11054ed394a08" dependencies = [ - "accesskit 0.12.3", - "accesskit_consumer 0.16.1", - "async-channel 2.2.1", + "accesskit", + "accesskit_consumer", + "async-channel", "async-once-cell", - "atspi 0.19.0", + "atspi", "futures-lite 1.13.0", "once_cell", "serde", "zbus 3.15.1", ] -[[package]] -name = "accesskit_windows" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eac0a7f2d7cd7a93b938af401d3d8e8b7094217989a7c25c55a953023436e31" -dependencies = [ - "accesskit 0.11.2", - "accesskit_consumer 0.15.2", - "arrayvec", - "once_cell", - "paste", - "windows 0.48.0", -] - [[package]] name = "accesskit_windows" version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afcae27ec0974fc7c3b0b318783be89fd1b2e66dd702179fe600166a38ff4a0b" dependencies = [ - "accesskit 0.12.3", - "accesskit_consumer 0.16.1", + "accesskit", + "accesskit_consumer", "once_cell", "paste", "static_assertions", "windows 0.48.0", ] -[[package]] -name = "accesskit_winit" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825d23acee1bd6d25cbaa3ca6ed6e73faf24122a774ec33d52c5c86c6ab423c0" -dependencies = [ - "accesskit 0.11.2", - "accesskit_macos 0.9.0", - "accesskit_unix 0.5.2", - "accesskit_windows 0.14.3", - "winit 0.28.7", -] - [[package]] name = "accesskit_winit" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5284218aca17d9e150164428a0ebc7b955f70e3a9a78b4c20894513aabf98a67" dependencies = [ - "accesskit 0.12.3", - "accesskit_macos 0.10.1", - "accesskit_unix 0.6.2", - "accesskit_windows 0.15.1", + "accesskit", + "accesskit_macos", + "accesskit_unix", + "accesskit_windows", "winit 0.29.15", ] @@ -444,17 +375,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - [[package]] name = "async-channel" version = "2.2.1" @@ -603,7 +523,7 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a53fc6301894e04a92cb2584fedde80cb25ba8e02d9dc39d4a87d036e22f397d" dependencies = [ - "async-channel 2.2.1", + "async-channel", "async-io 2.3.2", "async-lock 3.3.0", "async-signal", @@ -697,23 +617,6 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41e67cd8309bbd06cd603a9e693a784ac2e5d1e955f11286e355089fcab3047c" -[[package]] -name = "atspi" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "674e7a3376837b2e7d12d34d58ac47073c491dc3bf6f71a7adaf687d4d817faa" -dependencies = [ - "async-recursion", - "async-trait", - "atspi-macros", - "enumflags2", - "futures-lite 1.13.0", - "serde", - "tracing", - "zbus 3.15.1", - "zbus_names 2.6.1", -] - [[package]] name = "atspi" version = "0.19.0" @@ -751,16 +654,6 @@ dependencies = [ "zbus 3.15.1", ] -[[package]] -name = "atspi-macros" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "atspi-proxies" version = "0.3.0" @@ -1010,7 +903,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.2.1", + "async-channel", "async-lock 3.3.0", "async-task", "fastrand 2.0.2", @@ -1227,22 +1120,6 @@ dependencies = [ "error-code", ] -[[package]] -name = "cocoa" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" -dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics 0.22.3", - "foreign-types 0.3.2", - "libc", - "objc", -] - [[package]] name = "cocoa" version = "0.25.0" @@ -1778,15 +1655,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "ecolor" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63" -dependencies = [ - "bytemuck", -] - [[package]] name = "ecolor" version = "0.27.2" @@ -1797,34 +1665,6 @@ dependencies = [ "serde", ] -[[package]] -name = "eframe" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4596583a2c680c55b6feaa748f74890c4f9cb9c7cb69d6117110444cb65b2f" -dependencies = [ - "bytemuck", - "cocoa 0.24.1", - "egui 0.22.0", - "egui-winit 0.22.0", - "egui_glow 0.22.0", - "glow 0.12.3", - "glutin 0.30.10", - "glutin-winit 0.3.0", - "image 0.24.9", - "js-sys", - "log", - "objc", - "percent-encoding", - "raw-window-handle 0.5.2", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winapi", - "winit 0.28.7", -] - [[package]] name = "eframe" version = "0.27.2" @@ -1832,15 +1672,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "020e2ccef6bbcec71dbc542f7eed64a5846fc3076727f5746da8fd307c91bab2" dependencies = [ "bytemuck", - "cocoa 0.25.0", + "cocoa", "document-features", "egui 0.27.2", "egui-wgpu 0.27.2", "egui-winit 0.27.2", - "egui_glow 0.27.2", + "egui_glow", "glow 0.13.1", - "glutin 0.31.3", - "glutin-winit 0.4.2", + "glutin", + "glutin-winit", "image 0.24.9", "js-sys", "log", @@ -1871,26 +1711,13 @@ dependencies = [ "tracing", ] -[[package]] -name = "egui" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7" -dependencies = [ - "accesskit 0.11.2", - "ahash", - "epaint 0.22.0", - "log", - "nohash-hasher", -] - [[package]] name = "egui" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "584c5d1bf9a67b25778a3323af222dbe1a1feb532190e103901187f92c7fe29a" dependencies = [ - "accesskit 0.12.3", + "accesskit", "ahash", "epaint 0.27.2", "log", @@ -1943,35 +1770,18 @@ dependencies = [ "winit 0.28.7", ] -[[package]] -name = "egui-winit" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a49155fd4a0a4fb21224407a91de0030847972ef90fc64edb63621caea61cb2" -dependencies = [ - "accesskit_winit 0.14.4", - "arboard", - "egui 0.22.0", - "instant", - "log", - "raw-window-handle 0.5.2", - "smithay-clipboard 0.6.6", - "webbrowser", - "winit 0.28.7", -] - [[package]] name = "egui-winit" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e3da0cbe020f341450c599b35b92de4af7b00abde85624fd16f09c885573609" dependencies = [ - "accesskit_winit 0.16.1", + "accesskit_winit", "arboard", "egui 0.27.2", "log", "raw-window-handle 0.6.1", - "smithay-clipboard 0.7.1", + "smithay-clipboard", "web-time", "webbrowser", "winit 0.29.15", @@ -1995,33 +1805,27 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.22.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8c2752cdf1b0ef5fcda59a898cacabad974d4f5880e92a420b2c917022da64" +checksum = "e0e5d975f3c86edc3d35b1db88bb27c15dde7c55d3b5af164968ab5ede3f44ca" dependencies = [ "bytemuck", - "egui 0.22.0", - "glow 0.12.3", + "egui 0.27.2", + "glow 0.13.1", "log", - "memoffset 0.6.5", + "memoffset 0.9.1", "wasm-bindgen", "web-sys", + "winit 0.29.15", ] [[package]] -name = "egui_glow" +name = "egui_plot" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e5d975f3c86edc3d35b1db88bb27c15dde7c55d3b5af164968ab5ede3f44ca" +checksum = "a7854b86dc1c2d352c5270db3d600011daa913d6b554141a03939761323288a1" dependencies = [ - "bytemuck", "egui 0.27.2", - "glow 0.13.1", - "log", - "memoffset 0.9.1", - "wasm-bindgen", - "web-sys", - "winit 0.29.15", ] [[package]] @@ -2053,15 +1857,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "emath" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b" -dependencies = [ - "bytemuck", -] - [[package]] name = "emath" version = "0.27.2" @@ -2156,23 +1951,6 @@ dependencies = [ "parking_lot", ] -[[package]] -name = "epaint" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b" -dependencies = [ - "ab_glyph", - "ahash", - "atomic_refcell", - "bytemuck", - "ecolor 0.22.0", - "emath 0.22.0", - "log", - "nohash-hasher", - "parking_lot", -] - [[package]] name = "epaint" version = "0.27.2" @@ -2548,7 +2326,7 @@ name = "gamercade_app" version = "0.1.0" dependencies = [ "bytemuck", - "eframe 0.27.2", + "eframe", "egui_extras", "gamercade_interface", "hashbrown 0.14.3", @@ -2622,7 +2400,8 @@ dependencies = [ name = "gamercade_editor" version = "0.1.0" dependencies = [ - "eframe 0.22.0", + "eframe", + "egui_plot", "gamercade_audio", "gamercade_core", "gamercade_fs", @@ -2840,29 +2619,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "glutin" -version = "0.30.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc93b03242719b8ad39fb26ed2b01737144ce7bd4bfc7adadcef806596760fe" -dependencies = [ - "bitflags 1.3.2", - "cfg_aliases", - "cgl", - "core-foundation", - "dispatch", - "glutin_egl_sys 0.5.1", - "glutin_glx_sys 0.4.0", - "glutin_wgl_sys 0.4.0", - "libloading 0.7.4", - "objc2 0.3.0-beta.3.patch-leaks.3", - "once_cell", - "raw-window-handle 0.5.2", - "wayland-sys 0.30.1", - "windows-sys 0.45.0", - "x11-dl", -] - [[package]] name = "glutin" version = "0.31.3" @@ -2874,9 +2630,9 @@ dependencies = [ "cgl", "core-foundation", "dispatch", - "glutin_egl_sys 0.6.0", - "glutin_glx_sys 0.5.0", - "glutin_wgl_sys 0.5.0", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", "icrate", "libloading 0.8.3", "objc2 0.4.1", @@ -2887,18 +2643,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "glutin-winit" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629a873fc04062830bfe8f97c03773bcd7b371e23bcc465d0a61448cd1588fa4" -dependencies = [ - "cfg_aliases", - "glutin 0.30.10", - "raw-window-handle 0.5.2", - "winit 0.28.7", -] - [[package]] name = "glutin-winit" version = "0.4.2" @@ -2906,21 +2650,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebcdfba24f73b8412c5181e56f092b5eff16671c514ce896b258a0a64bd7735" dependencies = [ "cfg_aliases", - "glutin 0.31.3", + "glutin", "raw-window-handle 0.5.2", "winit 0.29.15", ] -[[package]] -name = "glutin_egl_sys" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af784eb26c5a68ec85391268e074f0aa618c096eadb5d6330b0911cf34fe57c5" -dependencies = [ - "gl_generator", - "windows-sys 0.45.0", -] - [[package]] name = "glutin_egl_sys" version = "0.6.0" @@ -2931,16 +2665,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "glutin_glx_sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b53cb5fe568964aa066a3ba91eac5ecbac869fb0842cd0dc9e412434f1a1494" -dependencies = [ - "gl_generator", - "x11-dl", -] - [[package]] name = "glutin_glx_sys" version = "0.5.0" @@ -2951,15 +2675,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "glutin_wgl_sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef89398e90033fc6bc65e9bd42fd29bbbfd483bda5b56dc5562f455550618165" -dependencies = [ - "gl_generator", -] - [[package]] name = "glutin_wgl_sys" version = "0.5.0" @@ -5642,16 +5357,6 @@ dependencies = [ "xkeysym", ] -[[package]] -name = "smithay-clipboard" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8" -dependencies = [ - "smithay-client-toolkit 0.16.1", - "wayland-client 0.29.5", -] - [[package]] name = "smithay-clipboard" version = "0.7.1" @@ -7055,18 +6760,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "wayland-sys" -version = "0.30.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06" -dependencies = [ - "dlib", - "lazy_static", - "log", - "pkg-config", -] - [[package]] name = "wayland-sys" version = "0.31.1" @@ -7283,7 +6976,7 @@ dependencies = [ "cfg_aliases", "core-graphics-types", "glow 0.13.1", - "glutin_wgl_sys 0.5.0", + "glutin_wgl_sys", "gpu-alloc 0.6.0", "gpu-allocator 0.25.0", "gpu-descriptor", diff --git a/gamercade_editor/Cargo.toml b/gamercade_editor/Cargo.toml index dcedd046..42ecd308 100644 --- a/gamercade_editor/Cargo.toml +++ b/gamercade_editor/Cargo.toml @@ -20,7 +20,8 @@ gamercade_sound_engine = { path = "../gamercade_sound_engine" } serde = { version = "1.0.198", features = ["derive"] } # Window and Rendering -eframe = "0.22.0" +eframe = "0.27.2" +egui_plot = "0.27.2" # File Dialogs rfd = "0.14.1" diff --git a/gamercade_editor/src/main.rs b/gamercade_editor/src/main.rs index 695ba408..2cbae3d6 100644 --- a/gamercade_editor/src/main.rs +++ b/gamercade_editor/src/main.rs @@ -1,12 +1,14 @@ -use eframe::epaint::Vec2; +use eframe::{egui::ViewportBuilder, epaint::Vec2}; use ui::Editor; mod ui; fn main() { + let viewport = ViewportBuilder::default().with_inner_size(Vec2::new(1366.0, 768.0)); + let options = eframe::NativeOptions { vsync: true, - initial_window_size: Some(Vec2::new(1366.0, 768.0)), + viewport, ..Default::default() }; diff --git a/gamercade_editor/src/ui/audio/instrument_editor/fm_editor.rs b/gamercade_editor/src/ui/audio/instrument_editor/fm_editor.rs index c0288532..bd58bc31 100644 --- a/gamercade_editor/src/ui/audio/instrument_editor/fm_editor.rs +++ b/gamercade_editor/src/ui/audio/instrument_editor/fm_editor.rs @@ -1,5 +1,5 @@ use eframe::{ - egui::{ComboBox, Image, Slider, TextureFilter, TextureOptions, Ui, Window}, + egui::{ComboBox, Image, Slider, TextureFilter, TextureOptions, TextureWrapMode, Ui, Window}, epaint::{ColorImage, TextureHandle, Vec2}, }; use gamercade_audio::{ @@ -54,12 +54,13 @@ impl FMHelp { TextureOptions { magnification: TextureFilter::Nearest, minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, }, ) }); ui.label("Algorithm Chart:"); - ui.add(Image::new(texture_id, self.diagram_size.unwrap())); + ui.add(Image::new(&*texture_id)); }); } } diff --git a/gamercade_editor/src/ui/audio/instrument_editor/piano_roll.rs b/gamercade_editor/src/ui/audio/instrument_editor/piano_roll.rs index 12c9cd79..f802adec 100644 --- a/gamercade_editor/src/ui/audio/instrument_editor/piano_roll.rs +++ b/gamercade_editor/src/ui/audio/instrument_editor/piano_roll.rs @@ -1,5 +1,5 @@ use eframe::{ - egui::{ImageButton, Key, TextureFilter, TextureOptions, Ui}, + egui::{Image, ImageButton, Key, TextureFilter, TextureOptions, TextureWrapMode, Ui}, epaint::{Color32, ColorImage, TextureHandle, Vec2}, }; use gamercade_audio::{NoteColor, NoteName, NotesIter, TOTAL_NOTES_COUNT}; @@ -145,7 +145,7 @@ impl PianoRoll { sync: &mut AudioSyncHelper, selected_instrument: usize, ) { - let texture_id = self + let texture_handle = self .default_piano_texture .get_or_insert_with(|| { ui.ctx().load_texture( @@ -154,10 +154,12 @@ impl PianoRoll { TextureOptions { magnification: TextureFilter::Nearest, minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, }, ) }) - .id(); + .clone(); + // Draw the actual piano keys for clicking ui.vertical(|ui| { ui.spacing_mut().item_spacing = Vec2 { @@ -172,17 +174,19 @@ impl PianoRoll { all_notes_iter.for_each(|(index, (note, _octave))| { let color = self.get_key_texture_tint(note, index); - let button_top = ImageButton::new(texture_id, TOP_KEY_SIZE).tint(color); + let button_top = ImageButton::new( + Image::new(&texture_handle) + .fit_to_exact_size(TOP_KEY_SIZE) + .maintain_aspect_ratio(false), + ) + .tint(color); + if ui.add(button_top).clicked() { sync.trigger_note(index, selected_instrument); }; }); }); - ui.spacing_mut().item_spacing = Vec2 { - x: NOTE_SPACING, - y: 0.0, - }; ui.horizontal(|ui| { let mut white_notes_iter = NotesIter::default().enumerate(); @@ -190,8 +194,10 @@ impl PianoRoll { if note.get_key_color() == NoteColor::White { let tint = self.get_key_texture_tint(note, index); - let button_bottom = - ImageButton::new(texture_id, BOTTOM_KEY_SIZE).tint(tint); + let button_bottom = ImageButton::new( + Image::new(&texture_handle).fit_to_exact_size(BOTTOM_KEY_SIZE), + ) + .tint(tint); if ui.add(button_bottom).clicked() { sync.trigger_note(index, selected_instrument); diff --git a/gamercade_editor/src/ui/audio/instrument_editor/sampler_editor.rs b/gamercade_editor/src/ui/audio/instrument_editor/sampler_editor.rs index 3c1479d7..f6af79b7 100644 --- a/gamercade_editor/src/ui/audio/instrument_editor/sampler_editor.rs +++ b/gamercade_editor/src/ui/audio/instrument_editor/sampler_editor.rs @@ -1,10 +1,9 @@ use eframe::{ - egui::{ - plot::{HLine, Line, Plot, PlotPoint, PlotPoints, VLine}, - Slider, Ui, - }, + egui::{Slider, Ui}, epaint::{Color32, Vec2}, }; +use egui_plot::{HLine, Line, Plot, PlotPoint, PlotPoints, VLine}; + use hound::WavReader; use rfd::FileDialog; diff --git a/gamercade_editor/src/ui/audio/instrument_editor/wavetable_editor.rs b/gamercade_editor/src/ui/audio/instrument_editor/wavetable_editor.rs index e35a3b37..78899b2e 100644 --- a/gamercade_editor/src/ui/audio/instrument_editor/wavetable_editor.rs +++ b/gamercade_editor/src/ui/audio/instrument_editor/wavetable_editor.rs @@ -1,10 +1,9 @@ use eframe::{ - egui::{ - plot::{HLine, Line, Plot, PlotPoint, PlotPoints, VLine}, - ComboBox, Slider, Ui, Window, - }, + egui::{ComboBox, Slider, Ui, Window}, epaint::{Color32, Vec2}, }; +use egui_plot::{HLine, Line, Plot, PlotPoint, PlotPoints, VLine}; + use gamercade_audio::{ WavetableBitDepth, WavetableDefinition, WavetableGenerator, WavetableWaveform, WAVETABLE_MAX_LENGTH, @@ -82,7 +81,7 @@ impl WavetableEditor { plot_ui.vline(VLine::new(0.0).color(Color32::RED)); plot_ui.vline(VLine::new(last_index as f64).color(Color32::RED)); - if plot_ui.plot_hovered() && primary_pointer_down { + if plot_ui.response().hovered() && primary_pointer_down { let point = plot_ui.pointer_coordinate().unwrap(); let (x, y) = plot_point_to_x_y(&point, last_index); diff --git a/gamercade_editor/src/ui/audio/oscilloscope.rs b/gamercade_editor/src/ui/audio/oscilloscope.rs index 80d04dfd..99eada69 100644 --- a/gamercade_editor/src/ui/audio/oscilloscope.rs +++ b/gamercade_editor/src/ui/audio/oscilloscope.rs @@ -1,12 +1,11 @@ use std::collections::VecDeque; use eframe::{ - egui::{ - plot::{Line, Plot, PlotPoints}, - Ui, Window, - }, + egui::{Ui, Window}, epaint::{Color32, Vec2}, }; +use egui_plot::{Line, Plot, PlotPoints}; + use gamercade_audio::SFX_CHANNELS; use gamercade_sound_engine::SoundOutputChannels; use rtrb::Consumer; diff --git a/gamercade_editor/src/ui/graphics/graphics_editor.rs b/gamercade_editor/src/ui/graphics/graphics_editor.rs index cc26c72d..adec8fd2 100644 --- a/gamercade_editor/src/ui/graphics/graphics_editor.rs +++ b/gamercade_editor/src/ui/graphics/graphics_editor.rs @@ -1,6 +1,6 @@ use eframe::egui::{ - Color32, ColorImage, Image, Slider, TextureFilter, TextureHandle, TextureId, TextureOptions, - Ui, Vec2, + Color32, ColorImage, Image, Slider, TextureFilter, TextureHandle, TextureOptions, + TextureWrapMode, Ui, Vec2, }; use super::{PaletteEditor, SpriteEditor, SpriteSheetEditor}; @@ -54,19 +54,17 @@ impl GraphicsEditor { } pub fn draw_contents(&mut self, ui: &mut Ui, data: &mut EditorGraphicsData) { - let texture_id = self - .default_palette_texture - .get_or_insert_with(|| { - ui.ctx().load_texture( - "default palette texture", - ColorImage::from_rgba_unmultiplied([1, 1], &[255, 255, 255, 255]), - TextureOptions { - magnification: TextureFilter::Nearest, - minification: TextureFilter::Nearest, - }, - ) - }) - .id(); + let texture_handle = self.default_palette_texture.get_or_insert_with(|| { + ui.ctx().load_texture( + "default palette texture", + ColorImage::from_rgba_unmultiplied([1, 1], &[255, 255, 255, 255]), + TextureOptions { + magnification: TextureFilter::Nearest, + minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, + }, + ) + }); match self.mode { GraphicsEditorMode::Palette => self.palette_editor.draw( @@ -74,14 +72,14 @@ impl GraphicsEditor { data, &self.sprite_sheet_editor, self.scale, - texture_id, + &texture_handle, ), GraphicsEditorMode::SpriteSheet => self.sprite_sheet_editor.draw( ui, data, &mut self.palette_editor, self.scale, - texture_id, + &texture_handle, ), GraphicsEditorMode::Sprite => self.sprite_editor.draw(ui), }; @@ -95,16 +93,18 @@ impl GraphicsEditor { } } -pub(crate) fn draw_palette_preview(ui: &mut Ui, palette: &Palette, texture_id: TextureId) { +pub(crate) fn draw_palette_preview(ui: &mut Ui, palette: &Palette, texture_handle: &TextureHandle) { ui.spacing_mut().item_spacing = Vec2 { x: 0.0, y: 0.0 }; ui.horizontal(|ui| { (0..PALETTE_COLORS / ROWS_PER_PALETTE_PREVIEW).for_each(|x| { ui.vertical(|ui| { (0..ROWS_PER_PALETTE_PREVIEW).for_each(|y| { let color = palette.colors[x + (y * ROWS_PER_PALETTE_PREVIEW)]; - let image = Image::new(texture_id, Vec2 { x: 10.0, y: 10.0 }).tint( - Color32::from_rgba_unmultiplied(color.r, color.g, color.b, color.a), - ); + let image = Image::new(texture_handle) + .tint(Color32::from_rgba_unmultiplied( + color.r, color.g, color.b, color.a, + )) + .fit_to_exact_size(Vec2::new(10.0, 10.0)); ui.add(image); }); }); diff --git a/gamercade_editor/src/ui/graphics/mod.rs b/gamercade_editor/src/ui/graphics/mod.rs index 3e45bfda..730fc00a 100644 --- a/gamercade_editor/src/ui/graphics/mod.rs +++ b/gamercade_editor/src/ui/graphics/mod.rs @@ -3,7 +3,7 @@ mod palette_editor_tab; mod sprite_editor_tab; mod sprite_sheet_editor_tab; -use eframe::egui::{TextureFilter, TextureOptions}; +use eframe::egui::{TextureFilter, TextureOptions, TextureWrapMode}; pub use graphics_editor::*; pub use palette_editor_tab::*; pub use sprite_editor_tab::*; @@ -76,6 +76,7 @@ pub(crate) fn load_buffered_image<'a>( TextureOptions { magnification: TextureFilter::Nearest, minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, }, ); handle @@ -87,6 +88,7 @@ pub(crate) fn load_buffered_image<'a>( TextureOptions { magnification: TextureFilter::Nearest, minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, }, )); handle.as_ref().unwrap() diff --git a/gamercade_editor/src/ui/graphics/palette_editor_tab/color_editor.rs b/gamercade_editor/src/ui/graphics/palette_editor_tab/color_editor.rs index e88f0e1d..a60e9b99 100644 --- a/gamercade_editor/src/ui/graphics/palette_editor_tab/color_editor.rs +++ b/gamercade_editor/src/ui/graphics/palette_editor_tab/color_editor.rs @@ -1,4 +1,4 @@ -use eframe::egui::{Checkbox, Color32, Image, Slider, TextureId, Ui, Vec2}; +use eframe::egui::{Checkbox, Color32, Image, Slider, TextureHandle, Ui, Vec2}; use gamercade_core::Color; #[derive(Clone, Debug, Default)] @@ -12,7 +12,7 @@ impl ColorEditor { &mut self, ui: &mut Ui, current_color: &mut Color, - texture_id: TextureId, + texture_handle: &TextureHandle, index: usize, ) { if self.prev_color != *current_color { @@ -26,8 +26,8 @@ impl ColorEditor { ui.label(format!("Color index: {index}")); - draw_picker(ui, texture_id, "Current", false, current_color); - draw_picker(ui, texture_id, "Preview", true, &mut self.preview); + draw_picker(ui, texture_handle, "Current", false, current_color); + draw_picker(ui, texture_handle, "Preview", true, &mut self.preview); ui.horizontal(|ui| { if ui.button("Revert").clicked() { @@ -46,7 +46,7 @@ impl ColorEditor { fn draw_picker( ui: &mut Ui, - texture_id: TextureId, + texture_handle: &TextureHandle, text: &'static str, editable: bool, color: &mut Color, @@ -86,9 +86,13 @@ fn draw_picker( }); }); - ui.add(Image::new(texture_id, Vec2 { x: 64.0, y: 64.0 }).tint( - Color32::from_rgba_unmultiplied(color.r, color.g, color.b, color.a), - )); + ui.add( + Image::new(texture_handle) + .fit_to_exact_size(Vec2::new(64.0, 64.0)) + .tint(Color32::from_rgba_unmultiplied( + color.r, color.g, color.b, color.a, + )), + ); }); }); } diff --git a/gamercade_editor/src/ui/graphics/palette_editor_tab/mod.rs b/gamercade_editor/src/ui/graphics/palette_editor_tab/mod.rs index 525774a1..56d3e015 100644 --- a/gamercade_editor/src/ui/graphics/palette_editor_tab/mod.rs +++ b/gamercade_editor/src/ui/graphics/palette_editor_tab/mod.rs @@ -10,7 +10,7 @@ use palette_viewer::PaletteViewer; use sprite_preview::SpritePreview; // Externals -use eframe::egui::{SidePanel, TextureId, TopBottomPanel, Ui}; +use eframe::egui::{SidePanel, TextureHandle, TopBottomPanel, Ui}; use super::SpriteSheetEditor; use gamercade_fs::{EditorGraphicsData, EditorPalette}; @@ -30,7 +30,7 @@ impl PaletteEditor { data: &mut EditorGraphicsData, sprite_sheet_editor: &SpriteSheetEditor, scale: f32, - texture_id: TextureId, + texture_handle: &TextureHandle, ) { // Draw Palette List SidePanel::left("palette_list_left_panel") @@ -38,7 +38,7 @@ impl PaletteEditor { .show_inside(ui, |ui| { TopBottomPanel::bottom("palette_list_bottom_panel") .show_inside(ui, |ui| self.palette_list.draw_buttons(ui, data)); - self.palette_list.draw(ui, texture_id, data); + self.palette_list.draw(ui, texture_handle, data); }); // Draw Sprite Preview @@ -65,7 +65,7 @@ impl PaletteEditor { ); }); - self.draw_color_editor(ui, texture_id, palette) + self.draw_color_editor(ui, texture_handle, palette) } // Draws the right side panel which includes palette viewer, color @@ -73,16 +73,20 @@ impl PaletteEditor { fn draw_color_editor( &mut self, ui: &mut Ui, - texture_id: TextureId, + texture_handle: &TextureHandle, palette: &mut EditorPalette, ) { ui.vertical(|ui| { - self.palette_viewer.draw(ui, palette, texture_id); + self.palette_viewer.draw(ui, palette, texture_handle); ui.horizontal(|ui| { let color = self.palette_viewer.get_color_mut(&mut palette.palette); - self.color_editor - .draw(ui, color, texture_id, self.palette_viewer.selected_color); + self.color_editor.draw( + ui, + color, + texture_handle, + self.palette_viewer.selected_color, + ); }); }); } diff --git a/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_list.rs b/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_list.rs index 0dca8ee0..27d4b939 100644 --- a/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_list.rs +++ b/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_list.rs @@ -1,5 +1,5 @@ use crate::ui::{draw_palette_preview, import_image_dialog}; -use eframe::egui::{ScrollArea, TextureId, Ui}; +use eframe::egui::{ScrollArea, TextureHandle, Ui}; use gamercade_core::{Color, Palette, PALETTE_COLORS}; use gamercade_fs::{EditorGraphicsData, EditorPalette}; use hashbrown::HashSet; @@ -15,7 +15,7 @@ impl PaletteList { pub(crate) fn draw( &mut self, ui: &mut Ui, - texture_id: TextureId, + texture_handle: &TextureHandle, data: &mut EditorGraphicsData, ) { ui.vertical(|ui| { @@ -37,7 +37,7 @@ impl PaletteList { }; // Draws the palette preview - draw_palette_preview(ui, &palette.palette, texture_id); + draw_palette_preview(ui, &palette.palette, texture_handle); }); }); }) diff --git a/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_viewer.rs b/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_viewer.rs index 8b6035ac..0f3751a4 100644 --- a/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_viewer.rs +++ b/gamercade_editor/src/ui/graphics/palette_editor_tab/palette_viewer.rs @@ -1,4 +1,4 @@ -use eframe::egui::{Color32, ImageButton, TextureId, Ui, Vec2}; +use eframe::egui::{Color32, Image, ImageButton, TextureHandle, Ui, Vec2}; use gamercade_core::{Color, Palette, PALETTE_COLORS}; use gamercade_fs::EditorPalette; @@ -13,7 +13,7 @@ impl PaletteViewer { &mut self, ui: &mut Ui, palette: &mut EditorPalette, - palette_texture: TextureId, + palette_texture: &TextureHandle, ) { ui.group(|ui| { ui.label("Palette Viewer"); @@ -33,12 +33,16 @@ impl PaletteViewer { let index = x + (y * 8); let selected = index == self.selected_color; let color = palette.colors[index]; - let image_button = - ImageButton::new(palette_texture, Vec2 { x: 24.0, y: 24.0 }) - .selected(selected) - .tint(Color32::from_rgba_unmultiplied( - color.r, color.g, color.b, color.a, - )); + let image_button = ImageButton::new( + Image::new(palette_texture) + .fit_to_exact_size(Vec2::new(24.0, 24.0)), + ) + .selected(selected) + .tint( + Color32::from_rgba_unmultiplied( + color.r, color.g, color.b, color.a, + ), + ); if ui.add(image_button).clicked() { self.selected_color = index }; diff --git a/gamercade_editor/src/ui/graphics/palette_editor_tab/sprite_preview.rs b/gamercade_editor/src/ui/graphics/palette_editor_tab/sprite_preview.rs index 99785bef..c67330de 100644 --- a/gamercade_editor/src/ui/graphics/palette_editor_tab/sprite_preview.rs +++ b/gamercade_editor/src/ui/graphics/palette_editor_tab/sprite_preview.rs @@ -97,13 +97,10 @@ fn add_image( ui.push_id(entry.label, |ui| { ScrollArea::both().show(ui, |ui| { - ui.add(Image::new( - image, - Vec2 { - x: sheet.width as f32 * scale, - y: sheet.height as f32 * scale, - }, - )); + ui.add(Image::new(image).fit_to_exact_size(Vec2 { + x: sheet.width as f32 * scale, + y: sheet.height as f32 * scale, + })); }); }); }); diff --git a/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/mod.rs b/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/mod.rs index 1dfa832a..a6609ec0 100644 --- a/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/mod.rs +++ b/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/mod.rs @@ -15,7 +15,7 @@ use sheet_list::SheetList; use sheet_settings::SheetSettings; // Externals -use eframe::egui::{TextEdit, TextureId, Ui}; +use eframe::egui::{TextEdit, TextureHandle, Ui}; use super::PaletteEditor; use gamercade_fs::EditorGraphicsData; @@ -35,7 +35,7 @@ impl SpriteSheetEditor { data: &mut EditorGraphicsData, palette_editor: &mut PaletteEditor, scale: f32, - texture_id: TextureId, + texture_handle: &TextureHandle, ) { ui.horizontal(|ui| { let selected_palette = palette_editor.selected_palette_mut(); @@ -49,7 +49,7 @@ impl SpriteSheetEditor { self.editor .draw(ui, &mut sheet.sprite_sheet, scale, palette); self.palette_preview - .draw(ui, &data.palettes, selected_palette, texture_id); + .draw(ui, &data.palettes, selected_palette, texture_handle); }); }); } diff --git a/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/palette_preview.rs b/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/palette_preview.rs index 16d09d08..5bc357fd 100644 --- a/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/palette_preview.rs +++ b/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/palette_preview.rs @@ -1,4 +1,4 @@ -use eframe::egui::{TextureId, Ui}; +use eframe::egui::{TextureHandle, Ui}; use crate::ui::draw_palette_preview; use gamercade_fs::EditorPalette; @@ -12,14 +12,14 @@ impl PalettePreview { ui: &mut Ui, palettes: &[EditorPalette], selected_palette: &mut usize, - texture_id: TextureId, + texture_handle: &TextureHandle, ) { ui.group(|ui| { ui.label("Palette Previewer"); ui.horizontal(|ui| { palettes.iter().enumerate().for_each(|(index, palette)| { - draw_preview(ui, index, palette, selected_palette, texture_id) + draw_preview(ui, index, palette, selected_palette, texture_handle) }); }) }); @@ -31,12 +31,12 @@ fn draw_preview( index: usize, palette: &EditorPalette, selected_palette: &mut usize, - texture_id: TextureId, + texture_handle: &TextureHandle, ) { // TODO: Make this whole thing clickable ui.vertical(|ui| { ui.selectable_value(selected_palette, index, &palette.name); - draw_palette_preview(ui, &palette.palette, texture_id); + draw_palette_preview(ui, &palette.palette, texture_handle); }); } diff --git a/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/sheet_editor.rs b/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/sheet_editor.rs index 84d7f912..20344f95 100644 --- a/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/sheet_editor.rs +++ b/gamercade_editor/src/ui/graphics/sprite_sheet_editor_tab/sheet_editor.rs @@ -1,6 +1,6 @@ use eframe::egui::{ - self, ColorImage, ImageButton, ScrollArea, TextureFilter, TextureHandle, TextureOptions, Ui, - Vec2, + self, ColorImage, Image, ImageButton, ScrollArea, TextureFilter, TextureHandle, TextureOptions, + TextureWrapMode, Ui, Vec2, }; use super::palette_to_map; @@ -58,6 +58,7 @@ impl SheetEditor { TextureOptions { magnification: TextureFilter::Nearest, minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, }, ); handle @@ -69,20 +70,19 @@ impl SheetEditor { TextureOptions { magnification: TextureFilter::Nearest, minification: TextureFilter::Nearest, + wrap_mode: TextureWrapMode::ClampToEdge, }, )); &mut self.texture_handles[index.0 as usize] } }; - let button = ImageButton::new( - image, - Vec2 { + let button = + ImageButton::new(Image::new(&*image).fit_to_exact_size(Vec2 { x: sheet.width as f32 * scale, y: sheet.height as f32 * scale, - }, - ) - .selected(self.selected_sprite == index); + })) + .selected(self.selected_sprite == index); if ui.add(button).clicked() { self.selected_sprite = index;