mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Allow hiding plots.
This commit is contained in:
parent
4ed905ca88
commit
40d7a26b37
@ -606,6 +606,7 @@ void View::ProcessPlotData( const QueuePlotData& ev )
|
|||||||
{
|
{
|
||||||
plot = m_slab.Alloc<PlotData>();
|
plot = m_slab.Alloc<PlotData>();
|
||||||
plot->name = ev.name;
|
plot->name = ev.name;
|
||||||
|
plot->enabled = true;
|
||||||
m_pendingPlots.emplace( ev.name, plot );
|
m_pendingPlots.emplace( ev.name, plot );
|
||||||
ServerQuery( ServerQueryPlotName, ev.name );
|
ServerQuery( ServerQueryPlotName, ev.name );
|
||||||
}
|
}
|
||||||
@ -2099,15 +2100,34 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover )
|
|||||||
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
|
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
|
||||||
const auto ty = ImGui::GetFontSize();
|
const auto ty = ImGui::GetFontSize();
|
||||||
auto draw = ImGui::GetWindowDrawList();
|
auto draw = ImGui::GetWindowDrawList();
|
||||||
|
const auto to = 9.f;
|
||||||
|
const auto th = ( ty - to ) * sqrt( 3 ) * 0.5;
|
||||||
|
|
||||||
for( auto& v : m_plots )
|
for( auto& v : m_plots )
|
||||||
{
|
{
|
||||||
assert( !v->data.empty() );
|
assert( !v->data.empty() );
|
||||||
|
|
||||||
draw->AddText( wpos + ImVec2( ty, offset ), 0xFF44DDDD, GetString( v->name ) );
|
if( v->enabled )
|
||||||
|
{
|
||||||
|
draw->AddTriangleFilled( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( ty - to/2, offset + to/2 ), wpos + ImVec2( ty * 0.5, offset + to/2 + th ), 0xFF44DDDD );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
draw->AddTriangle( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( to/2, offset + ty - to/2 ), wpos + ImVec2( to/2 + th, offset + ty * 0.5 ), 0xFF226E6E );
|
||||||
|
}
|
||||||
|
const auto txt = GetString( v->name );
|
||||||
|
draw->AddText( wpos + ImVec2( ty, offset ), v->enabled ? 0xFF44DDDD : 0xFF226E6E, txt );
|
||||||
draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD );
|
draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD );
|
||||||
|
|
||||||
|
if( hover && ImGui::IsMouseClicked( 0 ) && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( ty + ImGui::CalcTextSize( txt ).x, offset + ty ) ) )
|
||||||
|
{
|
||||||
|
v->enabled = !v->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
offset += ty;
|
offset += ty;
|
||||||
|
|
||||||
|
if( v->enabled )
|
||||||
|
{
|
||||||
auto& vec = v->data;
|
auto& vec = v->data;
|
||||||
auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - m_delay, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - m_delay, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
||||||
auto end = std::lower_bound( vec.begin(), vec.end(), m_zvEnd + m_resolution, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
auto end = std::lower_bound( vec.begin(), vec.end(), m_zvEnd + m_resolution, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
||||||
@ -2166,7 +2186,9 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover )
|
|||||||
draw->AddText( wpos + ImVec2( 0, offset ), 0x8844DDDD, tmp );
|
draw->AddText( wpos + ImVec2( 0, offset ), 0x8844DDDD, tmp );
|
||||||
}
|
}
|
||||||
draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD );
|
draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD );
|
||||||
offset += 1.2 * ty;
|
offset += ty;
|
||||||
|
}
|
||||||
|
offset += 0.2 * ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
|||||||
@ -73,6 +73,7 @@ private:
|
|||||||
uint64_t name;
|
uint64_t name;
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
|
bool enabled;
|
||||||
std::vector<PlotItem> data;
|
std::vector<PlotItem> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user