Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf@nereid.pl>2022-08-20 18:02:29 +0300
committerBartosz Taudul <wolf@nereid.pl>2022-08-20 18:02:29 +0300
commit655d8a01ea9cc08b014bd1f38e3db2bc87be90e6 (patch)
tree2ce67c718b76b8ea7e41ecd6551cc171a8106ed1 /server/TracyTimelineController.cpp
parent49bda91be56581dd2d33ff1829deec4f07b7d0f1 (diff)
Move vis data to timeline controller.
Diffstat (limited to 'server/TracyTimelineController.cpp')
-rw-r--r--server/TracyTimelineController.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/server/TracyTimelineController.cpp b/server/TracyTimelineController.cpp
index 0c1943ff..1a32845e 100644
--- a/server/TracyTimelineController.cpp
+++ b/server/TracyTimelineController.cpp
@@ -9,9 +9,15 @@ TimelineController::TimelineController()
: m_height( 0 )
, m_offset( 0 )
, m_scroll( 0 )
+ , m_firstFrame( true )
{
}
+void TimelineController::FirstFrameExpired()
+{
+ m_firstFrame = false;
+}
+
void TimelineController::End( float offset )
{
const auto scrollPos = ImGui::GetScrollY();
@@ -26,4 +32,45 @@ void TimelineController::End( float offset )
m_scroll = scrollPos;
}
+float TimelineController::AdjustThreadPosition( VisData& vis, float wy, int& offset )
+{
+ if( vis.offset < offset )
+ {
+ vis.offset = offset;
+ }
+ else if( vis.offset > offset )
+ {
+ const auto diff = vis.offset - offset;
+ const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
+ offset = vis.offset = int( std::max<double>( vis.offset - move, offset ) );
+ }
+
+ return offset + wy;
+}
+
+void TimelineController::AdjustThreadHeight( VisData& vis, int oldOffset, int& offset )
+{
+ const auto h = offset - oldOffset;
+ if( vis.height > h )
+ {
+ vis.height = h;
+ offset = oldOffset + vis.height;
+ }
+ else if( vis.height < h )
+ {
+ if( m_firstFrame )
+ {
+ vis.height = h;
+ offset = oldOffset + h;
+ }
+ else
+ {
+ const auto diff = h - vis.height;
+ const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
+ vis.height = int( std::min<double>( vis.height + move, h ) );
+ offset = oldOffset + vis.height;
+ }
+ }
+}
+
}