Update Event

This commit is contained in:
Kirigaya Kazuto 2017-04-24 10:32:00 +08:00
parent ebe2ce68bb
commit d266d1e128
2 changed files with 26 additions and 9 deletions

View File

@ -124,6 +124,11 @@ Brush::Brush(Renderer Rnd) : Renderer(Rnd)
}
int Brush::fillRect(PosInfo info)
{
return Renderer::fillRect(info.getRect(area));
}
@ -240,7 +245,7 @@ PosInfo Board::getPosInfo()
return info;
}
void Board::draw(const Brush& b)
void Board::draw(Brush& b)
{
/// FIXME: Bug Found while trying to draw a Board in Board.
for(auto& p:_wlst)
@ -324,24 +329,32 @@ std::string TextButton::getText()
return _word;
}
void TextButton::draw(const Brush&)
void TextButton::draw(Brush&)
{
/// FIXME: Unfinished TextButton::draw() due to Font loading in Frame.
printf("TextButton::draw()\n");
}
void ColorButton::draw(const Brush& b)
void ColorButton::draw(Brush& b)
{
RGBA td=b.getColor();
switch(_colorstatus)
{
case 0:/// Normal
/// How to fill rect with PosInfo and Brush...
b.setColor(normal);
b.fillRect(info);
break;
case 1:/// Active (MouseOver)
b.setColor(active);
b.fillRect(info);
break;
case 2:/// Pressed Down (MouseUp)
b.setColor(active);
b.fillRect(info);
break;
}
b.setColor(td);
}

View File

@ -13,6 +13,8 @@ namespace Widget
class PosInfo
{
public:
PosInfo() : x(0),y(0),w(1),h(1){}
PosInfo(double X,double Y,double W,double H) : x(X),y(Y),w(W),h(H) {}
double x,y;
double w,h;
Rect getRect(Rect Area);
@ -39,6 +41,7 @@ public:
int copyFullFill(Texture t);
Rect getArea();
void setArea(Rect Area);
int fillRect(PosInfo info);
protected:
Brush(Renderer Rnd);
private:
@ -50,7 +53,8 @@ private:
class BoardBase : public EventHandlerBase
{
public:
virtual void draw(const Brush&)=0;
virtual void draw(Brush&)=0;
PosInfo info;
};
class Frame
@ -87,7 +91,7 @@ public:
void add(WidgetBase*);
int remove(Board*);
int remove(WidgetBase*);
virtual void draw(const Brush&);
virtual void draw(Brush&);
virtual bool event(const EventBase& ev) override;
Board* getParent();
Frame* getFrame();
@ -95,7 +99,7 @@ public:
private:
std::list<Board*> _blst;
std::list<WidgetBase*> _wlst;
PosInfo info;
Board* _parent;
Frame* _frame;
friend class Frame;
@ -125,7 +129,7 @@ class TextButton : public ButtonBase
public:
void setText(std::string Text);
std::string getText();
virtual void draw(const Brush&) override;
virtual void draw(Brush&) override;
private:
std::string _word;
Texture _text;
@ -135,7 +139,7 @@ class ColorButton : public ButtonBase
{
public:
RGBA normal,active,clicked;
virtual void draw(const Brush&) override;
virtual void draw(Brush&) override;
protected:
void onPressed();
void onClick();
@ -150,7 +154,7 @@ class ProcessBarBase : public WidgetBase
public:
int currentVal,maxVal;
ProcessBarBase();
virtual void draw(const Brush&) override;
virtual void draw(Brush&) override;
};
}/// End of namespace MiniEngine::Widget