mirror of
https://github.com/wolfpld/tracy.git
synced 2026-11-11 02:15:26 +00:00
Source tooltip may render more than one active line.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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<int>( m_srcHintCache.get().size(), srcline + after );
|
||||
bool first = true;
|
||||
int bottomEmpty = 0;
|
||||
for( int i=start; i<end; i++ )
|
||||
constexpr int MaxRenderedLines = 40;
|
||||
const int start = std::max( 0, (int)lineStart - ( before+1 ) );
|
||||
const int end = std::min<int>( m_srcHintCache.get().size(), (int)lineEnd + after );
|
||||
const int endLoop = std::min( end, start + MaxRenderedLines );
|
||||
for( int i=start; i<endLoop; i++ )
|
||||
{
|
||||
auto& line = lines[i];
|
||||
const auto lineNum = uint32_t( i+1 );
|
||||
const bool inRange = lineNum >= 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();
|
||||
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
bool DrawGpu( const TimelineContext& ctx, const GpuCtxData& gpu, int& offset );
|
||||
bool DrawCpuData( const TimelineContext& ctx, const std::vector<CpuUsageDraw>& cpuDraw, const std::vector<std::vector<CpuCtxDraw>>& 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(); }
|
||||
|
||||
|
||||
@@ -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 ) )
|
||||
{
|
||||
|
||||
@@ -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 ) )
|
||||
|
||||
@@ -551,7 +551,7 @@ void View::DrawFrameTreeLevel( const unordered_flat_map<uint64_t, MemCallstackFr
|
||||
}
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
DrawSourceTooltip( fileName, frame.line );
|
||||
DrawSourceTooltip( fileName, frame.line, frame.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( !ViewDispatch( fileName, frame.line, frame.symAddr ) )
|
||||
@@ -706,7 +706,7 @@ void View::DrawFrameTreeLevel( const unordered_flat_map<uint64_t, CallstackFrame
|
||||
}
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
DrawSourceTooltip( fileName, frame.line );
|
||||
DrawSourceTooltip( fileName, frame.line, frame.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( !ViewDispatch( fileName, frame.line, frame.symAddr ) )
|
||||
@@ -856,7 +856,7 @@ void View::DrawParentsFrameTreeLevel( const unordered_flat_map<uint64_t, Callsta
|
||||
}
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
DrawSourceTooltip( fileName, frame.line );
|
||||
DrawSourceTooltip( fileName, frame.line, frame.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( !ViewDispatch( fileName, frame.line, frame.symAddr ) )
|
||||
|
||||
@@ -587,7 +587,7 @@ void View::DrawLockInfoWindow()
|
||||
ImGui::TextUnformatted( 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 ) )
|
||||
|
||||
@@ -470,7 +470,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 ) )
|
||||
@@ -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 ) )
|
||||
|
||||
@@ -510,14 +510,14 @@ void View::DrawSamplesStatistics( Vector<SymList>& 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<SymList>& 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 ) )
|
||||
{
|
||||
|
||||
@@ -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 ) )
|
||||
|
||||
@@ -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 ) )
|
||||
|
||||
Reference in New Issue
Block a user