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:
parent
84abfadc72
commit
acc1d9d834
@ -70,6 +70,7 @@ View::View( const char* addr )
|
|||||||
, m_zvScroll( 0 )
|
, m_zvScroll( 0 )
|
||||||
, m_zoneInfoWindow( nullptr )
|
, m_zoneInfoWindow( nullptr )
|
||||||
, m_lockHighlight { -1 }
|
, m_lockHighlight { -1 }
|
||||||
|
, m_drawRegion( false )
|
||||||
, m_showOptions( false )
|
, m_showOptions( false )
|
||||||
, m_showMessages( false )
|
, m_showMessages( false )
|
||||||
, m_drawZones( true )
|
, m_drawZones( true )
|
||||||
@ -102,6 +103,7 @@ View::View( FileRead& f )
|
|||||||
, m_zvHeight( 0 )
|
, m_zvHeight( 0 )
|
||||||
, m_zvScroll( 0 )
|
, m_zvScroll( 0 )
|
||||||
, m_zoneInfoWindow( nullptr )
|
, m_zoneInfoWindow( nullptr )
|
||||||
|
, m_drawRegion( false )
|
||||||
, m_showOptions( false )
|
, m_showOptions( false )
|
||||||
, m_showMessages( false )
|
, m_showMessages( false )
|
||||||
, m_drawZones( true )
|
, m_drawZones( true )
|
||||||
@ -1490,13 +1492,29 @@ void View::DrawFrames()
|
|||||||
|
|
||||||
void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
|
void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
|
||||||
{
|
{
|
||||||
|
assert( timespan > 0 );
|
||||||
auto& io = ImGui::GetIO();
|
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 ) )
|
if( ImGui::IsMouseDragging( 1, 0 ) )
|
||||||
{
|
{
|
||||||
m_pause = true;
|
m_pause = true;
|
||||||
const auto delta = ImGui::GetMouseDragDelta( 1, 0 );
|
const auto delta = ImGui::GetMouseDragDelta( 1, 0 );
|
||||||
const auto nspx = double( timespan ) / w;
|
|
||||||
const auto dpx = int64_t( delta.x * nspx );
|
const auto dpx = int64_t( delta.x * nspx );
|
||||||
if( dpx != 0 )
|
if( dpx != 0 )
|
||||||
{
|
{
|
||||||
@ -1751,7 +1769,18 @@ void View::DrawZones()
|
|||||||
|
|
||||||
ImGui::EndChild();
|
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();
|
auto& io = ImGui::GetIO();
|
||||||
draw->AddLine( ImVec2( io.MousePos.x, linepos.y ), ImVec2( io.MousePos.x, linepos.y + lineh ), 0x33FFFFFF );
|
draw->AddLine( ImVec2( io.MousePos.x, linepos.y ), ImVec2( io.MousePos.x, linepos.y + lineh ), 0x33FFFFFF );
|
||||||
|
|||||||
@ -238,6 +238,10 @@ private:
|
|||||||
LockHighlight m_lockHighlight;
|
LockHighlight m_lockHighlight;
|
||||||
const MessageData* m_msgHighlight;
|
const MessageData* m_msgHighlight;
|
||||||
|
|
||||||
|
bool m_drawRegion;
|
||||||
|
uint64_t m_regionStart;
|
||||||
|
uint64_t m_regionEnd;
|
||||||
|
|
||||||
bool m_showOptions;
|
bool m_showOptions;
|
||||||
bool m_showMessages;
|
bool m_showMessages;
|
||||||
bool m_drawZones;
|
bool m_drawZones;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user