diff --git a/editor/src/editor/Editor.cpp b/editor/src/editor/Editor.cpp index 3d0c70ea..dc46b41a 100644 --- a/editor/src/editor/Editor.cpp +++ b/editor/src/editor/Editor.cpp @@ -313,32 +313,6 @@ void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v) break; } } -class CHoverButton: public CTextButton { -public: - CHoverButton(const CRect& size, IControlListener* listener = nullptr, int32_t tag = -1, UTF8StringPtr title = nullptr) - : CTextButton(size, listener, tag, title) {} - - void setHoverColor(const CColor& color) - { - hoverColor = color; - } - - CMouseEventResult onMouseEntered (CPoint& where, const CButtonState& buttons) override - { - backupColor = getTextColor(); - setTextColor(hoverColor); - return CTextButton::onMouseEntered(where, buttons); - } - - CMouseEventResult onMouseExited (CPoint& where, const CButtonState& buttons) override - { - setTextColor(backupColor); - return CTextButton::onMouseExited(where, buttons); - } -private: - CColor hoverColor; - CColor backupColor; -}; void Editor::Impl::createFrameContents() { diff --git a/editor/src/editor/GUIComponents.cpp b/editor/src/editor/GUIComponents.cpp index d604d76e..cf344489 100644 --- a/editor/src/editor/GUIComponents.cpp +++ b/editor/src/editor/GUIComponents.cpp @@ -427,3 +427,21 @@ void SValueMenu::onItemClicked(int32_t index) if (getValue() != oldValue) valueChanged(); } + +void CHoverButton::setHoverColor (const CColor& color) +{ + hoverColor_ = color; +} + +CMouseEventResult CHoverButton::onMouseEntered (CPoint& where, const CButtonState& buttons) +{ + backupColor_ = getTextColor(); + setTextColor(hoverColor_); + return CTextButton::onMouseEntered(where, buttons); +} + +CMouseEventResult CHoverButton::onMouseExited (CPoint& where, const CButtonState& buttons) +{ + setTextColor(backupColor_); + return CTextButton::onMouseExited(where, buttons); +} diff --git a/editor/src/editor/GUIComponents.h b/editor/src/editor/GUIComponents.h index 8c295f5e..6b970864 100644 --- a/editor/src/editor/GUIComponents.h +++ b/editor/src/editor/GUIComponents.h @@ -11,6 +11,7 @@ #include "vstgui/lib/controls/cslider.h" #include "vstgui/lib/controls/cknob.h" #include "vstgui/lib/controls/ctextlabel.h" +#include "vstgui/lib/controls/cbuttons.h" #include "vstgui/lib/controls/coptionmenu.h" #include "vstgui/lib/cviewcontainer.h" #include "vstgui/lib/ccolor.h" @@ -146,3 +147,17 @@ private: SValueMenu& menu_; }; }; + +/// +class CHoverButton: public CTextButton { +public: + CHoverButton(const CRect& size, IControlListener* listener = nullptr, int32_t tag = -1, UTF8StringPtr title = nullptr) + : CTextButton(size, listener, tag, title) {} + + void setHoverColor(const CColor& color); + CMouseEventResult onMouseEntered (CPoint& where, const CButtonState& buttons) override; + CMouseEventResult onMouseExited (CPoint& where, const CButtonState& buttons) override; +private: + CColor hoverColor_; + CColor backupColor_; +};