Move HoverButton to GUIComponents
This commit is contained in:
parent
59c64bcb91
commit
574afcaf74
3 changed files with 33 additions and 26 deletions
|
|
@ -313,32 +313,6 @@ void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v)
|
||||||
break;
|
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()
|
void Editor::Impl::createFrameContents()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -427,3 +427,21 @@ void SValueMenu::onItemClicked(int32_t index)
|
||||||
if (getValue() != oldValue)
|
if (getValue() != oldValue)
|
||||||
valueChanged();
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "vstgui/lib/controls/cslider.h"
|
#include "vstgui/lib/controls/cslider.h"
|
||||||
#include "vstgui/lib/controls/cknob.h"
|
#include "vstgui/lib/controls/cknob.h"
|
||||||
#include "vstgui/lib/controls/ctextlabel.h"
|
#include "vstgui/lib/controls/ctextlabel.h"
|
||||||
|
#include "vstgui/lib/controls/cbuttons.h"
|
||||||
#include "vstgui/lib/controls/coptionmenu.h"
|
#include "vstgui/lib/controls/coptionmenu.h"
|
||||||
#include "vstgui/lib/cviewcontainer.h"
|
#include "vstgui/lib/cviewcontainer.h"
|
||||||
#include "vstgui/lib/ccolor.h"
|
#include "vstgui/lib/ccolor.h"
|
||||||
|
|
@ -146,3 +147,17 @@ private:
|
||||||
SValueMenu& menu_;
|
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_;
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue