From 17d4a82ca5f1996906f07d945f499f40936754f7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 28 Aug 2019 19:49:27 +0200 Subject: [PATCH] Preserve timeline vertical scroll position. --- server/TracyUserData.cpp | 4 ++++ server/TracyView.cpp | 10 +++++----- server/TracyView.hpp | 3 --- server/TracyViewData.hpp | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/server/TracyUserData.cpp b/server/TracyUserData.cpp index 712b2223..94e8de3f 100644 --- a/server/TracyUserData.cpp +++ b/server/TracyUserData.cpp @@ -68,6 +68,8 @@ void UserData::LoadState( ViewData& data ) { fread( &data.zvStart, 1, sizeof( data.zvStart ), f ); fread( &data.zvEnd, 1, sizeof( data.zvEnd ), f ); + fread( &data.zvHeight, 1, sizeof( data.zvHeight ), f ); + fread( &data.zvScroll, 1, sizeof( data.zvScroll ), f ); } fclose( f ); } @@ -82,6 +84,8 @@ void UserData::SaveState( const ViewData& data ) fwrite( &ver, 1, sizeof( ver ), f ); fwrite( &data.zvStart, 1, sizeof( data.zvStart ), f ); fwrite( &data.zvEnd, 1, sizeof( data.zvEnd ), f ); + fwrite( &data.zvHeight, 1, sizeof( data.zvHeight ), f ); + fwrite( &data.zvScroll, 1, sizeof( data.zvScroll ), f ); fclose( f ); } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 14b59a49..e068d8b9 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -1776,7 +1776,7 @@ void View::DrawZones() ImGui::BeginChild( "##zoneWin", ImVec2( ImGui::GetWindowContentRegionWidth(), ImGui::GetContentRegionAvail().y ), false, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); const auto wpos = ImGui::GetCursorScreenPos(); - const auto h = std::max( m_zvHeight, ImGui::GetContentRegionAvail().y - 4 ); // magic border value + const auto h = std::max( m_vd.zvHeight, ImGui::GetContentRegionAvail().y - 4 ); // magic border value ImGui::InvisibleButton( "##zones", ImVec2( w, h ) ); bool hover = ImGui::IsItemHovered(); @@ -2223,15 +2223,15 @@ void View::DrawZones() } const auto scrollPos = ImGui::GetScrollY(); - if( scrollPos == 0 && m_zvScroll != 0 ) + if( scrollPos == 0 && m_vd.zvScroll != 0 ) { - m_zvHeight = 0; + m_vd.zvHeight = 0; } else { - if( offset > m_zvHeight ) m_zvHeight = offset; + if( offset > m_vd.zvHeight ) m_vd.zvHeight = offset; } - m_zvScroll = scrollPos; + m_vd.zvScroll = scrollPos; ImGui::EndChild(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 0ee19ee6..934a542b 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -250,9 +250,6 @@ private: ViewData m_vd; - int m_zvHeight = 0; - int m_zvScroll = 0; - const ZoneEvent* m_zoneInfoWindow = nullptr; const ZoneEvent* m_zoneHighlight; DecayValue m_zoneSrcLocHighlight = 0; diff --git a/server/TracyViewData.hpp b/server/TracyViewData.hpp index e1471dfd..558d62e6 100644 --- a/server/TracyViewData.hpp +++ b/server/TracyViewData.hpp @@ -10,6 +10,8 @@ struct ViewData { int64_t zvStart = 0; int64_t zvEnd = 0; + int32_t zvHeight = 0; + int32_t zvScroll = 0; }; }