mirror of https://github.com/AxioDL/metaforce.git
Initial icon API additions
This commit is contained in:
parent
17c036e78f
commit
9230ccdabd
|
@ -22,6 +22,7 @@ private:
|
|||
Zeus::CColor m_textColor;
|
||||
std::string m_textStr;
|
||||
std::unique_ptr<TextView> m_text;
|
||||
boo::ITexture* m_icon = nullptr;
|
||||
|
||||
SolidShaderVert m_verts[40];
|
||||
VertexBufferBinding m_vertsBinding;
|
||||
|
@ -83,11 +84,11 @@ public:
|
|||
|
||||
~Button() {closeMenu({});}
|
||||
Button(ViewResources& res, View& parentView,
|
||||
IButtonBinding* controlBinding, const std::string& text,
|
||||
IButtonBinding* controlBinding, const std::string& text, boo::ITexture* icon=nullptr,
|
||||
Style style=Style::Block, RectangleConstraint constraint=RectangleConstraint());
|
||||
Button(ViewResources& res, View& parentView,
|
||||
IButtonBinding* controlBinding, const std::string& text,
|
||||
const Zeus::CColor& textColor, Style style=Style::Block,
|
||||
IButtonBinding* controlBinding, const std::string& text, const Zeus::CColor& textColor,
|
||||
boo::ITexture* icon=nullptr, Style style=Style::Block,
|
||||
RectangleConstraint constraint=RectangleConstraint());
|
||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||
|
@ -99,6 +100,7 @@ public:
|
|||
|
||||
void setText(const std::string& text, const Zeus::CColor& textColor);
|
||||
void setText(const std::string& text);
|
||||
void setIcon(boo::ITexture* icon);
|
||||
const std::string& getText() const {return m_textStr;}
|
||||
void colorGlyphs(const Zeus::CColor& newColor);
|
||||
int nominalWidth() const {return m_nomWidth;}
|
||||
|
|
|
@ -63,7 +63,7 @@ private:
|
|||
OKButton(FileBrowser& fb, ViewResources& res, const std::string& text)
|
||||
: m_fb(fb), m_text(text)
|
||||
{
|
||||
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
|
||||
m_button.m_view.reset(new Button(res, fb, this, text, nullptr, Button::Style::Block,
|
||||
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
|
||||
}
|
||||
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)
|
||||
: m_fb(fb), m_text(text)
|
||||
{
|
||||
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
|
||||
m_button.m_view.reset(new Button(res, fb, this, text, nullptr, Button::Style::Block,
|
||||
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();}
|
||||
|
|
|
@ -147,20 +147,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static FCharFilter const AllCharFilter =
|
||||
std::make_pair("all-glyphs", [](uint32_t)->bool
|
||||
{return true;});
|
||||
|
||||
static FCharFilter const LatinCharFilter =
|
||||
std::make_pair("latin-glyphs", [](uint32_t c)->bool
|
||||
{return c <= 0xff || ((c - 0x2200) <= (0x23FF - 0x2200));});
|
||||
|
||||
static FCharFilter const LatinAndJapaneseCharFilter =
|
||||
std::make_pair("latin-and-jp-glyphs", [](uint32_t c)->bool
|
||||
{return LatinCharFilter.second(c) ||
|
||||
((c - 0x2E00) <= (0x30FF - 0x2E00)) ||
|
||||
((c - 0x4E00) <= (0x9FFF - 0x4E00)) ||
|
||||
((c - 0xFF00) <= (0xFFEF - 0xFF00));});
|
||||
extern const FCharFilter AllCharFilter;
|
||||
extern const FCharFilter LatinCharFilter;
|
||||
extern const FCharFilter LatinAndJapaneseCharFilter;
|
||||
|
||||
class FontCache
|
||||
{
|
||||
|
|
|
@ -12,16 +12,15 @@ void Button::Resources::init(boo::IGraphicsDataFactory* factory, const IThemeDat
|
|||
}
|
||||
|
||||
Button::Button(ViewResources& res, View& parentView,
|
||||
IButtonBinding* controlBinding, const std::string& text,
|
||||
IButtonBinding* controlBinding, const std::string& text, boo::ITexture* icon,
|
||||
Style style, RectangleConstraint constraint)
|
||||
: Button(res, parentView, controlBinding, text, res.themeData().uiText(), style, constraint) {}
|
||||
: Button(res, parentView, controlBinding, text, res.themeData().uiText(), icon, style, constraint) {}
|
||||
|
||||
Button::Button(ViewResources& res, View& parentView,
|
||||
IButtonBinding* controlBinding, const std::string& text,
|
||||
const Zeus::CColor& textColor, Style style,
|
||||
RectangleConstraint constraint)
|
||||
IButtonBinding* controlBinding, const std::string& text, const Zeus::CColor& textColor,
|
||||
boo::ITexture* icon, Style style, RectangleConstraint constraint)
|
||||
: Control(res, parentView, controlBinding),
|
||||
m_style(style), m_textColor(textColor), m_textStr(text), m_constraint(constraint)
|
||||
m_style(style), m_textColor(textColor), m_textStr(text), m_icon(icon), m_constraint(constraint)
|
||||
{
|
||||
m_vertsBinding.initSolid(res, 40, m_viewVertBlockBuf);
|
||||
commitResources(res);
|
||||
|
@ -89,7 +88,9 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
|||
m_verts[4].m_pos.assign(width+1, 1, 0);
|
||||
|
||||
m_textWidth = width;
|
||||
if (m_menuStyle != IButtonBinding::MenuStyle::None)
|
||||
if (m_menuStyle == IButtonBinding::MenuStyle::Primary)
|
||||
width += 12*pf;
|
||||
else if (m_menuStyle == IButtonBinding::MenuStyle::Auxiliary)
|
||||
width += 16*pf;
|
||||
|
||||
m_verts[5].m_pos.assign(1, height+1, 0);
|
||||
|
@ -121,12 +122,19 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
|||
|
||||
int arrowX = m_textWidth + 5*pf;
|
||||
int arrowY = 7*pf;
|
||||
int menuBgX = m_textWidth;
|
||||
if (m_menuStyle == IButtonBinding::MenuStyle::Primary)
|
||||
{
|
||||
menuBgX = 0;
|
||||
arrowX -= 5*pf;
|
||||
}
|
||||
|
||||
m_verts[28].m_pos.assign(arrowX + 4*pf, arrowY + 1*pf, 0);
|
||||
m_verts[29].m_pos.assign(arrowX, arrowY + 5*pf, 0);
|
||||
m_verts[30].m_pos.assign(arrowX + 8*pf, arrowY + 5*pf, 0);
|
||||
|
||||
m_verts[31].m_pos.assign(m_textWidth+1, height+1, 0);
|
||||
m_verts[32].m_pos.assign(m_textWidth+1, 1, 0);
|
||||
m_verts[31].m_pos.assign(menuBgX+1, height+1, 0);
|
||||
m_verts[32].m_pos.assign(menuBgX+1, 1, 0);
|
||||
m_verts[33].m_pos.assign(width+1, height+1, 0);
|
||||
m_verts[34].m_pos.assign(width+1, 1, 0);
|
||||
|
||||
|
@ -547,6 +555,7 @@ void Button::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|||
{
|
||||
gfxQ->draw(31, 4);
|
||||
gfxQ->draw(28, 3);
|
||||
if (m_menuStyle == IButtonBinding::MenuStyle::Auxiliary)
|
||||
gfxQ->draw(35, 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,21 @@ namespace Specter
|
|||
{
|
||||
static LogVisor::LogModule Log("Specter::FontCache");
|
||||
|
||||
const FCharFilter AllCharFilter =
|
||||
std::make_pair("all-glyphs", [](uint32_t)->bool
|
||||
{return true;});
|
||||
|
||||
const FCharFilter LatinCharFilter =
|
||||
std::make_pair("latin-glyphs", [](uint32_t c)->bool
|
||||
{return c <= 0xff || ((c - 0x2200) <= (0x23FF - 0x2200));});
|
||||
|
||||
const FCharFilter LatinAndJapaneseCharFilter =
|
||||
std::make_pair("latin-and-jp-glyphs", [](uint32_t c)->bool
|
||||
{return LatinCharFilter.second(c) ||
|
||||
((c - 0x2E00) <= (0x30FF - 0x2E00)) ||
|
||||
((c - 0x4E00) <= (0x9FFF - 0x4E00)) ||
|
||||
((c - 0xFF00) <= (0xFFEF - 0xFF00));});
|
||||
|
||||
FontTag::FontTag(const std::string& name, bool subpixel, float points, uint32_t dpi)
|
||||
{
|
||||
XXH64_state_t st;
|
||||
|
|
|
@ -21,10 +21,10 @@ MessageWindow::MessageWindow(ViewResources& res, View& parentView,
|
|||
m_text->typesetGlyphs(message, res.themeData().uiText(), 380 * res.pixelFactor());
|
||||
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,
|
||||
m_ok.m_view.reset(new Button(res, *this, &m_okBind, m_okBind.m_name, nullptr,
|
||||
Button::Style::Block, RectangleConstraint(150 * res.pixelFactor())));
|
||||
if (type == Type::ConfirmOkCancel)
|
||||
m_cancel.m_view.reset(new Button(res, *this, &m_cancelBind, m_cancelBind.m_name,
|
||||
m_cancel.m_view.reset(new Button(res, *this, &m_cancelBind, m_cancelBind.m_name, nullptr,
|
||||
Button::Style::Block, RectangleConstraint(150 * res.pixelFactor())));
|
||||
|
||||
updateContentOpacity(0.0);
|
||||
|
|
Loading…
Reference in New Issue