From ecfeb01aad1fd06cf126a9a23cc72293994bfb02 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 6 Jun 2020 12:31:47 +0200 Subject: [PATCH] Set source view content width to max value, regardless of clipping. --- server/TracySourceView.cpp | 15 +++++++++++++-- server/TracySourceView.hpp | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index b9a74c32..5da3835c 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -436,6 +436,7 @@ void SourceView::ParseSource( const char* fileName, const Worker& worker, const { if( m_file != fileName ) { + m_srcWidth = 0; m_file = fileName; m_fileStringIdx = worker.FindStringIdx( fileName ); m_lines.clear(); @@ -510,6 +511,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker ) m_maxJumpLevel = 0; m_asmSelected = -1; m_asmCountBase = -1; + m_asmWidth = 0; if( symAddr == 0 ) return false; m_cpuArch = worker.GetCpuArch(); if( m_cpuArch == CpuArchUnknown ) return false; @@ -889,6 +891,7 @@ void SourceView::Render( const Worker& worker, View& view ) void SourceView::RenderSimpleSourceView() { + ImGui::SetNextWindowContentSize( ImVec2( m_srcWidth, 0 ) ); ImGui::BeginChild( "##sourceView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_HorizontalScrollbar ); if( m_font ) ImGui::PushFont( m_font ); @@ -915,6 +918,8 @@ void SourceView::RenderSimpleSourceView() } RenderLine( line, lineNum++, 0, 0, 0, nullptr ); } + const auto& win = ImGui::GetCurrentWindow(); + m_srcWidth = win->DC.CursorMaxPos.x - win->DC.CursorStartPos.x; } else { @@ -1376,6 +1381,7 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_mapDC.CursorMaxPos.x - win->DC.CursorStartPos.x; } else { @@ -1654,6 +1662,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_mapDC.CursorMaxPos.x - win->DC.CursorStartPos.x; } else { @@ -2080,7 +2091,7 @@ void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint { const auto ty = ImGui::GetFontSize(); auto draw = ImGui::GetWindowDrawList(); - const auto w = ImGui::GetWindowWidth(); + const auto w = m_srcWidth; const auto wpos = ImGui::GetCursorScreenPos(); if( m_fileStringIdx == m_hoveredSource && lineNum == m_hoveredLine ) { @@ -2257,7 +2268,7 @@ void SourceView::RenderAsmLine( AsmLine& line, uint32_t ipcnt, uint32_t iptotal, { const auto ty = ImGui::GetFontSize(); auto draw = ImGui::GetWindowDrawList(); - const auto w = ImGui::GetWindowWidth(); + const auto w = m_asmWidth; const auto wpos = ImGui::GetCursorScreenPos(); if( m_selectedAddressesHover.find( line.addr ) != m_selectedAddressesHover.end() ) { diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index 3fce239b..75b80c54 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -239,6 +239,9 @@ private: unordered_flat_set m_srcSampleSelect; uint32_t m_asmGroupSelect = -1; uint32_t m_srcGroupSelect = -1; + + float m_srcWidth; + float m_asmWidth; }; }