mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Vertical scrolling of zone area.
This commit is contained in:
parent
737671adbf
commit
1b4a9379cc
@ -66,6 +66,8 @@ View::View( const char* addr )
|
|||||||
, m_frameStart( 0 )
|
, m_frameStart( 0 )
|
||||||
, m_zvStart( 0 )
|
, m_zvStart( 0 )
|
||||||
, m_zvEnd( 0 )
|
, m_zvEnd( 0 )
|
||||||
|
, m_zvHeight( 0 )
|
||||||
|
, m_zvScroll( 0 )
|
||||||
, m_zoneInfoWindow( nullptr )
|
, m_zoneInfoWindow( nullptr )
|
||||||
, m_lockHighlight { -1 }
|
, m_lockHighlight { -1 }
|
||||||
{
|
{
|
||||||
@ -92,6 +94,8 @@ View::View( FileRead& f )
|
|||||||
, m_frameStart( 0 )
|
, m_frameStart( 0 )
|
||||||
, m_zvStart( 0 )
|
, m_zvStart( 0 )
|
||||||
, m_zvEnd( 0 )
|
, m_zvEnd( 0 )
|
||||||
|
, m_zvHeight( 0 )
|
||||||
|
, m_zvScroll( 0 )
|
||||||
, m_zoneInfoWindow( nullptr )
|
, m_zoneInfoWindow( nullptr )
|
||||||
{
|
{
|
||||||
assert( s_instance == nullptr );
|
assert( s_instance == nullptr );
|
||||||
@ -1229,29 +1233,10 @@ void View::DrawFrames()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::DrawZones()
|
void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
|
||||||
{
|
{
|
||||||
if( m_zvStart == m_zvEnd ) return;
|
|
||||||
assert( m_zvStart < m_zvEnd );
|
|
||||||
|
|
||||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
|
||||||
if( window->SkipItems ) return;
|
|
||||||
|
|
||||||
auto& io = ImGui::GetIO();
|
auto& io = ImGui::GetIO();
|
||||||
|
|
||||||
const auto wpos = ImGui::GetCursorScreenPos();
|
|
||||||
const auto w = ImGui::GetWindowContentRegionWidth();
|
|
||||||
const auto h = ImGui::GetContentRegionAvail().y;
|
|
||||||
auto draw = ImGui::GetWindowDrawList();
|
|
||||||
|
|
||||||
ImGui::InvisibleButton( "##zones", ImVec2( w, h ) );
|
|
||||||
bool hover = ImGui::IsItemHovered();
|
|
||||||
|
|
||||||
auto timespan = m_zvEnd - m_zvStart;
|
|
||||||
auto pxns = w / double( timespan );
|
|
||||||
|
|
||||||
if( hover )
|
|
||||||
{
|
|
||||||
if( ImGui::IsMouseDragging( 1, 0 ) )
|
if( ImGui::IsMouseDragging( 1, 0 ) )
|
||||||
{
|
{
|
||||||
m_pause = true;
|
m_pause = true;
|
||||||
@ -1287,7 +1272,25 @@ void View::DrawZones()
|
|||||||
timespan = m_zvEnd - m_zvStart;
|
timespan = m_zvEnd - m_zvStart;
|
||||||
pxns = w / double( timespan );
|
pxns = w / double( timespan );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::DrawZoneFrames()
|
||||||
|
{
|
||||||
|
auto& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
const auto wpos = ImGui::GetCursorScreenPos();
|
||||||
|
const auto w = ImGui::GetWindowContentRegionWidth() - ImGui::GetStyle().ScrollbarSize;
|
||||||
|
const auto h = ImGui::GetFontSize();
|
||||||
|
const auto wh = ImGui::GetContentRegionAvail().y;
|
||||||
|
auto draw = ImGui::GetWindowDrawList();
|
||||||
|
|
||||||
|
ImGui::InvisibleButton( "##zoneFrames", ImVec2( w, h ) );
|
||||||
|
bool hover = ImGui::IsItemHovered();
|
||||||
|
|
||||||
|
auto timespan = m_zvEnd - m_zvStart;
|
||||||
|
auto pxns = w / double( timespan );
|
||||||
|
|
||||||
|
if( hover ) HandleZoneViewMouse( timespan, wpos, w, pxns );
|
||||||
|
|
||||||
m_zvStartNext = 0;
|
m_zvStartNext = 0;
|
||||||
|
|
||||||
@ -1330,7 +1333,7 @@ void View::DrawZones()
|
|||||||
|
|
||||||
if( fbegin >= m_zvStart && fsz > 4 )
|
if( fbegin >= m_zvStart && fsz > 4 )
|
||||||
{
|
{
|
||||||
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, h ), 0x22FFFFFF );
|
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, wh ), 0x22FFFFFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fsz >= 5 )
|
if( fsz >= 5 )
|
||||||
@ -1360,16 +1363,43 @@ void View::DrawZones()
|
|||||||
const auto fend = GetFrameEnd( zend-1 );
|
const auto fend = GetFrameEnd( zend-1 );
|
||||||
if( fend == m_zvEnd )
|
if( fend == m_zvEnd )
|
||||||
{
|
{
|
||||||
draw->AddLine( wpos + ImVec2( ( fend - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, h ), 0x22FFFFFF );
|
draw->AddLine( wpos + ImVec2( ( fend - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, wh ), 0x22FFFFFF );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( false );
|
while( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::DrawZones()
|
||||||
|
{
|
||||||
|
if( m_zvStart == m_zvEnd ) return;
|
||||||
|
assert( m_zvStart < m_zvEnd );
|
||||||
|
|
||||||
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
|
if( window->SkipItems ) return;
|
||||||
|
|
||||||
|
DrawZoneFrames();
|
||||||
|
|
||||||
|
ImGui::BeginChild( "##zoneWin", ImVec2( ImGui::GetWindowContentRegionWidth(), ImGui::GetContentRegionAvail().y ), false, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoScrollWithMouse );
|
||||||
|
|
||||||
|
window = ImGui::GetCurrentWindow();
|
||||||
|
const auto wpos = ImGui::GetCursorScreenPos();
|
||||||
|
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
|
||||||
|
const auto h = std::max<float>( m_zvHeight, ImGui::GetContentRegionAvail().y - 4 ); // magic border value
|
||||||
|
auto draw = ImGui::GetWindowDrawList();
|
||||||
|
|
||||||
|
ImGui::InvisibleButton( "##zones", ImVec2( w, h ) );
|
||||||
|
bool hover = ImGui::IsItemHovered();
|
||||||
|
|
||||||
|
auto timespan = m_zvEnd - m_zvStart;
|
||||||
|
auto pxns = w / double( timespan );
|
||||||
|
|
||||||
|
if( hover ) HandleZoneViewMouse( timespan, wpos, w, pxns );
|
||||||
|
|
||||||
// zones
|
// zones
|
||||||
LockHighlight nextLockHighlight { -1 };
|
LockHighlight nextLockHighlight { -1 };
|
||||||
const auto ty = ImGui::GetFontSize();
|
const auto ty = ImGui::GetFontSize();
|
||||||
const auto ostep = ty + 1;
|
const auto ostep = ty + 1;
|
||||||
int offset = 20;
|
int offset = 0;
|
||||||
const auto to = 9.f;
|
const auto to = 9.f;
|
||||||
const auto th = ( ty - to ) * sqrt( 3 ) * 0.5;
|
const auto th = ( ty - to ) * sqrt( 3 ) * 0.5;
|
||||||
for( auto& v : m_threads )
|
for( auto& v : m_threads )
|
||||||
@ -1406,6 +1436,19 @@ void View::DrawZones()
|
|||||||
offset += ostep * 0.2f;
|
offset += ostep * 0.2f;
|
||||||
}
|
}
|
||||||
m_lockHighlight = nextLockHighlight;
|
m_lockHighlight = nextLockHighlight;
|
||||||
|
|
||||||
|
const auto scrollPos = ImGui::GetScrollY();
|
||||||
|
if( scrollPos == 0 && m_zvScroll != 0 )
|
||||||
|
{
|
||||||
|
m_zvHeight = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( offset > m_zvHeight ) m_zvHeight = offset;
|
||||||
|
}
|
||||||
|
m_zvScroll = scrollPos;
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth )
|
int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth )
|
||||||
@ -1416,7 +1459,7 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd + m_resolution, [] ( const auto& l, const auto& r ) { return l->start < r; } );
|
const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd + m_resolution, [] ( const auto& l, const auto& r ) { return l->start < r; } );
|
||||||
if( it == zitend ) return depth;
|
if( it == zitend ) return depth;
|
||||||
|
|
||||||
const auto w = ImGui::GetWindowContentRegionWidth();
|
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
|
||||||
const auto ty = ImGui::GetFontSize();
|
const auto ty = ImGui::GetFontSize();
|
||||||
const auto ostep = ty + 1;
|
const auto ostep = ty + 1;
|
||||||
const auto offset = _offset + ostep * depth;
|
const auto offset = _offset + ostep * depth;
|
||||||
|
|||||||
@ -112,11 +112,14 @@ private:
|
|||||||
void DrawImpl();
|
void DrawImpl();
|
||||||
void DrawConnection();
|
void DrawConnection();
|
||||||
void DrawFrames();
|
void DrawFrames();
|
||||||
|
void DrawZoneFrames();
|
||||||
void DrawZones();
|
void DrawZones();
|
||||||
int DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth );
|
int DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth );
|
||||||
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight );
|
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight );
|
||||||
void DrawZoneInfoWindow();
|
void DrawZoneInfoWindow();
|
||||||
|
|
||||||
|
void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns );
|
||||||
|
|
||||||
uint32_t GetZoneColor( const Event& ev );
|
uint32_t GetZoneColor( const Event& ev );
|
||||||
uint32_t GetZoneColor( const QueueSourceLocation& srcloc );
|
uint32_t GetZoneColor( const QueueSourceLocation& srcloc );
|
||||||
uint32_t GetZoneHighlight( const Event& ev, bool migration );
|
uint32_t GetZoneHighlight( const Event& ev, bool migration );
|
||||||
@ -183,6 +186,9 @@ private:
|
|||||||
|
|
||||||
int8_t m_lastCpu;
|
int8_t m_lastCpu;
|
||||||
|
|
||||||
|
uint64_t m_zvHeight;
|
||||||
|
uint64_t m_zvScroll;
|
||||||
|
|
||||||
const Event* m_zoneInfoWindow;
|
const Event* m_zoneInfoWindow;
|
||||||
const Event* m_zoneHighlight;
|
const Event* m_zoneHighlight;
|
||||||
LockHighlight m_lockHighlight;
|
LockHighlight m_lockHighlight;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user