mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-25 23:15:06 -04:00
Auto-Hide Cursor after 3 seconds if F1 menu not open
This commit is contained in:
@@ -368,10 +368,16 @@ namespace dusk {
|
||||
m_menuTools.ShowStateShare();
|
||||
DuskDebugPad(); // temporary, remove later
|
||||
|
||||
// Only show cursor when menu or any windows are open
|
||||
if (showMenu || ImGui::GetIO().MetricsRenderWindows > 0) {
|
||||
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange;
|
||||
// Imgui will re-show cursor.
|
||||
// Hide mouse cursor if the F1 menu is not open and the cursor is idle for 3 seconds.
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (showMenu) {
|
||||
mouseHideTimer = 0.0f;
|
||||
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange; // Imgui will re-show cursor.
|
||||
} else if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f) {
|
||||
mouseHideTimer = 0.0f;
|
||||
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange; // Imgui will re-show cursor.
|
||||
} else if (mouseHideTimer <= 3.0f) {
|
||||
mouseHideTimer += ImGui::GetIO().DeltaTime;
|
||||
} else {
|
||||
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
|
||||
SDL_HideCursor();
|
||||
|
||||
@@ -38,6 +38,8 @@ private:
|
||||
remain(duration) {}
|
||||
};
|
||||
|
||||
float mouseHideTimer = 0.0f;
|
||||
|
||||
bool m_isHidden = true;
|
||||
bool m_isLaunchInitialized = false;
|
||||
bool m_touchTapActive = false;
|
||||
|
||||
Reference in New Issue
Block a user