Commit: 0523aab3fef96cbd09a30b47b14cb7b7d0ee6c58 Author: Jacques Lucke Date: Tue Apr 27 18:55:54 2021 +0200 Branches: profiler-editor https://developer.blender.org/rB0523aab3fef96cbd09a30b47b14cb7b7d0ee6c58
make view2d work =================================================================== M source/blender/editors/space_profiler/profiler_draw.cc M source/blender/editors/space_profiler/space_profiler.cc =================================================================== diff --git a/source/blender/editors/space_profiler/profiler_draw.cc b/source/blender/editors/space_profiler/profiler_draw.cc index b447bd649a4..27e6da4a97b 100644 --- a/source/blender/editors/space_profiler/profiler_draw.cc +++ b/source/blender/editors/space_profiler/profiler_draw.cc @@ -76,6 +76,19 @@ class ProfilerDrawer { this->draw_all_nodes(); UI_block_end(C, ui_block_); UI_block_draw(C, ui_block_); + + this->update_view2d_bounds(); + } + + void update_view2d_bounds() + { + const float duration_ms = this->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); + + UI_view2d_scrollers_draw(®ion_->v2d, nullptr); } void compute_vertical_extends_of_all_nodes() @@ -177,7 +190,7 @@ class ProfilerDrawer { 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); - return ms_since_begin / 5.0f; + return UI_view2d_view_to_region_x(®ion_->v2d, ms_since_begin); } Color4f get_node_color(ProfileNode &node) diff --git a/source/blender/editors/space_profiler/space_profiler.cc b/source/blender/editors/space_profiler/space_profiler.cc index 9e21bde224d..bcb2a63c019 100644 --- a/source/blender/editors/space_profiler/space_profiler.cc +++ b/source/blender/editors/space_profiler/space_profiler.cc @@ -17,6 +17,7 @@ #include <cstring> #include "BLI_listbase.h" +#include "BLI_rect.h" #include "BKE_screen.h" @@ -58,6 +59,18 @@ static SpaceLink *profiler_create(const ScrArea *UNUSED(area), const Scene *UNUS ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "profiler main region"); BLI_addtail(&sprofiler->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; + + View2D *v2d = ®ion->v2d; + v2d->scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM; + v2d->keepzoom = V2D_LOCKZOOM_Y; + v2d->keeptot = V2D_KEEPTOT_BOUNDS; + v2d->align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y; + v2d->min[0] = 0.0001f; + v2d->min[1] = 100.0f; + v2d->max[0] = 100000.0f; + v2d->max[1] = 100.0f; + BLI_rctf_init(&v2d->tot, 0, 5000, -1, 0); + v2d->cur = v2d->tot; } return (SpaceLink *)sprofiler; @@ -89,8 +102,9 @@ static void profiler_keymap(wmKeyConfig *UNUSED(keyconf)) { } -static void profiler_main_region_init(wmWindowManager *UNUSED(wm), ARegion *UNUSED(region)) +static void profiler_main_region_init(wmWindowManager *UNUSED(wm), ARegion *region) { + UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy); } static void profiler_main_region_draw(const bContext *C, ARegion *region) @@ -157,7 +171,7 @@ void ED_spacetype_profiler(void) /* regions: main window */ art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype profiler region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag = ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; art->init = profiler_main_region_init; art->draw = profiler_main_region_draw; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs