diff --git a/profiler_gui/blocks_graphics_view.cpp b/profiler_gui/blocks_graphics_view.cpp index b0971b2..81f276d 100644 --- a/profiler_gui/blocks_graphics_view.cpp +++ b/profiler_gui/blocks_graphics_view.cpp @@ -518,6 +518,8 @@ void EasyGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocksTr m_pScrollbar->setMinimapFrom(longestItem->threadId(), longestItem->items(0)); EASY_GLOBALS.selected_thread = longestItem->threadId(); emit EASY_GLOBALS.events.selectedThreadChanged(longestItem->threadId()); + + scrollTo(longestItem); } m_idleTimer.start(IDLE_TIMER_INTERVAL); @@ -733,10 +735,7 @@ void EasyGraphicsView::onGraphicsScrollbarWheel(qreal _mouseX, int _wheelDelta) { if (item->threadId() == EASY_GLOBALS.selected_thread) { - m_bUpdatingRect = true; - auto vbar = verticalScrollBar(); - vbar->setValue(item->y() + (item->boundingRect().height() - vbar->pageStep()) * 0.5); - m_bUpdatingRect = false; + scrollTo(item); break; } } @@ -744,6 +743,14 @@ void EasyGraphicsView::onGraphicsScrollbarWheel(qreal _mouseX, int _wheelDelta) onWheel(_mouseX, _wheelDelta); } +void EasyGraphicsView::scrollTo(const EasyGraphicsItem* _item) +{ + m_bUpdatingRect = true; + auto vbar = verticalScrollBar(); + vbar->setValue(_item->y() + (_item->boundingRect().height() - vbar->pageStep()) * 0.5); + m_bUpdatingRect = false; +} + void EasyGraphicsView::onWheel(qreal _mouseX, int _wheelDelta) { const decltype(m_scale) scaleCoeff = _wheelDelta > 0 ? ::profiler_gui::SCALING_COEFFICIENT : ::profiler_gui::SCALING_COEFFICIENT_INV; diff --git a/profiler_gui/blocks_graphics_view.h b/profiler_gui/blocks_graphics_view.h index db86078..9b9555a 100644 --- a/profiler_gui/blocks_graphics_view.h +++ b/profiler_gui/blocks_graphics_view.h @@ -183,6 +183,7 @@ private: void updateVisibleSceneRect(); void updateTimelineStep(qreal _windowWidth); void scaleTo(qreal _scale); + void scrollTo(const EasyGraphicsItem* _item); void onWheel(qreal _mouseX, int _wheelDelta); qreal setTree(EasyGraphicsItem* _item, ::profiler::block_index_t _parent, const ::profiler::BlocksTree::children_t& _children, qreal& _height, qreal _y, short _level); diff --git a/profiler_gui/easy_graphics_scrollbar.cpp b/profiler_gui/easy_graphics_scrollbar.cpp index 5ac0327..908ea41 100644 --- a/profiler_gui/easy_graphics_scrollbar.cpp +++ b/profiler_gui/easy_graphics_scrollbar.cpp @@ -120,15 +120,7 @@ void EasyGraphicsSliderItem::paint(QPainter* _painter, const QStyleOptionGraphic const auto br = rect(); qreal w = width() * currentScale; - qreal dx = 0; - -// if (w < 1.0) -// { -// dx = (w - 1.0) * 0.5; -// w = 1.0; -// } - - QRectF r(dx + br.left() * currentScale, br.top() + INDICATOR_SIZE, w, br.height() - INDICATOR_SIZE_x2); + QRectF r(br.left() * currentScale, br.top() + INDICATOR_SIZE, w, br.height() - INDICATOR_SIZE_x2); const auto r_right = r.right(); const auto r_bottom = r.bottom(); auto b = brush();