Fix up compilation.

This commit is contained in:
jmsgrogan 2023-01-18 11:17:41 +00:00
parent 7cab70f839
commit 19091a0e80
13 changed files with 46 additions and 48 deletions

View file

@ -4,7 +4,7 @@
StatusBar::StatusBar() StatusBar::StatusBar()
{ {
setBackground(ThemeToken::SystemToken::Secondary); setBackground(Theme::Sys::Color::Secondary);
} }
std::unique_ptr<StatusBar> StatusBar::Create() std::unique_ptr<StatusBar> StatusBar::Create()

View file

@ -38,7 +38,7 @@ void TabbedPanelWidget::addPanel(WidgetUPtr panel, const std::string& label)
{ {
auto button = Button::Create(); auto button = Button::Create();
button->setLabel(label); button->setLabel(label);
button->setBackground(ThemeToken::SystemToken::Primary); button->setBackground(Theme::Sys::Color::Primary);
button->setMargin({1, 0, 0, 1}); button->setMargin({1, 0, 0, 1});
auto rawPanel = panel.get(); auto rawPanel = panel.get();

View file

@ -8,11 +8,11 @@
TopBar::TopBar() TopBar::TopBar()
{ {
setBackground(ThemeToken::SystemToken::Secondary); setBackground(Theme::Sys::Color::Secondary);
auto fileButton = Button::Create(); auto fileButton = Button::Create();
fileButton->setLabel("File"); fileButton->setLabel("File");
fileButton->setBackground(ThemeToken::SystemToken::Primary); fileButton->setBackground(Theme::Sys::Color::Primary);
fileButton->setMargin(2); fileButton->setMargin(2);
fileButton->setMaxWidth(60); fileButton->setMaxWidth(60);

View file

@ -4,8 +4,9 @@
const float ButtonData::DEFAULT_CONTAINER_OPACITY = 1; const float ButtonData::DEFAULT_CONTAINER_OPACITY = 1;
const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mContainerColors = { const std::map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mContainerColors = {
{{Component::Elevated, State::Enabled}, Theme::Sys::Color::Surface}, {{Component::Elevated, State::Enabled}, Theme::Sys::Color::Surface},
{{Component::Elevated, State::Disabled}, Theme::Sys::Color::On_Surface}, {{Component::Elevated, State::Disabled}, Theme::Sys::Color::On_Surface},
{{Component::Elevated, State::Hovered}, Theme::Sys::Color::Primary}, {{Component::Elevated, State::Hovered}, Theme::Sys::Color::Primary},
{{Component::Elevated, State::Focused}, Theme::Sys::Color::Primary}, {{Component::Elevated, State::Focused}, Theme::Sys::Color::Primary},
@ -18,12 +19,12 @@ const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonDa
{{Component::Filled, State::Pressed}, Theme::Sys::Color::On_Primary}, {{Component::Filled, State::Pressed}, Theme::Sys::Color::On_Primary},
}; };
const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mContainerShadowColors = { const std::map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mContainerShadowColors = {
{{Component::Elevated, State::Enabled}, Theme::Sys::Color::Shadow}, {{Component::Elevated, State::Enabled}, Theme::Sys::Color::Shadow},
{{Component::Filled, State::Enabled}, Theme::Sys::Color::Shadow}, {{Component::Filled, State::Enabled}, Theme::Sys::Color::Shadow},
}; };
const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Elevation> ButtonData::mContainerElevations = { const std::map<ButtonData::ComponentState, Theme::Sys::Elevation> ButtonData::mContainerElevations = {
{{Component::Elevated, State::Enabled}, Theme::Sys::Elevation::Level_1}, {{Component::Elevated, State::Enabled}, Theme::Sys::Elevation::Level_1},
{{Component::Elevated, State::Disabled}, Theme::Sys::Elevation::Level_0}, {{Component::Elevated, State::Disabled}, Theme::Sys::Elevation::Level_0},
{{Component::Elevated, State::Hovered}, Theme::Sys::Elevation::Level_2}, {{Component::Elevated, State::Hovered}, Theme::Sys::Elevation::Level_2},
@ -36,19 +37,19 @@ const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Elevation> Butt
{{Component::Filled, State::Pressed}, Theme::Sys::Elevation::Level_0}, {{Component::Filled, State::Pressed}, Theme::Sys::Elevation::Level_0},
}; };
const std::unordered_map<ButtonData::ComponentState, float> ButtonData::mContainerOpacity = { const std::map<ButtonData::ComponentState, float> ButtonData::mContainerOpacity = {
{{Component::Elevated, State::Disabled}, 0.12}, {{Component::Elevated, State::Disabled}, 0.12f},
{{Component::Elevated, State::Hovered}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Hover)}, {{Component::Elevated, State::Hovered}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Hover)},
{{Component::Elevated, State::Focused}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Focus)}, {{Component::Elevated, State::Focused}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Focus)},
{{Component::Elevated, State::Pressed}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Pressed)}, {{Component::Elevated, State::Pressed}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Pressed)},
{{Component::Filled, State::Disabled}, 0.12}, {{Component::Filled, State::Disabled}, 0.12f},
{{Component::Filled, State::Hovered}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Hover)}, {{Component::Filled, State::Hovered}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Hover)},
{{Component::Filled, State::Focused}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Focus)}, {{Component::Filled, State::Focused}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Focus)},
{{Component::Filled, State::Pressed}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Pressed)}, {{Component::Filled, State::Pressed}, OpacityTokens::getValue(Theme::Sys::StateLayerOpacity::State::Pressed)},
}; };
const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mLabelTextColors = { const std::map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mLabelTextColors = {
{{Component::Elevated, State::Enabled}, Theme::Sys::Color::Primary}, {{Component::Elevated, State::Enabled}, Theme::Sys::Color::Primary},
{{Component::Elevated, State::Disabled}, Theme::Sys::Color::On_Surface}, {{Component::Elevated, State::Disabled}, Theme::Sys::Color::On_Surface},
{{Component::Elevated, State::Hovered}, Theme::Sys::Color::Primary}, {{Component::Elevated, State::Hovered}, Theme::Sys::Color::Primary},
@ -62,17 +63,17 @@ const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonDa
{{Component::Filled, State::Pressed}, Theme::Sys::Color::On_Primary}, {{Component::Filled, State::Pressed}, Theme::Sys::Color::On_Primary},
}; };
const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Typescale> ButtonData::mLabelTypescales = { const std::map<ButtonData::ComponentState, Theme::Sys::Typescale> ButtonData::mLabelTypescales = {
{{Component::Elevated, State::Enabled}, Theme::Sys::Typescale::Label_Large}, {{Component::Elevated, State::Enabled}, Theme::Sys::Typescale::Label_Large},
{{Component::Filled, State::Enabled}, Theme::Sys::Typescale::Label_Large}, {{Component::Filled, State::Enabled}, Theme::Sys::Typescale::Label_Large},
}; };
const std::unordered_map<ButtonData::ComponentState, float> ButtonData::mLabelTextOpacity = { const std::map<ButtonData::ComponentState, float> ButtonData::mLabelTextOpacity = {
{{Component::Elevated, State::Disabled}, 0.38}, {{Component::Elevated, State::Disabled}, 0.38f},
{{Component::Filled, State::Disabled}, 0.38}, {{Component::Filled, State::Disabled}, 0.38f},
}; };
const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mIconColors = { const std::map<ButtonData::ComponentState, Theme::Sys::Color> ButtonData::mIconColors = {
{{Component::Elevated, State::Enabled}, Theme::Sys::Color::Primary}, {{Component::Elevated, State::Enabled}, Theme::Sys::Color::Primary},
{{Component::Elevated, State::Disabled}, Theme::Sys::Color::On_Surface}, {{Component::Elevated, State::Disabled}, Theme::Sys::Color::On_Surface},
{{Component::Elevated, State::Hovered}, Theme::Sys::Color::Primary}, {{Component::Elevated, State::Hovered}, Theme::Sys::Color::Primary},
@ -86,9 +87,9 @@ const std::unordered_map<ButtonData::ComponentState, Theme::Sys::Color> ButtonDa
{{Component::Filled, State::Pressed}, Theme::Sys::Color::On_Primary}, {{Component::Filled, State::Pressed}, Theme::Sys::Color::On_Primary},
}; };
const std::unordered_map<ButtonData::ComponentState, float> ButtonData::mIconOpacity = { const std::map<ButtonData::ComponentState, float> ButtonData::mIconOpacity = {
{{Component::Elevated, State::Disabled}, 0.38}, {{Component::Elevated, State::Disabled}, 0.38f},
{{Component::Filled, State::Disabled}, 0.38}, {{Component::Filled, State::Disabled}, 0.38f},
}; };
Theme::Sys::Color ButtonData::getContainerColor() const Theme::Sys::Color ButtonData::getContainerColor() const

View file

@ -4,7 +4,7 @@
#include "FontTokens.h" #include "FontTokens.h"
#include "ElevationTokens.h" #include "ElevationTokens.h"
#include <unordered_map> #include <map>
class ButtonData class ButtonData
{ {
@ -67,17 +67,17 @@ public:
private: private:
using ComponentState = std::pair<Component, State>; using ComponentState = std::pair<Component, State>;
static const std::unordered_map<ComponentState, Theme::Sys::Color> mContainerColors; static const std::map<ComponentState, Theme::Sys::Color> mContainerColors;
static const std::unordered_map<ComponentState, Theme::Sys::Color> mContainerShadowColors; static const std::map<ComponentState, Theme::Sys::Color> mContainerShadowColors;
static const std::unordered_map<ComponentState, Theme::Sys::Elevation> mContainerElevations; static const std::map<ComponentState, Theme::Sys::Elevation> mContainerElevations;
static const std::unordered_map<ComponentState, float> mContainerOpacity; static const std::map<ComponentState, float> mContainerOpacity;
static const std::unordered_map<ComponentState, Theme::Sys::Color> mLabelTextColors; static const std::map<ComponentState, Theme::Sys::Color> mLabelTextColors;
static const std::unordered_map<ComponentState, Theme::Sys::Typescale> mLabelTypescales; static const std::map<ComponentState, Theme::Sys::Typescale> mLabelTypescales;
static const std::unordered_map<ComponentState, float> mLabelTextOpacity; static const std::map<ComponentState, float> mLabelTextOpacity;
static const std::unordered_map<ComponentState, Theme::Sys::Color> mIconColors; static const std::map<ComponentState, Theme::Sys::Color> mIconColors;
static const std::unordered_map<ComponentState, float> mIconOpacity; static const std::map<ComponentState, float> mIconOpacity;
static const Theme::Sys::Color DEFAULT_CONTAINER_COLOR{ Theme::Sys::Color::None }; static const Theme::Sys::Color DEFAULT_CONTAINER_COLOR{ Theme::Sys::Color::None };
static const Theme::Sys::Color DEFAULT_CONTAINER_SHADOW_COLOR{ Theme::Sys::Color::None }; static const Theme::Sys::Color DEFAULT_CONTAINER_SHADOW_COLOR{ Theme::Sys::Color::None };

View file

@ -15,7 +15,7 @@ TextBox::TextBox()
mContent(), mContent(),
mCaps(false) mCaps(false)
{ {
mBackground = ThemeToken::SystemToken::Background; mBackground = Theme::Sys::Color::Background;
mPadding = {20, 0, 20, 0}; mPadding = {20, 0, 20, 0};
} }

View file

@ -44,10 +44,7 @@ namespace Theme
Label_Small, Label_Small,
Body_Large, Body_Large,
Body_Medium, Body_Medium,
Body_Small, Body_Small
Label_Large,
Label_Medium,
Label_Small
}; };
}; };
}; };

View file

@ -25,15 +25,15 @@ public:
switch (token) switch (token)
{ {
case Theme::Sys::StateLayerOpacity::State::Hover: case Theme::Sys::StateLayerOpacity::State::Hover:
return 0.08; return 0.08f;
case Theme::Sys::StateLayerOpacity::State::Focus: case Theme::Sys::StateLayerOpacity::State::Focus:
return 0.12; return 0.12f;
case Theme::Sys::StateLayerOpacity::State::Pressed: case Theme::Sys::StateLayerOpacity::State::Pressed:
return 0.12; return 0.12f;
case Theme::Sys::StateLayerOpacity::State::Dragged: case Theme::Sys::StateLayerOpacity::State::Dragged:
return 0.16; return 0.16f;
default: default:
return 0.0; return 0.0f;
} }
} }
}; };

View file

@ -7,7 +7,7 @@
class ThemeManager class ThemeManager
{ {
public: public:
Color getColor(ThemeToken::SystemToken token) const; Color getColor(Theme::Sys::Color token) const;
private: private:
std::unique_ptr<ITheme> mActiveTheme; std::unique_ptr<ITheme> mActiveTheme;

View file

@ -7,7 +7,7 @@ ThemeManager::ThemeManager()
mTheme = std::make_unique<LightTheme>(); mTheme = std::make_unique<LightTheme>();
} }
Color ThemeManager::getColor(ThemeToken::SystemToken token) const Color ThemeManager::getColor(Theme::Sys::Color token) const
{ {
return mTheme->getColor(token); return mTheme->getColor(token);
} }

View file

@ -6,7 +6,7 @@ class ThemeManager
{ {
public: public:
ThemeManager(); ThemeManager();
Color getColor(ThemeToken::SystemToken token) const; Color getColor(Theme::Sys::Color token) const;
private: private:
std::unique_ptr<ITheme> mTheme; std::unique_ptr<ITheme> mTheme;
}; };

View file

@ -23,8 +23,8 @@ Widget::Widget()
mRootNode(std::make_unique<TransformNode>()), mRootNode(std::make_unique<TransformNode>()),
mChildren(), mChildren(),
mBorderThickness(0), mBorderThickness(0),
mBackground(ThemeToken::SystemToken::Primary), mBackground(Theme::Sys::Color::Primary),
mBorder(ThemeToken::SystemToken::Outline), mBorder(Theme::Sys::Color::Outline),
mVisible(true) mVisible(true)
{ {
mName = "Widget"; mName = "Widget";
@ -66,7 +66,7 @@ TransformNode* Widget::getRootNode() const
void Widget::setBackground(ThemeToken::SystemToken token) void Widget::setBackground(Theme::Sys::Color token)
{ {
if (mBackground != token) if (mBackground != token)
{ {

View file

@ -47,7 +47,7 @@ public:
virtual bool onKeyboardEvent(const KeyboardEvent* event); virtual bool onKeyboardEvent(const KeyboardEvent* event);
void setBackground(ThemeToken::SystemToken token); void setBackground(Theme::Sys::Color token);
void setVisible(bool visible); void setVisible(bool visible);
@ -78,8 +78,8 @@ protected:
std::vector<std::unique_ptr<Widget> > mChildren; std::vector<std::unique_ptr<Widget> > mChildren;
unsigned mBorderThickness{0}; unsigned mBorderThickness{0};
ThemeToken::SystemToken mBackground; Theme::Sys::Color mBackground;
ThemeToken::SystemToken mBorder; Theme::Sys::Color mBorder;
bool mVisible{true}; bool mVisible{true};