From 9a1c2e516e88e09835efe07c97345953094027cc Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Sat, 7 Mar 2026 16:46:58 +0300 Subject: [PATCH] Revert GUI tap changes for now, as GUI doesnt work properly when program is lagging --- src/GUIStuff/Elements/Element.cpp | 5 ++--- src/GUIStuff/GUIManager.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/GUIStuff/Elements/Element.cpp b/src/GUIStuff/Elements/Element.cpp index d415702..38da295 100644 --- a/src/GUIStuff/Elements/Element.cpp +++ b/src/GUIStuff/Elements/Element.cpp @@ -49,6 +49,7 @@ namespace GUIStuff { if(hovered) { held = true; clicked = true; + selected = true; timeClicked = std::chrono::steady_clock::now(); clickPos = cursorPos; } @@ -56,10 +57,8 @@ namespace GUIStuff { selected = false; } else if(!isLeftHeld) { - if(held && hovered && (std::chrono::steady_clock::now() - timeClicked) < std::chrono::milliseconds(250) && vec_distance_sqrd(clickPos, cursorPos) < (25 * 25)) { - selected = true; + if(held && hovered && (std::chrono::steady_clock::now() - timeClicked) < std::chrono::milliseconds(250) && vec_distance_sqrd(clickPos, cursorPos) < (25 * 25)) tapped = true; - } held = false; } diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp index d1a279f..3dac43f 100644 --- a/src/GUIStuff/GUIManager.cpp +++ b/src/GUIStuff/GUIManager.cpp @@ -334,14 +334,14 @@ bool GUIManager::radio_button(const char* id, bool val, const std::function(); e->update(*io, val, elemUpdate); pop_id(); - return e->selection.tapped; + return e->selection.clicked; } void GUIManager::checkbox(const char* id, bool* val, const std::function& elemUpdate) { push_id(id); CheckBox* e = insert_element(); e->update(*io, *val, elemUpdate); - if(e->selection.tapped) + if(e->selection.clicked) *val = !(*val); pop_id(); } @@ -431,7 +431,8 @@ bool GUIManager::selectable_button(const char* id, const std::function(); e->update(*io, drawType, elemUpdate, isSelected); - bool toRet = onClick ? e->selection.clicked : e->selection.tapped; + //bool toRet = onClick ? e->selection.clicked : e->selection.tapped; + bool toRet = e->selection.clicked; pop_id(); return toRet; } @@ -856,7 +857,7 @@ bool GUIManager::rotate_wheel(const char* id, double* angle, float size, const s CLAY_AUTO_ID({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(size), .height = CLAY_SIZING_FIXED(size) } } }) { RotateWheel* e = insert_element(); e->update(*io, angle, elemUpdate); - toRet = e->selection.tapped; + toRet = e->selection.clicked; } pop_id(); return toRet;