mirror of https://github.com/AxioDL/metaforce.git
Icon classes with Button integration
This commit is contained in:
parent
29ccd701c5
commit
c08a9e5355
|
@ -58,6 +58,7 @@ list(APPEND SPECTER_HEADERS
|
||||||
include/Specter/NodeSocket.hpp
|
include/Specter/NodeSocket.hpp
|
||||||
include/Specter/PathButtons.hpp
|
include/Specter/PathButtons.hpp
|
||||||
include/Specter/FileBrowser.hpp
|
include/Specter/FileBrowser.hpp
|
||||||
|
include/Specter/Icon.hpp
|
||||||
include/Specter/FontCache.hpp
|
include/Specter/FontCache.hpp
|
||||||
include/Specter/Translator.hpp)
|
include/Specter/Translator.hpp)
|
||||||
|
|
||||||
|
@ -89,6 +90,7 @@ list(APPEND SPECTER_SOURCES
|
||||||
lib/NodeSocket.cpp
|
lib/NodeSocket.cpp
|
||||||
lib/PathButtons.cpp
|
lib/PathButtons.cpp
|
||||||
lib/FileBrowser.cpp
|
lib/FileBrowser.cpp
|
||||||
|
lib/Icon.cpp
|
||||||
lib/FontCache.cpp
|
lib/FontCache.cpp
|
||||||
lib/Translator.cpp
|
lib/Translator.cpp
|
||||||
atdna_FontCache.cpp)
|
atdna_FontCache.cpp)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "Specter/TextView.hpp"
|
#include "Specter/TextView.hpp"
|
||||||
#include "Specter/Control.hpp"
|
#include "Specter/Control.hpp"
|
||||||
|
#include "Specter/Icon.hpp"
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
@ -20,16 +21,17 @@ private:
|
||||||
Style m_style;
|
Style m_style;
|
||||||
IButtonBinding::MenuStyle m_menuStyle = IButtonBinding::MenuStyle::None;
|
IButtonBinding::MenuStyle m_menuStyle = IButtonBinding::MenuStyle::None;
|
||||||
Zeus::CColor m_textColor;
|
Zeus::CColor m_textColor;
|
||||||
|
Zeus::CColor m_bgColor;
|
||||||
std::string m_textStr;
|
std::string m_textStr;
|
||||||
std::unique_ptr<TextView> m_text;
|
std::unique_ptr<TextView> m_text;
|
||||||
boo::ITexture* m_icon = nullptr;
|
std::unique_ptr<IconView> m_icon;
|
||||||
|
|
||||||
SolidShaderVert m_verts[40];
|
SolidShaderVert m_verts[40];
|
||||||
VertexBufferBinding m_vertsBinding;
|
VertexBufferBinding m_vertsBinding;
|
||||||
|
|
||||||
RectangleConstraint m_constraint;
|
RectangleConstraint m_constraint;
|
||||||
int m_nomWidth, m_nomHeight;
|
int m_nomWidth, m_nomHeight;
|
||||||
int m_textWidth;
|
int m_textWidth, m_textIconWidth;
|
||||||
|
|
||||||
struct ButtonTarget : View
|
struct ButtonTarget : View
|
||||||
{
|
{
|
||||||
|
@ -84,11 +86,12 @@ public:
|
||||||
|
|
||||||
~Button() {closeMenu({});}
|
~Button() {closeMenu({});}
|
||||||
Button(ViewResources& res, View& parentView,
|
Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text, boo::ITexture* icon=nullptr,
|
IButtonBinding* controlBinding, const std::string& text, Icon* icon=nullptr,
|
||||||
Style style=Style::Block, RectangleConstraint constraint=RectangleConstraint());
|
Style style=Style::Block, const Zeus::CColor& bgColor=Zeus::CColor::skWhite,
|
||||||
|
RectangleConstraint constraint=RectangleConstraint());
|
||||||
Button(ViewResources& res, View& parentView,
|
Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text, const Zeus::CColor& textColor,
|
IButtonBinding* controlBinding, const std::string& text, const Zeus::CColor& textColor,
|
||||||
boo::ITexture* icon=nullptr, Style style=Style::Block,
|
Icon* icon=nullptr, Style style=Style::Block, const Zeus::CColor& bgColor=Zeus::CColor::skWhite,
|
||||||
RectangleConstraint constraint=RectangleConstraint());
|
RectangleConstraint constraint=RectangleConstraint());
|
||||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
@ -100,7 +103,7 @@ public:
|
||||||
|
|
||||||
void setText(const std::string& text, const Zeus::CColor& textColor);
|
void setText(const std::string& text, const Zeus::CColor& textColor);
|
||||||
void setText(const std::string& text);
|
void setText(const std::string& text);
|
||||||
void setIcon(boo::ITexture* icon);
|
void setIcon(Icon* icon=nullptr);
|
||||||
const std::string& getText() const {return m_textStr;}
|
const std::string& getText() const {return m_textStr;}
|
||||||
void colorGlyphs(const Zeus::CColor& newColor);
|
void colorGlyphs(const Zeus::CColor& newColor);
|
||||||
int nominalWidth() const {return m_nomWidth;}
|
int nominalWidth() const {return m_nomWidth;}
|
||||||
|
@ -115,6 +118,8 @@ public:
|
||||||
m_viewVertBlock.m_color = color;
|
m_viewVertBlock.m_color = color;
|
||||||
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(ViewBlock));
|
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(ViewBlock));
|
||||||
m_text->setMultiplyColor(color);
|
m_text->setMultiplyColor(color);
|
||||||
|
if (m_icon)
|
||||||
|
m_icon->setMultiplyColor(color);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
OKButton(FileBrowser& fb, ViewResources& res, const std::string& text)
|
OKButton(FileBrowser& fb, ViewResources& res, const std::string& text)
|
||||||
: m_fb(fb), m_text(text)
|
: m_fb(fb), m_text(text)
|
||||||
{
|
{
|
||||||
m_button.m_view.reset(new Button(res, fb, this, text, nullptr, Button::Style::Block,
|
m_button.m_view.reset(new Button(res, fb, this, text, nullptr, Button::Style::Block, Zeus::CColor::skWhite,
|
||||||
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
|
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
|
||||||
}
|
}
|
||||||
const char* name(const Control* control) const {return m_text.c_str();}
|
const char* name(const Control* control) const {return m_text.c_str();}
|
||||||
|
@ -79,7 +79,7 @@ private:
|
||||||
CancelButton(FileBrowser& fb, ViewResources& res, const std::string& text)
|
CancelButton(FileBrowser& fb, ViewResources& res, const std::string& text)
|
||||||
: m_fb(fb), m_text(text)
|
: m_fb(fb), m_text(text)
|
||||||
{
|
{
|
||||||
m_button.m_view.reset(new Button(res, fb, this, text, nullptr, Button::Style::Block,
|
m_button.m_view.reset(new Button(res, fb, this, text, nullptr, Button::Style::Block, Zeus::CColor::skWhite,
|
||||||
RectangleConstraint(m_fb.m_ok.m_button.m_view->nominalWidth(), -1, RectangleConstraint::Test::Minimum)));
|
RectangleConstraint(m_fb.m_ok.m_button.m_view->nominalWidth(), -1, RectangleConstraint::Test::Minimum)));
|
||||||
}
|
}
|
||||||
const char* name(const Control* control) const {return m_text.c_str();}
|
const char* name(const Control* control) const {return m_text.c_str();}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
#ifndef SPECTER_ICON_HPP
|
||||||
|
#define SPECTER_ICON_HPP
|
||||||
|
|
||||||
|
#include "View.hpp"
|
||||||
|
|
||||||
|
namespace Specter
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Icon
|
||||||
|
{
|
||||||
|
boo::ITexture* m_tex = nullptr;
|
||||||
|
Zeus::CVector2f m_uvCoords[4];
|
||||||
|
Icon() = default;
|
||||||
|
Icon(boo::ITexture* tex, float rect[4])
|
||||||
|
: m_tex(tex)
|
||||||
|
{
|
||||||
|
m_uvCoords[0][0] = rect[0];
|
||||||
|
m_uvCoords[0][1] = -rect[3];
|
||||||
|
|
||||||
|
m_uvCoords[1][0] = rect[0];
|
||||||
|
m_uvCoords[1][1] = -rect[1];
|
||||||
|
|
||||||
|
m_uvCoords[2][0] = rect[2];
|
||||||
|
m_uvCoords[2][1] = -rect[3];
|
||||||
|
|
||||||
|
m_uvCoords[3][0] = rect[2];
|
||||||
|
m_uvCoords[3][1] = -rect[1];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <size_t COLS, size_t ROWS>
|
||||||
|
class IconAtlas
|
||||||
|
{
|
||||||
|
boo::ITexture* m_tex = nullptr;
|
||||||
|
Icon m_icons[COLS][ROWS];
|
||||||
|
|
||||||
|
Icon MakeIcon(float x, float y)
|
||||||
|
{
|
||||||
|
float rect[] = {x / float(COLS), y / float(ROWS),
|
||||||
|
x / float(COLS) + 1.f / float(COLS), y / float(ROWS) + 1.f / float(ROWS)};
|
||||||
|
return Icon(m_tex, rect);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
IconAtlas() = default;
|
||||||
|
operator bool() const {return m_tex != nullptr;}
|
||||||
|
void initializeAtlas(boo::ITexture* tex)
|
||||||
|
{
|
||||||
|
m_tex = tex;
|
||||||
|
for (int c=0 ; c<COLS ; ++c)
|
||||||
|
for (int r=0 ; r<ROWS ; ++r)
|
||||||
|
m_icons[c][r] = MakeIcon(c, r);
|
||||||
|
}
|
||||||
|
Icon& getIcon(size_t c, size_t r) {return m_icons[c][r];}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IconView : public View
|
||||||
|
{
|
||||||
|
VertexBufferBinding m_vertexBinding;
|
||||||
|
public:
|
||||||
|
IconView(ViewResources& res, View& parentView, Icon& icon);
|
||||||
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
||||||
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SPECTER_ICON_HPP
|
|
@ -69,12 +69,6 @@ public:
|
||||||
if (m_toolbar.m_view)
|
if (m_toolbar.m_view)
|
||||||
m_toolbar.m_view->setMultiplyColor(color);
|
m_toolbar.m_view->setMultiplyColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const Zeus::CColor& spaceTriangleColor() const
|
|
||||||
{
|
|
||||||
static const Zeus::CColor defaultColor = {0.75, 0.75, 0.75, 1.0};
|
|
||||||
return defaultColor;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexBufferBinding m_vertsBinding;
|
VertexBufferBinding m_vertsBinding;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Toolbar(ViewResources& res, View& parentView, Position toolbarPos);
|
Toolbar(ViewResources& res, View& parentView, Position toolbarPos);
|
||||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
@ -105,6 +105,14 @@ public:
|
||||||
m_children.emplace_back();
|
m_children.emplace_back();
|
||||||
m_children.back().m_view = v;
|
m_children.back().m_view = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMultiplyColor(const Zeus::CColor& color)
|
||||||
|
{
|
||||||
|
View::setMultiplyColor(color);
|
||||||
|
for (ViewChild<View*>& c : m_children)
|
||||||
|
if (c.m_view)
|
||||||
|
c.m_view->setMultiplyColor(color);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ class IThemeData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual const Zeus::CColor& uiText() const=0;
|
virtual const Zeus::CColor& uiText() const=0;
|
||||||
|
virtual const Zeus::CColor& uiAltText() const=0;
|
||||||
virtual const Zeus::CColor& fieldText() const=0;
|
virtual const Zeus::CColor& fieldText() const=0;
|
||||||
virtual const Zeus::CColor& fieldMarkedText() const=0;
|
virtual const Zeus::CColor& fieldMarkedText() const=0;
|
||||||
virtual const Zeus::CColor& selectedFieldText() const=0;
|
virtual const Zeus::CColor& selectedFieldText() const=0;
|
||||||
|
@ -59,6 +60,7 @@ public:
|
||||||
class DefaultThemeData : public IThemeData
|
class DefaultThemeData : public IThemeData
|
||||||
{
|
{
|
||||||
Zeus::CColor m_uiText = Zeus::CColor::skWhite;
|
Zeus::CColor m_uiText = Zeus::CColor::skWhite;
|
||||||
|
Zeus::CColor m_uiAltText = Zeus::CColor::skGrey;
|
||||||
Zeus::CColor m_fieldText = Zeus::CColor::skBlack;
|
Zeus::CColor m_fieldText = Zeus::CColor::skBlack;
|
||||||
Zeus::CColor m_fieldMarkedText = {0.25, 0.25, 0.25, 1.0};
|
Zeus::CColor m_fieldMarkedText = {0.25, 0.25, 0.25, 1.0};
|
||||||
Zeus::CColor m_selectedFieldText = Zeus::CColor::skWhite;
|
Zeus::CColor m_selectedFieldText = Zeus::CColor::skWhite;
|
||||||
|
@ -102,6 +104,7 @@ class DefaultThemeData : public IThemeData
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual const Zeus::CColor& uiText() const {return m_uiText;}
|
virtual const Zeus::CColor& uiText() const {return m_uiText;}
|
||||||
|
virtual const Zeus::CColor& uiAltText() const {return m_uiAltText;}
|
||||||
virtual const Zeus::CColor& fieldText() const {return m_fieldText;}
|
virtual const Zeus::CColor& fieldText() const {return m_fieldText;}
|
||||||
virtual const Zeus::CColor& fieldMarkedText() const {return m_fieldMarkedText;}
|
virtual const Zeus::CColor& fieldMarkedText() const {return m_fieldMarkedText;}
|
||||||
virtual const Zeus::CColor& selectedFieldText() const {return m_selectedFieldText;}
|
virtual const Zeus::CColor& selectedFieldText() const {return m_selectedFieldText;}
|
||||||
|
|
|
@ -12,15 +12,15 @@ void Button::Resources::init(boo::IGraphicsDataFactory* factory, const IThemeDat
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button(ViewResources& res, View& parentView,
|
Button::Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text, boo::ITexture* icon,
|
IButtonBinding* controlBinding, const std::string& text, Icon* icon,
|
||||||
Style style, RectangleConstraint constraint)
|
Style style, const Zeus::CColor& bgColor, RectangleConstraint constraint)
|
||||||
: Button(res, parentView, controlBinding, text, res.themeData().uiText(), icon, style, constraint) {}
|
: Button(res, parentView, controlBinding, text, res.themeData().uiText(), icon, style, bgColor, constraint) {}
|
||||||
|
|
||||||
Button::Button(ViewResources& res, View& parentView,
|
Button::Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text, const Zeus::CColor& textColor,
|
IButtonBinding* controlBinding, const std::string& text, const Zeus::CColor& textColor,
|
||||||
boo::ITexture* icon, Style style, RectangleConstraint constraint)
|
Icon* icon, Style style, const Zeus::CColor& bgColor, RectangleConstraint constraint)
|
||||||
: Control(res, parentView, controlBinding),
|
: Control(res, parentView, controlBinding),
|
||||||
m_style(style), m_textColor(textColor), m_textStr(text), m_icon(icon), m_constraint(constraint)
|
m_style(style), m_textColor(textColor), m_bgColor(bgColor), m_textStr(text), m_constraint(constraint)
|
||||||
{
|
{
|
||||||
m_vertsBinding.initSolid(res, 40, m_viewVertBlockBuf);
|
m_vertsBinding.initSolid(res, 40, m_viewVertBlockBuf);
|
||||||
commitResources(res);
|
commitResources(res);
|
||||||
|
@ -30,19 +30,21 @@ Button::Button(ViewResources& res, View& parentView,
|
||||||
|
|
||||||
if (style == Style::Block)
|
if (style == Style::Block)
|
||||||
{
|
{
|
||||||
m_verts[0].m_color = res.themeData().button1Inactive();
|
Zeus::CColor c1 = res.themeData().button1Inactive() * bgColor;
|
||||||
m_verts[1].m_color = res.themeData().button2Inactive();
|
Zeus::CColor c2 = res.themeData().button2Inactive() * bgColor;
|
||||||
m_verts[2].m_color = res.themeData().button1Inactive();
|
m_verts[0].m_color = c1;
|
||||||
m_verts[3].m_color = res.themeData().button2Inactive();
|
m_verts[1].m_color = c2;
|
||||||
m_verts[4].m_color = res.themeData().button2Inactive();
|
m_verts[2].m_color = c1;
|
||||||
|
m_verts[3].m_color = c2;
|
||||||
|
m_verts[4].m_color = c2;
|
||||||
for (int i=5 ; i<28 ; ++i)
|
for (int i=5 ; i<28 ; ++i)
|
||||||
m_verts[i].m_color = res.themeData().button2Inactive();
|
m_verts[i].m_color = c2;
|
||||||
m_verts[31].m_color = rootView().themeData().button1Inactive();
|
m_verts[31].m_color = c1;
|
||||||
m_verts[32].m_color = rootView().themeData().button2Inactive();
|
m_verts[32].m_color = c2;
|
||||||
m_verts[33].m_color = rootView().themeData().button1Inactive();
|
m_verts[33].m_color = c1;
|
||||||
m_verts[34].m_color = rootView().themeData().button2Inactive();
|
m_verts[34].m_color = c2;
|
||||||
for (int i=35 ; i<39 ; ++i)
|
for (int i=35 ; i<39 ; ++i)
|
||||||
m_verts[i].m_color = res.themeData().button2Inactive();
|
m_verts[i].m_color = c2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -58,11 +60,14 @@ Button::Button(ViewResources& res, View& parentView,
|
||||||
if (controlBinding)
|
if (controlBinding)
|
||||||
m_menuStyle = controlBinding->menuStyle(this);
|
m_menuStyle = controlBinding->menuStyle(this);
|
||||||
|
|
||||||
|
if (icon)
|
||||||
|
m_icon.reset(new IconView(res, *this, *icon));
|
||||||
|
|
||||||
m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Center));
|
m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Center));
|
||||||
setText(m_textStr);
|
setText(m_textStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setText(const std::string &text)
|
void Button::setText(const std::string& text)
|
||||||
{
|
{
|
||||||
setText(text, m_textColor);
|
setText(text, m_textColor);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +83,11 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
|
|
||||||
if (m_style == Style::Block)
|
if (m_style == Style::Block)
|
||||||
{
|
{
|
||||||
std::pair<int,int> constraint = m_constraint.solve(m_text->nominalWidth() + 12 * pf, 20 * pf);
|
m_textWidth = m_text->nominalWidth();
|
||||||
|
int nomWidth = m_textWidth + 12*pf;
|
||||||
|
if (m_icon)
|
||||||
|
nomWidth += 18*pf;
|
||||||
|
std::pair<int,int> constraint = m_constraint.solve(nomWidth, 20 * pf);
|
||||||
width = constraint.first;
|
width = constraint.first;
|
||||||
height = constraint.second;
|
height = constraint.second;
|
||||||
m_verts[0].m_pos.assign(1, height+1, 0);
|
m_verts[0].m_pos.assign(1, height+1, 0);
|
||||||
|
@ -87,7 +96,7 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
m_verts[3].m_pos.assign(width+1, 1, 0);
|
m_verts[3].m_pos.assign(width+1, 1, 0);
|
||||||
m_verts[4].m_pos.assign(width+1, 1, 0);
|
m_verts[4].m_pos.assign(width+1, 1, 0);
|
||||||
|
|
||||||
m_textWidth = width;
|
m_textIconWidth = width;
|
||||||
if (m_menuStyle == IButtonBinding::MenuStyle::Primary)
|
if (m_menuStyle == IButtonBinding::MenuStyle::Primary)
|
||||||
width += 12*pf;
|
width += 12*pf;
|
||||||
else if (m_menuStyle == IButtonBinding::MenuStyle::Auxiliary)
|
else if (m_menuStyle == IButtonBinding::MenuStyle::Auxiliary)
|
||||||
|
@ -120,9 +129,9 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
m_verts[26].m_pos.assign(width+1, 1, 0);
|
m_verts[26].m_pos.assign(width+1, 1, 0);
|
||||||
m_verts[27].m_pos.assign(width+1, 0, 0);
|
m_verts[27].m_pos.assign(width+1, 0, 0);
|
||||||
|
|
||||||
int arrowX = m_textWidth + 5*pf;
|
int arrowX = m_textIconWidth + 5*pf;
|
||||||
int arrowY = 7*pf;
|
int arrowY = 7*pf;
|
||||||
int menuBgX = m_textWidth;
|
int menuBgX = m_textIconWidth;
|
||||||
if (m_menuStyle == IButtonBinding::MenuStyle::Primary)
|
if (m_menuStyle == IButtonBinding::MenuStyle::Primary)
|
||||||
{
|
{
|
||||||
menuBgX = 0;
|
menuBgX = 0;
|
||||||
|
@ -138,10 +147,10 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
m_verts[33].m_pos.assign(width+1, height+1, 0);
|
m_verts[33].m_pos.assign(width+1, height+1, 0);
|
||||||
m_verts[34].m_pos.assign(width+1, 1, 0);
|
m_verts[34].m_pos.assign(width+1, 1, 0);
|
||||||
|
|
||||||
m_verts[35].m_pos.assign(m_textWidth, height+1, 0);
|
m_verts[35].m_pos.assign(m_textIconWidth, height+1, 0);
|
||||||
m_verts[36].m_pos.assign(m_textWidth, 1, 0);
|
m_verts[36].m_pos.assign(m_textIconWidth, 1, 0);
|
||||||
m_verts[37].m_pos.assign(m_textWidth+1, height+1, 0);
|
m_verts[37].m_pos.assign(m_textIconWidth+1, height+1, 0);
|
||||||
m_verts[38].m_pos.assign(m_textWidth+1, 1, 0);
|
m_verts[38].m_pos.assign(m_textIconWidth+1, 1, 0);
|
||||||
|
|
||||||
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
||||||
}
|
}
|
||||||
|
@ -160,6 +169,7 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
m_verts[30].m_pos.assign(arrowX + 8*pf, 5*pf, 0);
|
m_verts[30].m_pos.assign(arrowX + 8*pf, 5*pf, 0);
|
||||||
|
|
||||||
m_textWidth = width;
|
m_textWidth = width;
|
||||||
|
m_textIconWidth = width;
|
||||||
|
|
||||||
int arrowLineWidth = 7*pf;
|
int arrowLineWidth = 7*pf;
|
||||||
if (m_menuStyle != IButtonBinding::MenuStyle::None)
|
if (m_menuStyle != IButtonBinding::MenuStyle::None)
|
||||||
|
@ -184,6 +194,16 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
m_nomHeight = height;
|
m_nomHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Button::setIcon(Icon* icon)
|
||||||
|
{
|
||||||
|
if (icon)
|
||||||
|
m_icon.reset(new IconView(rootView().viewRes(), *this, *icon));
|
||||||
|
else
|
||||||
|
m_icon.reset();
|
||||||
|
setText(m_textStr);
|
||||||
|
updateSize();
|
||||||
|
}
|
||||||
|
|
||||||
void Button::colorGlyphs(const Zeus::CColor& newColor)
|
void Button::colorGlyphs(const Zeus::CColor& newColor)
|
||||||
{
|
{
|
||||||
m_textColor = newColor;
|
m_textColor = newColor;
|
||||||
|
@ -197,11 +217,13 @@ void Button::ButtonTarget::setInactive()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[0].m_color = rootView().themeData().button1Inactive();
|
Zeus::CColor c1 = rootView().themeData().button1Inactive() * m_button.m_bgColor;
|
||||||
m_button.m_verts[1].m_color = rootView().themeData().button2Inactive();
|
Zeus::CColor c2 = rootView().themeData().button2Inactive() * m_button.m_bgColor;
|
||||||
m_button.m_verts[2].m_color = rootView().themeData().button1Inactive();
|
m_button.m_verts[0].m_color = c1;
|
||||||
m_button.m_verts[3].m_color = rootView().themeData().button2Inactive();
|
m_button.m_verts[1].m_color = c2;
|
||||||
m_button.m_verts[4].m_color = rootView().themeData().button2Inactive();
|
m_button.m_verts[2].m_color = c1;
|
||||||
|
m_button.m_verts[3].m_color = c2;
|
||||||
|
m_button.m_verts[4].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -217,10 +239,12 @@ void Button::MenuTarget::setInactive()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[31].m_color = rootView().themeData().button1Inactive();
|
Zeus::CColor c1 = rootView().themeData().button1Inactive() * m_button.m_bgColor;
|
||||||
m_button.m_verts[32].m_color = rootView().themeData().button2Inactive();
|
Zeus::CColor c2 = rootView().themeData().button2Inactive() * m_button.m_bgColor;
|
||||||
m_button.m_verts[33].m_color = rootView().themeData().button1Inactive();
|
m_button.m_verts[31].m_color = c1;
|
||||||
m_button.m_verts[34].m_color = rootView().themeData().button2Inactive();
|
m_button.m_verts[32].m_color = c2;
|
||||||
|
m_button.m_verts[33].m_color = c1;
|
||||||
|
m_button.m_verts[34].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -237,11 +261,13 @@ void Button::ButtonTarget::setHover()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[0].m_color = rootView().themeData().button1Hover();
|
Zeus::CColor c1 = rootView().themeData().button1Hover() * m_button.m_bgColor;
|
||||||
m_button.m_verts[1].m_color = rootView().themeData().button2Hover();
|
Zeus::CColor c2 = rootView().themeData().button2Hover() * m_button.m_bgColor;
|
||||||
m_button.m_verts[2].m_color = rootView().themeData().button1Hover();
|
m_button.m_verts[0].m_color = c1;
|
||||||
m_button.m_verts[3].m_color = rootView().themeData().button2Hover();
|
m_button.m_verts[1].m_color = c2;
|
||||||
m_button.m_verts[4].m_color = rootView().themeData().button2Hover();
|
m_button.m_verts[2].m_color = c1;
|
||||||
|
m_button.m_verts[3].m_color = c2;
|
||||||
|
m_button.m_verts[4].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -257,10 +283,12 @@ void Button::MenuTarget::setHover()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[31].m_color = rootView().themeData().button1Hover();
|
Zeus::CColor c1 = rootView().themeData().button1Hover() * m_button.m_bgColor;
|
||||||
m_button.m_verts[32].m_color = rootView().themeData().button2Hover();
|
Zeus::CColor c2 = rootView().themeData().button2Hover() * m_button.m_bgColor;
|
||||||
m_button.m_verts[33].m_color = rootView().themeData().button1Hover();
|
m_button.m_verts[31].m_color = c1;
|
||||||
m_button.m_verts[34].m_color = rootView().themeData().button2Hover();
|
m_button.m_verts[32].m_color = c2;
|
||||||
|
m_button.m_verts[33].m_color = c1;
|
||||||
|
m_button.m_verts[34].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -277,11 +305,13 @@ void Button::ButtonTarget::setPressed()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[0].m_color = rootView().themeData().button1Press();
|
Zeus::CColor c1 = rootView().themeData().button1Press() * m_button.m_bgColor;
|
||||||
m_button.m_verts[1].m_color = rootView().themeData().button2Press();
|
Zeus::CColor c2 = rootView().themeData().button2Press() * m_button.m_bgColor;
|
||||||
m_button.m_verts[2].m_color = rootView().themeData().button1Press();
|
m_button.m_verts[0].m_color = c1;
|
||||||
m_button.m_verts[3].m_color = rootView().themeData().button2Press();
|
m_button.m_verts[1].m_color = c2;
|
||||||
m_button.m_verts[4].m_color = rootView().themeData().button2Press();
|
m_button.m_verts[2].m_color = c1;
|
||||||
|
m_button.m_verts[3].m_color = c2;
|
||||||
|
m_button.m_verts[4].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -297,10 +327,12 @@ void Button::MenuTarget::setPressed()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[31].m_color = rootView().themeData().button1Press();
|
Zeus::CColor c1 = rootView().themeData().button1Press() * m_button.m_bgColor;
|
||||||
m_button.m_verts[32].m_color = rootView().themeData().button2Press();
|
Zeus::CColor c2 = rootView().themeData().button2Press() * m_button.m_bgColor;
|
||||||
m_button.m_verts[33].m_color = rootView().themeData().button1Press();
|
m_button.m_verts[31].m_color = c1;
|
||||||
m_button.m_verts[34].m_color = rootView().themeData().button2Press();
|
m_button.m_verts[32].m_color = c2;
|
||||||
|
m_button.m_verts[33].m_color = c1;
|
||||||
|
m_button.m_verts[34].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -317,11 +349,13 @@ void Button::ButtonTarget::setDisabled()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[0].m_color = rootView().themeData().button1Disabled();
|
Zeus::CColor c1 = rootView().themeData().button1Disabled() * m_button.m_bgColor;
|
||||||
m_button.m_verts[1].m_color = rootView().themeData().button2Disabled();
|
Zeus::CColor c2 = rootView().themeData().button2Disabled() * m_button.m_bgColor;
|
||||||
m_button.m_verts[2].m_color = rootView().themeData().button1Disabled();
|
m_button.m_verts[0].m_color = c1;
|
||||||
m_button.m_verts[3].m_color = rootView().themeData().button2Disabled();
|
m_button.m_verts[1].m_color = c2;
|
||||||
m_button.m_verts[4].m_color = rootView().themeData().button2Disabled();
|
m_button.m_verts[2].m_color = c1;
|
||||||
|
m_button.m_verts[3].m_color = c2;
|
||||||
|
m_button.m_verts[4].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -339,10 +373,12 @@ void Button::MenuTarget::setDisabled()
|
||||||
{
|
{
|
||||||
if (m_button.m_style == Style::Block)
|
if (m_button.m_style == Style::Block)
|
||||||
{
|
{
|
||||||
m_button.m_verts[31].m_color = rootView().themeData().button1Disabled();
|
Zeus::CColor c1 = rootView().themeData().button1Disabled() * m_button.m_bgColor;
|
||||||
m_button.m_verts[32].m_color = rootView().themeData().button2Disabled();
|
Zeus::CColor c2 = rootView().themeData().button2Disabled() * m_button.m_bgColor;
|
||||||
m_button.m_verts[33].m_color = rootView().themeData().button1Disabled();
|
m_button.m_verts[31].m_color = c1;
|
||||||
m_button.m_verts[34].m_color = rootView().themeData().button2Disabled();
|
m_button.m_verts[32].m_color = c2;
|
||||||
|
m_button.m_verts[33].m_color = c1;
|
||||||
|
m_button.m_verts[34].m_color = c2;
|
||||||
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
m_button.m_vertsBinding.load(m_button.m_verts, sizeof(m_button.m_verts));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -486,8 +522,27 @@ void Button::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
View::resized(root, sub);
|
View::resized(root, sub);
|
||||||
boo::SWindowRect textRect = sub;
|
boo::SWindowRect textRect = sub;
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
|
|
||||||
|
if (m_icon)
|
||||||
|
{
|
||||||
|
textRect.location[0] += 18*pf;
|
||||||
|
boo::SWindowRect iconRect = sub;
|
||||||
|
iconRect.size[0] = 16*pf;
|
||||||
|
iconRect.size[1] = 16*pf;
|
||||||
|
iconRect.location[1] += 2*pf;
|
||||||
|
if (m_style == Style::Block)
|
||||||
|
{
|
||||||
|
iconRect.location[0] += 5*pf;
|
||||||
|
iconRect.location[1] += pf;
|
||||||
|
}
|
||||||
|
m_icon->resized(root, iconRect);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_style == Style::Block)
|
if (m_style == Style::Block)
|
||||||
textRect.location[1] += 7 * pf;
|
{
|
||||||
|
textRect.location[0] += 6*pf;
|
||||||
|
textRect.location[1] += 7*pf;
|
||||||
|
}
|
||||||
textRect.location[0] += m_textWidth / 2;
|
textRect.location[0] += m_textWidth / 2;
|
||||||
textRect.size[0] = m_textWidth;
|
textRect.size[0] = m_textWidth;
|
||||||
textRect.size[1] = m_nomHeight;
|
textRect.size[1] = m_nomHeight;
|
||||||
|
@ -506,7 +561,7 @@ void Button::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boo::SWindowRect targetRect = sub;
|
boo::SWindowRect targetRect = sub;
|
||||||
targetRect.size[0] = m_textWidth;
|
targetRect.size[0] = m_textIconWidth;
|
||||||
m_buttonTarget.m_view->resized(root, targetRect);
|
m_buttonTarget.m_view->resized(root, targetRect);
|
||||||
targetRect.location[0] += targetRect.size[0];
|
targetRect.location[0] += targetRect.size[0];
|
||||||
targetRect.size[0] = 16*pf;
|
targetRect.size[0] = 16*pf;
|
||||||
|
@ -525,7 +580,7 @@ void Button::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boo::SWindowRect targetRect = sub;
|
boo::SWindowRect targetRect = sub;
|
||||||
targetRect.size[0] = m_textWidth + 3*pf;
|
targetRect.size[0] = m_textIconWidth + 3*pf;
|
||||||
targetRect.size[1] = m_nomHeight;
|
targetRect.size[1] = m_nomHeight;
|
||||||
m_buttonTarget.m_view->resized(root, targetRect);
|
m_buttonTarget.m_view->resized(root, targetRect);
|
||||||
targetRect.location[0] += targetRect.size[0];
|
targetRect.location[0] += targetRect.size[0];
|
||||||
|
@ -568,7 +623,11 @@ void Button::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
gfxQ->draw(31, 4);
|
gfxQ->draw(31, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_text->draw(gfxQ);
|
|
||||||
|
if (m_icon)
|
||||||
|
m_icon->draw(gfxQ);
|
||||||
|
if (m_textStr.size())
|
||||||
|
m_text->draw(gfxQ);
|
||||||
|
|
||||||
if (m_modalMenu.m_view)
|
if (m_modalMenu.m_view)
|
||||||
m_modalMenu.m_view->draw(gfxQ);
|
m_modalMenu.m_view->draw(gfxQ);
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include "Specter/Icon.hpp"
|
||||||
|
#include "Specter/RootView.hpp"
|
||||||
|
|
||||||
|
namespace Specter
|
||||||
|
{
|
||||||
|
|
||||||
|
IconView::IconView(ViewResources& res, View& parentView, Icon& icon)
|
||||||
|
: View(res, parentView)
|
||||||
|
{
|
||||||
|
m_vertexBinding.initTex(res, 4, m_viewVertBlockBuf, icon.m_tex);
|
||||||
|
commitResources(res);
|
||||||
|
TexShaderVert verts[] =
|
||||||
|
{
|
||||||
|
{{0, 1, 0}, icon.m_uvCoords[0]},
|
||||||
|
{{0, 0, 0}, icon.m_uvCoords[1]},
|
||||||
|
{{1, 1, 0}, icon.m_uvCoords[2]},
|
||||||
|
{{1, 0, 0}, icon.m_uvCoords[3]},
|
||||||
|
};
|
||||||
|
m_vertexBinding.load(verts, sizeof(verts));
|
||||||
|
setBackground(Zeus::CColor::skBlue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
|
{
|
||||||
|
m_viewVertBlock.setViewRect(root, sub);
|
||||||
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
|
m_viewVertBlock.m_mv[0][0] *= sub.size[0];
|
||||||
|
m_viewVertBlock.m_mv[1][1] *= sub.size[1];
|
||||||
|
View::resized(m_viewVertBlock, sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
{
|
||||||
|
gfxQ->setShaderDataBinding(m_vertexBinding);
|
||||||
|
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
||||||
|
gfxQ->draw(0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -33,7 +33,7 @@ void Menu::reset(IMenuNode* rootNode)
|
||||||
m_subMenu.reset();
|
m_subMenu.reset();
|
||||||
|
|
||||||
const std::string* headText = rootNode->text();
|
const std::string* headText = rootNode->text();
|
||||||
m_headText->typesetGlyphs(headText?*headText:"", rootView().themeData().uiText());
|
m_headText->typesetGlyphs(headText?*headText:"", rootView().themeData().uiAltText());
|
||||||
|
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
int itemAdv = (ROW_HEIGHT + ITEM_MARGIN*2) * pf;
|
int itemAdv = (ROW_HEIGHT + ITEM_MARGIN*2) * pf;
|
||||||
|
|
|
@ -22,10 +22,12 @@ MessageWindow::MessageWindow(ViewResources& res, View& parentView,
|
||||||
constraint() = RectangleConstraint(400 * res.pixelFactor(), 80 * res.pixelFactor() + m_text->nominalHeight());
|
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,
|
m_ok.m_view.reset(new Button(res, *this, &m_okBind, m_okBind.m_name, nullptr,
|
||||||
Button::Style::Block, RectangleConstraint(150 * res.pixelFactor())));
|
Button::Style::Block, Zeus::CColor::skWhite,
|
||||||
|
RectangleConstraint(150 * res.pixelFactor())));
|
||||||
if (type == Type::ConfirmOkCancel)
|
if (type == Type::ConfirmOkCancel)
|
||||||
m_cancel.m_view.reset(new Button(res, *this, &m_cancelBind, m_cancelBind.m_name, nullptr,
|
m_cancel.m_view.reset(new Button(res, *this, &m_cancelBind, m_cancelBind.m_name, nullptr,
|
||||||
Button::Style::Block, RectangleConstraint(150 * res.pixelFactor())));
|
Button::Style::Block, Zeus::CColor::skWhite,
|
||||||
|
RectangleConstraint(150 * res.pixelFactor())));
|
||||||
|
|
||||||
updateContentOpacity(0.0);
|
updateContentOpacity(0.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@ Space::Space(ViewResources& res, View& parentView, ISpaceController& controller,
|
||||||
{
|
{
|
||||||
commitResources(res);
|
commitResources(res);
|
||||||
setBackground(res.themeData().spaceBackground());
|
setBackground(res.themeData().spaceBackground());
|
||||||
|
static const Zeus::CColor triColor = {0.75, 0.75, 0.75, 1.0};
|
||||||
if (controller.spaceSplitAllowed())
|
if (controller.spaceSplitAllowed())
|
||||||
m_cornerView.m_view.reset(new CornerView(res, *this, spaceTriangleColor()));
|
m_cornerView.m_view.reset(new CornerView(res, *this, triColor));
|
||||||
if (tbPos != Toolbar::Position::None)
|
if (tbPos != Toolbar::Position::None)
|
||||||
m_toolbar.m_view.reset(new Toolbar(res, *this, tbPos));
|
m_toolbar.m_view.reset(new Toolbar(res, *this, tbPos));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue