diff --git a/profiler/src/profiler/TracyMarkdown.cpp b/profiler/src/profiler/TracyMarkdown.cpp index 377d97fe..42b2d227 100644 --- a/profiler/src/profiler/TracyMarkdown.cpp +++ b/profiler/src/profiler/TracyMarkdown.cpp @@ -512,7 +512,7 @@ private: ImGui::Dummy( ImVec2( 0, ImGui::GetTextLineHeight() * 0.25f ) ); ImGui::Separator(); ImGui::Dummy( ImVec2( 0, ImGui::GetTextLineHeight() * 0.25f ) ); - m_view->DrawSourceTooltip( m_worker->GetString( idx ), lineStart, 3, 3, false ); + m_view->DrawSourceTooltip( m_worker->GetString( idx ), lineStart, lineEnd, 3, 3, false ); } else { diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index 8214f1a4..8d0ad95e 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -1419,7 +1419,7 @@ void View::CrashTooltip() ImGui::EndTooltip(); } -bool View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before, int after, bool separateTooltip ) +bool View::DrawSourceTooltip( const char* filename, uint32_t lineStart, uint32_t lineEnd, int before, int after, bool separateTooltip ) { if( !filename ) return false; if( !SourceFileValid( filename, m_worker.GetCaptureTime(), *this, m_worker ) ) return false; @@ -1429,13 +1429,17 @@ bool View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before if( separateTooltip ) ImGui::BeginTooltip(); ImGui::PushFont( g_fonts.mono, FontNormal ); auto& lines = m_srcHintCache.get(); - const int start = std::max( 0, (int)srcline - ( before+1 ) ); - const int end = std::min( m_srcHintCache.get().size(), srcline + after ); bool first = true; int bottomEmpty = 0; - for( int i=start; i( m_srcHintCache.get().size(), (int)lineEnd + after ); + const int endLoop = std::min( end, start + MaxRenderedLines ); + for( int i=start; i= lineStart && lineNum <= lineEnd; if( line.begin == line.end ) { if( !first ) bottomEmpty++; @@ -1465,7 +1469,7 @@ bool View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before ImGui::SameLine( 0, 0 ); } auto color = SyntaxColors[(int)it->color]; - if( i != srcline-1 ) color = ( color & 0xFFFFFF ) | 0x99000000; + if( !inRange ) color = ( color & 0xFFFFFF ) | 0x99000000; TextColoredUnformatted( color, it->begin, it->end ); ImGui::SameLine( 0, 0 ); ptr = it->end; @@ -1474,6 +1478,7 @@ bool View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before ImGui::ItemSize( ImVec2( 0, 0 ), 0 ); } } + if( end != endLoop ) ImGui::TextDisabled( "… (+%i more lines)", end - endLoop ); ImGui::PopFont(); if( separateTooltip ) ImGui::EndTooltip(); ImGui::PopStyleVar(); diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 418a0853..7fa81d0b 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -213,7 +213,7 @@ public: bool DrawGpu( const TimelineContext& ctx, const GpuCtxData& gpu, int& offset ); bool DrawCpuData( const TimelineContext& ctx, const std::vector& cpuDraw, const std::vector>& ctxDraw, int& offset, bool hasCpuData ); void DrawThreadMigrations( const TimelineContext& ctx, const int origOffset, uint64_t thread ); - bool DrawSourceTooltip( const char* filename, uint32_t line, int before = 3, int after = 3, bool separateTooltip = true ); + bool DrawSourceTooltip( const char* filename, uint32_t lineStart, uint32_t lineEnd, int before = 3, int after = 3, bool separateTooltip = true ); bool IsBackgroundDone() const { return m_worker.IsBackgroundDone(); } diff --git a/profiler/src/profiler/TracyView_Callstack.cpp b/profiler/src/profiler/TracyView_Callstack.cpp index 28675d81..11acb802 100644 --- a/profiler/src/profiler/TracyView_Callstack.cpp +++ b/profiler/src/profiler/TracyView_Callstack.cpp @@ -648,12 +648,12 @@ void View::DrawCallstackTable( const CallstackFrameId* data, size_t size, const if( sym ) { const auto symtxt = m_worker.GetString( sym->file ); - DrawSourceTooltip( symtxt, sym->line ); + DrawSourceTooltip( symtxt, sym->line, sym->line ); } } else { - DrawSourceTooltip( filename, frame.line ); + DrawSourceTooltip( filename, frame.line, frame.line ); } if( ImGui::IsItemClicked( 1 ) ) { diff --git a/profiler/src/profiler/TracyView_FindZone.cpp b/profiler/src/profiler/TracyView_FindZone.cpp index d6aefdad..efa546cf 100644 --- a/profiler/src/profiler/TracyView_FindZone.cpp +++ b/profiler/src/profiler/TracyView_FindZone.cpp @@ -393,7 +393,7 @@ void View::DrawFindZone() ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "(%s) %s", RealToString( zones.size() ), LocationToString( fileName, srcloc.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, srcloc.line ); + DrawSourceTooltip( fileName, srcloc.line, srcloc.line ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) ) diff --git a/profiler/src/profiler/TracyView_FrameTree.cpp b/profiler/src/profiler/TracyView_FrameTree.cpp index f664ebb4..ea4a3853 100644 --- a/profiler/src/profiler/TracyView_FrameTree.cpp +++ b/profiler/src/profiler/TracyView_FrameTree.cpp @@ -551,7 +551,7 @@ void View::DrawFrameTreeLevel( const unordered_flat_maptimeline.size() ), LocationToString( fileName, sl.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, sl.line, 1, 1 ); + DrawSourceTooltip( fileName, sl.line, sl.line, 1, 1 ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) ) @@ -557,7 +557,7 @@ void View::DrawOptions() ImGui::TextDisabled( "(%s) %s", RealToString( l.second->timeline.size() ), LocationToString( fileName, sl.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, sl.line, 1, 1 ); + DrawSourceTooltip( fileName, sl.line, sl.line, 1, 1 ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) ) @@ -644,7 +644,7 @@ void View::DrawOptions() ImGui::TextDisabled( "(%s) %s", RealToString( l.second->timeline.size() ), LocationToString( fileName, sl.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, sl.line, 1, 1 ); + DrawSourceTooltip( fileName, sl.line, sl.line, 1, 1 ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) ) diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index 15e4cbe7..c3fd3636 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -510,14 +510,14 @@ void View::DrawSamplesStatistics( Vector& data, int64_t timeRange, uint if( frame && frame->size > 1 ) { ImGui::BeginTooltip(); - if( DrawSourceTooltip( file, line, 3, 3, false ) ) ImGui::Separator(); + if( DrawSourceTooltip( file, line, line, 3, 3, false ) ) ImGui::Separator(); TextDisabledUnformatted( "Local call stack:" ); PrintLocalStack( frame, m_worker, *this ); ImGui::EndTooltip(); } else { - DrawSourceTooltip( file, line ); + DrawSourceTooltip( file, line, line ); } if( ImGui::IsItemClicked( 1 ) ) { @@ -744,14 +744,14 @@ void View::DrawSamplesStatistics( Vector& data, int64_t timeRange, uint if( frame && frame->size > 1 ) { ImGui::BeginTooltip(); - if( DrawSourceTooltip( file, line, 3, 3, false ) ) ImGui::Separator(); + if( DrawSourceTooltip( file, line, line, 3, 3, false ) ) ImGui::Separator(); TextDisabledUnformatted( "Local call stack:" ); PrintLocalStack( frame, m_worker, *this ); ImGui::EndTooltip(); passed = true; } } - if( !passed ) DrawSourceTooltip( file, line ); + if( !passed ) DrawSourceTooltip( file, line, line ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) ) @@ -1229,12 +1229,12 @@ void View::DrawSampleParents() if( sym ) { const auto symtxt = m_worker.GetString( sym->file ); - DrawSourceTooltip( symtxt, sym->line ); + DrawSourceTooltip( symtxt, sym->line, sym->line ); } } else { - DrawSourceTooltip( txt, frame.line ); + DrawSourceTooltip( txt, frame.line, frame.line ); } if( ImGui::IsItemClicked( 1 ) ) { diff --git a/profiler/src/profiler/TracyView_Statistics.cpp b/profiler/src/profiler/TracyView_Statistics.cpp index 2166b260..d2a65cc7 100644 --- a/profiler/src/profiler/TracyView_Statistics.cpp +++ b/profiler/src/profiler/TracyView_Statistics.cpp @@ -745,7 +745,7 @@ void View::DrawStatistics() TextDisabledUnformatted( LocationToString( file, srcloc.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( file, srcloc.line ); + DrawSourceTooltip( file, srcloc.line, srcloc.line ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) ) diff --git a/profiler/src/profiler/TracyView_ZoneInfo.cpp b/profiler/src/profiler/TracyView_ZoneInfo.cpp index 5aeec9a0..60deca0d 100644 --- a/profiler/src/profiler/TracyView_ZoneInfo.cpp +++ b/profiler/src/profiler/TracyView_ZoneInfo.cpp @@ -308,7 +308,7 @@ void View::DrawZoneInfoWindow() TextFocusedClipboard( "Location:", LocationToString( fileName, srcloc.line ), LocationToString( m_worker.GetString( srcloc.file ), srcloc.line ), 3 ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, srcloc.line ); + DrawSourceTooltip( fileName, srcloc.line, srcloc.line ); if( ImGui::IsItemClicked( ImGuiMouseButton_Right ) && SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) ) { ViewSourceCheckKeyMod( fileName, srcloc.line, m_worker.GetString( srcloc.function ) ); @@ -922,7 +922,7 @@ void View::DrawZoneInfoWindow() TextDisabledUnformatted( LocationToString( fileName, srcloc.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, srcloc.line ); + DrawSourceTooltip( fileName, srcloc.line, srcloc.line ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) ) @@ -1541,7 +1541,7 @@ void View::DrawGpuInfoWindow() TextDisabledUnformatted( LocationToString( fileName, srcloc.line ) ); if( ImGui::IsItemHovered() ) { - DrawSourceTooltip( fileName, srcloc.line ); + DrawSourceTooltip( fileName, srcloc.line, srcloc.line ); if( ImGui::IsItemClicked( 1 ) ) { if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this, m_worker ) )