1
0
Fork 0

Update to egui 0.22

This commit is contained in:
dzil123 2023-08-14 21:39:44 -07:00 committed by Robbert van der Helm
parent 07a310f778
commit eb968ba446
5 changed files with 62 additions and 74 deletions

65
Cargo.lock generated
View file

@ -57,7 +57,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [
"cfg-if 1.0.0",
"getrandom 0.2.9",
"once_cell",
"version_check",
]
@ -414,7 +413,7 @@ dependencies = [
[[package]]
name = "baseview"
version = "0.1.0"
source = "git+https://github.com/RustAudio/baseview.git?rev=7001c2521fa1a439a01967cb881b411cd75d9ee0#7001c2521fa1a439a01967cb881b411cd75d9ee0"
source = "git+https://github.com/RustAudio/baseview.git?rev=1d9806d5bd92275d0d8142d9c9c90198757b9b25#1d9806d5bd92275d0d8142d9c9c90198757b9b25"
dependencies = [
"cocoa",
"core-foundation",
@ -432,7 +431,7 @@ dependencies = [
[[package]]
name = "baseview"
version = "0.1.0"
source = "git+https://github.com/RustAudio/baseview.git?rev=eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c#eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c"
source = "git+https://github.com/RustAudio/baseview.git?rev=7001c2521fa1a439a01967cb881b411cd75d9ee0#7001c2521fa1a439a01967cb881b411cd75d9ee0"
dependencies = [
"cocoa",
"core-foundation",
@ -1215,10 +1214,19 @@ dependencies = [
]
[[package]]
name = "egui"
version = "0.19.0"
name = "ecolor"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc9fcd393c3daaaf5909008a1d948319d538b79c51871e4df0993260260a94e4"
checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63"
dependencies = [
"bytemuck",
]
[[package]]
name = "egui"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7"
dependencies = [
"ahash 0.8.3",
"epaint",
@ -1228,9 +1236,9 @@ dependencies = [
[[package]]
name = "egui-baseview"
version = "0.1.0"
source = "git+https://github.com/BillyDM/egui-baseview.git?rev=46e21cc11c57c705fb83611389399ec3d2670a44#46e21cc11c57c705fb83611389399ec3d2670a44"
source = "git+https://github.com/BillyDM/egui-baseview.git?rev=27c027c22a83d2eb214074f922ba4115f712e483#27c027c22a83d2eb214074f922ba4115f712e483"
dependencies = [
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c)",
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=1d9806d5bd92275d0d8142d9c9c90198757b9b25)",
"copypasta 0.8.2",
"egui",
"egui_glow",
@ -1240,15 +1248,15 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad77d4a00402bae9658ee64be148f4b2a0b38e4fc7874970575ca01ed1c5b75d"
checksum = "1f8c2752cdf1b0ef5fcda59a898cacabad974d4f5880e92a420b2c917022da64"
dependencies = [
"bytemuck",
"egui",
"glow 0.11.2",
"glow 0.12.1",
"log",
"memoffset 0.6.5",
"tracing",
"wasm-bindgen",
"web-sys",
]
@ -1261,23 +1269,24 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "emath"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9542a40106fdba943a055f418d1746a050e1a903a049b030c2b097d4686a33cf"
checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b"
dependencies = [
"bytemuck",
]
[[package]]
name = "epaint"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ba04741be7f6602b1a1b28f1082cce45948a7032961c52814f8946b28493300"
checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b"
dependencies = [
"ab_glyph",
"ahash 0.8.3",
"atomic_refcell",
"bytemuck",
"ecolor",
"emath",
"nohash-hasher",
"parking_lot 0.12.1",
@ -2531,7 +2540,7 @@ dependencies = [
"atomic_float",
"atomic_refcell",
"backtrace",
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=7001c2521fa1a439a01967cb881b411cd75d9ee0)",
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=1d9806d5bd92275d0d8142d9c9c90198757b9b25)",
"bitflags",
"cfg-if 1.0.0",
"clap",
@ -2578,7 +2587,7 @@ dependencies = [
name = "nih_plug_egui"
version = "0.0.0"
dependencies = [
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c)",
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=1d9806d5bd92275d0d8142d9c9c90198757b9b25)",
"crossbeam",
"egui",
"egui-baseview",
@ -4053,26 +4062,6 @@ dependencies = [
"winnow",
]
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite",
"tracing-core",
]
[[package]]
name = "tracing-core"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
dependencies = [
"once_cell",
]
[[package]]
name = "transpose"
version = "0.2.2"

View file

@ -100,7 +100,7 @@ assert_no_alloc = { git = "https://github.com/robbert-vdh/rust-assert-no-alloc.g
# Used for the `standalone` feature
# NOTE: OpenGL support is not needed here, but rust-analyzer gets confused when
# some crates do use it and others don't
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "7001c2521fa1a439a01967cb881b411cd75d9ee0", features = ["opengl"], optional = true }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "1d9806d5bd92275d0d8142d9c9c90198757b9b25", features = ["opengl"], optional = true }
# All the claps!
clap = { version = "4.1.8", features = ["derive", "wrap_help"], optional = true }
cpal = { version = "0.15", optional = true }

View file

@ -19,12 +19,12 @@ opengl = []
[dependencies]
nih_plug = { path = ".." }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c" }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "1d9806d5bd92275d0d8142d9c9c90198757b9b25" }
crossbeam = "0.8"
# The `egui-default-features` feature enables the default features. This makes
# it possible to opt out of this if needed.
egui = { version = "0.19", default-features = false }
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "46e21cc11c57c705fb83611389399ec3d2670a44" }
egui = { version = "0.22", default-features = false }
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "27c027c22a83d2eb214074f922ba4115f712e483" }
lazy_static = "1.4"
parking_lot = "0.12"
# To make the state persistable

View file

@ -79,20 +79,20 @@ impl<'a, P: Param> ParamSlider<'a, P> {
/// Enable the keyboard entry part of the widget.
fn begin_keyboard_entry(&self, ui: &Ui) {
ui.memory().request_focus(self.keyboard_focus_id.unwrap());
ui.memory_mut(|mem| mem.request_focus(self.keyboard_focus_id.unwrap()));
// Always initialize the field to the current value, that seems nicer than having to
// being typing from scratch
let value_entry_mutex = ui
.memory()
.data
let value_entry_mutex = ui.memory_mut(|mem| {
mem.data
.get_temp_mut_or_default::<Arc<Mutex<String>>>(*VALUE_ENTRY_MEMORY_ID)
.clone();
.clone()
});
*value_entry_mutex.lock() = self.string_value();
}
fn keyboard_entry_active(&self, ui: &Ui) -> bool {
ui.memory().has_focus(self.keyboard_focus_id.unwrap())
ui.memory(|mem| mem.has_focus(self.keyboard_focus_id.unwrap()))
}
fn begin_drag(&self) {
@ -151,27 +151,26 @@ impl<'a, P: Param> ParamSlider<'a, P> {
}
fn get_drag_normalized_start_value_memory(ui: &Ui) -> f32 {
ui.memory()
.data
ui.memory(|mem| {
mem.data
.get_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID)
.unwrap_or(0.5)
})
}
fn set_drag_normalized_start_value_memory(ui: &Ui, amount: f32) {
ui.memory()
.data
.insert_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID, amount);
ui.memory_mut(|mem| {
mem.data
.insert_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID, amount)
});
}
fn get_drag_amount_memory(ui: &Ui) -> f32 {
ui.memory()
.data
.get_temp(*DRAG_AMOUNT_MEMORY_ID)
.unwrap_or(0.0)
ui.memory(|mem| mem.data.get_temp(*DRAG_AMOUNT_MEMORY_ID).unwrap_or(0.0))
}
fn set_drag_amount_memory(ui: &Ui, amount: f32) {
ui.memory().data.insert_temp(*DRAG_AMOUNT_MEMORY_ID, amount);
ui.memory_mut(|mem| mem.data.insert_temp(*DRAG_AMOUNT_MEMORY_ID, amount));
}
fn slider_ui(&self, ui: &mut Ui, response: &mut Response) {
@ -184,7 +183,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
Self::set_drag_amount_memory(ui, 0.0);
}
if let Some(click_pos) = response.interact_pointer_pos() {
if ui.input().modifiers.command {
if ui.input(|i| i.modifiers.command) {
// Like double clicking, Ctrl+Click should reset the parameter
self.reset_param();
response.mark_changed();
@ -194,7 +193,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
// // Allow typing in the value on an Alt+Click. Right now this is shown as part of the
// // value field, so it only makes sense when we're drawing that.
// self.begin_keyboard_entry(ui);
} else if ui.input().modifiers.shift {
} else if ui.input(|i| i.modifiers.shift) {
// And shift dragging should switch to a more granulra input method
self.granular_drag(ui, response.drag_delta());
response.mark_changed();
@ -250,11 +249,11 @@ impl<'a, P: Param> ParamSlider<'a, P> {
// has been clicked on
let keyboard_focus_id = self.keyboard_focus_id.unwrap();
if self.keyboard_entry_active(ui) {
let value_entry_mutex = ui
.memory()
.data
let value_entry_mutex = ui.memory_mut(|mem| {
mem.data
.get_temp_mut_or_default::<Arc<Mutex<String>>>(*VALUE_ENTRY_MEMORY_ID)
.clone();
.clone()
});
let mut value_entry = value_entry_mutex.lock();
ui.add(
@ -262,16 +261,16 @@ impl<'a, P: Param> ParamSlider<'a, P> {
.id(keyboard_focus_id)
.font(TextStyle::Monospace),
);
if ui.input().key_pressed(Key::Escape) {
if ui.input(|i| i.key_pressed(Key::Escape)) {
// Cancel when pressing escape
ui.memory().surrender_focus(keyboard_focus_id);
} else if ui.input().key_pressed(Key::Enter) {
ui.memory_mut(|mem| mem.surrender_focus(keyboard_focus_id));
} else if ui.input(|i| i.key_pressed(Key::Enter)) {
// And try to set the value by string when pressing enter
self.begin_drag();
self.set_from_string(&value_entry);
self.end_drag();
ui.memory().surrender_focus(keyboard_focus_id);
ui.memory_mut(|mem| mem.surrender_focus(keyboard_focus_id));
}
} else {
let text = WidgetText::from(self.string_value()).into_galley(

View file

@ -4,7 +4,7 @@ use egui::Color32;
/// Additively modify the hue, saturation, and lightness [0, 1] values of a color.
pub fn add_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 {
let mut hsv = egui::color::Hsva::from(color);
let mut hsv = egui::epaint::Hsva::from(color);
hsv.h += h;
hsv.s += s;
hsv.v += v;
@ -13,7 +13,7 @@ pub fn add_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 {
/// Multiplicatively modify the hue, saturation, and lightness [0, 1] values of a color.
pub fn scale_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 {
let mut hsv = egui::color::Hsva::from(color);
let mut hsv = egui::epaint::Hsva::from(color);
hsv.h *= h;
hsv.s *= s;
hsv.v *= v;