From 81cb4acbe65c8ecc6ea17f87e6149177a0d4ed38 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 5 Jul 2026 18:47:38 +0200 Subject: [PATCH] Use ImGui mouse button identifiers instead of raw numeric ids. --- profiler/src/main.cpp | 4 +- profiler/src/profiler/TracySourceView.cpp | 24 ++++++------ .../src/profiler/TracyTimelineController.cpp | 2 +- profiler/src/profiler/TracyTimelineItem.cpp | 6 +-- .../src/profiler/TracyTimelineItemThread.cpp | 2 +- .../src/profiler/TracyView_ContextSwitch.cpp | 12 +++--- profiler/src/profiler/TracyView_CpuData.cpp | 6 +-- profiler/src/profiler/TracyView_FindZone.cpp | 8 ++-- .../src/profiler/TracyView_FlameGraph.cpp | 10 ++--- .../src/profiler/TracyView_FrameOverview.cpp | 14 +++---- .../src/profiler/TracyView_FrameTimeline.cpp | 20 +++++----- .../src/profiler/TracyView_GpuTimeline.cpp | 10 ++--- profiler/src/profiler/TracyView_Locks.cpp | 8 ++-- profiler/src/profiler/TracyView_Memory.cpp | 8 ++-- .../profiler/TracyView_NotificationArea.cpp | 26 ++++++------- profiler/src/profiler/TracyView_Options.cpp | 4 +- profiler/src/profiler/TracyView_Plots.cpp | 2 +- profiler/src/profiler/TracyView_Ranges.cpp | 14 +++---- profiler/src/profiler/TracyView_Samples.cpp | 4 +- profiler/src/profiler/TracyView_Timeline.cpp | 20 +++++----- profiler/src/profiler/TracyView_ZoneInfo.cpp | 16 ++++---- .../src/profiler/TracyView_ZoneTimeline.cpp | 38 +++++++++---------- 22 files changed, 129 insertions(+), 129 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 9a96c251..d55bb8ac 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -1383,7 +1383,7 @@ Would you like to enable achievements? if( ( animStage == 0 || animStage == 2 ) && ImGui::IsMouseHoveringRect( cursorScreen - ImVec2( dpiScale * 2, dpiScale * 2 ), cursorScreen + starSize + ImVec2( dpiScale * 4, dpiScale * 4 ) ) ) { color = 0xFFFFFFFF; - if( ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { if( animStage == 0 ) { @@ -1414,7 +1414,7 @@ Would you like to enable achievements? ImGui::PopFont(); if( animStage == 2 ) { - if( ImGui::IsMouseHoveringRect( dismiss - ImVec2( 0, dpiScale * 6 ), dismiss + ImVec2( aSize, th * 1.5f + dpiScale * 4 ) ) && ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseHoveringRect( dismiss - ImVec2( 0, dpiScale * 6 ), dismiss + ImVec2( aSize, th * 1.5f + dpiScale * 4 ) ) && ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { s_achievementItem = aItem; s_switchAchievementCategory = true; diff --git a/profiler/src/profiler/TracySourceView.cpp b/profiler/src/profiler/TracySourceView.cpp index 2319cf29..a731f7f1 100644 --- a/profiler/src/profiler/TracySourceView.cpp +++ b/profiler/src/profiler/TracySourceView.cpp @@ -1271,7 +1271,7 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) UnsetFont(); ImGui::EndTooltip(); } - if( ImGui::IsMouseClicked( 1 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Right ) ) { OpenSymbol( fileName, sd->line, v.addr, v.addr, worker, view ); } @@ -2428,13 +2428,13 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker } ImGui::EndTooltip(); SetFont(); - if( ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { m_targetAddr = v.first; m_selectedAddresses.clear(); m_selectedAddresses.emplace( v.first ); } - else if( ImGui::IsMouseClicked( 1 ) ) + else if( ImGui::IsMouseClicked( ImGuiMouseButton_Right ) ) { ImGui::OpenPopup( "jumpPopup" ); m_jumpPopupAddr = v.first; @@ -3109,7 +3109,7 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add ImGui::EndTooltip(); SetFont(); - if( ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { mouseHandled = true; auto& io = ImGui::GetIO(); @@ -3158,7 +3158,7 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add m_srcGroupSelect = lineNum; } } - else if( ImGui::IsMouseClicked( 1 ) ) + else if( ImGui::IsMouseClicked( ImGuiMouseButton_Right ) ) { mouseHandled = true; m_srcSampleSelect.clear(); @@ -3277,10 +3277,10 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add if( match > 0 && ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( w, ty ) ) ) { draw->AddRectFilled( wpos + ImVec2( 0, 1 ), wpos + ImVec2( w, ty ), 0x11FFFFFF ); - if( !mouseHandled && ( ImGui::IsMouseClicked( 0 ) || ImGui::IsMouseClicked( 1 ) ) ) + if( !mouseHandled && ( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) || ImGui::IsMouseClicked( ImGuiMouseButton_Right ) ) ) { m_displayMode = DisplayMixed; - SelectLine( lineNum, worker, ImGui::IsMouseClicked( 0 ) ); + SelectLine( lineNum, worker, ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ); } else { @@ -3462,7 +3462,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr ImGui::EndTooltip(); SetFont(); - if( ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { auto& io = ImGui::GetIO(); if( io.KeyCtrl ) @@ -3510,12 +3510,12 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr m_asmGroupSelect = idx; } } - else if( ImGui::IsMouseClicked( 1 ) ) + else if( ImGui::IsMouseClicked( ImGuiMouseButton_Right ) ) { m_asmSampleSelect.clear(); m_asmGroupSelect = -1; } - else if( stats && !stats->parents.empty() && ImGui::IsMouseClicked( 2 ) ) + else if( stats && !stats->parents.empty() && ImGui::IsMouseClicked( ImGuiMouseButton_Middle ) ) { view.ShowSampleParents( symAddrParents, false ); } @@ -4264,7 +4264,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr SetFont(); } } - if( ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { m_asmSelected = asmIdx; ResetAsm(); @@ -4297,7 +4297,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr FollowRead( asmIdx, line.writeX86[idx++], 64 ); } } - else if( ImGui::IsMouseClicked( 1 ) ) + else if( ImGui::IsMouseClicked( ImGuiMouseButton_Right ) ) { m_asmSelected = -1; ResetAsm(); diff --git a/profiler/src/profiler/TracyTimelineController.cpp b/profiler/src/profiler/TracyTimelineController.cpp index 164ce01e..8ad815f7 100644 --- a/profiler/src/profiler/TracyTimelineController.cpp +++ b/profiler/src/profiler/TracyTimelineController.cpp @@ -107,7 +107,7 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool const auto mouseMoved = mouseDelta.x != 0.0f || mouseDelta.y != 0.0f; const auto& mousePos = ImGui::GetIO().MousePos; const auto mouseVisible = ImGui::IsMousePosValid( &mousePos ); - return ( ( imguiChangedScroll || mouseMoved || !mouseVisible ) && !ImGui::IsMouseDown( 1 ) ) || !m_centerItemkey; + return ( ( imguiChangedScroll || mouseMoved || !mouseVisible ) && !ImGui::IsMouseDown( ImGuiMouseButton_Right ) ) || !m_centerItemkey; }; if( !vcenter ) diff --git a/profiler/src/profiler/TracyTimelineItem.cpp b/profiler/src/profiler/TracyTimelineItem.cpp index b2351dfb..d44f26c1 100644 --- a/profiler/src/profiler/TracyTimelineItem.cpp +++ b/profiler/src/profiler/TracyTimelineItem.cpp @@ -94,11 +94,11 @@ void TimelineItem::Draw( bool firstFrame, const TimelineContext& ctx, int yOffse { HeaderTooltip( label ); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_showFull = !m_showFull; } - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { const auto t0 = RangeBegin(); const auto t1 = RangeEnd(); @@ -107,7 +107,7 @@ void TimelineItem::Draw( bool firstFrame, const TimelineContext& ctx, int yOffse m_view.ZoomToRange( t0, t1 ); } } - if( IsMouseClicked( 1 ) ) + if( IsMouseClicked( ImGuiMouseButton_Right ) ) { ImGui::OpenPopup( "menuPopup" ); } diff --git a/profiler/src/profiler/TracyTimelineItemThread.cpp b/profiler/src/profiler/TracyTimelineItemThread.cpp index 9732c74a..18766c85 100644 --- a/profiler/src/profiler/TracyTimelineItemThread.cpp +++ b/profiler/src/profiler/TracyTimelineItemThread.cpp @@ -249,7 +249,7 @@ void TimelineItemThread::HeaderExtraContents( const TimelineContext& ctx, int of if( ctx.hover && ImGui::IsMouseHoveringRect( ctx.wpos + ImVec2( 1.5f * ty + labelWidth, offset ), ctx.wpos + ImVec2( 1.5f * ty + labelWidth + ghostSz, offset + ty ) ) ) { - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_ghost = !m_ghost; } diff --git a/profiler/src/profiler/TracyView_ContextSwitch.cpp b/profiler/src/profiler/TracyView_ContextSwitch.cpp index 84dea8cc..4179bed1 100644 --- a/profiler/src/profiler/TracyView_ContextSwitch.cpp +++ b/profiler/src/profiler/TracyView_ContextSwitch.cpp @@ -262,7 +262,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< } tooltip = true; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( prev.End(), ev.WakeupVal() ); } @@ -274,7 +274,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< TextFocused( "Thread is", "waking up" ); TextFocused( "Scheduling delay:", TimeToString( ev.Start() - ev.WakeupVal() ) ); TextFocused( "CPU:", RealToString( ev.Cpu() ) ); - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( prev.End(), ev.WakeupVal() ); } @@ -289,7 +289,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< ImGui::Separator(); TextDisabledUnformatted( ICON_FA_HOURGLASS_HALF " Wait stack:" ); CallstackTooltipContents( waitStack ); - if( ImGui::IsMouseClicked( 0 ) ) + if( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) ) { m_callstackView = { .id = waitStack, @@ -340,7 +340,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< } ImGui::EndTooltip(); - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( ev.Start(), end ); } @@ -357,7 +357,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< TextFocused( "Time:", TimeToString( end - ev.Start() ) ); ImGui::EndTooltip(); - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( ev.Start(), end ); } @@ -391,7 +391,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< } ImGui::EndTooltip(); - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( ev.Start(), end ); } diff --git a/profiler/src/profiler/TracyView_CpuData.cpp b/profiler/src/profiler/TracyView_CpuData.cpp index f101ff16..bde2b96d 100644 --- a/profiler/src/profiler/TracyView_CpuData.cpp +++ b/profiler/src/profiler/TracyView_CpuData.cpp @@ -197,7 +197,7 @@ bool View::DrawCpuData( const TimelineContext& ctx, const std::vector>& zones ) if( ImGui::IsItemHovered() ) { m_zoneHighlight = ev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( *ev ); } @@ -1456,12 +1456,12 @@ void View::DrawFindZone() TextFocused( "Time spent in the right bins:", TimeToString( tAfter ) ); ImGui::EndTooltip(); - if( IsMouseClicked( 1 ) ) + if( IsMouseClicked( ImGuiMouseButton_Right ) ) { m_findZone.highlight.active = false; m_findZone.ResetGroups(); } - else if( IsMouseClicked( 0 ) ) + else if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_findZone.highlight.active = true; m_findZone.highlight.start = t0; @@ -1469,7 +1469,7 @@ void View::DrawFindZone() m_findZone.hlOrig_t0 = t0; m_findZone.hlOrig_t1 = t1; } - else if( IsMouseDragging( 0 ) ) + else if( IsMouseDragging( ImGuiMouseButton_Left ) ) { if( t0 < m_findZone.hlOrig_t0 ) { diff --git a/profiler/src/profiler/TracyView_FlameGraph.cpp b/profiler/src/profiler/TracyView_FlameGraph.cpp index b892a0b4..5db2f369 100644 --- a/profiler/src/profiler/TracyView_FlameGraph.cpp +++ b/profiler/src/profiler/TracyView_FlameGraph.cpp @@ -631,7 +631,7 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct TextDisabledUnformatted( buf ); } - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { ViewDispatch( file, line, symAddr ); } @@ -661,7 +661,7 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct } ImGui::EndTooltip(); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_findZone.ShowZone( item.srcloc, slName ); } @@ -807,7 +807,7 @@ static bool DrawFlameGraphHorizontalPosition( int64_t& vStart, int64_t& vEnd, do ImGui::EndTooltip(); } - if( active && ImGui::IsMouseDragging( 0 ) ) + if( active && ImGui::IsMouseDragging( ImGuiMouseButton_Left ) ) { const auto delta = ImGui::GetIO().MouseDelta.x; ApplyFlameGraphPan( vStart, vEnd, pan, delta * totalSpan / w ); @@ -1269,9 +1269,9 @@ void View::DrawFlameGraph() ImGui::IsMouseHoveringRect( ImVec2( wpos.x, clipMin.y ), ImVec2( wpos.x + w, clipMax.y ), false ); const bool wheel_scroll = fabs( io.MouseWheelH ) > fabs( io.MouseWheel ); - if( hover && ( IsMouseDragging( 1 ) || wheel_scroll ) ) + if( hover && ( IsMouseDragging( ImGuiMouseButton_Right ) || wheel_scroll ) ) { - const auto delta = GetMouseDragDelta( 1 ); + const auto delta = GetMouseDragDelta( ImGuiMouseButton_Right ); const auto hwheel_delta = io.MouseWheelH * 50.f * m_horizontalScrollMultiplier; if( delta.x != 0 || hwheel_delta != 0 ) { diff --git a/profiler/src/profiler/TracyView_FrameOverview.cpp b/profiler/src/profiler/TracyView_FrameOverview.cpp index 13e49a3d..45b85b44 100644 --- a/profiler/src/profiler/TracyView_FrameOverview.cpp +++ b/profiler/src/profiler/TracyView_FrameOverview.cpp @@ -96,11 +96,11 @@ void View::DrawFrames() if( hover ) { const auto hwheel_delta = io.MouseWheelH * 100.f * m_horizontalScrollMultiplier; - if( IsMouseDragging( 1 ) || hwheel_delta != 0 ) + if( IsMouseDragging( ImGuiMouseButton_Right ) || hwheel_delta != 0 ) { m_viewMode = ViewMode::Paused; m_viewModeHeuristicTry = false; - auto delta = GetMouseDragDelta( 1 ).x; + auto delta = GetMouseDragDelta( ImGuiMouseButton_Right ).x; if( delta == 0 ) delta = hwheel_delta; if( abs( delta ) >= fwidth ) { @@ -137,7 +137,7 @@ void View::DrawFrames() ImGui::SameLine(); ImGui::TextDisabled( "(%.1f FPS)", 1000000000.0 / f ); - if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { m_worker.GetFrameTime( *m_frames, sel ), m_worker.GetFrameTime( *m_frames, sel + g - 1 ), true }; + if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { m_worker.GetFrameTime( *m_frames, sel ), m_worker.GetFrameTime( *m_frames, sel + g - 1 ), true }; } else { @@ -203,7 +203,7 @@ void View::DrawFrames() if( io.KeyCtrl ) { - if( fi && IsMouseDown( 0 ) ) + if( fi && IsMouseDown( ImGuiMouseButton_Left ) ) { m_showPlayback = true; m_playback.pause = true; @@ -212,7 +212,7 @@ void View::DrawFrames() } else { - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_viewMode = ViewMode::Paused; m_viewModeHeuristicTry = false; @@ -222,7 +222,7 @@ void View::DrawFrames() m_vd.zvEnd = m_worker.GetFrameEnd( *m_frames, sel + group - 1 ); if( m_vd.zvStart == m_vd.zvEnd ) m_vd.zvStart--; } - else if( IsMouseDragging( 0 ) ) + else if( IsMouseDragging( ImGuiMouseButton_Left ) ) { const auto t0 = std::min( m_vd.zvStart, m_worker.GetFrameBegin( *m_frames, sel ) ); const auto t1 = std::max( m_vd.zvEnd, m_worker.GetFrameEnd( *m_frames, sel + group - 1 ) ); @@ -230,7 +230,7 @@ void View::DrawFrames() } } - if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { m_worker.GetFrameBegin( *m_frames, sel ), m_worker.GetFrameEnd( *m_frames, sel + group - 1 ), true }; + if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { m_worker.GetFrameBegin( *m_frames, sel ), m_worker.GetFrameEnd( *m_frames, sel + group - 1 ), true }; } if( ( !m_worker.IsConnected() || m_viewMode == ViewMode::Paused ) && wheel != 0 ) diff --git a/profiler/src/profiler/TracyView_FrameTimeline.cpp b/profiler/src/profiler/TracyView_FrameTimeline.cpp index 924cd673..73c726c6 100644 --- a/profiler/src/profiler/TracyView_FrameTimeline.cpp +++ b/profiler/src/profiler/TracyView_FrameTimeline.cpp @@ -146,7 +146,7 @@ void View::DrawTimelineFrames( const FrameData& frames ) if( ImGui::IsMouseHoveringRect( wpos + ImVec2( x0, 0 ), wpos + ImVec2( x1, ty ) ) ) { tooltipDisplayed = true; - if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { fbegin, fend, true }; + if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { fbegin, fend, true }; ImGui::BeginTooltip(); ImGui::TextUnformatted( GetFrameText( frames, i, ftime ) ); @@ -159,7 +159,7 @@ void View::DrawTimelineFrames( const FrameData& frames ) ImGui::Separator(); DrawFrameImage( m_FrameTextureCache, *fi ); - if( ImGui::GetIO().KeyCtrl && IsMouseClicked( 0 ) ) + if( ImGui::GetIO().KeyCtrl && IsMouseClicked( ImGuiMouseButton_Left ) ) { m_showPlayback = true; m_playback.pause = true; @@ -168,7 +168,7 @@ void View::DrawTimelineFrames( const FrameData& frames ) } ImGui::EndTooltip(); - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( fbegin, fend ); } @@ -315,7 +315,7 @@ void View::DrawTimelineFrames( const FrameData& frames ) ImGui::TextUnformatted( GetFrameSetName( frames ) ); ImGui::EndTooltip(); } - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_frames = &frames; } @@ -467,8 +467,8 @@ void View::DrawTimelineSections() TextFocused( "Execution time:", TimeToString( groupEnd - start ) ); ImGui::EndTooltip(); - if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { start, groupEnd, true }; - if( IsMouseClicked( 2 ) ) ZoomToRange( start, groupEnd ); + if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { start, groupEnd, true }; + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) ZoomToRange( start, groupEnd ); } else { @@ -479,8 +479,8 @@ void View::DrawTimelineSections() TextFocused( "Time from start of program:", TimeToStringExact( start ) ); ImGui::EndTooltip(); - if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { start, end, true }; - if( IsMouseClicked( 2 ) ) ZoomToRange( start, end ); + if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { start, end, true }; + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) ZoomToRange( start, end ); } } @@ -533,8 +533,8 @@ void View::DrawTimelineSections() TextFocused( "Time from start of program:", TimeToStringExact( start ) ); ImGui::EndTooltip(); - if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { start, end, true }; - if( IsMouseClicked( 2 ) ) ZoomToRange( start, end ); + if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { start, end, true }; + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) ZoomToRange( start, end ); } ++i; diff --git a/profiler/src/profiler/TracyView_GpuTimeline.cpp b/profiler/src/profiler/TracyView_GpuTimeline.cpp index 2b80db2a..48c3064f 100644 --- a/profiler/src/profiler/TracyView_GpuTimeline.cpp +++ b/profiler/src/profiler/TracyView_GpuTimeline.cpp @@ -195,7 +195,7 @@ int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, TextFocused( "Execution time:", TimeToString( rend - start ) ); ImGui::EndTooltip(); - if( IsMouseClicked( 2 ) && rend - start > 0 ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) && rend - start > 0 ) { ZoomToRange( start, rend ); } @@ -205,11 +205,11 @@ int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const auto zoneThread = thread != 0 ? thread : m_worker.DecompressThread( ev.Thread() ); ZoneTooltip( ev ); - if( IsMouseClicked( 2 ) && rend - start > 0 ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) && rend - start > 0 ) { ZoomToZone( ev ); } - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { ShowZoneInfo( ev, zoneThread ); } @@ -291,11 +291,11 @@ int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const auto zoneThread = thread != 0 ? thread : m_worker.DecompressThread( ev.Thread() ); ZoneTooltip( ev ); - if( !m_zoomAnim.active && IsMouseClicked( 2 ) ) + if( !m_zoomAnim.active && IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( ev ); } - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { ShowZoneInfo( ev, zoneThread ); } diff --git a/profiler/src/profiler/TracyView_Locks.cpp b/profiler/src/profiler/TracyView_Locks.cpp index a40da532..a0279e9b 100644 --- a/profiler/src/profiler/TracyView_Locks.cpp +++ b/profiler/src/profiler/TracyView_Locks.cpp @@ -95,11 +95,11 @@ void View::DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLoca TextFocused( "Lock events:", RealToString( lockmap.timeline.size() ) ); ImGui::EndTooltip(); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_lockInfoWindow = id; } - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToRange( range.start, range.end ); } @@ -159,11 +159,11 @@ int View::DrawLocks( const TimelineContext& ctx, const std::vector& vec, const std::function& vec, const std::function range.max ) { @@ -156,7 +156,7 @@ void View::HandleRange( Range& range, int64_t timespan, const ImVec2& wpos, floa const auto nspx = double( timespan ) / w; range.max = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx; range.hiMax = true; - ConsumeMouseEvents( 0 ); + ConsumeMouseEvents( ImGuiMouseButton_Left ); ImGui::SetMouseCursor( ImGuiMouseCursor_ResizeEW ); if( range.min > range.max ) { @@ -173,11 +173,11 @@ void View::HandleRange( Range& range, int64_t timespan, const ImVec2& wpos, floa { range.hiMin = true; ImGui::SetMouseCursor( ImGuiMouseCursor_ResizeEW ); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { range.modMin = true; range.min = m_vd.zvStart + ( io.MousePos.x - wpos.x ) / pxns; - ConsumeMouseEvents( 0 ); + ConsumeMouseEvents( ImGuiMouseButton_Left ); if( range.min > range.max ) { std::swap( range.min, range.max ); @@ -193,11 +193,11 @@ void View::HandleRange( Range& range, int64_t timespan, const ImVec2& wpos, floa { range.hiMax = true; ImGui::SetMouseCursor( ImGuiMouseCursor_ResizeEW ); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { range.modMax = true; range.max = m_vd.zvStart + ( io.MousePos.x - wpos.x ) / pxns; - ConsumeMouseEvents( 0 ); + ConsumeMouseEvents( ImGuiMouseButton_Left ); if( range.min > range.max ) { std::swap( range.min, range.max ); diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index c1a90e0d..6bdce158 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -53,7 +53,7 @@ void View::DrawSampleList( const TimelineContext& ctx, const std::vectorcallstack.Val() ); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_callstackView = { .id = it->callstack.Val(), diff --git a/profiler/src/profiler/TracyView_Timeline.cpp b/profiler/src/profiler/TracyView_Timeline.cpp index 3217d1ef..a8942d3d 100644 --- a/profiler/src/profiler/TracyView_Timeline.cpp +++ b/profiler/src/profiler/TracyView_Timeline.cpp @@ -23,16 +23,16 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w ) const auto nspx = double( timespan ) / w; - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_highlight.active = true; m_highlight.start = m_highlight.end = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx; } - else if( IsMouseDragging( 0 ) ) + else if( IsMouseDragging( ImGuiMouseButton_Left ) ) { m_highlight.end = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx; } - else if( m_highlight.active && !IsMouseDown( 0 ) ) + else if( m_highlight.active && !IsMouseDown( ImGuiMouseButton_Left ) ) { if( ImGui::GetIO().KeyCtrl && m_highlight.start != m_highlight.end ) { @@ -41,16 +41,16 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w ) m_highlight.active = false; } - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { m_highlightZoom.active = true; m_highlightZoom.start = m_highlightZoom.end = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx; } - else if( IsMouseDragging( 2 ) ) + else if( IsMouseDragging( ImGuiMouseButton_Middle ) ) { m_highlightZoom.end = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx; } - else if( m_highlightZoom.active && !IsMouseDown( 2 ) ) + else if( m_highlightZoom.active && !IsMouseDown( ImGuiMouseButton_Middle ) ) { if( m_highlightZoom.start != m_highlightZoom.end ) { @@ -88,13 +88,13 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w ) } const bool wheel_scroll = abs( io.MouseWheelH ) > abs( io.MouseWheel ); - if( IsMouseDragging( 1 ) || wheel_scroll ) + if( IsMouseDragging( ImGuiMouseButton_Right ) || wheel_scroll ) { m_viewMode = ViewMode::Paused; m_viewModeHeuristicTry = false; m_zoomAnim.active = false; if( !m_playback.pause && m_playback.sync ) m_playback.pause = true; - const auto delta = GetMouseDragDelta( 1 ); + const auto delta = GetMouseDragDelta( ImGuiMouseButton_Right ); m_yDelta = delta.y; const auto hwheel_delta = io.MouseWheelH * 50.f * m_horizontalScrollMultiplier; const auto dpx = int64_t( (delta.x * nspx) + (hwheel_delta * nspx)); @@ -292,7 +292,7 @@ void View::DrawTimeline() v->range.StartFrame(); HandleRange( v->range, timespan, ImGui::GetCursorScreenPos(), w ); } - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { const auto ty = ImGui::GetTextLineHeight(); for( auto& ann : m_annotations ) @@ -303,7 +303,7 @@ void View::DrawTimeline() if( ImGui::IsMouseHoveringRect( linepos + ImVec2( aMin, lineh - ty * 1.5f ), linepos + ImVec2( aMax, lineh ) ) ) { m_selectedAnnotation = ann.get(); - ConsumeMouseEvents( 0 ); + ConsumeMouseEvents( ImGuiMouseButton_Left ); break; } } diff --git a/profiler/src/profiler/TracyView_ZoneInfo.cpp b/profiler/src/profiler/TracyView_ZoneInfo.cpp index b092072a..5ca114fd 100644 --- a/profiler/src/profiler/TracyView_ZoneInfo.cpp +++ b/profiler/src/profiler/TracyView_ZoneInfo.cpp @@ -925,7 +925,7 @@ void View::DrawZoneInfoWindow() if( hover ) { m_zoneHighlight = v; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( *v ); } @@ -1185,7 +1185,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime ) if( ImGui::IsItemHovered() ) { m_zoneHighlight = &cev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( cev ); } @@ -1254,7 +1254,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime ) if( ImGui::IsItemHovered() ) { m_zoneHighlight = &cev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( cev ); } @@ -1320,7 +1320,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime ) if( ImGui::IsItemHovered() ) { m_zoneHighlight = &cev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( cev ); } @@ -1533,7 +1533,7 @@ void View::DrawGpuInfoWindow() if( hover ) { m_gpuHighlight = v; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( *v ); } @@ -1659,7 +1659,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime ) if( ImGui::IsItemHovered() ) { m_gpuHighlight = &cev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( cev ); } @@ -1722,7 +1722,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime ) if( ImGui::IsItemHovered() ) { m_gpuHighlight = &cev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( cev ); } @@ -1778,7 +1778,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime ) if( ImGui::IsItemHovered() ) { m_gpuHighlight = &cev; - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { ZoomToZone( cev ); } diff --git a/profiler/src/profiler/TracyView_ZoneTimeline.cpp b/profiler/src/profiler/TracyView_ZoneTimeline.cpp index 5d3c8962..bd540ba0 100644 --- a/profiler/src/profiler/TracyView_ZoneTimeline.cpp +++ b/profiler/src/profiler/TracyView_ZoneTimeline.cpp @@ -161,12 +161,12 @@ void View::DrawThreadMessagesList( const TimelineContext& ctx, const std::vector ImGui::EndTooltip(); m_msgHighlight = &msg; - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_showMessages = true; m_msgToFocus = &msg; } - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { CenterAtTime( msg.time ); } @@ -188,14 +188,14 @@ void View::DrawThreadMessagesList( const TimelineContext& ctx, const std::vector if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px - (ty - to) * 0.5 - 1, offset ), wpos + ImVec2( px + (ty - to) * 0.5 + 1, offset + ty ) ) ) { CrashTooltip(); - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { m_callstackView = { .id = crash.callstack, .thread = crash.thread }; } - if( IsMouseClicked( 2 ) ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { CenterAtTime( crash.time ); } @@ -297,7 +297,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector 1 ) { ImGui::BeginTooltip(); @@ -306,7 +306,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector 0 ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) && rend - ev.Start() > 0 ) { ZoomToRange( ev.Start(), rend ); } @@ -315,11 +315,11 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector 0 ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) && rend - ev.Start() > 0 ) { ZoomToZone( ev ); } - if( IsMouseClicked( 0 ) ) + if( IsMouseClicked( ImGuiMouseButton_Left ) ) { if( ImGui::GetIO().KeyCtrl ) { @@ -388,13 +388,13 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector 0 ) + if( IsMouseClicked( ImGuiMouseButton_Middle ) && rend - ev.start.Val() > 0 ) { ZoomToRange( ev.start.Val(), rend ); } @@ -485,7 +485,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector> 63 != 0 ) @@ -587,11 +587,11 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector