mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Drag range boundary to change its span.
This commit is contained in:
parent
2f5f2e5b1d
commit
c1bf853310
@ -1679,6 +1679,81 @@ void View::DrawFrames()
|
||||
draw->AddLine( wpos + ImVec2( 0, round( Height - Height * BestTime / MaxFrameTime ) ), wpos + ImVec2( w, round( Height - Height * BestTime / MaxFrameTime ) ), 0x44DD9900 );
|
||||
}
|
||||
|
||||
void View::HandleRange( Range& range, int64_t timespan, const ImVec2& wpos, float w )
|
||||
{
|
||||
if( !ImGui::IsMouseDown( 0 ) ) range.modMin = range.modMax = false;
|
||||
if( !range.active ) return;
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
if( range.modMin )
|
||||
{
|
||||
const auto nspx = double( timespan ) / w;
|
||||
range.min = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx;
|
||||
range.hiMin = true;
|
||||
io.MouseDown[0] = false;
|
||||
if( range.min > range.max )
|
||||
{
|
||||
std::swap( range.min, range.max );
|
||||
std::swap( range.hiMin, range.hiMax );
|
||||
std::swap( range.modMin, range.modMax );
|
||||
}
|
||||
}
|
||||
else if( range.modMax )
|
||||
{
|
||||
const auto nspx = double( timespan ) / w;
|
||||
range.max = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx;
|
||||
range.hiMax = true;
|
||||
io.MouseDown[0] = false;
|
||||
if( range.min > range.max )
|
||||
{
|
||||
std::swap( range.min, range.max );
|
||||
std::swap( range.hiMin, range.hiMax );
|
||||
std::swap( range.modMin, range.modMax );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto pxns = w / double( timespan );
|
||||
const auto px0 = ( range.min - m_vd.zvStart ) * pxns;
|
||||
if( abs( px0 - ( io.MousePos.x - wpos.x ) ) < 3 )
|
||||
{
|
||||
range.hiMin = true;
|
||||
if( ImGui::IsMouseClicked( 0 ) )
|
||||
{
|
||||
range.modMin = true;
|
||||
range.min = m_vd.zvStart + ( io.MousePos.x - wpos.x ) / pxns;
|
||||
io.MouseDown[0] = false;
|
||||
if( range.min > range.max )
|
||||
{
|
||||
std::swap( range.min, range.max );
|
||||
std::swap( range.hiMin, range.hiMax );
|
||||
std::swap( range.modMin, range.modMax );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto px1 = ( range.max - m_vd.zvStart ) * pxns;
|
||||
if( abs( px1 - ( io.MousePos.x - wpos.x ) ) < 3 )
|
||||
{
|
||||
range.hiMax = true;
|
||||
if( ImGui::IsMouseClicked( 0 ) )
|
||||
{
|
||||
range.modMax = true;
|
||||
range.max = m_vd.zvStart + ( io.MousePos.x - wpos.x ) / pxns;
|
||||
io.MouseDown[0] = false;
|
||||
if( range.min > range.max )
|
||||
{
|
||||
std::swap( range.min, range.max );
|
||||
std::swap( range.hiMin, range.hiMax );
|
||||
std::swap( range.modMin, range.modMax );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
|
||||
{
|
||||
assert( timespan > 0 );
|
||||
@ -2330,6 +2405,7 @@ void View::DrawZones()
|
||||
const bool drawMouseLine = ImGui::IsMouseHoveringRect( winpos, winpos + winsize, false );
|
||||
if( drawMouseLine )
|
||||
{
|
||||
HandleRange( m_findZone.range, timespan, ImGui::GetCursorScreenPos(), w );
|
||||
HandleZoneViewMouse( timespan, ImGui::GetCursorScreenPos(), w, pxns );
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,8 @@ class View
|
||||
bool active = false;
|
||||
bool hiMin = false;
|
||||
bool hiMax = false;
|
||||
bool modMin = false;
|
||||
bool modMax = false;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -199,6 +201,7 @@ private:
|
||||
template<typename Adapter, typename V>
|
||||
void DrawGpuInfoChildren( const V& children, int64_t ztime );
|
||||
|
||||
void HandleRange( Range& range, int64_t timespan, const ImVec2& wpos, float w );
|
||||
void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns );
|
||||
|
||||
uint32_t GetThreadColor( uint64_t thread, int depth );
|
||||
|
Loading…
Reference in New Issue
Block a user