From a2fa7dd0ed54ee4b968ec590a7384b1d147463f8 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 19 Sep 2017 01:24:31 +0200 Subject: [PATCH] Frame list can be now scrolled using right mouse button. --- server/TracyView.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index e32b9a50..56606031 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "../common/TracyProtocol.hpp" #include "../common/TracySystem.hpp" @@ -431,6 +432,8 @@ void View::DrawFrames() ImGuiWindow* window = ImGui::GetCurrentWindow(); if( window->SkipItems ) return; + auto& io = ImGui::GetIO(); + const auto wpos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin() + ImVec2( 0, Offset ); const auto wspace = ImGui::GetWindowContentRegionMax() - ImGui::GetWindowContentRegionMin(); const auto w = wspace.x; @@ -440,7 +443,7 @@ void View::DrawFrames() bool hover = ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( w, 60 ) ); if( hover ) { - const auto wheel = ImGui::GetIO().MouseWheel; + const auto wheel = io.MouseWheel; if( wheel > 0 ) { if( m_frameScale > 0 ) m_frameScale--; @@ -457,6 +460,18 @@ void View::DrawFrames() const int onScreen = ( w - 2 ) / fwidth; if( !m_pause ) m_frameStart = ( total < onScreen * group ) ? 0 : total - onScreen * group; + if( hover && ImGui::IsMouseDragging( 1, 0 ) ) + { + m_pause = true; + const auto delta = ImGui::GetMouseDragDelta( 1, 0 ).x; + if( abs( delta ) >= fwidth ) + { + const auto d = (int)delta / fwidth; + m_frameStart = std::max( 0, m_frameStart - d * group ); + io.MouseClickedPos[1].x = io.MousePos.x + d * fwidth - delta; + } + } + int i = 0, idx = 0; while( i < onScreen && m_frameStart + idx < total ) {