Skip to content

Commit

Permalink
Add switch for vertical centering on/off at run-time.
Browse files Browse the repository at this point in the history
  • Loading branch information
tvoeroes committed Jan 29, 2023
1 parent bca8f28 commit 6d8a82c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/TracyView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ class View
std::string m_filename, m_filenameStaging;
bool m_staticView;
ViewMode m_viewMode;
bool m_verticallyCenterTimeline = false;
bool m_viewModeHeuristicTry = false;
DecayValue<bool> m_forceConnectionPopup = false;
uint64_t m_totalMemory;
Expand Down
3 changes: 3 additions & 0 deletions server/TracyView_Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ void View::DrawOptions()
SmallColorBox( 0xFFDD9900 );
ImGui::PopFont();
ImGui::Unindent();
val = m_verticallyCenterTimeline;
ImGui::Checkbox( "Vertically center timeline", &val );
m_verticallyCenterTimeline = val;
if( m_worker.HasContextSwitches() )
{
ImGui::Separator();
Expand Down
8 changes: 7 additions & 1 deletion server/TracyView_Timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ void View::DrawTimeline()
if( m_yDelta != 0 )
{
auto& io = ImGui::GetIO();
if( !m_verticallyCenterTimeline )
{
auto y = ImGui::GetScrollY();
ImGui::SetScrollY( y - m_yDelta );
}
io.MouseClickedPos[1].y = io.MousePos.y;
}

Expand Down Expand Up @@ -378,7 +383,8 @@ void View::DrawTimeline()
}
}

m_tc.End( pxns, wpos, hover, drawMouseLine && m_viewMode == ViewMode::Paused, yMin, yMax );
const auto vcenter = m_verticallyCenterTimeline && drawMouseLine && m_viewMode == ViewMode::Paused;
m_tc.End( pxns, wpos, hover, vcenter, yMin, yMax );
ImGui::EndChild();

m_lockHighlight = m_nextLockHighlight;
Expand Down

0 comments on commit 6d8a82c

Please sign in to comment.