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

@ -9,6 +9,7 @@
#include "TextNode.h"
#include "TransformNode.h"
#include "RootNode.h"
#include "ThemeManager.h"
#include "Window.h"
#include "FileLogger.h"
@ -22,8 +23,8 @@ Widget::Widget()
mRootNode(std::make_unique<TransformNode>()),
mChildren(),
mBorderThickness(0),
mBackgroundColor(Color(255, 255, 255)),
mBorderColor(Color(0, 0, 0)),
mBackground(ThemeToken::SystemToken::Primary),
mBorder(ThemeToken::SystemToken::Outline),
mVisible(true)
{
mName = "Widget";
@ -65,11 +66,11 @@ TransformNode* Widget::getRootNode() const
void Widget::setBackgroundColor(const Color& color)
void Widget::setBackground(ThemeToken::SystemToken token)
{
if (mBackgroundColor != color)
if (mBackground != token)
{
mBackgroundColor = color;
mBackground = token;
mMaterialDirty = true;
}
}
@ -239,8 +240,8 @@ void Widget::updateBackground(const PaintEvent* event)
if (mMaterialDirty)
{
mBackgroundNode->setFillColor(mBackgroundColor);
mBackgroundNode->setStrokeColor(mBorderColor);
mBackgroundNode->setFillColor(event->getThemesManager()->getColor(mBackground));
mBackgroundNode->setStrokeColor(event->getThemesManager()->getColor(mBorder));
mBackgroundNode->setStrokeThickness(mBorderThickness);
}