Add initial token theming.

This commit is contained in:
jmsgrogan 2023-01-17 13:01:59 +00:00
parent 3d37a7244b
commit 1f85954e98
34 changed files with 406 additions and 253 deletions

View file

@ -3,6 +3,8 @@
#include "TextNode.h"
#include "GeometryNode.h"
#include "TransformNode.h"
#include "ThemeManager.h"
#include "PaintEvent.h"
#include "MouseEvent.h"
#include "FileLogger.h"
@ -10,8 +12,8 @@
Button::Button()
: Widget(),
mLabel(),
mCachedColor(255, 255, 255),
mClickedColor(Color(180, 180, 180)),
mCachedColor(ThemeToken::SystemToken::Primary),
mClickedColor(ThemeToken::SystemToken::Secondary),
mClickFunc()
{
mName = "Button";
@ -46,8 +48,8 @@ void Button::onMyMouseEvent(const MouseEvent* event)
MLOG_INFO("Widget mouse event");
if(event->getAction() == MouseEvent::Action::Pressed)
{
mCachedColor = mBackgroundColor;
setBackgroundColor(mClickedColor);
mCachedColor = mBackground;
setBackground(mClickedColor);
if(mClickFunc)
{
mClickFunc(this);
@ -55,7 +57,7 @@ void Button::onMyMouseEvent(const MouseEvent* event)
}
else if(event->getAction() == MouseEvent::Action::Released)
{
setBackgroundColor(mCachedColor);
setBackground(mCachedColor);
}
}
@ -94,7 +96,7 @@ void Button::updateLabel(const PaintEvent* event)
if (mMaterialDirty)
{
mTextNode->setFillColor(mBackgroundColor);
mTextNode->setFillColor(event->getThemesManager()->getColor(mBackground));
}
if (mContentDirty)

View file

@ -36,8 +36,8 @@ protected:
private:
std::string mLabel;
clickFunc mClickFunc;
Color mCachedColor;
Color mClickedColor;
ThemeToken::SystemToken mCachedColor;
ThemeToken::SystemToken mClickedColor;
std::unique_ptr<TextNode> mTextNode;
bool mContentDirty{true};

View file

@ -4,6 +4,9 @@
#include "TransformNode.h"
#include "GeometryNode.h"
#include "ThemeManager.h"
#include "PaintEvent.h"
Label::Label()
: Widget(),
mLabel()
@ -51,7 +54,7 @@ void Label::updateLabel(const PaintEvent* event)
if (mMaterialDirty)
{
mTextNode->setFillColor(mBackgroundColor);
mTextNode->setFillColor(event->getThemesManager()->getColor(mBackground));
}
if (mTransformDirty)

View file

@ -5,6 +5,9 @@
#include "KeyboardEvent.h"
#include "TransformNode.h"
#include "ThemeManager.h"
#include "PaintEvent.h"
#include <sstream>
TextBox::TextBox()
@ -12,7 +15,7 @@ TextBox::TextBox()
mContent(),
mCaps(false)
{
mBackgroundColor = Color(250, 250, 250);
mBackground = ThemeToken::SystemToken::Background;
mPadding = {20, 0, 20, 0};
}
@ -95,7 +98,7 @@ void TextBox::updateLabel(const PaintEvent* event)
if (mMaterialDirty)
{
mTextNode->setFillColor(mBackgroundColor);
mTextNode->setFillColor(event->getThemesManager()->getColor(mBackground));
}
if (mTransformDirty)