[Bf-blender-cvs] [6cbeb7de8b0] profiler-editor: improve tooltip
Jacques Lucke
noreply at git.blender.org
Thu Apr 29 11:30:49 CEST 2021
Commit: 6cbeb7de8b029dd4c5c99d324625deeabdc980c7
Author: Jacques Lucke
Date: Tue Apr 27 19:10:50 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rB6cbeb7de8b029dd4c5c99d324625deeabdc980c7
improve tooltip
===================================================================
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 27e6da4a97b..2e14369c753 100644
--- a/source/blender/editors/space_profiler/profiler_draw.cc
+++ b/source/blender/editors/space_profiler/profiler_draw.cc
@@ -82,8 +82,8 @@ class ProfilerDrawer {
void update_view2d_bounds()
{
- const float duration_ms = this->duration_to_ms(profiler_layout_->end_time() -
- profiler_layout_->begin_time());
+ const float duration_ms = duration_to_ms(profiler_layout_->end_time() -
+ profiler_layout_->begin_time());
/* Giving a bit more space on the right side is convenient. */
const float extended_duration_ms = std::max(duration_ms * 1.1f, 5000.0f);
UI_view2d_totRect_set(®ion_->v2d, extended_duration_ms, 1);
@@ -161,6 +161,10 @@ class ProfilerDrawer {
}
}
+ struct NodeTooltipArg {
+ ProfileNode *node;
+ };
+
void draw_node_label(ProfileNode &node, const int left_x, const int right_x)
{
const int x = std::max(0, left_x);
@@ -183,13 +187,27 @@ class ProfilerDrawer {
nullptr);
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
UI_but_drawflag_disable(but, UI_BUT_TEXT_RIGHT);
+
+ UI_but_func_tooltip_set(but,
+ node_tooltip_fn,
+ new (MEM_mallocN(sizeof(NodeTooltipArg), __func__))
+ NodeTooltipArg{&node});
+ }
+
+ static char *node_tooltip_fn(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
+ {
+ NodeTooltipArg &arg = *(NodeTooltipArg *)argN;
+ ProfileNode &node = *arg.node;
+ std::stringstream ss;
+ ss << "Duration: " << duration_to_ms(node.end_time() - node.begin_time()) << " ms";
+ return BLI_strdup(ss.str().c_str());
}
int time_to_x(const TimePoint time) const
{
const TimePoint begin_time = profiler_layout_->begin_time();
const Duration time_since_begin = time - begin_time;
- const float ms_since_begin = this->duration_to_ms(time_since_begin);
+ const float ms_since_begin = duration_to_ms(time_since_begin);
return UI_view2d_view_to_region_x(®ion_->v2d, ms_since_begin);
}
@@ -202,7 +220,7 @@ class ProfilerDrawer {
return {r, g, b, 1.0f};
}
- float duration_to_ms(const Duration duration) const
+ static float duration_to_ms(const Duration duration)
{
return duration.count() / 1000000.0f;
}
More information about the Bf-blender-cvs
mailing list