From facae0b9e14f4c836e4540fca5ef06919d490700 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 17 Aug 2018 15:33:12 +0200 Subject: [PATCH] Draw text editor with potential source code. --- server/TracyView.cpp | 14 ++++++++++++++ server/TracyView.hpp | 1 + 2 files changed, 15 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 391c43dd..91d1140a 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -595,6 +595,7 @@ bool View::DrawImpl() if( m_callstackInfoWindow != 0 ) DrawCallstackWindow(); if( m_memoryAllocInfoWindow >= 0 ) DrawMemoryAllocWindow(); if( m_showInfo ) DrawInfo(); + if( m_textEditorFile ) DrawTextEditor(); if( m_zoomAnim.active ) { @@ -5830,6 +5831,19 @@ void View::DrawInfo() ImGui::End(); } +void View::DrawTextEditor() +{ + bool show = true; + ImGui::Begin( "Source view", &show ); + ImGui::TextColored( ImVec4( 1.f, 0.3f, 0.3f, 1.f ), "/!\\ The source file contents might not reflect the actual profiled code! /!\\" ); + TextFocused( "File:", m_textEditorFile ); + if( m_textEditorFont ) ImGui::PushFont( m_textEditorFont ); + m_textEditor->Render( m_textEditorFile, ImVec2(), true ); + if( m_textEditorFont ) ImGui::PopFont(); + ImGui::End(); + if( !show ) m_textEditorFile = nullptr; +} + template void View::ListMemData( T ptr, T end, std::function DrawAddress, const char* id ) { diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 89784e0c..616f7934 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -92,6 +92,7 @@ private: void DrawCallstackWindow(); void DrawMemoryAllocWindow(); void DrawInfo(); + void DrawTextEditor(); template void ListMemData( T ptr, T end, std::function DrawAddress, const char* id = nullptr );