mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Source tooltip implementation.
This commit is contained in:
parent
0b6e55ee87
commit
8f0c5e867e
@ -17801,4 +17801,50 @@ const char* View::SourceSubstitution( const char* srcFile ) const
|
|||||||
return res.c_str();
|
return res.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before, int after, bool separateTooltip )
|
||||||
|
{
|
||||||
|
if( !SourceFileValid( filename, m_worker.GetCaptureTime(), *this, m_worker ) ) return;
|
||||||
|
m_srcHintCache.Parse( filename, m_worker, *this );
|
||||||
|
if( m_srcHintCache.empty() ) return;
|
||||||
|
if( separateTooltip ) ImGui::BeginTooltip();
|
||||||
|
if( m_fixedFont ) ImGui::PushFont( m_fixedFont );
|
||||||
|
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 );
|
||||||
|
for( int i=start; i<end; i++ )
|
||||||
|
{
|
||||||
|
auto& line = lines[i];
|
||||||
|
if( line.begin == line.end )
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted( "" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ptr = line.begin;
|
||||||
|
auto it = line.tokens.begin();
|
||||||
|
while( ptr < line.end )
|
||||||
|
{
|
||||||
|
if( it == line.tokens.end() )
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted( ptr, line.end );
|
||||||
|
ImGui::SameLine( 0, 0 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( ptr < it->begin )
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted( ptr, it->begin );
|
||||||
|
ImGui::SameLine( 0, 0 );
|
||||||
|
}
|
||||||
|
TextColoredUnformatted( i == srcline-1 ? SyntaxColors[(int)it->color] : SyntaxColorsDimmed[(int)it->color], it->begin, it->end );
|
||||||
|
ImGui::SameLine( 0, 0 );
|
||||||
|
ptr = it->end;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
ImGui::ItemSize( ImVec2( 0, 0 ), 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( m_fixedFont ) ImGui::PopFont();
|
||||||
|
if( separateTooltip ) ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "TracyDecayValue.hpp"
|
#include "TracyDecayValue.hpp"
|
||||||
#include "TracyImGui.hpp"
|
#include "TracyImGui.hpp"
|
||||||
#include "TracyShortPtr.hpp"
|
#include "TracyShortPtr.hpp"
|
||||||
|
#include "TracySourceContents.hpp"
|
||||||
#include "TracyTexture.hpp"
|
#include "TracyTexture.hpp"
|
||||||
#include "TracyUserData.hpp"
|
#include "TracyUserData.hpp"
|
||||||
#include "TracyVector.hpp"
|
#include "TracyVector.hpp"
|
||||||
@ -193,6 +194,7 @@ private:
|
|||||||
void DrawSampleParents();
|
void DrawSampleParents();
|
||||||
void DrawRanges();
|
void DrawRanges();
|
||||||
void DrawRangeEntry( Range& range, const char* label, uint32_t color, const char* popupLabel, int id );
|
void DrawRangeEntry( Range& range, const char* label, uint32_t color, const char* popupLabel, int id );
|
||||||
|
void DrawSourceTooltip( const char* filename, uint32_t line, int before = 3, int after = 3, bool separateTooltip = true );
|
||||||
|
|
||||||
void ListMemData( std::vector<const MemEvent*>& vec, std::function<void(const MemEvent*)> DrawAddress, const char* id = nullptr, int64_t startTime = -1, uint64_t pool = 0 );
|
void ListMemData( std::vector<const MemEvent*>& vec, std::function<void(const MemEvent*)> DrawAddress, const char* id = nullptr, int64_t startTime = -1, uint64_t pool = 0 );
|
||||||
|
|
||||||
@ -414,6 +416,7 @@ private:
|
|||||||
Vector<const ZoneEvent*> m_zoneInfoStack;
|
Vector<const ZoneEvent*> m_zoneInfoStack;
|
||||||
Vector<const GpuEvent*> m_gpuInfoStack;
|
Vector<const GpuEvent*> m_gpuInfoStack;
|
||||||
|
|
||||||
|
SourceContents m_srcHintCache;
|
||||||
std::unique_ptr<SourceView> m_sourceView;
|
std::unique_ptr<SourceView> m_sourceView;
|
||||||
const char* m_sourceViewFile;
|
const char* m_sourceViewFile;
|
||||||
bool m_uarchSet = false;
|
bool m_uarchSet = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user