From 792843d34e33f5e4cef28c08b66715b0358f428b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 20 Sep 2017 02:19:39 +0200 Subject: [PATCH] Use invisible button to fake frames widget. This handles both positioning and prevents window from being moved by mouse. --- server/TracyView.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 4f9a73e8..1d2b0e70 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -438,7 +438,6 @@ static int GetFrameGroup( int frameScale ) void View::DrawFrames() { - enum { Offset = 25 }; enum { Height = 40 }; enum { MaxFrameTime = 50 * 1000 * 1000 }; // 50ms @@ -447,13 +446,15 @@ void View::DrawFrames() auto& io = ImGui::GetIO(); - const auto wpos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin() + ImVec2( 0, Offset ); + const auto wpos = ImGui::GetCursorScreenPos(); const auto wspace = ImGui::GetWindowContentRegionMax() - ImGui::GetWindowContentRegionMin(); const auto w = wspace.x; auto draw = ImGui::GetWindowDrawList(); + ImGui::InvisibleButton( "##frames", ImVec2( w, Height ) ); + bool hover = ImGui::IsItemHovered(); + draw->AddRectFilled( wpos, wpos + ImVec2( w, Height ), 0x33FFFFFF ); - bool hover = ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( w, 60 ) ); const auto wheel = io.MouseWheel; const auto prevScale = m_frameScale; if( hover )