From 733b9c4048653cada4ee5a986a40a28f7d0c6760 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 1 Aug 2020 11:49:43 +0200 Subject: [PATCH] Add wrapper for ImGui mouse handling. --- profiler/build/win32/Tracy.vcxproj | 2 ++ profiler/build/win32/Tracy.vcxproj.filters | 6 +++++ server/TracyMouse.cpp | 26 ++++++++++++++++++++++ server/TracyMouse.hpp | 16 +++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 server/TracyMouse.cpp create mode 100644 server/TracyMouse.hpp diff --git a/profiler/build/win32/Tracy.vcxproj b/profiler/build/win32/Tracy.vcxproj index a4d0c975..9236c5c8 100644 --- a/profiler/build/win32/Tracy.vcxproj +++ b/profiler/build/win32/Tracy.vcxproj @@ -119,6 +119,7 @@ + @@ -200,6 +201,7 @@ + diff --git a/profiler/build/win32/Tracy.vcxproj.filters b/profiler/build/win32/Tracy.vcxproj.filters index 11de8bbc..4896670b 100644 --- a/profiler/build/win32/Tracy.vcxproj.filters +++ b/profiler/build/win32/Tracy.vcxproj.filters @@ -201,6 +201,9 @@ server + + server + @@ -491,6 +494,9 @@ server + + server + diff --git a/server/TracyMouse.cpp b/server/TracyMouse.cpp new file mode 100644 index 00000000..4c385179 --- /dev/null +++ b/server/TracyMouse.cpp @@ -0,0 +1,26 @@ +#include "TracyMouse.hpp" + +namespace tracy +{ + +bool IsMouseDown( ImGuiMouseButton button ) +{ + return ImGui::IsMouseDown( button ); +} + +bool IsMouseClicked( ImGuiMouseButton button ) +{ + return ImGui::IsMouseClicked( button ); +} + +bool IsMouseDragging( ImGuiMouseButton button, float lock_threshold ) +{ + return ImGui::IsMouseDragging( button, lock_threshold ); +} + +ImVec2 GetMouseDragDelta( ImGuiMouseButton button, float lock_threshold ) +{ + return ImGui::GetMouseDragDelta( button, lock_threshold ); +} + +} diff --git a/server/TracyMouse.hpp b/server/TracyMouse.hpp new file mode 100644 index 00000000..7b4c6b32 --- /dev/null +++ b/server/TracyMouse.hpp @@ -0,0 +1,16 @@ +#ifndef __TRACYMOUSE_HPP__ +#define __TRACYMOUSE_HPP__ + +#include "../imgui/imgui.h" + +namespace tracy +{ + +bool IsMouseDown( ImGuiMouseButton button ); +bool IsMouseClicked( ImGuiMouseButton button ); +bool IsMouseDragging( ImGuiMouseButton button, float lock_threshold = -1.f ); +ImVec2 GetMouseDragDelta( ImGuiMouseButton button, float lock_threshold = -1.f ); + +} + +#endif