Preserve timeline vertical scroll position.

This commit is contained in:
Bartosz Taudul 2019-08-28 19:49:27 +02:00
parent abde0c252d
commit 17d4a82ca5
4 changed files with 11 additions and 8 deletions

View File

@ -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 );
}

View File

@ -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<float>( m_zvHeight, ImGui::GetContentRegionAvail().y - 4 ); // magic border value
const auto h = std::max<float>( 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();

View File

@ -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<int16_t> m_zoneSrcLocHighlight = 0;

View File

@ -10,6 +10,8 @@ struct ViewData
{
int64_t zvStart = 0;
int64_t zvEnd = 0;
int32_t zvHeight = 0;
int32_t zvScroll = 0;
};
}