diff --git a/MiniEngine_Widget.cpp b/MiniEngine_Widget.cpp index f30a3a6..926a629 100644 --- a/MiniEngine_Widget.cpp +++ b/MiniEngine_Widget.cpp @@ -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); } diff --git a/MiniEngine_Widget.h b/MiniEngine_Widget.h index 7acd3c5..5a31601 100644 --- a/MiniEngine_Widget.h +++ b/MiniEngine_Widget.h @@ -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 _blst; std::list _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