metaforce/specter/include/Specter/Button.hpp

80 lines
2.3 KiB
C++
Raw Normal View History

2015-11-21 01:14:49 +00:00
#ifndef SPECTER_BUTTON_HPP
#define SPECTER_BUTTON_HPP
2015-12-05 00:42:46 +00:00
#include "Specter/TextView.hpp"
#include "Specter/Control.hpp"
2015-12-05 00:42:46 +00:00
namespace Specter
{
class Button : public Control
2015-12-05 00:42:46 +00:00
{
2015-12-13 21:00:30 +00:00
public:
enum class Style
{
Block,
Text,
};
private:
Style m_style;
Zeus::CColor m_textColor;
2015-12-05 00:42:46 +00:00
std::string m_textStr;
std::unique_ptr<TextView> m_text;
2015-12-17 21:28:37 +00:00
SolidShaderVert m_verts[28];
VertexBufferBinding m_vertsBinding;
2015-12-05 00:42:46 +00:00
2015-12-22 01:33:27 +00:00
RectangleConstraint m_constraint;
2015-12-05 00:42:46 +00:00
int m_nomWidth, m_nomHeight;
bool m_pressed = false;
bool m_hovered = false;
void setInactive();
void setHover();
void setPressed();
void setDisabled();
2015-12-13 21:00:30 +00:00
2015-12-05 00:42:46 +00:00
public:
class Resources
{
friend class ViewResources;
friend class Button;
void init(boo::IGraphicsDataFactory* factory, const IThemeData& theme);
2015-12-05 00:42:46 +00:00
};
Button(ViewResources& res, View& parentView,
2015-12-13 21:00:30 +00:00
IButtonBinding* controlBinding, const std::string& text,
2015-12-22 01:33:27 +00:00
Style style=Style::Block, RectangleConstraint constraint=RectangleConstraint());
2015-12-13 21:00:30 +00:00
Button(ViewResources& res, View& parentView,
IButtonBinding* controlBinding, const std::string& text,
2015-12-22 01:33:27 +00:00
const Zeus::CColor& textColor, Style style=Style::Block,
RectangleConstraint constraint=RectangleConstraint());
2015-12-05 00:42:46 +00:00
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseEnter(const boo::SWindowCoord&);
void mouseLeave(const boo::SWindowCoord&);
2015-12-22 01:33:27 +00:00
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
2015-12-05 00:42:46 +00:00
void draw(boo::IGraphicsCommandQueue* gfxQ);
2015-12-13 21:00:30 +00:00
void setText(const std::string& text, const Zeus::CColor& textColor);
2015-12-05 00:42:46 +00:00
void setText(const std::string& text);
const std::string& getText() const {return m_textStr;}
2015-12-13 21:00:30 +00:00
void colorGlyphs(const Zeus::CColor& newColor);
2015-12-05 00:42:46 +00:00
int nominalWidth() const {return m_nomWidth;}
int nominalHeight() const {return m_nomHeight;}
void setMultiplyColor(const Zeus::CColor& color)
{
View::setMultiplyColor(color);
2015-12-17 21:28:37 +00:00
m_viewVertBlock.m_color = color;
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(ViewBlock));
m_text->setMultiplyColor(color);
}
2015-12-05 00:42:46 +00:00
};
}
2015-11-21 01:14:49 +00:00
#endif // SPECTER_BUTTON_HPP