From 8080f5d9320983d6b04898a9f3a26b0760641a8d Mon Sep 17 00:00:00 2001 From: oznogon Date: Mon, 13 Apr 2026 22:37:46 -0700 Subject: [PATCH 1/6] Add, implement GuiElement::interceptsPointer() to flag which elements should capture hover state --- src/gui/gui2_button.h | 6 ++---- src/gui/gui2_element.h | 8 ++++---- src/gui/gui2_listbox.h | 1 + src/gui/gui2_panel.h | 8 +++----- src/gui/gui2_progressbar.h | 7 ++----- src/gui/gui2_progressslider.h | 1 + src/gui/gui2_rotationdial.h | 1 + src/gui/gui2_scrollbar.h | 8 +++----- src/gui/gui2_selector.h | 2 +- src/gui/gui2_slider.h | 8 ++++---- src/gui/gui2_textentry.h | 8 +++----- src/gui/hotkeyBinder.h | 8 +++----- 12 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/gui/gui2_button.h b/src/gui/gui2_button.h index 3ddcfc591d..cf31e4127f 100644 --- a/src/gui/gui2_button.h +++ b/src/gui/gui2_button.h @@ -1,5 +1,4 @@ -#ifndef GUI2_BUTTON_H -#define GUI2_BUTTON_H +#pragma once #include "gui2_element.h" @@ -25,6 +24,7 @@ class GuiButton : public GuiElement virtual void onDraw(sp::RenderTarget& renderer) override; virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } GuiButton* setText(string text); GuiButton* setTextSize(float size); @@ -33,5 +33,3 @@ class GuiButton : public GuiElement string getText() const; string getIcon() const; }; - -#endif//GUI2_BUTTON_H diff --git a/src/gui/gui2_element.h b/src/gui/gui2_element.h index bfb364fbb4..fae6f93a31 100644 --- a/src/gui/gui2_element.h +++ b/src/gui/gui2_element.h @@ -1,5 +1,4 @@ -#ifndef GUI2_ELEMENT_H -#define GUI2_ELEMENT_H +#pragma once #include #include "stringImproved.h" @@ -51,6 +50,9 @@ class GuiElement : public GuiContainer virtual void onTextInput(sp::TextInputEvent e); virtual void onFocusGained() {} virtual void onFocusLost() {} + // Return true if this element is allowed to intercept the pointer, + // i.e. for determining hover state. + virtual bool interceptsPointer() const { return false; } virtual void setAttribute(const string& key, const string& value) override; GuiElement* setSize(glm::vec2 size); @@ -91,5 +93,3 @@ class GuiElement : public GuiContainer protected: State getState() const; }; - -#endif//GUI2_ELEMENT_H diff --git a/src/gui/gui2_listbox.h b/src/gui/gui2_listbox.h index b2b04427cc..915dc904de 100644 --- a/src/gui/gui2_listbox.h +++ b/src/gui/gui2_listbox.h @@ -29,4 +29,5 @@ class GuiListbox : public GuiEntryList virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; virtual bool onMouseWheelScroll(glm::vec2 position, float value) override; + virtual bool interceptsPointer() const override { return true; } }; diff --git a/src/gui/gui2_panel.h b/src/gui/gui2_panel.h index 5d67d69d85..e26197d042 100644 --- a/src/gui/gui2_panel.h +++ b/src/gui/gui2_panel.h @@ -1,10 +1,9 @@ -#ifndef GUI2_PANEL_H -#define GUI2_PANEL_H +#pragma once #include "gui2_element.h" - class GuiThemeStyle; + class GuiPanel : public GuiElement { protected: @@ -14,6 +13,5 @@ class GuiPanel : public GuiElement virtual void onDraw(sp::RenderTarget& renderer) override; virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } }; - -#endif//GUI2_PANEL_H diff --git a/src/gui/gui2_progressbar.h b/src/gui/gui2_progressbar.h index 1f862b9a23..62d59d5eb3 100644 --- a/src/gui/gui2_progressbar.h +++ b/src/gui/gui2_progressbar.h @@ -1,10 +1,9 @@ -#ifndef GUI2_PROGRESSBAR_H -#define GUI2_PROGRESSBAR_H +#pragma once #include "gui2_element.h" - class GuiThemeStyle; + class GuiProgressbar : public GuiElement { protected: @@ -28,5 +27,3 @@ class GuiProgressbar : public GuiElement GuiProgressbar* setColor(glm::u8vec4 color); GuiProgressbar* setDrawBackground(bool drawBackground); }; - -#endif//GUI2_PROGRESSBAR_H diff --git a/src/gui/gui2_progressslider.h b/src/gui/gui2_progressslider.h index 2674335df3..6fe74ce373 100644 --- a/src/gui/gui2_progressslider.h +++ b/src/gui/gui2_progressslider.h @@ -14,6 +14,7 @@ class GuiProgressSlider : public GuiProgressbar virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } private: func_t callback; diff --git a/src/gui/gui2_rotationdial.h b/src/gui/gui2_rotationdial.h index a17f07bd04..b215907110 100644 --- a/src/gui/gui2_rotationdial.h +++ b/src/gui/gui2_rotationdial.h @@ -29,6 +29,7 @@ class GuiRotationDial : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } GuiRotationDial* setValue(float value); float getValue() const; diff --git a/src/gui/gui2_scrollbar.h b/src/gui/gui2_scrollbar.h index b449bc0faa..f13fb2ed92 100644 --- a/src/gui/gui2_scrollbar.h +++ b/src/gui/gui2_scrollbar.h @@ -1,10 +1,9 @@ -#ifndef GUI2_SCROLLBAR_H -#define GUI2_SCROLLBAR_H +#pragma once #include "gui2_element.h" - class GuiThemeStyle; + class GuiScrollbar : public GuiElement { typedef std::function func_t; @@ -34,6 +33,7 @@ class GuiScrollbar : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } GuiScrollbar* setRange(int min_value, int max_value); GuiScrollbar* setValueSize(int size); @@ -51,5 +51,3 @@ class GuiScrollbar : public GuiElement int getCorrectedMax() const; int getMin() const; }; - -#endif//GUI2_SCROLLBAR_H diff --git a/src/gui/gui2_selector.h b/src/gui/gui2_selector.h index 63cbba511c..2b9f1f58e1 100644 --- a/src/gui/gui2_selector.h +++ b/src/gui/gui2_selector.h @@ -2,7 +2,6 @@ #include "gui2_entrylist.h" - class GuiArrowButton; class GuiThemeStyle; class GuiToggleButton; @@ -25,6 +24,7 @@ class GuiSelector : public GuiEntryList virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onFocusLost() override; + virtual bool interceptsPointer() const override { return true; } GuiSelector* setTextSize(float size); }; diff --git a/src/gui/gui2_slider.h b/src/gui/gui2_slider.h index b8450ad4fe..107fadfd2a 100644 --- a/src/gui/gui2_slider.h +++ b/src/gui/gui2_slider.h @@ -1,10 +1,10 @@ -#ifndef GUI2_SLIDER_H -#define GUI2_SLIDER_H +#pragma once #include "gui2_element.h" #include "gui2_label.h" class GuiThemeStyle; + class GuiBasicSlider : public GuiElement { public: @@ -24,6 +24,7 @@ class GuiBasicSlider : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } GuiBasicSlider* setValue(float value); GuiBasicSlider* setRange(float min, float max); @@ -86,11 +87,10 @@ class GuiSlider2D : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } GuiSlider2D* clearSnapValues(); GuiSlider2D* addSnapValue(glm::vec2 value, glm::vec2 range); GuiSlider2D* setValue(glm::vec2 value); glm::vec2 getValue(); }; - -#endif//GUI2_SLIDER_H diff --git a/src/gui/gui2_textentry.h b/src/gui/gui2_textentry.h index 1b76772a49..f004b14948 100644 --- a/src/gui/gui2_textentry.h +++ b/src/gui/gui2_textentry.h @@ -1,11 +1,10 @@ -#ifndef GUI2_TEXTENTRY_H -#define GUI2_TEXTENTRY_H +#pragma once #include "gui2_element.h" #include "timer.h" - class GuiThemeStyle; + class GuiTextEntry : public GuiElement { public: @@ -40,6 +39,7 @@ class GuiTextEntry : public GuiElement virtual void onDraw(sp::RenderTarget& renderer) override; virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; + virtual bool interceptsPointer() const override { return true; } virtual void onTextInput(const string& text) override; virtual void onTextInput(sp::TextInputEvent e) override; virtual void onFocusGained() override; @@ -64,5 +64,3 @@ class GuiTextEntry : public GuiElement int getTextOffsetForPosition(glm::vec2 position); void runChangeCallback(); }; - -#endif//GUI2_TEXTENTRY_H diff --git a/src/gui/hotkeyBinder.h b/src/gui/hotkeyBinder.h index 06eae49bac..26b93faa00 100644 --- a/src/gui/hotkeyBinder.h +++ b/src/gui/hotkeyBinder.h @@ -1,10 +1,9 @@ -#ifndef HOTKEYBINDER_H -#define HOTKEYBINDER_H +#pragma once #include "gui2_element.h" - class GuiThemeStyle; + class GuiHotkeyBinder : public GuiElement { private: @@ -17,6 +16,5 @@ class GuiHotkeyBinder : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onDraw(sp::RenderTarget& renderer) override; + virtual bool interceptsPointer() const override { return true; } }; - -#endif //HOTKEYBINDER_H From 7d74aa43cac4ec2b9d2f3e4f69e35e8836ce9e8d Mon Sep 17 00:00:00 2001 From: oznogon Date: Mon, 13 Apr 2026 22:40:38 -0700 Subject: [PATCH 2/6] Add methods to manage per-element hover state - Add GuiContainer::getHoverElement() to return the GUI element being hovered at the mouse position. This is patterend after getClickElement() but uses interceptsPointer() instead of onMouseDown(). - Add GuiContainer::clearHover() to clear active hover effects for an element and its children. --- src/gui/gui2_container.cpp | 29 +++++++++++++++++++++++++++-- src/gui/gui2_container.h | 8 ++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/gui/gui2_container.cpp b/src/gui/gui2_container.cpp index 48ca46b184..fb7e9d8baf 100644 --- a/src/gui/gui2_container.cpp +++ b/src/gui/gui2_container.cpp @@ -30,8 +30,6 @@ void GuiContainer::drawElements(glm::vec2 mouse_position, sp::Rect parent_rect, element->owner = nullptr; delete element; }else{ - element->hover = element->rect.contains(mouse_position); - if (element->visible) { element->onDraw(renderer); @@ -97,6 +95,33 @@ GuiElement* GuiContainer::executeScrollOnElement(glm::vec2 position, float value return nullptr; } +GuiElement* GuiContainer::getHoverElement(glm::vec2 mouse_position) +{ + for (auto it = children.rbegin(); it != children.rend(); it++) + { + GuiElement* element = *it; + + if (element->visible && element->enabled && element->rect.contains(mouse_position)) + { + GuiElement* hovered = element->getHoverElement(mouse_position); + if (hovered) return hovered; + if (element->interceptsPointer()) return element; + } + } + + return nullptr; +} + +void GuiContainer::clearHover() +{ + for (GuiElement* element : children) + { + element->hover = false; + element->hover_coordinates = {-100, -100}; + element->clearHover(); + } +} + void GuiContainer::updateLayout(const sp::Rect& rect) { this->rect = rect; diff --git a/src/gui/gui2_container.h b/src/gui/gui2_container.h index 547aabb80c..b35d49b6c1 100644 --- a/src/gui/gui2_container.h +++ b/src/gui/gui2_container.h @@ -1,5 +1,4 @@ -#ifndef GUI2_CONTAINER_H -#define GUI2_CONTAINER_H +#pragma once #include #include @@ -17,6 +16,7 @@ namespace sp { class GuiElement; class GuiLayout; class GuiTheme; + class GuiContainer : sp::NonCopyable { public: @@ -63,6 +63,8 @@ class GuiContainer : sp::NonCopyable virtual void drawDebugElements(sp::Rect parent_rect, sp::RenderTarget& window); GuiElement* getClickElement(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id); GuiElement* executeScrollOnElement(glm::vec2 position, float value); + GuiElement* getHoverElement(glm::vec2 mouse_position); + void clearHover(); friend class GuiElement; @@ -70,5 +72,3 @@ class GuiContainer : sp::NonCopyable private: std::unique_ptr layout_manager = nullptr; }; - -#endif//GUI2_CONTAINER_H From 6dec09c06704a4f2a123eeeea2f303faf730dc16 Mon Sep 17 00:00:00 2001 From: oznogon Date: Mon, 13 Apr 2026 23:37:09 -0700 Subject: [PATCH 3/6] Use getHoverElement() in GuiCanvas Implement new per-element hover detection on GuiCanvas, which recurses into child elements. --- src/gui/gui2_canvas.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/gui2_canvas.cpp b/src/gui/gui2_canvas.cpp index f4ad51ed50..64147fd8d1 100644 --- a/src/gui/gui2_canvas.cpp +++ b/src/gui/gui2_canvas.cpp @@ -25,6 +25,13 @@ void GuiCanvas::render(sp::RenderTarget& renderer) runUpdates(this); updateLayout(window_rect); + clearHover(); + GuiElement* hovered = getHoverElement(mouse_position); + if (hovered) + { + hovered->hover = true; + hovered->hover_coordinates = mouse_position; + } drawElements(mouse_position, window_rect, renderer); if (enable_debug_rendering) @@ -172,9 +179,6 @@ void GuiCanvas::runUpdates(GuiContainer* parent) element->owner = nullptr; delete element; }else{ - element->hover = element->rect.contains(mouse_position); - element->hover_coordinates = mouse_position; - element->onUpdate(); if (element->isVisible()) runUpdates(element); From 4ace940a0bbe317ba21d1832e6e478a7d40c0406 Mon Sep 17 00:00:00 2001 From: oznogon Date: Tue, 14 Apr 2026 08:33:17 -0700 Subject: [PATCH 4/6] Move hover clearance to GuiContainer::drawElements Since we already iterate on elements in drawElements, check and clear hover there if necessary instead of in a separate pass. This changes the arguments for drawElements to pass the hovered element. --- src/gui/gui2_canvas.cpp | 8 +------- src/gui/gui2_container.cpp | 35 ++++++++++++++++------------------- src/gui/gui2_container.h | 3 +-- src/gui/gui2_element.cpp | 2 +- src/gui/gui2_element.h | 20 +++++++++----------- 5 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/gui/gui2_canvas.cpp b/src/gui/gui2_canvas.cpp index 64147fd8d1..dd79090097 100644 --- a/src/gui/gui2_canvas.cpp +++ b/src/gui/gui2_canvas.cpp @@ -25,14 +25,8 @@ void GuiCanvas::render(sp::RenderTarget& renderer) runUpdates(this); updateLayout(window_rect); - clearHover(); GuiElement* hovered = getHoverElement(mouse_position); - if (hovered) - { - hovered->hover = true; - hovered->hover_coordinates = mouse_position; - } - drawElements(mouse_position, window_rect, renderer); + drawElements(mouse_position, hovered, window_rect, renderer); if (enable_debug_rendering) { diff --git a/src/gui/gui2_container.cpp b/src/gui/gui2_container.cpp index fb7e9d8baf..d059629608 100644 --- a/src/gui/gui2_container.cpp +++ b/src/gui/gui2_container.cpp @@ -11,29 +11,36 @@ GuiContainer::~GuiContainer() } } -void GuiContainer::drawElements(glm::vec2 mouse_position, sp::Rect parent_rect, sp::RenderTarget& renderer) +void GuiContainer::drawElements(glm::vec2 mouse_position, GuiElement* hovered_element, sp::Rect parent_rect, sp::RenderTarget& renderer) { - for(auto it = children.begin(); it != children.end(); ) + for (auto it = children.begin(); it != children.end(); ) { GuiElement* element = *it; if (element->destroyed) { - //Find the owning cancas, as we need to remove ourselves if we are the focus or click element. + // Find the owning canvas, as we need to remove ourselves if we are + // the focus or click element. GuiCanvas* canvas = dynamic_cast(element->getTopLevelContainer()); - if (canvas) - canvas->unfocusElementTree(element); + if (canvas) canvas->unfocusElementTree(element); - //Delete it from our list. + // Delete it from our list. it = children.erase(it); // Free up the memory used by the element. element->owner = nullptr; delete element; - }else{ + } + else + { + // Manage this element's hover state. + element->hover = (element == hovered_element); + element->hover_coordinates = (element == hovered_element) ? mouse_position : glm::vec2{-100, -100}; + + // Draw the element. if (element->visible) { element->onDraw(renderer); - element->drawElements(mouse_position, element->rect, renderer); + element->drawElements(mouse_position, hovered_element, element->rect, renderer); } it++; @@ -105,23 +112,13 @@ GuiElement* GuiContainer::getHoverElement(glm::vec2 mouse_position) { GuiElement* hovered = element->getHoverElement(mouse_position); if (hovered) return hovered; - if (element->interceptsPointer()) return element; + if (element->intercepts_pointer) return element; } } return nullptr; } -void GuiContainer::clearHover() -{ - for (GuiElement* element : children) - { - element->hover = false; - element->hover_coordinates = {-100, -100}; - element->clearHover(); - } -} - void GuiContainer::updateLayout(const sp::Rect& rect) { this->rect = rect; diff --git a/src/gui/gui2_container.h b/src/gui/gui2_container.h index b35d49b6c1..51411926a8 100644 --- a/src/gui/gui2_container.h +++ b/src/gui/gui2_container.h @@ -59,12 +59,11 @@ class GuiContainer : sp::NonCopyable virtual void setAttribute(const string& key, const string& value); protected: - virtual void drawElements(glm::vec2 mouse_position, sp::Rect parent_rect, sp::RenderTarget& window); + virtual void drawElements(glm::vec2 mouse_position, GuiElement* hovered_element, sp::Rect parent_rect, sp::RenderTarget& window); virtual void drawDebugElements(sp::Rect parent_rect, sp::RenderTarget& window); GuiElement* getClickElement(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id); GuiElement* executeScrollOnElement(glm::vec2 position, float value); GuiElement* getHoverElement(glm::vec2 mouse_position); - void clearHover(); friend class GuiElement; diff --git a/src/gui/gui2_element.cpp b/src/gui/gui2_element.cpp index 2b4de8a811..dfc1df57bb 100644 --- a/src/gui/gui2_element.cpp +++ b/src/gui/gui2_element.cpp @@ -4,7 +4,7 @@ GuiElement::GuiElement(GuiContainer* owner, const string& id) -: owner(owner), visible(true), enabled(true), hover(false), focus(false), id(id) +: owner(owner), id(id) { owner->children.push_back(this); destroyed = false; diff --git a/src/gui/gui2_element.h b/src/gui/gui2_element.h index fae6f93a31..cd84f277d2 100644 --- a/src/gui/gui2_element.h +++ b/src/gui/gui2_element.h @@ -9,24 +9,25 @@ #include "graphics/renderTarget.h" #include "io/textinput.h" - class Layout; + class GuiElement : public GuiContainer { private: bool destroyed; protected: GuiContainer* owner; - bool visible; - bool enabled; - bool hover; + bool visible = true; + bool enabled = true; + bool hover = false; glm::vec2 hover_coordinates; - bool focus; + bool focus = false; + bool intercepts_pointer = false; string id; public: - constexpr static float GuiSizeMatchHeight = -1.0; - constexpr static float GuiSizeMatchWidth = -1.0; - constexpr static float GuiSizeMax = -2.0; + constexpr static float GuiSizeMatchHeight = -1.0f; + constexpr static float GuiSizeMatchWidth = -1.0f; + constexpr static float GuiSizeMax = -2.0f; enum class State { @@ -50,9 +51,6 @@ class GuiElement : public GuiContainer virtual void onTextInput(sp::TextInputEvent e); virtual void onFocusGained() {} virtual void onFocusLost() {} - // Return true if this element is allowed to intercept the pointer, - // i.e. for determining hover state. - virtual bool interceptsPointer() const { return false; } virtual void setAttribute(const string& key, const string& value) override; GuiElement* setSize(glm::vec2 size); From 227e29f7d04f3cca251e7a606ae26faf399306dd Mon Sep 17 00:00:00 2001 From: oznogon Date: Tue, 14 Apr 2026 08:34:19 -0700 Subject: [PATCH 5/6] Implement new hover management in relevant... ...GuiElement subclasses + frequencyCurve --- src/gui/gui2_button.cpp | 1 + src/gui/gui2_button.h | 1 - src/gui/gui2_listbox.cpp | 1 + src/gui/gui2_listbox.h | 1 - src/gui/gui2_panel.cpp | 1 + src/gui/gui2_panel.h | 1 - src/gui/gui2_progressslider.cpp | 1 + src/gui/gui2_progressslider.h | 1 - src/gui/gui2_rotationdial.cpp | 1 + src/gui/gui2_rotationdial.h | 1 - src/gui/gui2_scrollbar.cpp | 1 + src/gui/gui2_scrollbar.h | 1 - src/gui/gui2_selector.cpp | 1 + src/gui/gui2_selector.h | 1 - src/gui/gui2_slider.cpp | 2 ++ src/gui/gui2_slider.h | 2 -- src/gui/gui2_textentry.cpp | 1 + src/gui/gui2_textentry.h | 1 - src/gui/hotkeyBinder.cpp | 1 + src/gui/hotkeyBinder.h | 1 - src/screenComponents/frequencyCurve.cpp | 4 ++-- src/screenComponents/frequencyCurve.h | 2 +- 22 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/gui2_button.cpp b/src/gui/gui2_button.cpp index ab6fb2ce38..933b10b35b 100644 --- a/src/gui/gui2_button.cpp +++ b/src/gui/gui2_button.cpp @@ -6,6 +6,7 @@ GuiButton::GuiButton(GuiContainer* owner, string id, string text, func_t func) : GuiElement(owner, id), text(text), func(func) { + intercepts_pointer = true; text_size = -1; back_style = theme->getStyle("button.back"); front_style = theme->getStyle("button.front"); diff --git a/src/gui/gui2_button.h b/src/gui/gui2_button.h index cf31e4127f..38de1ea0df 100644 --- a/src/gui/gui2_button.h +++ b/src/gui/gui2_button.h @@ -24,7 +24,6 @@ class GuiButton : public GuiElement virtual void onDraw(sp::RenderTarget& renderer) override; virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } GuiButton* setText(string text); GuiButton* setTextSize(float size); diff --git a/src/gui/gui2_listbox.cpp b/src/gui/gui2_listbox.cpp index 76b4a0028b..04b726f23e 100644 --- a/src/gui/gui2_listbox.cpp +++ b/src/gui/gui2_listbox.cpp @@ -7,6 +7,7 @@ GuiListbox::GuiListbox(GuiContainer* owner, string id, func_t func) : GuiEntryList(owner, id, func), text_size(30), button_height(50), text_alignment(sp::Alignment::Center) { + intercepts_pointer = true; scroll = new GuiScrollbar(this, id + "_SCROLL", 0, 0, 0, [](int value) {}); scroll ->setClickChange(button_height) diff --git a/src/gui/gui2_listbox.h b/src/gui/gui2_listbox.h index 915dc904de..b2b04427cc 100644 --- a/src/gui/gui2_listbox.h +++ b/src/gui/gui2_listbox.h @@ -29,5 +29,4 @@ class GuiListbox : public GuiEntryList virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; virtual bool onMouseWheelScroll(glm::vec2 position, float value) override; - virtual bool interceptsPointer() const override { return true; } }; diff --git a/src/gui/gui2_panel.cpp b/src/gui/gui2_panel.cpp index 48c76516c9..39c519da48 100644 --- a/src/gui/gui2_panel.cpp +++ b/src/gui/gui2_panel.cpp @@ -5,6 +5,7 @@ GuiPanel::GuiPanel(GuiContainer* owner, string id) : GuiElement(owner, id) { + intercepts_pointer = true; style = theme->getStyle("panel"); } diff --git a/src/gui/gui2_panel.h b/src/gui/gui2_panel.h index e26197d042..d9ad6b60c5 100644 --- a/src/gui/gui2_panel.h +++ b/src/gui/gui2_panel.h @@ -13,5 +13,4 @@ class GuiPanel : public GuiElement virtual void onDraw(sp::RenderTarget& renderer) override; virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } }; diff --git a/src/gui/gui2_progressslider.cpp b/src/gui/gui2_progressslider.cpp index fc85155b14..62fb4ccee0 100644 --- a/src/gui/gui2_progressslider.cpp +++ b/src/gui/gui2_progressslider.cpp @@ -5,6 +5,7 @@ GuiProgressSlider::GuiProgressSlider(GuiContainer* owner, string id, float min_value, float max_value, float start_value, func_t func) : GuiProgressbar(owner, id, min_value, max_value, start_value), callback(func) { + intercepts_pointer = true; } bool GuiProgressSlider::onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) diff --git a/src/gui/gui2_progressslider.h b/src/gui/gui2_progressslider.h index 6fe74ce373..2674335df3 100644 --- a/src/gui/gui2_progressslider.h +++ b/src/gui/gui2_progressslider.h @@ -14,7 +14,6 @@ class GuiProgressSlider : public GuiProgressbar virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } private: func_t callback; diff --git a/src/gui/gui2_rotationdial.cpp b/src/gui/gui2_rotationdial.cpp index d58b78fb87..273d9c2dbc 100644 --- a/src/gui/gui2_rotationdial.cpp +++ b/src/gui/gui2_rotationdial.cpp @@ -9,6 +9,7 @@ GuiRotationDial::GuiRotationDial(GuiContainer* owner, string id, float min_value, float max_value, float start_value, float rotation_offset, float ring_thickness, func_t func) : GuiElement(owner, id), min_value(min_value), max_value(max_value), value(start_value), rotation_offset(rotation_offset), ring_thickness(ring_thickness), func(func) { + intercepts_pointer = true; radius = std::min(rect.size.x, rect.size.y) * 0.5f; // Fetch styles diff --git a/src/gui/gui2_rotationdial.h b/src/gui/gui2_rotationdial.h index b215907110..a17f07bd04 100644 --- a/src/gui/gui2_rotationdial.h +++ b/src/gui/gui2_rotationdial.h @@ -29,7 +29,6 @@ class GuiRotationDial : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } GuiRotationDial* setValue(float value); float getValue() const; diff --git a/src/gui/gui2_scrollbar.cpp b/src/gui/gui2_scrollbar.cpp index 3567dc8405..03f439e03e 100644 --- a/src/gui/gui2_scrollbar.cpp +++ b/src/gui/gui2_scrollbar.cpp @@ -6,6 +6,7 @@ GuiScrollbar::GuiScrollbar(GuiContainer* owner, string id, int min_value, int max_value, int start_value, func_t func) : GuiElement(owner, id), min_value(min_value), max_value(max_value), desired_value(start_value), value_size(1), func(func) { + intercepts_pointer = true; back_style = theme->getStyle("scrollbar.back"); front_style = theme->getStyle("scrollbar.front"); diff --git a/src/gui/gui2_scrollbar.h b/src/gui/gui2_scrollbar.h index f13fb2ed92..482ad48b82 100644 --- a/src/gui/gui2_scrollbar.h +++ b/src/gui/gui2_scrollbar.h @@ -33,7 +33,6 @@ class GuiScrollbar : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } GuiScrollbar* setRange(int min_value, int max_value); GuiScrollbar* setValueSize(int size); diff --git a/src/gui/gui2_selector.cpp b/src/gui/gui2_selector.cpp index 3eb375901e..bf8c726e45 100644 --- a/src/gui/gui2_selector.cpp +++ b/src/gui/gui2_selector.cpp @@ -10,6 +10,7 @@ GuiSelector::GuiSelector(GuiContainer* owner, string id, func_t func) : GuiEntryList(owner, id, func) { + intercepts_pointer = true; back_style = theme->getStyle("selector.back"); front_style = theme->getStyle("selector.front"); left = new GuiArrowButton(this, id + "_ARROW_LEFT", 0, [this]() { diff --git a/src/gui/gui2_selector.h b/src/gui/gui2_selector.h index 2b9f1f58e1..b4a0bbbe07 100644 --- a/src/gui/gui2_selector.h +++ b/src/gui/gui2_selector.h @@ -24,7 +24,6 @@ class GuiSelector : public GuiEntryList virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onFocusLost() override; - virtual bool interceptsPointer() const override { return true; } GuiSelector* setTextSize(float size); }; diff --git a/src/gui/gui2_slider.cpp b/src/gui/gui2_slider.cpp index 2f41247bec..be715237f4 100644 --- a/src/gui/gui2_slider.cpp +++ b/src/gui/gui2_slider.cpp @@ -8,6 +8,7 @@ GuiBasicSlider::GuiBasicSlider(GuiContainer* owner, string id, float min_value, float max_value, float start_value, func_t func) : GuiElement(owner, id), min_value(min_value), max_value(max_value), value(start_value), func(func) { + intercepts_pointer = true; front_style = theme->getStyle("slider.front"); back_style = theme->getStyle("slider.back"); } @@ -229,6 +230,7 @@ GuiSlider* GuiSlider::addOverlay(unsigned int precision, float font_size) GuiSlider2D::GuiSlider2D(GuiContainer* owner, string id, glm::vec2 min_value, glm::vec2 max_value, glm::vec2 start_value, func_t func) : GuiElement(owner, id), min_value(min_value), max_value(max_value), value(start_value), func(func) { + intercepts_pointer = true; front_style = theme->getStyle("slider.front"); back_style = theme->getStyle("slider.back"); } diff --git a/src/gui/gui2_slider.h b/src/gui/gui2_slider.h index 107fadfd2a..2863b70c37 100644 --- a/src/gui/gui2_slider.h +++ b/src/gui/gui2_slider.h @@ -24,7 +24,6 @@ class GuiBasicSlider : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } GuiBasicSlider* setValue(float value); GuiBasicSlider* setRange(float min, float max); @@ -87,7 +86,6 @@ class GuiSlider2D : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseUp(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } GuiSlider2D* clearSnapValues(); GuiSlider2D* addSnapValue(glm::vec2 value, glm::vec2 range); diff --git a/src/gui/gui2_textentry.cpp b/src/gui/gui2_textentry.cpp index e78f0bc96b..95491c14e7 100644 --- a/src/gui/gui2_textentry.cpp +++ b/src/gui/gui2_textentry.cpp @@ -6,6 +6,7 @@ GuiTextEntry::GuiTextEntry(GuiContainer* owner, string id, string text) : GuiElement(owner, id), text(text), text_size(30), func(nullptr) { + intercepts_pointer = true; blink_timer.repeat(blink_rate); front_style = theme->getStyle("textentry.front"); back_style = theme->getStyle("textentry.back"); diff --git a/src/gui/gui2_textentry.h b/src/gui/gui2_textentry.h index f004b14948..f1b70a0481 100644 --- a/src/gui/gui2_textentry.h +++ b/src/gui/gui2_textentry.h @@ -39,7 +39,6 @@ class GuiTextEntry : public GuiElement virtual void onDraw(sp::RenderTarget& renderer) override; virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onMouseDrag(glm::vec2 position, sp::io::Pointer::ID id) override; - virtual bool interceptsPointer() const override { return true; } virtual void onTextInput(const string& text) override; virtual void onTextInput(sp::TextInputEvent e) override; virtual void onFocusGained() override; diff --git a/src/gui/hotkeyBinder.cpp b/src/gui/hotkeyBinder.cpp index 7916b04675..28d784ec77 100644 --- a/src/gui/hotkeyBinder.cpp +++ b/src/gui/hotkeyBinder.cpp @@ -8,6 +8,7 @@ GuiHotkeyBinder::GuiHotkeyBinder(GuiContainer* owner, string id, sp::io::Keybinding* key) : GuiElement(owner, id), key(key) { + intercepts_pointer = true; front_style = theme->getStyle("textentry.front"); back_style = theme->getStyle("textentry.back"); } diff --git a/src/gui/hotkeyBinder.h b/src/gui/hotkeyBinder.h index 26b93faa00..393b7f0851 100644 --- a/src/gui/hotkeyBinder.h +++ b/src/gui/hotkeyBinder.h @@ -16,5 +16,4 @@ class GuiHotkeyBinder : public GuiElement virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override; virtual void onDraw(sp::RenderTarget& renderer) override; - virtual bool interceptsPointer() const override { return true; } }; diff --git a/src/screenComponents/frequencyCurve.cpp b/src/screenComponents/frequencyCurve.cpp index 8c956c4462..9b34221c09 100644 --- a/src/screenComponents/frequencyCurve.cpp +++ b/src/screenComponents/frequencyCurve.cpp @@ -79,8 +79,8 @@ void GuiFrequencyCurve::onDraw(sp::RenderTarget& renderer) } } -void GuiFrequencyCurve::drawElements(glm::vec2 mouse_position, sp::Rect parent_rect, sp::RenderTarget& window) +void GuiFrequencyCurve::drawElements(glm::vec2 mouse_position, GuiElement* hovered_element, sp::Rect parent_rect, sp::RenderTarget& window) { this->mouse_position = mouse_position; - GuiContainer::drawElements(mouse_position, parent_rect, window); + GuiContainer::drawElements(mouse_position, hovered_element, parent_rect, window); } \ No newline at end of file diff --git a/src/screenComponents/frequencyCurve.h b/src/screenComponents/frequencyCurve.h index 1aca4d9d49..d9e1046670 100644 --- a/src/screenComponents/frequencyCurve.h +++ b/src/screenComponents/frequencyCurve.h @@ -15,7 +15,7 @@ class GuiFrequencyCurve : public GuiPanel GuiFrequencyCurve(GuiContainer* owner, string id, bool frequency_is_beam, bool more_damage_is_positive); virtual void onDraw(sp::RenderTarget& target) override; - virtual void drawElements(glm::vec2 mouse_position, sp::Rect parent_rect, sp::RenderTarget& window) override; + virtual void drawElements(glm::vec2 mouse_position, GuiElement* hovered_element, sp::Rect parent_rect, sp::RenderTarget& window) override; GuiFrequencyCurve* setFrequency(int frequency) { this->frequency = frequency; return this; } From 159b52da4a1716a122b479b97b9ca332b63a599a Mon Sep 17 00:00:00 2001 From: oznogon Date: Tue, 14 Apr 2026 08:48:00 -0700 Subject: [PATCH 6/6] GuiFrequencyCurve pragma once --- src/screenComponents/frequencyCurve.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/screenComponents/frequencyCurve.h b/src/screenComponents/frequencyCurve.h index d9e1046670..edafd067f0 100644 --- a/src/screenComponents/frequencyCurve.h +++ b/src/screenComponents/frequencyCurve.h @@ -1,5 +1,4 @@ -#ifndef FREQUENCY_CURVE_H -#define FREQUENCY_CURVE_H +#pragma once #include "gui/gui2_panel.h" @@ -21,5 +20,3 @@ class GuiFrequencyCurve : public GuiPanel void setEnemyHasEquipment(bool state) { this->enemy_has_equipment = state; } }; - -#endif//FREQUENCY_CURVE_H