[Bf-blender-cvs] [ef2bec0db23] profiler-editor: support click to zoom

Jacques Lucke noreply at git.blender.org
Thu Apr 29 11:30:49 CEST 2021


Commit: ef2bec0db2359311d58572fbc4574b088e384235
Author: Jacques Lucke
Date:   Tue Apr 27 19:22:42 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rBef2bec0db2359311d58572fbc4574b088e384235

support click to zoom

===================================================================

M	source/blender/editors/space_profiler/profiler_draw.cc

===================================================================

diff --git a/source/blender/editors/space_profiler/profiler_draw.cc b/source/blender/editors/space_profiler/profiler_draw.cc
index 2e14369c753..1ae3de48690 100644
--- a/source/blender/editors/space_profiler/profiler_draw.cc
+++ b/source/blender/editors/space_profiler/profiler_draw.cc
@@ -192,6 +192,7 @@ class ProfilerDrawer {
                             node_tooltip_fn,
                             new (MEM_mallocN(sizeof(NodeTooltipArg), __func__))
                                 NodeTooltipArg{&node});
+    UI_but_func_set(but, node_click_fn, &node, profiler_layout_);
   }
 
   static char *node_tooltip_fn(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
@@ -203,6 +204,25 @@ class ProfilerDrawer {
     return BLI_strdup(ss.str().c_str());
   }
 
+  static void node_click_fn(bContext *C, void *arg1, void *arg2)
+  {
+    ProfileNode &node = *(ProfileNode *)arg1;
+    ProfilerLayout &profiler_layout = *(ProfilerLayout *)arg2;
+
+    ARegion *region = CTX_wm_region(C);
+
+    const TimePoint begin_time = profiler_layout.begin_time();
+    const float left_ms = duration_to_ms(node.begin_time() - begin_time);
+    const float right_ms = duration_to_ms(node.end_time() - begin_time);
+    const float duration_ms = right_ms - left_ms;
+    const float padding = duration_ms * 0.05f;
+
+    rctf new_view;
+    BLI_rctf_init(&new_view, left_ms - padding, right_ms + padding, -1, 0);
+
+    UI_view2d_smooth_view(C, region, &new_view, U.smooth_viewtx);
+  }
+
   int time_to_x(const TimePoint time) const
   {
     const TimePoint begin_time = profiler_layout_->begin_time();



More information about the Bf-blender-cvs mailing list