Initial commit.

This commit is contained in:
jmsgrogan 2020-05-02 08:31:03 +01:00
commit 59c6161fdb
134 changed files with 4751 additions and 0 deletions

View file

@ -0,0 +1,44 @@
#include "Button.h"
#include <iostream>
Button::Button()
: Widget(),
mLabel()
{
}
std::shared_ptr<Button> Button::Create()
{
return std::make_shared<Button>();
}
void Button::SetLabel(const std::string& text)
{
mLabel = text;
}
void Button::OnMyMouseEvent(MouseEventPtr event)
{
if(event->GetAction() == MouseEvent::Action::Pressed)
{
std::cout << "Clicked !!" << std::endl;
SetBackgroundColor(Color::Create(0, 255, 0));
}
}
void Button::OnPaintEvent(PaintEventPtr event)
{
mLayers.clear();
AddBackground(event);
if(!mLabel.empty())
{
auto middle = DiscretePoint(mLocation.GetX() + mWidth/2,
mLocation.GetY() + mHeight/2);
auto text = TextElement::Create(mLabel, middle);
auto textLayer = VisualLayer::Create();
textLayer->SetText(text);
mLayers.push_back(textLayer);
}
}