mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Added IsAnyMouseDown() helper.
Examples: DirectX9/10/11: Using IsAnyMouseDown() instead of local function.
This commit is contained in:
parent
febde0eb21
commit
7cc1bc7635
@ -227,15 +227,6 @@ void ImGui_ImplDX10_RenderDrawLists(ImDrawData* draw_data)
|
||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
||||
}
|
||||
|
||||
static bool IsAnyMouseButtonDown()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
|
||||
if (io.MouseDown[n])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process Win32 mouse/keyboard inputs.
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||
@ -259,8 +250,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa
|
||||
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
|
||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
|
||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
|
||||
if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
|
||||
SetCapture(hwnd);
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
||||
::SetCapture(hwnd);
|
||||
io.MouseDown[button] = true;
|
||||
return 0;
|
||||
}
|
||||
@ -273,8 +264,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa
|
||||
if (msg == WM_RBUTTONUP) button = 1;
|
||||
if (msg == WM_MBUTTONUP) button = 2;
|
||||
io.MouseDown[button] = false;
|
||||
if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
|
||||
ReleaseCapture();
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
||||
::ReleaseCapture();
|
||||
return 0;
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
|
@ -234,15 +234,6 @@ void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
||||
}
|
||||
|
||||
static bool IsAnyMouseButtonDown()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
|
||||
if (io.MouseDown[n])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process Win32 mouse/keyboard inputs.
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||
@ -266,8 +257,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa
|
||||
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
|
||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
|
||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
|
||||
if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
|
||||
SetCapture(hwnd);
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
||||
::SetCapture(hwnd);
|
||||
io.MouseDown[button] = true;
|
||||
return 0;
|
||||
}
|
||||
@ -280,8 +271,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa
|
||||
if (msg == WM_RBUTTONUP) button = 1;
|
||||
if (msg == WM_MBUTTONUP) button = 2;
|
||||
io.MouseDown[button] = false;
|
||||
if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
|
||||
ReleaseCapture();
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
||||
::ReleaseCapture();
|
||||
return 0;
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
|
@ -173,15 +173,6 @@ void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||
d3d9_state_block->Release();
|
||||
}
|
||||
|
||||
static bool IsAnyMouseButtonDown()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
|
||||
if (io.MouseDown[n])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process Win32 mouse/keyboard inputs.
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||
@ -205,8 +196,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa
|
||||
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
|
||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
|
||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
|
||||
if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
|
||||
SetCapture(hwnd);
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
||||
::SetCapture(hwnd);
|
||||
io.MouseDown[button] = true;
|
||||
return 0;
|
||||
}
|
||||
@ -219,8 +210,8 @@ IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wPa
|
||||
if (msg == WM_RBUTTONUP) button = 1;
|
||||
if (msg == WM_MBUTTONUP) button = 2;
|
||||
io.MouseDown[button] = false;
|
||||
if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
|
||||
ReleaseCapture();
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
||||
::ReleaseCapture();
|
||||
return 0;
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
|
@ -4526,6 +4526,15 @@ bool ImGui::IsMouseDown(int button)
|
||||
return g.IO.MouseDown[button];
|
||||
}
|
||||
|
||||
bool ImGui::IsAnyMouseDown()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++)
|
||||
if (g.IO.MouseDown[n])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGui::IsMouseClicked(int button, bool repeat)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
1
imgui.h
1
imgui.h
@ -507,6 +507,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)..
|
||||
IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
|
||||
IMGUI_API bool IsMouseDown(int button); // is mouse button held
|
||||
IMGUI_API bool IsAnyMouseDown(); // is any mouse button held
|
||||
IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down)
|
||||
IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
|
Loading…
Reference in New Issue
Block a user