1
0
Fork 0

Update to egui 0.17

This commit is contained in:
Robbert van der Helm 2022-02-27 16:49:18 +01:00
parent b40c43a862
commit 07d8f81f44
4 changed files with 31 additions and 32 deletions

38
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "ab_glyph"
version = "0.2.13"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61caed9aec6daeee1ea38ccf5fb225e4f96c1eeead1b4a5c267324a63cf02326"
checksum = "d54a65e0d4f66f8536c98cb3ca81ca33b7e2ca43442465507a3a62291ec0d9e4"
dependencies = [
"ab_glyph_rasterizer",
"owned_ttf_parser",
@ -31,9 +31,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.53"
version = "1.0.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
[[package]]
name = "assert_no_alloc"
@ -296,9 +296,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "egui"
version = "0.16.1"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c733356eb5f1139fdeedc370c00e9ea689c5d9120502c43925285bc7249a333"
checksum = "0a3cd1d47e12f7a17912595241622e373aa652a4e0fa90b3f9278f90a64aedf7"
dependencies = [
"ahash",
"epaint",
@ -308,7 +308,7 @@ dependencies = [
[[package]]
name = "egui-baseview"
version = "0.0.0"
source = "git+https://github.com/robbert-vdh/egui-baseview.git?branch=fix/update-dependencies#3893ef0e369fc64170c1cc1f37426809d81da31b"
source = "git+https://github.com/robbert-vdh/egui-baseview.git?branch=fix/update-dependencies#afde9c661809ee08d69864caa899246592d93f8c"
dependencies = [
"baseview",
"copypasta",
@ -320,15 +320,15 @@ dependencies = [
[[package]]
name = "emath"
version = "0.16.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55673de2eb96660dde25ba7b2d36a7054beead1a2bec74dcfd5eb05a1e1ba76d"
checksum = "a977a80456be58a2c2d48e69c1d0baadef46cecef5a0c98df141c468da006f12"
[[package]]
name = "epaint"
version = "0.16.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adfd9296f7f92902e41c0e8e5deca6d2fb29f289c86d03a01ea01bd7498316c2"
checksum = "033292846059f08e03a71e1b5db2ee6ab7c9622c3b48da21f4bd13258ebee2db"
dependencies = [
"ab_glyph",
"ahash",
@ -371,9 +371,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.4"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
dependencies = [
"cfg-if",
"libc",
@ -446,9 +446,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.118"
version = "0.2.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94"
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
[[package]]
name = "libloading"
@ -630,9 +630,9 @@ checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "owned_ttf_parser"
version = "0.14.0"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef05f2882a8b3e7acc10c153ade2631f7bfc8ce00d2bf3fb8f4e9d2ae6ea5c3"
checksum = "4fb1e509cfe7a12db2a90bfa057dfcdbc55a347f5da677c506b53dd099cfec9d"
dependencies = [
"ttf-parser",
]
@ -868,9 +868,9 @@ dependencies = [
[[package]]
name = "ttf-parser"
version = "0.14.0"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ccbe8381883510b6a2d8f1e32905bddd178c11caef8083086d0c0c9ab0ac281"
checksum = "c74c96594835e10fa545e2a51e8709f30b173a092bfd6036ef2cec53376244f3"
[[package]]
name = "unicode-xid"

View file

@ -12,7 +12,7 @@ nih_plug = { path = ".." }
baseview = { git = "https://github.com/robbert-vdh/baseview.git", branch = "feature/mouse-event-modifiers" }
crossbeam = "0.8"
egui = "0.16"
egui = "0.17"
# Upstream doesn't work with the current baseview and egui versions
egui-baseview = { git = "https://github.com/robbert-vdh/egui-baseview.git", branch = "fix/update-dependencies" }
lazy_static = "1.4"

View file

@ -5,7 +5,7 @@
use baseview::gl::GlConfig;
use baseview::{Size, WindowHandle, WindowOpenOptions, WindowScalePolicy};
use crossbeam::atomic::AtomicCell;
use egui::CtxRef;
use egui::Context;
use egui_baseview::EguiWindow;
use nih_plug::{Editor, ParamSetter, ParentWindowHandle};
use parking_lot::RwLock;
@ -35,7 +35,7 @@ pub fn create_egui_editor<T, U>(
) -> Option<Box<dyn Editor>>
where
T: 'static + Send + Sync,
U: Fn(&CtxRef, &ParamSetter, &mut T) + 'static + Send + Sync,
U: Fn(&Context, &ParamSetter, &mut T) + 'static + Send + Sync,
{
Some(Box::new(EguiEditor {
egui_state,
@ -77,7 +77,7 @@ struct EguiEditor<T> {
egui_state: Arc<EguiState>,
/// The plugin's state. This is kept in between editor openenings.
user_state: Arc<RwLock<T>>,
update: Arc<dyn Fn(&CtxRef, &ParamSetter, &mut T) + 'static + Send + Sync>,
update: Arc<dyn Fn(&Context, &ParamSetter, &mut T) + 'static + Send + Sync>,
}
impl<T> Editor for EguiEditor<T>

View file

@ -1,4 +1,4 @@
use egui::{vec2, Response, Sense, Stroke, TextStyle, Ui, Vec2, Widget};
use egui::{vec2, Response, Sense, Stroke, TextStyle, Ui, Vec2, Widget, WidgetText};
use lazy_static::lazy_static;
use super::util;
@ -181,11 +181,11 @@ impl<'a, P: Param> ParamSlider<'a, P> {
let should_draw_frame = ui.visuals().button_frame;
let padding = ui.spacing().button_padding;
let text = ui.painter().layout(
format!("{}", self.param),
TextStyle::Button,
visuals.text_color(),
let text = WidgetText::from(format!("{}", self.param)).into_galley(
ui,
None,
ui.available_width() - (padding.x * 2.0),
TextStyle::Button,
);
let (_, rect) = ui.allocate_space(text.size() + (padding * 2.0));
@ -195,7 +195,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
let stroke = visuals.bg_stroke;
ui.painter().rect(
rect.expand(visuals.expansion),
visuals.corner_radius,
visuals.rounding,
fill,
stroke,
);
@ -205,7 +205,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
.layout()
.align_size_within_rect(text.size(), rect.shrink2(padding))
.min;
ui.painter().galley(text_pos, text);
text.paint_with_visuals(ui.painter(), text_pos, &visuals);
}
}
}
@ -215,8 +215,7 @@ impl<P: Param> Widget for ParamSlider<'_, P> {
ui.horizontal(|ui| {
// Allocate space, but add some padding on the top and bottom to make it look a bit slimmer.
let height = ui
.fonts()
.row_height(TextStyle::Body)
.text_style_height(&TextStyle::Body)
.max(ui.spacing().interact_size.y);
let slider_height = ui.painter().round_to_pixel(height * 0.65);
let response = ui