1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Measurement of time period by LMB dragging.

This commit is contained in:
Bartosz Taudul 2017-10-15 16:42:56 +02:00
parent 84abfadc72
commit acc1d9d834
2 changed files with 35 additions and 2 deletions

View File

@ -70,6 +70,7 @@ View::View( const char* addr )
, m_zvScroll( 0 )
, m_zoneInfoWindow( nullptr )
, m_lockHighlight { -1 }
, m_drawRegion( false )
, m_showOptions( false )
, m_showMessages( false )
, m_drawZones( true )
@ -102,6 +103,7 @@ View::View( FileRead& f )
, m_zvHeight( 0 )
, m_zvScroll( 0 )
, m_zoneInfoWindow( nullptr )
, m_drawRegion( false )
, m_showOptions( false )
, m_showMessages( false )
, m_drawZones( true )
@ -1490,13 +1492,29 @@ void View::DrawFrames()
void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
{
assert( timespan > 0 );
auto& io = ImGui::GetIO();
const auto nspx = double( timespan ) / w;
if( ImGui::IsMouseClicked( 0 ) )
{
m_drawRegion = true;
m_regionEnd = m_regionStart = m_zvStart + ( io.MousePos.x - wpos.x ) * nspx;
}
else if( ImGui::IsMouseDragging( 0, 0 ) )
{
m_regionEnd = m_zvStart + ( io.MousePos.x - wpos.x ) * nspx;
}
else
{
m_drawRegion = false;
}
if( ImGui::IsMouseDragging( 1, 0 ) )
{
m_pause = true;
const auto delta = ImGui::GetMouseDragDelta( 1, 0 );
const auto nspx = double( timespan ) / w;
const auto dpx = int64_t( delta.x * nspx );
if( dpx != 0 )
{
@ -1751,7 +1769,18 @@ void View::DrawZones()
ImGui::EndChild();
if( drawMouseLine )
if( m_drawRegion && m_regionStart != m_regionEnd )
{
const auto s = std::min( m_regionStart, m_regionEnd );
const auto e = std::max( m_regionStart, m_regionEnd );
draw->AddRectFilled( ImVec2( wpos.x + ( s - m_zvStart ) * pxns, linepos.y ), ImVec2( wpos.x + ( e - m_zvStart ) * pxns, linepos.y + lineh ), 0x22DD8888 );
draw->AddRect( ImVec2( wpos.x + ( s - m_zvStart ) * pxns, linepos.y ), ImVec2( wpos.x + ( e - m_zvStart ) * pxns, linepos.y + lineh ), 0x44DD8888 );
ImGui::BeginTooltip();
ImGui::Text( "%s", TimeToString( e - s ) );
ImGui::EndTooltip();
}
else if( drawMouseLine )
{
auto& io = ImGui::GetIO();
draw->AddLine( ImVec2( io.MousePos.x, linepos.y ), ImVec2( io.MousePos.x, linepos.y + lineh ), 0x33FFFFFF );

View File

@ -238,6 +238,10 @@ private:
LockHighlight m_lockHighlight;
const MessageData* m_msgHighlight;
bool m_drawRegion;
uint64_t m_regionStart;
uint64_t m_regionEnd;
bool m_showOptions;
bool m_showMessages;
bool m_drawZones;