Skip to content

Commit e59d58c

Browse files
authored
Upgrade egui to 0.32 (#244)
### Checklist * [x] I have read the [Contributor Guide](../CONTRIBUTING.md) * [x] I have read and agree to the [Code of Conduct](../CODE_OF_CONDUCT.md) * [x] I have added a description of my changes and why I'd like them included in the section below ### Description of Changes Updated egui to 0.32 and fixed clippy warnings.
1 parent b2e556e commit e59d58c

File tree

10 files changed

+675
-677
lines changed

10 files changed

+675
-677
lines changed

Cargo.lock

Lines changed: 631 additions & 635 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ if_let_mutex = "warn"
8383
implicit_clone = "warn"
8484
implied_bounds_in_impls = "warn"
8585
imprecise_flops = "warn"
86+
indexing_slicing = "warn"
8687
index_refutable_slice = "warn"
8788
inefficient_to_string = "warn"
8889
infinite_loop = "warn"
@@ -119,12 +120,10 @@ map_err_ignore = "warn"
119120
map_flatten = "warn"
120121
map_unwrap_or = "warn"
121122
match_bool = "warn"
122-
match_on_vec_items = "warn"
123123
match_same_arms = "warn"
124124
match_wild_err_arm = "warn"
125125
match_wildcard_for_single_variants = "warn"
126126
mem_forget = "warn"
127-
mismatched_target_os = "warn"
128127
mismatching_type_param_order = "warn"
129128
missing_assert_message = "warn"
130129
missing_enforced_import_renames = "warn"

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ allow-unwrap-in-tests = true
88
disallowed-methods = [
99
# std functions
1010
{ path = "std::env::var_os", reason = "use std::env::var and UTF-8 strings instead, including for paths" },
11-
{ path = "std::env::env_os", reason = "use std::env::var and UTF-8 strings instead, including for paths" },
11+
{ path = "std::env::vars_os", reason = "use std::env::var and UTF-8 strings instead, including for paths" },
1212
{ path = "std::env::args_os", reason = "use std::env::var and UTF-8 strings instead, including for paths" },
1313
{ path = "std::env::set_var", reason = "this is unsound in (at least) glibc, and its usage in multi-threaded programs is _heavily_ discouraged" },
1414
{ path = "std::thread::spawn", reason = "spawn threads with std::thread::Builder instead to ensure they have a name specified" },

puffin_egui/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ include = [
2222
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2323

2424
[dependencies]
25-
egui = { version = "0.31.0", default-features = false }
26-
egui_extras = { version = "0.31.0", default-features = false, features = [
25+
egui = { version = "0.32.0", default-features = false }
26+
egui_extras = { version = "0.32.0", default-features = false, features = [
2727
"serde",
2828
] }
2929
indexmap = { version = "2.1.0", features = ["serde"] }
@@ -41,7 +41,7 @@ vec1 = "1.8"
4141
web-time = "0.2"
4242

4343
[dev-dependencies]
44-
eframe = { version = "0.31.0", default-features = false, features = [
44+
eframe = { version = "0.32.0", default-features = false, features = [
4545
"default_fonts",
4646
"glow",
4747
"persistence",

puffin_egui/src/flamegraph.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -781,20 +781,21 @@ fn paint_scope(
781781
log_once::warn_once!("Missing scope metadata");
782782
return Ok(PaintResult::Culled);
783783
};
784-
egui::show_tooltip_at_pointer(
785-
&info.ctx,
784+
Tooltip::always_open(
785+
info.ctx.clone(),
786786
info.layer_id,
787787
Id::new("puffin_profiler_tooltip"),
788-
|ui| {
789-
paint_scope_details(ui, scope.id, scope.record.data, scope_details);
788+
PopupAnchor::Pointer,
789+
)
790+
.show(|ui| {
791+
paint_scope_details(ui, scope.id, scope.record.data, scope_details);
790792

791-
ui.monospace(format!(
792-
"duration: {:7.3} ms",
793-
to_ms(scope.record.duration_ns)
794-
));
795-
ui.monospace(format!("children: {num_children:3}"));
796-
},
797-
);
793+
ui.monospace(format!(
794+
"duration: {:7.3} ms",
795+
to_ms(scope.record.duration_ns)
796+
));
797+
ui.monospace(format!("children: {num_children:3}"));
798+
});
798799
}
799800
}
800801

@@ -846,14 +847,15 @@ fn paint_merge_scope(
846847
}
847848

848849
if result == PaintResult::Hovered {
849-
egui::show_tooltip_at_pointer(
850-
&info.ctx,
850+
Tooltip::always_open(
851+
info.ctx.clone(),
851852
info.layer_id,
852853
Id::new("puffin_profiler_tooltip"),
853-
|ui| {
854-
merge_scope_tooltip(ui, info.scope_collection, merge, info.num_frames);
855-
},
856-
);
854+
PopupAnchor::Pointer,
855+
)
856+
.show(|ui| {
857+
merge_scope_tooltip(ui, info.scope_collection, merge, info.num_frames);
858+
});
857859
}
858860
}
859861

@@ -886,7 +888,7 @@ fn paint_scope_details(ui: &mut Ui, scope_id: ScopeId, data: &str, scope_details
886888

887889
if !data.is_empty() {
888890
ui.monospace("data");
889-
ui.monospace(egui::TextBuffer::as_str(&data));
891+
ui.monospace(data);
890892
ui.end_row();
891893
}
892894

puffin_egui/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod stats;
1818

1919
pub use {egui, maybe_mut_ref::MaybeMutRef, puffin};
2020

21-
use egui::*;
21+
use egui::{scroll_area::ScrollSource, *};
2222
use puffin::*;
2323
use std::{
2424
collections::{BTreeMap, BTreeSet},
@@ -544,9 +544,9 @@ impl ProfilerUi {
544544
let overhead_ms = num_scopes as f64 * 1.0e-6 * realistic_ns_overhead;
545545
if overhead_ms > 1.0 {
546546
let overhead = if overhead_ms < 2.0 {
547-
format!("{:.1} ms", overhead_ms)
547+
format!("{overhead_ms:.1} ms")
548548
} else {
549-
format!("{:.0} ms", overhead_ms)
549+
format!("{overhead_ms:.0} ms")
550550
};
551551

552552
let text = format!(
@@ -628,7 +628,7 @@ impl ProfilerUi {
628628
Frame::dark_canvas(ui.style()).show(ui, |ui| {
629629
egui::ScrollArea::horizontal()
630630
.stick_to_right(true)
631-
.drag_to_scroll(false)
631+
.scroll_source(ScrollSource::SCROLL_BAR | ScrollSource::MOUSE_WHEEL)
632632
.show(ui, |ui| {
633633
let slowest_visible = self.show_frame_list(
634634
ui,
@@ -750,14 +750,15 @@ impl ProfilerUi {
750750
// preview when hovering is really annoying when viewing multiple frames
751751
if is_hovered && !is_selected && !viewing_multiple_frames {
752752
*hovered_frame = Some(frame.clone());
753-
egui::show_tooltip_at_pointer(
754-
ui.ctx(),
753+
Tooltip::always_open(
754+
ui.ctx().clone(),
755755
ui.layer_id(),
756756
Id::new("puffin_frame_tooltip"),
757-
|ui| {
758-
ui.label(format!("{:.1} ms", frame.duration_ns() as f64 * 1e-6));
759-
},
760-
);
757+
PopupAnchor::Pointer,
758+
)
759+
.show(|ui| {
760+
ui.label(format!("{:.1} ms", frame.duration_ns() as f64 * 1e-6));
761+
});
761762
}
762763

763764
if response.dragged() {

puffin_http/src/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ impl Client {
4747
let _: std::thread::JoinHandle<()> = std::thread::Builder::new()
4848
.name("http_client_thread".to_owned())
4949
.spawn(move || {
50-
log::info!("Connecting to {}…", addr);
50+
log::info!("Connecting to {addr}…");
5151
while alive.load(SeqCst) {
5252
match std::net::TcpStream::connect(&addr) {
5353
Ok(mut stream) => {
5454
*frame_view.lock() = FrameView::default();
55-
log::info!("Connected to {}", addr);
55+
log::info!("Connected to {addr}");
5656
connected.store(true, SeqCst);
5757
while alive.load(SeqCst) {
5858
match consume_message(&mut stream) {
@@ -73,7 +73,7 @@ impl Client {
7373
}
7474
}
7575
Err(err) => {
76-
log::debug!("Failed to connect to {}: {}", addr, err);
76+
log::debug!("Failed to connect to {addr}: {err}");
7777
std::thread::sleep(std::time::Duration::from_secs(1));
7878
}
7979
}

puffin_http/src/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@ impl Server {
263263

264264
while let Ok(frame) = rx.recv() {
265265
if let Err(err) = server_impl.accept_new_clients() {
266-
log::warn!("puffin server failure: {}", err);
266+
log::warn!("puffin server failure: {err}");
267267
}
268268

269269
if let Err(err) = server_impl.send(&frame) {
270-
log::warn!("puffin server failure: {}", err);
270+
log::warn!("puffin server failure: {err}");
271271
}
272272
}
273273
})
@@ -345,7 +345,7 @@ impl PuffinServerImpl {
345345
.set_nonblocking(false)
346346
.context("stream.set_nonblocking")?;
347347

348-
log::info!("{} connected", client_addr);
348+
log::info!("{client_addr} connected");
349349

350350
let (packet_tx, packet_rx) = crossbeam_channel::bounded(MAX_FRAMES_IN_QUEUE);
351351

puffin_viewer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ puffin_egui = { version = "0.29.0", path = "../puffin_egui", features = [
3434
puffin_http = { version = "0.16.1", path = "../puffin_http" }
3535

3636
argh = "0.1"
37-
eframe = { version = "0.31.0", default-features = false, features = [
37+
eframe = { version = "0.32.0", default-features = false, features = [
3838
"default_fonts",
3939
"glow",
4040
"persistence",

puffin_viewer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl PuffinViewer {
153153
}
154154

155155
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
156-
egui::menu::bar(ui, |ui| {
156+
egui::MenuBar::new().ui(ui, |ui| {
157157
egui::widgets::global_theme_preference_switch(ui);
158158

159159
ui.menu_button("File", |ui| {

0 commit comments

Comments
 (0)