mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Reorder threads by drag and drop.
This commit is contained in:
parent
29d8911c6b
commit
689f4999e3
@ -5543,36 +5543,25 @@ void View::DrawOptions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int idIdx = 0;
|
const auto wposx = ImGui::GetCursorScreenPos().x;
|
||||||
|
m_threadDnd.clear();
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int upIdx = -1;
|
|
||||||
int downIdx = -1;
|
|
||||||
for( const auto& t : m_threadOrder )
|
for( const auto& t : m_threadOrder )
|
||||||
{
|
{
|
||||||
ImGui::PushID( idIdx++ );
|
m_threadDnd.push_back( ImGui::GetCursorScreenPos().y );
|
||||||
#ifdef TRACY_EXTENDED_FONT
|
ImGui::PushID( idx );
|
||||||
if( ImGui::SmallButton( ICON_FA_CARET_UP ) )
|
const auto threadName = m_worker.GetThreadString( t->id );
|
||||||
#else
|
SmallCheckbox( threadName, &Vis( t ).visible );
|
||||||
if( ImGui::SmallButton( "^" ) )
|
if( ImGui::BeginDragDropSource( ImGuiDragDropFlags_SourceNoHoldToOpenOthers ) )
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
upIdx = idx;
|
ImGui::SetDragDropPayload( "ThreadOrder", &idx, sizeof(int) );
|
||||||
}
|
|
||||||
ImGui::PopID();
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::PushID( idIdx++ );
|
|
||||||
#ifdef TRACY_EXTENDED_FONT
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
if( ImGui::SmallButton( ICON_FA_CARET_DOWN ) )
|
ImGui::TextUnformatted( ICON_FA_RANDOM );
|
||||||
#else
|
|
||||||
if( ImGui::SmallButton( "v" ) )
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
downIdx = idx;
|
|
||||||
}
|
|
||||||
ImGui::PopID();
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::PushID( idIdx++ );
|
#endif
|
||||||
SmallCheckbox( m_worker.GetThreadString( t->id ), &Vis( t ).visible );
|
ImGui::TextUnformatted( threadName );
|
||||||
|
ImGui::EndDragDropSource();
|
||||||
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
if( crash.thread == t->id )
|
if( crash.thread == t->id )
|
||||||
{
|
{
|
||||||
@ -5601,13 +5590,45 @@ void View::DrawOptions()
|
|||||||
ImGui::TextDisabled( "%s top level zones", RealToString( t->timeline.size(), true ) );
|
ImGui::TextDisabled( "%s top level zones", RealToString( t->timeline.size(), true ) );
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if( upIdx > 0 )
|
if( m_threadDnd.size() > 1 )
|
||||||
{
|
{
|
||||||
std::swap( m_threadOrder[upIdx], m_threadOrder[upIdx-1] );
|
const auto w = ImGui::GetContentRegionAvail().x;
|
||||||
|
const auto dist = m_threadDnd[1] - m_threadDnd[0];
|
||||||
|
const auto half = dist * 0.5f;
|
||||||
|
m_threadDnd.push_back( m_threadDnd.back() + dist );
|
||||||
|
|
||||||
|
int target = -1;
|
||||||
|
int source;
|
||||||
|
for( size_t i=0; i<m_threadDnd.size(); i++ )
|
||||||
|
{
|
||||||
|
if( ImGui::BeginDragDropTargetCustom( ImRect( wposx, m_threadDnd[i] - half, wposx + w, m_threadDnd[i] + half ), i+1 ) )
|
||||||
|
{
|
||||||
|
auto draw = ImGui::GetWindowDrawList();
|
||||||
|
draw->AddLine( ImVec2( wposx, m_threadDnd[i] ), ImVec2( wposx + w, m_threadDnd[i] ), ImGui::GetColorU32(ImGuiCol_DragDropTarget), 2.f );
|
||||||
|
if( auto payload = ImGui::AcceptDragDropPayload( "ThreadOrder", ImGuiDragDropFlags_AcceptNoDrawDefaultRect ) )
|
||||||
|
{
|
||||||
|
target = (int)i;
|
||||||
|
source = *(int*)payload->Data;
|
||||||
}
|
}
|
||||||
if( downIdx >= 0 && (size_t)downIdx < m_threadOrder.size() - 1 )
|
ImGui::EndDragDropTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( target >= 0 && target != source )
|
||||||
{
|
{
|
||||||
std::swap( m_threadOrder[downIdx], m_threadOrder[downIdx+1] );
|
const auto srcval = m_threadOrder[source];
|
||||||
|
if( target < source )
|
||||||
|
{
|
||||||
|
assert( source < m_threadOrder.size() );
|
||||||
|
m_threadOrder.erase( m_threadOrder.begin() + source );
|
||||||
|
m_threadOrder.insert( m_threadOrder.begin() + target, srcval );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert( target <= m_threadOrder.size() );
|
||||||
|
m_threadOrder.insert( m_threadOrder.begin() + target, srcval );
|
||||||
|
m_threadOrder.erase( m_threadOrder.begin() + source );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,7 @@ private:
|
|||||||
flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift;
|
flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift;
|
||||||
flat_hash_map<const PlotData*, PlotView, nohash<const PlotData*>> m_plotView;
|
flat_hash_map<const PlotData*, PlotView, nohash<const PlotData*>> m_plotView;
|
||||||
Vector<const ThreadData*> m_threadOrder;
|
Vector<const ThreadData*> m_threadOrder;
|
||||||
|
Vector<float> m_threadDnd;
|
||||||
|
|
||||||
tracy_force_inline VisData& Vis( const void* ptr )
|
tracy_force_inline VisData& Vis( const void* ptr )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user