Start adding themed buttons.
This commit is contained in:
parent
dfbc87cb09
commit
942cc2539c
18 changed files with 781 additions and 173 deletions
|
@ -9,13 +9,12 @@
|
|||
#include "MouseEvent.h"
|
||||
#include "FileLogger.h"
|
||||
|
||||
Button::Button()
|
||||
Button::Button(ButtonData::Component component)
|
||||
: Widget(),
|
||||
mLabel(),
|
||||
mCachedColor(ThemeToken::SystemToken::Primary),
|
||||
mClickedColor(ThemeToken::SystemToken::Secondary),
|
||||
mClickFunc()
|
||||
{
|
||||
mStyle.mComponent = component;
|
||||
mName = "Button";
|
||||
}
|
||||
|
||||
|
@ -24,9 +23,9 @@ Button::~Button()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<Button> Button::Create()
|
||||
std::unique_ptr<Button> Button::Create(ButtonData::Component component)
|
||||
{
|
||||
return std::make_unique<Button>();
|
||||
return std::make_unique<Button>(component);
|
||||
}
|
||||
|
||||
void Button::setOnClickFunction(clickFunc func)
|
||||
|
@ -48,8 +47,8 @@ void Button::onMyMouseEvent(const MouseEvent* event)
|
|||
MLOG_INFO("Widget mouse event");
|
||||
if(event->getAction() == MouseEvent::Action::Pressed)
|
||||
{
|
||||
mCachedColor = mBackground;
|
||||
setBackground(mClickedColor);
|
||||
mStyle.mState = ButtonData::State::Pressed;
|
||||
setBackground(mStyle.getContainerColor());
|
||||
if(mClickFunc)
|
||||
{
|
||||
mClickFunc(this);
|
||||
|
@ -57,7 +56,8 @@ void Button::onMyMouseEvent(const MouseEvent* event)
|
|||
}
|
||||
else if(event->getAction() == MouseEvent::Action::Released)
|
||||
{
|
||||
setBackground(mCachedColor);
|
||||
mStyle.mState = ButtonData::State::Enabled;
|
||||
setBackground(mStyle.getContainerColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue