mirror of https://github.com/AxioDL/metaforce.git
constexpr refactor
This commit is contained in:
parent
4b0c7e6410
commit
56c72423e0
|
@ -82,11 +82,11 @@ public:
|
|||
|
||||
~Button() { closeMenu({}); }
|
||||
Button(ViewResources& res, View& parentView, IButtonBinding* controlBinding, std::string_view text,
|
||||
Icon* icon = nullptr, Style style = Style::Block, const zeus::CColor& bgColor = zeus::CColor::skWhite,
|
||||
Icon* icon = nullptr, Style style = Style::Block, const zeus::CColor& bgColor = zeus::skWhite,
|
||||
RectangleConstraint constraint = RectangleConstraint());
|
||||
Button(ViewResources& res, View& parentView, IButtonBinding* controlBinding, std::string_view text,
|
||||
const zeus::CColor& textColor, Icon* icon = nullptr, Style style = Style::Block,
|
||||
const zeus::CColor& bgColor = zeus::CColor::skWhite, RectangleConstraint constraint = RectangleConstraint());
|
||||
const zeus::CColor& bgColor = zeus::skWhite, RectangleConstraint constraint = RectangleConstraint());
|
||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||
void mouseMove(const boo::SWindowCoord&);
|
||||
|
|
|
@ -49,7 +49,7 @@ private:
|
|||
std::string m_text;
|
||||
OKButton(FileBrowser& fb, ViewResources& res, std::string_view text) : m_fb(fb), m_text(text) {
|
||||
m_button.m_view.reset(
|
||||
new Button(res, fb, this, text, nullptr, Button::Style::Block, zeus::CColor::skWhite,
|
||||
new Button(res, fb, this, text, nullptr, Button::Style::Block, zeus::skWhite,
|
||||
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
|
||||
}
|
||||
std::string_view name(const Control* control) const { return m_text; }
|
||||
|
@ -63,7 +63,7 @@ private:
|
|||
std::string m_text;
|
||||
CancelButton(FileBrowser& fb, ViewResources& res, std::string_view text) : m_fb(fb), m_text(text) {
|
||||
m_button.m_view.reset(new Button(
|
||||
res, fb, this, text, nullptr, Button::Style::Block, zeus::CColor::skWhite,
|
||||
res, fb, this, text, nullptr, Button::Style::Block, zeus::skWhite,
|
||||
RectangleConstraint(m_fb.m_ok.m_button.m_view->nominalWidth(), -1, RectangleConstraint::Test::Minimum)));
|
||||
}
|
||||
std::string_view name(const Control* control) const { return m_text; }
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
TextView::Alignment align = TextView::Alignment::Left, size_t lineCapacity = 256,
|
||||
float lineHeight = 1.0);
|
||||
|
||||
void typesetGlyphs(std::string_view str, const zeus::CColor& defaultColor = zeus::CColor::skWhite, unsigned wrap = 0);
|
||||
void typesetGlyphs(std::wstring_view str, const zeus::CColor& defaultColor = zeus::CColor::skWhite,
|
||||
void typesetGlyphs(std::string_view str, const zeus::CColor& defaultColor = zeus::skWhite, unsigned wrap = 0);
|
||||
void typesetGlyphs(std::wstring_view str, const zeus::CColor& defaultColor = zeus::skWhite,
|
||||
unsigned wrap = 0);
|
||||
|
||||
void colorGlyphs(const zeus::CColor& newColor);
|
||||
|
|
|
@ -89,8 +89,8 @@ public:
|
|||
std::vector<RenderGlyph>& accessGlyphs() { return m_glyphs; }
|
||||
const std::vector<RenderGlyph>& accessGlyphs() const { return m_glyphs; }
|
||||
|
||||
void typesetGlyphs(std::string_view str, const zeus::CColor& defaultColor = zeus::CColor::skWhite);
|
||||
void typesetGlyphs(std::wstring_view str, const zeus::CColor& defaultColor = zeus::CColor::skWhite);
|
||||
void typesetGlyphs(std::string_view str, const zeus::CColor& defaultColor = zeus::skWhite);
|
||||
void typesetGlyphs(std::wstring_view str, const zeus::CColor& defaultColor = zeus::skWhite);
|
||||
void invalidateGlyphs();
|
||||
|
||||
void colorGlyphs(const zeus::CColor& newColor);
|
||||
|
|
|
@ -73,7 +73,7 @@ class View {
|
|||
public:
|
||||
struct SolidShaderVert {
|
||||
zeus::CVector3f m_pos;
|
||||
zeus::CColor m_color = zeus::CColor::skClear;
|
||||
zeus::CColor m_color = zeus::skClear;
|
||||
};
|
||||
struct TexShaderVert {
|
||||
zeus::CVector3f m_pos;
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
};
|
||||
struct ViewBlock {
|
||||
zeus::CMatrix4f m_mv;
|
||||
zeus::CColor m_color = zeus::CColor::skWhite;
|
||||
zeus::CColor m_color = zeus::skWhite;
|
||||
void setViewRect(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
||||
m_mv[0][0] = 2.0f / root.size[0];
|
||||
m_mv[1][1] = 2.0f / root.size[1];
|
||||
|
|
|
@ -55,11 +55,11 @@ public:
|
|||
};
|
||||
|
||||
class DefaultThemeData : public IThemeData {
|
||||
zeus::CColor m_uiText = zeus::CColor::skWhite;
|
||||
zeus::CColor m_uiAltText = zeus::CColor::skGrey;
|
||||
zeus::CColor m_fieldText = zeus::CColor::skBlack;
|
||||
zeus::CColor m_uiText = zeus::skWhite;
|
||||
zeus::CColor m_uiAltText = zeus::skGrey;
|
||||
zeus::CColor m_fieldText = zeus::skBlack;
|
||||
zeus::CColor m_fieldMarkedText = {0.25, 0.25, 0.25, 1.0};
|
||||
zeus::CColor m_selectedFieldText = zeus::CColor::skWhite;
|
||||
zeus::CColor m_selectedFieldText = zeus::skWhite;
|
||||
|
||||
zeus::CColor m_vpBg = {0.2, 0.2, 0.2, 1.0};
|
||||
zeus::CColor m_tbBg = {0.2, 0.2, 0.2, 0.9};
|
||||
|
|
|
@ -48,9 +48,9 @@ Button::Button(ViewResources& res, View& parentView, IButtonBinding* controlBind
|
|||
m_verts[i].m_color = c2;
|
||||
} else {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_verts[i].m_color = zeus::skClear;
|
||||
for (int i = 31; i < 35; ++i)
|
||||
m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_verts[i].m_color = zeus::skClear;
|
||||
}
|
||||
for (int i = 28; i < 31; ++i)
|
||||
m_verts[i].m_color = m_textColor;
|
||||
|
@ -212,7 +212,7 @@ void Button::ButtonTarget::setInactive() {
|
|||
m_button._loadVerts();
|
||||
} else {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
m_button.m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_button.m_verts[i].m_color = zeus::skClear;
|
||||
m_button._loadVerts();
|
||||
m_button.m_text->colorGlyphs(m_button.m_textColor);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void Button::MenuTarget::setInactive() {
|
|||
for (int i = 28; i < 31; ++i)
|
||||
m_button.m_verts[i].m_color = m_button.m_textColor;
|
||||
for (int i = 31; i < 35; ++i)
|
||||
m_button.m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_button.m_verts[i].m_color = zeus::skClear;
|
||||
m_button._loadVerts();
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ void Button::ButtonTarget::setDisabled() {
|
|||
m_button._loadVerts();
|
||||
} else {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
m_button.m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_button.m_verts[i].m_color = zeus::skClear;
|
||||
m_button._loadVerts();
|
||||
zeus::CColor dimText = m_button.m_textColor;
|
||||
dimText[3] *= 0.5;
|
||||
|
@ -343,7 +343,7 @@ void Button::MenuTarget::setDisabled() {
|
|||
for (int i = 28; i < 31; ++i)
|
||||
m_button.m_verts[i].m_color = dimText;
|
||||
for (int i = 31; i < 35; ++i)
|
||||
m_button.m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_button.m_verts[i].m_color = zeus::skClear;
|
||||
m_button._loadVerts();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ IconView::IconView(ViewResources& res, View& parentView, Icon& icon) : View(res,
|
|||
{{1, 0, 0}, icon.m_uvCoords[3]},
|
||||
};
|
||||
m_vertexBinding.load<decltype(verts)>(verts);
|
||||
setBackground(zeus::CColor::skBlue);
|
||||
setBackground(zeus::skBlue);
|
||||
}
|
||||
|
||||
void IconView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
||||
|
|
|
@ -18,10 +18,10 @@ MessageWindow::MessageWindow(ViewResources& res, View& parentView, Type type, st
|
|||
constraint() = RectangleConstraint(400 * res.pixelFactor(), 80 * res.pixelFactor() + m_text->nominalHeight());
|
||||
|
||||
m_ok.m_view.reset(new Button(res, *this, &m_okBind, m_okBind.m_name, nullptr, Button::Style::Block,
|
||||
zeus::CColor::skWhite, RectangleConstraint(150 * res.pixelFactor())));
|
||||
zeus::skWhite, RectangleConstraint(150 * res.pixelFactor())));
|
||||
if (type == Type::ConfirmOkCancel)
|
||||
m_cancel.m_view.reset(new Button(res, *this, &m_cancelBind, m_cancelBind.m_name, nullptr, Button::Style::Block,
|
||||
zeus::CColor::skWhite, RectangleConstraint(150 * res.pixelFactor())));
|
||||
zeus::skWhite, RectangleConstraint(150 * res.pixelFactor())));
|
||||
|
||||
updateContentOpacity(0.0);
|
||||
}
|
||||
|
|
|
@ -122,12 +122,12 @@ void ModalWindow::setLineColors(float t) {
|
|||
|
||||
m_cornersOutline[0]->colorGlyphs(c1);
|
||||
if (t < 0.5) {
|
||||
m_cornersOutline[1]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[2]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[3]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[1]->colorGlyphs(zeus::skClear);
|
||||
m_cornersOutline[2]->colorGlyphs(zeus::skClear);
|
||||
m_cornersOutline[3]->colorGlyphs(zeus::skClear);
|
||||
} else if (t < 1.0) {
|
||||
m_cornersOutline[1]->colorGlyphs(c2);
|
||||
m_cornersOutline[2]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[2]->colorGlyphs(zeus::skClear);
|
||||
m_cornersOutline[3]->colorGlyphs(c2);
|
||||
} else {
|
||||
m_cornersOutline[1]->colorGlyphs(c2);
|
||||
|
@ -173,12 +173,12 @@ void ModalWindow::setLineColorsOut(float t) {
|
|||
|
||||
m_cornersOutline[2]->colorGlyphs(c1);
|
||||
if (t < 0.5) {
|
||||
m_cornersOutline[1]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[0]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[3]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[1]->colorGlyphs(zeus::skClear);
|
||||
m_cornersOutline[0]->colorGlyphs(zeus::skClear);
|
||||
m_cornersOutline[3]->colorGlyphs(zeus::skClear);
|
||||
} else if (t < 1.0) {
|
||||
m_cornersOutline[1]->colorGlyphs(c2);
|
||||
m_cornersOutline[0]->colorGlyphs(zeus::CColor::skClear);
|
||||
m_cornersOutline[0]->colorGlyphs(zeus::skClear);
|
||||
m_cornersOutline[3]->colorGlyphs(c2);
|
||||
} else {
|
||||
m_cornersOutline[1]->colorGlyphs(c2);
|
||||
|
|
|
@ -85,11 +85,11 @@ void Table::_setHeaderVerts(const boo::SWindowRect& sub) {
|
|||
zeus::CColor cm2 = *c2;
|
||||
if (sCol == c) {
|
||||
if (sDir == SortDirection::Ascending) {
|
||||
cm1 *= zeus::CColor::skGreen;
|
||||
cm2 *= zeus::CColor::skGreen;
|
||||
cm1 *= zeus::skGreen;
|
||||
cm2 *= zeus::skGreen;
|
||||
} else if (sDir == SortDirection::Descending) {
|
||||
cm1 *= zeus::CColor::skRed;
|
||||
cm2 *= zeus::CColor::skRed;
|
||||
cm1 *= zeus::skRed;
|
||||
cm2 *= zeus::skRed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,13 +99,13 @@ void TextField::setText(std::string_view str) {
|
|||
void TextField::setInactive() {
|
||||
const IThemeData& theme = rootView().themeData();
|
||||
if (m_error) {
|
||||
m_verts[0].m_color = theme.textfield1Inactive() * zeus::CColor::skRed;
|
||||
m_verts[1].m_color = theme.textfield2Inactive() * zeus::CColor::skRed;
|
||||
m_verts[2].m_color = theme.textfield1Inactive() * zeus::CColor::skRed;
|
||||
m_verts[3].m_color = theme.textfield2Inactive() * zeus::CColor::skRed;
|
||||
m_verts[4].m_color = theme.textfield2Inactive() * zeus::CColor::skRed;
|
||||
m_verts[0].m_color = theme.textfield1Inactive() * zeus::skRed;
|
||||
m_verts[1].m_color = theme.textfield2Inactive() * zeus::skRed;
|
||||
m_verts[2].m_color = theme.textfield1Inactive() * zeus::skRed;
|
||||
m_verts[3].m_color = theme.textfield2Inactive() * zeus::skRed;
|
||||
m_verts[4].m_color = theme.textfield2Inactive() * zeus::skRed;
|
||||
for (int i = 5; i < 28; ++i)
|
||||
m_verts[i].m_color = theme.textfield2Inactive() * zeus::CColor::skRed;
|
||||
m_verts[i].m_color = theme.textfield2Inactive() * zeus::skRed;
|
||||
} else {
|
||||
m_verts[0].m_color = theme.textfield1Inactive();
|
||||
m_verts[1].m_color = theme.textfield2Inactive();
|
||||
|
@ -122,13 +122,13 @@ void TextField::setInactive() {
|
|||
void TextField::setHover() {
|
||||
const IThemeData& theme = rootView().themeData();
|
||||
if (m_error) {
|
||||
m_verts[0].m_color = theme.textfield1Hover() * zeus::CColor::skRed;
|
||||
m_verts[1].m_color = theme.textfield2Hover() * zeus::CColor::skRed;
|
||||
m_verts[2].m_color = theme.textfield1Hover() * zeus::CColor::skRed;
|
||||
m_verts[3].m_color = theme.textfield2Hover() * zeus::CColor::skRed;
|
||||
m_verts[4].m_color = theme.textfield2Hover() * zeus::CColor::skRed;
|
||||
m_verts[0].m_color = theme.textfield1Hover() * zeus::skRed;
|
||||
m_verts[1].m_color = theme.textfield2Hover() * zeus::skRed;
|
||||
m_verts[2].m_color = theme.textfield1Hover() * zeus::skRed;
|
||||
m_verts[3].m_color = theme.textfield2Hover() * zeus::skRed;
|
||||
m_verts[4].m_color = theme.textfield2Hover() * zeus::skRed;
|
||||
for (int i = 5; i < 28; ++i)
|
||||
m_verts[i].m_color = theme.textfield2Inactive() * zeus::CColor::skRed;
|
||||
m_verts[i].m_color = theme.textfield2Inactive() * zeus::skRed;
|
||||
} else {
|
||||
m_verts[0].m_color = theme.textfield1Hover();
|
||||
m_verts[1].m_color = theme.textfield2Hover();
|
||||
|
@ -145,13 +145,13 @@ void TextField::setHover() {
|
|||
void TextField::setDisabled() {
|
||||
const IThemeData& theme = rootView().themeData();
|
||||
if (m_error) {
|
||||
m_verts[0].m_color = theme.textfield1Disabled() * zeus::CColor::skRed;
|
||||
m_verts[1].m_color = theme.textfield2Disabled() * zeus::CColor::skRed;
|
||||
m_verts[2].m_color = theme.textfield1Disabled() * zeus::CColor::skRed;
|
||||
m_verts[3].m_color = theme.textfield2Disabled() * zeus::CColor::skRed;
|
||||
m_verts[4].m_color = theme.textfield2Disabled() * zeus::CColor::skRed;
|
||||
m_verts[0].m_color = theme.textfield1Disabled() * zeus::skRed;
|
||||
m_verts[1].m_color = theme.textfield2Disabled() * zeus::skRed;
|
||||
m_verts[2].m_color = theme.textfield1Disabled() * zeus::skRed;
|
||||
m_verts[3].m_color = theme.textfield2Disabled() * zeus::skRed;
|
||||
m_verts[4].m_color = theme.textfield2Disabled() * zeus::skRed;
|
||||
for (int i = 5; i < 28; ++i)
|
||||
m_verts[i].m_color = theme.textfield2Disabled() * zeus::CColor::skRed;
|
||||
m_verts[i].m_color = theme.textfield2Disabled() * zeus::skRed;
|
||||
} else {
|
||||
m_verts[0].m_color = theme.textfield1Disabled();
|
||||
m_verts[1].m_color = theme.textfield2Disabled();
|
||||
|
@ -516,14 +516,14 @@ void TextField::think() {
|
|||
errMult = m_viewVertBlock.m_color;
|
||||
errBg = rootView().themeData().tooltipBackground() * m_viewVertBlock.m_color;
|
||||
} else if (m_errorFrames >= 360) {
|
||||
errMult = zeus::CColor::skClear;
|
||||
errMult = zeus::skClear;
|
||||
errBg = rootView().themeData().tooltipBackground();
|
||||
errBg[3] = 0.0;
|
||||
} else {
|
||||
float t = (m_errorFrames - 300) / 60.0;
|
||||
errMult = zeus::CColor::lerp(m_viewVertBlock.m_color, zeus::CColor::skClear, t);
|
||||
errMult = zeus::CColor::lerp(m_viewVertBlock.m_color, zeus::skClear, t);
|
||||
errBg = zeus::CColor::lerp(rootView().themeData().tooltipBackground() * m_viewVertBlock.m_color,
|
||||
zeus::CColor::skClear, t);
|
||||
zeus::skClear, t);
|
||||
}
|
||||
for (size_t i = 32; i < 41; ++i)
|
||||
m_verts[i].m_color = errBg;
|
||||
|
@ -782,7 +782,7 @@ void TextField::resized(const boo::SWindowRect& root, const boo::SWindowRect& su
|
|||
m_verts[39].m_pos.assign(eX, eY + eHeight, 0);
|
||||
m_verts[40].m_pos.assign(eX + 14 * pf, eY + eHeight, 0);
|
||||
for (size_t i = 32; i < 41; ++i)
|
||||
m_verts[i].m_color = zeus::CColor::skClear;
|
||||
m_verts[i].m_color = zeus::skClear;
|
||||
}
|
||||
|
||||
m_vertsBinding.load<decltype(m_verts)>(m_verts);
|
||||
|
|
|
@ -35,7 +35,7 @@ Tooltip::Tooltip(ViewResources& res, View& parentView, std::string_view title, s
|
|||
m_title.reset(new TextView(res, *this, res.m_heading14));
|
||||
m_title->typesetGlyphs(m_titleStr);
|
||||
m_message.reset(new MultiLineTextView(res, *this, res.m_mainFont));
|
||||
m_message->typesetGlyphs(m_messageStr, zeus::CColor::skWhite, int(TOOLTIP_MAX_TEXT_WIDTH * res.pixelFactor()));
|
||||
m_message->typesetGlyphs(m_messageStr, zeus::skWhite, int(TOOLTIP_MAX_TEXT_WIDTH * res.pixelFactor()));
|
||||
|
||||
float pf = res.pixelFactor();
|
||||
std::pair<int, int> margin = m_cornersOutline[0]->queryGlyphDimensions(0);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9b4434e6e0e2cb35a966a0d699c3046e3848c874
|
||||
Subproject commit b854e76dc9bc15f5fcdccfa4d7bb29d95d377058
|
Loading…
Reference in New Issue