Make source location display optional.

This commit is contained in:
Bartosz Taudul 2020-04-02 01:37:56 +02:00
parent 39cb9f4a32
commit d3c278cb02
2 changed files with 49 additions and 40 deletions

View File

@ -30,6 +30,7 @@ SourceView::SourceView( ImFont* font )
, m_codeLen( 0 ) , m_codeLen( 0 )
, m_highlightAddr( 0 ) , m_highlightAddr( 0 )
, m_asmRelative( false ) , m_asmRelative( false )
, m_asmShowSourceLocation( true )
{ {
} }
@ -291,6 +292,10 @@ void SourceView::Render( const Worker& worker )
else else
{ {
SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative locations", &m_asmRelative ); SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative locations", &m_asmRelative );
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
SmallCheckbox( ICON_FA_FILE_IMPORT " Show source locations", &m_asmShowSourceLocation );
} }
uint64_t jumpOut = 0; uint64_t jumpOut = 0;
@ -499,6 +504,8 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
buf[16] = '\0'; buf[16] = '\0';
TextDisabledUnformatted( buf ); TextDisabledUnformatted( buf );
if( m_asmShowSourceLocation )
{
const auto stw = ImGui::CalcTextSize( " " ).x; const auto stw = ImGui::CalcTextSize( " " ).x;
ImGui::SameLine(); ImGui::SameLine();
uint32_t srcline; uint32_t srcline;
@ -547,6 +554,7 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
ImGui::SameLine( 0, 0 ); ImGui::SameLine( 0, 0 );
ImGui::ItemSize( ImVec2( stw * 32, ty ), 0 ); ImGui::ItemSize( ImVec2( stw * 32, ty ), 0 );
} }
}
ImGui::SameLine( 0, ty ); ImGui::SameLine( 0, ty );
const auto msz = line.mnemonic.size(); const auto msz = line.mnemonic.size();

View File

@ -56,6 +56,7 @@ private:
uint32_t m_codeLen; uint32_t m_codeLen;
DecayValue<uint64_t> m_highlightAddr; DecayValue<uint64_t> m_highlightAddr;
bool m_asmRelative; bool m_asmRelative;
bool m_asmShowSourceLocation;
std::vector<Line> m_lines; std::vector<Line> m_lines;
std::vector<AsmLine> m_asm; std::vector<AsmLine> m_asm;