EmbarkStudios / puffin

🐦 Friendly little instrumentation profiler for Rust 🦀
Apache License 2.0
1.49k stars 75 forks source link

Update to egui 0.26 #188

Closed rib closed 8 months ago

rib commented 9 months ago

This updates egui and eframe to 0.26 and also bumps the version of puffin_egui to 0.26 for consistency.

emilk commented 9 months ago

Have you tested the viewer, so that one can click scopes, zoom, etc?

rib commented 9 months ago

ooh actually it looks like selecting frames isn't working as it should here. you can select a range of frames ok, but not click an individual frame. you can also start selecting a range of frames but release the mouse button with a single frame selected and that works to select a single frame, but just left clicking a frame doesn't work atm.

The other general interactions including panning and zooming seem to be working ok

rib commented 9 months ago

oh, or you can long press to select - so it looks like it's related to relying on .dragged() so I guess related to this change in egui:

commit a815923717365b2e49b18d238f5dc2b72d023ee0
Author: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Date:   Thu Jan 25 17:28:53 2024 +0100

    Improve `Response.dragged`, `drag_started` and `clicked` (#3888)

    If a widgets sense both clicks and drags, we don't know wether or not a
    mouse press on it will be a short click or a long drag.

    With this PR, `response.dragged` and `response.drag_started` isn't true
    until we know it is a drag and not a click.
    If the widget ONLY senses drags, then we know as soon as someone presses
    on it that it is a drag.
    If it is sensitive to both clicks and drags, we don't know until the
    mouse moves a bit, or stays pressed down long enough.

    This PR also ensures that `response.clicked` and is only true for
    widgets that senses clicks.

maybe we can ensure that the frames are only sensitive to drag.

rib commented 9 months ago

okey yeah this seems to fix it:

diff --git a/puffin_egui/src/lib.rs b/puffin_egui/src/lib.rs
index 313b953..d6c9b6a 100644
--- a/puffin_egui/src/lib.rs
+++ b/puffin_egui/src/lib.rs
@@ -663,7 +663,7 @@ impl ProfilerUi {
         };

         let desired_size = Vec2::new(desired_width, self.flamegraph_options.frame_list_height);
-        let (response, painter) = ui.allocate_painter(desired_size, Sense::click_and_drag());
+        let (response, painter) = ui.allocate_painter(desired_size, Sense::drag());
         let rect = response.rect;

         let frame_spacing = 2.0;
emilk commented 8 months ago

egui 0.26.1 has been published

fornwall commented 8 months ago

Updated to require egui 0.26.1.