Fix off-by-one-frame in timeline item height.

This commit is contained in:
Tomaž Vöröš 2023-01-27 20:00:05 +01:00
parent 7b9b810421
commit 2df56e9941
2 changed files with 4 additions and 2 deletions

View File

@ -30,8 +30,10 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, float
for( auto& item : m_items ) for( auto& item : m_items )
{ {
auto currentFrameItemHeight = item->GetNextFrameHeight();
item->Draw( m_firstFrame, pxns, yOffset, wpos, hover, yMin, yMax ); item->Draw( m_firstFrame, pxns, yOffset, wpos, hover, yMin, yMax );
yOffset += item->GetNextFrameHeight(); if( m_firstFrame ) currentFrameItemHeight = item->GetNextFrameHeight();
yOffset += currentFrameItemHeight;
} }
const auto scrollPos = ImGui::GetScrollY(); const auto scrollPos = ImGui::GetScrollY();

View File

@ -321,6 +321,7 @@ void View::DrawTimeline()
const auto yMin = ImGui::GetCursorScreenPos().y; const auto yMin = ImGui::GetCursorScreenPos().y;
const auto yMax = linepos.y + lineh; const auto yMax = linepos.y + lineh;
ImGui::SetNextWindowContentSize( ImVec2( 0, m_tc.GetHeight() ) );
ImGui::BeginChild( "##zoneWin", ImVec2( ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y ), false, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); ImGui::BeginChild( "##zoneWin", ImVec2( ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y ), false, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoScrollWithMouse );
if( m_yDelta != 0 ) if( m_yDelta != 0 )
@ -333,7 +334,6 @@ void View::DrawTimeline()
const auto wpos = ImGui::GetCursorScreenPos(); const auto wpos = ImGui::GetCursorScreenPos();
const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
// note that m_tc.GetHeight() returns the height from the previous draw
const auto h = std::max<float>( m_tc.GetHeight(), ImGui::GetContentRegionAvail().y - 4 ); // magic border value const auto h = std::max<float>( m_tc.GetHeight(), ImGui::GetContentRegionAvail().y - 4 ); // magic border value
ImGui::ItemSize( ImVec2( w, h ) ); ImGui::ItemSize( ImVec2( w, h ) );