Update to egui 0.22
This commit is contained in:
parent
07a310f778
commit
eb968ba446
65
Cargo.lock
generated
65
Cargo.lock
generated
|
@ -57,7 +57,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
|
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"getrandom 0.2.9",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
@ -414,7 +413,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "baseview"
|
name = "baseview"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
|
@ -432,7 +431,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "baseview"
|
name = "baseview"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
|
@ -1215,10 +1214,19 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui"
|
name = "ecolor"
|
||||||
version = "0.19.0"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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 = [
|
dependencies = [
|
||||||
"ahash 0.8.3",
|
"ahash 0.8.3",
|
||||||
"epaint",
|
"epaint",
|
||||||
|
@ -1228,9 +1236,9 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui-baseview"
|
name = "egui-baseview"
|
||||||
version = "0.1.0"
|
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 = [
|
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",
|
"copypasta 0.8.2",
|
||||||
"egui",
|
"egui",
|
||||||
"egui_glow",
|
"egui_glow",
|
||||||
|
@ -1240,15 +1248,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui_glow"
|
name = "egui_glow"
|
||||||
version = "0.19.0"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad77d4a00402bae9658ee64be148f4b2a0b38e4fc7874970575ca01ed1c5b75d"
|
checksum = "1f8c2752cdf1b0ef5fcda59a898cacabad974d4f5880e92a420b2c917022da64"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"egui",
|
"egui",
|
||||||
"glow 0.11.2",
|
"glow 0.12.1",
|
||||||
|
"log",
|
||||||
"memoffset 0.6.5",
|
"memoffset 0.6.5",
|
||||||
"tracing",
|
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
@ -1261,23 +1269,24 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "emath"
|
name = "emath"
|
||||||
version = "0.19.0"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9542a40106fdba943a055f418d1746a050e1a903a049b030c2b097d4686a33cf"
|
checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epaint"
|
name = "epaint"
|
||||||
version = "0.19.0"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5ba04741be7f6602b1a1b28f1082cce45948a7032961c52814f8946b28493300"
|
checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ab_glyph",
|
"ab_glyph",
|
||||||
"ahash 0.8.3",
|
"ahash 0.8.3",
|
||||||
"atomic_refcell",
|
"atomic_refcell",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
"ecolor",
|
||||||
"emath",
|
"emath",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
|
@ -2531,7 +2540,7 @@ dependencies = [
|
||||||
"atomic_float",
|
"atomic_float",
|
||||||
"atomic_refcell",
|
"atomic_refcell",
|
||||||
"backtrace",
|
"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",
|
"bitflags",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -2578,7 +2587,7 @@ dependencies = [
|
||||||
name = "nih_plug_egui"
|
name = "nih_plug_egui"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
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",
|
"crossbeam",
|
||||||
"egui",
|
"egui",
|
||||||
"egui-baseview",
|
"egui-baseview",
|
||||||
|
@ -4053,26 +4062,6 @@ dependencies = [
|
||||||
"winnow",
|
"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]]
|
[[package]]
|
||||||
name = "transpose"
|
name = "transpose"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
|
@ -100,7 +100,7 @@ assert_no_alloc = { git = "https://github.com/robbert-vdh/rust-assert-no-alloc.g
|
||||||
# Used for the `standalone` feature
|
# Used for the `standalone` feature
|
||||||
# NOTE: OpenGL support is not needed here, but rust-analyzer gets confused when
|
# NOTE: OpenGL support is not needed here, but rust-analyzer gets confused when
|
||||||
# some crates do use it and others don't
|
# 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!
|
# All the claps!
|
||||||
clap = { version = "4.1.8", features = ["derive", "wrap_help"], optional = true }
|
clap = { version = "4.1.8", features = ["derive", "wrap_help"], optional = true }
|
||||||
cpal = { version = "0.15", optional = true }
|
cpal = { version = "0.15", optional = true }
|
||||||
|
|
|
@ -19,12 +19,12 @@ opengl = []
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nih_plug = { path = ".." }
|
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"
|
crossbeam = "0.8"
|
||||||
# The `egui-default-features` feature enables the default features. This makes
|
# The `egui-default-features` feature enables the default features. This makes
|
||||||
# it possible to opt out of this if needed.
|
# it possible to opt out of this if needed.
|
||||||
egui = { version = "0.19", default-features = false }
|
egui = { version = "0.22", default-features = false }
|
||||||
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "46e21cc11c57c705fb83611389399ec3d2670a44" }
|
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "27c027c22a83d2eb214074f922ba4115f712e483" }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
# To make the state persistable
|
# To make the state persistable
|
||||||
|
|
|
@ -79,20 +79,20 @@ impl<'a, P: Param> ParamSlider<'a, P> {
|
||||||
|
|
||||||
/// Enable the keyboard entry part of the widget.
|
/// Enable the keyboard entry part of the widget.
|
||||||
fn begin_keyboard_entry(&self, ui: &Ui) {
|
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
|
// Always initialize the field to the current value, that seems nicer than having to
|
||||||
// being typing from scratch
|
// being typing from scratch
|
||||||
let value_entry_mutex = ui
|
let value_entry_mutex = ui.memory_mut(|mem| {
|
||||||
.memory()
|
mem.data
|
||||||
.data
|
|
||||||
.get_temp_mut_or_default::<Arc<Mutex<String>>>(*VALUE_ENTRY_MEMORY_ID)
|
.get_temp_mut_or_default::<Arc<Mutex<String>>>(*VALUE_ENTRY_MEMORY_ID)
|
||||||
.clone();
|
.clone()
|
||||||
|
});
|
||||||
*value_entry_mutex.lock() = self.string_value();
|
*value_entry_mutex.lock() = self.string_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keyboard_entry_active(&self, ui: &Ui) -> bool {
|
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) {
|
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 {
|
fn get_drag_normalized_start_value_memory(ui: &Ui) -> f32 {
|
||||||
ui.memory()
|
ui.memory(|mem| {
|
||||||
.data
|
mem.data
|
||||||
.get_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID)
|
.get_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID)
|
||||||
.unwrap_or(0.5)
|
.unwrap_or(0.5)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_drag_normalized_start_value_memory(ui: &Ui, amount: f32) {
|
fn set_drag_normalized_start_value_memory(ui: &Ui, amount: f32) {
|
||||||
ui.memory()
|
ui.memory_mut(|mem| {
|
||||||
.data
|
mem.data
|
||||||
.insert_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID, amount);
|
.insert_temp(*DRAG_NORMALIZED_START_VALUE_MEMORY_ID, amount)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_drag_amount_memory(ui: &Ui) -> f32 {
|
fn get_drag_amount_memory(ui: &Ui) -> f32 {
|
||||||
ui.memory()
|
ui.memory(|mem| mem.data.get_temp(*DRAG_AMOUNT_MEMORY_ID).unwrap_or(0.0))
|
||||||
.data
|
|
||||||
.get_temp(*DRAG_AMOUNT_MEMORY_ID)
|
|
||||||
.unwrap_or(0.0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_drag_amount_memory(ui: &Ui, amount: f32) {
|
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) {
|
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);
|
Self::set_drag_amount_memory(ui, 0.0);
|
||||||
}
|
}
|
||||||
if let Some(click_pos) = response.interact_pointer_pos() {
|
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
|
// Like double clicking, Ctrl+Click should reset the parameter
|
||||||
self.reset_param();
|
self.reset_param();
|
||||||
response.mark_changed();
|
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
|
// // 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.
|
// // value field, so it only makes sense when we're drawing that.
|
||||||
// self.begin_keyboard_entry(ui);
|
// 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
|
// And shift dragging should switch to a more granulra input method
|
||||||
self.granular_drag(ui, response.drag_delta());
|
self.granular_drag(ui, response.drag_delta());
|
||||||
response.mark_changed();
|
response.mark_changed();
|
||||||
|
@ -250,11 +249,11 @@ impl<'a, P: Param> ParamSlider<'a, P> {
|
||||||
// has been clicked on
|
// has been clicked on
|
||||||
let keyboard_focus_id = self.keyboard_focus_id.unwrap();
|
let keyboard_focus_id = self.keyboard_focus_id.unwrap();
|
||||||
if self.keyboard_entry_active(ui) {
|
if self.keyboard_entry_active(ui) {
|
||||||
let value_entry_mutex = ui
|
let value_entry_mutex = ui.memory_mut(|mem| {
|
||||||
.memory()
|
mem.data
|
||||||
.data
|
|
||||||
.get_temp_mut_or_default::<Arc<Mutex<String>>>(*VALUE_ENTRY_MEMORY_ID)
|
.get_temp_mut_or_default::<Arc<Mutex<String>>>(*VALUE_ENTRY_MEMORY_ID)
|
||||||
.clone();
|
.clone()
|
||||||
|
});
|
||||||
let mut value_entry = value_entry_mutex.lock();
|
let mut value_entry = value_entry_mutex.lock();
|
||||||
|
|
||||||
ui.add(
|
ui.add(
|
||||||
|
@ -262,16 +261,16 @@ impl<'a, P: Param> ParamSlider<'a, P> {
|
||||||
.id(keyboard_focus_id)
|
.id(keyboard_focus_id)
|
||||||
.font(TextStyle::Monospace),
|
.font(TextStyle::Monospace),
|
||||||
);
|
);
|
||||||
if ui.input().key_pressed(Key::Escape) {
|
if ui.input(|i| i.key_pressed(Key::Escape)) {
|
||||||
// Cancel when pressing escape
|
// Cancel when pressing escape
|
||||||
ui.memory().surrender_focus(keyboard_focus_id);
|
ui.memory_mut(|mem| mem.surrender_focus(keyboard_focus_id));
|
||||||
} else if ui.input().key_pressed(Key::Enter) {
|
} else if ui.input(|i| i.key_pressed(Key::Enter)) {
|
||||||
// And try to set the value by string when pressing enter
|
// And try to set the value by string when pressing enter
|
||||||
self.begin_drag();
|
self.begin_drag();
|
||||||
self.set_from_string(&value_entry);
|
self.set_from_string(&value_entry);
|
||||||
self.end_drag();
|
self.end_drag();
|
||||||
|
|
||||||
ui.memory().surrender_focus(keyboard_focus_id);
|
ui.memory_mut(|mem| mem.surrender_focus(keyboard_focus_id));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let text = WidgetText::from(self.string_value()).into_galley(
|
let text = WidgetText::from(self.string_value()).into_galley(
|
||||||
|
|
|
@ -4,7 +4,7 @@ use egui::Color32;
|
||||||
|
|
||||||
/// Additively modify the hue, saturation, and lightness [0, 1] values of a color.
|
/// 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 {
|
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.h += h;
|
||||||
hsv.s += s;
|
hsv.s += s;
|
||||||
hsv.v += v;
|
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.
|
/// 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 {
|
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.h *= h;
|
||||||
hsv.s *= s;
|
hsv.s *= s;
|
||||||
hsv.v *= v;
|
hsv.v *= v;
|
||||||
|
|
Loading…
Reference in a new issue