summaryrefslogtreecommitdiff
path: root/plugingui/widget.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui/widget.h')
-rw-r--r--plugingui/widget.h92
1 files changed, 49 insertions, 43 deletions
diff --git a/plugingui/widget.h b/plugingui/widget.h
index 47c374e..6bfffb5 100644
--- a/plugingui/widget.h
+++ b/plugingui/widget.h
@@ -24,11 +24,12 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef __DRUMGIZMO_WIDGET_H__
-#define __DRUMGIZMO_WIDGET_H__
+#pragma once
#include "guievent.h"
#include "pixelbuffer.h"
+#include "notifier.h"
+#include "layout.h"
#include <vector>
@@ -36,64 +37,69 @@ namespace GUI {
class Window;
-class Widget {
+class Widget : public Listener, public LayoutItem {
+ friend class Painter;
public:
- Widget(Widget *parent);
- virtual ~Widget();
+ Widget(Widget* parent);
+ virtual ~Widget();
- virtual void show();
- virtual void hide();
+ virtual void show();
+ virtual void hide();
- virtual void resize(int width, int height);
- virtual void move(size_t x, size_t y);
+ // From LayoutItem
+ virtual void resize(int width, int height) override;
+ virtual void move(size_t x, size_t y) override;
+ virtual int x() override;
+ virtual int y() override;
+ virtual size_t width() override;
+ virtual size_t height() override;
- virtual size_t x();
- virtual size_t y();
- virtual size_t windowX();
- virtual size_t windowY();
- virtual size_t width();
- virtual size_t height();
+ virtual size_t windowX();
+ virtual size_t windowY();
- virtual bool isFocusable() { return false; }
- virtual bool catchMouse() { return false; }
+ virtual bool isFocusable() { return false; }
+ virtual bool catchMouse() { return false; }
- void addChild(Widget *widget);
- void removeChild(Widget *widget);
+ void addChild(Widget* widget);
+ void removeChild(Widget* widget);
- virtual void repaintEvent(RepaintEvent *e) {}
- virtual void mouseMoveEvent(MouseMoveEvent *e) {}
- virtual void buttonEvent(ButtonEvent *e) {}
- virtual void scrollEvent(ScrollEvent *e) {}
- virtual void keyEvent(KeyEvent *e) {}
+ virtual void repaintEvent(RepaintEvent* repaintEvent) {}
+ virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) {}
+ virtual void buttonEvent(ButtonEvent* buttonEvent) {}
+ virtual void scrollEvent(ScrollEvent* scrollEvent) {}
+ virtual void keyEvent(KeyEvent* keyEvent) {}
+ virtual void mouseLeaveEvent() {}
+ virtual void mouseEnterEvent() {}
- virtual void mouseLeaveEvent() {}
- virtual void mouseEnterEvent() {}
+ Widget* find(int x, int y);
- Widget *find(size_t x, size_t y);
+ virtual Window* window();
- virtual Window *window();
+ std::vector<PixelBufferAlpha*> getPixelBuffers();
- void repaint_r(RepaintEvent *e);
+ bool hasKeyboardFocus();
- PixelBufferAlpha pixbuf;
- std::vector<PixelBufferAlpha *> getPixelBuffers();
+ bool visible();
+ void setVisible(bool visible);
- bool hasKeyboardFocus();
+ Notifier<int, int> sizeChangeNotifier; // (int, width, int height)
- Widget *parent;
+protected:
+ void repaintChildren(RepaintEvent* repaintEvent);
- bool visible();
- void setVisible(bool visible);
+ PixelBufferAlpha pixbuf{0,0};
-protected:
- std::vector<Widget*> children;
- Window *_window;
- size_t _x, _y, _width, _height;
+ std::vector<Widget*> children;
-private:
- bool _visible;
-};
+ Widget* parent = nullptr;
+ Window* _window = nullptr;
+
+ int _x{0};
+ int _y{0};
+ size_t _width{0};
+ size_t _height{0};
+ bool _visible = true;
};
-#endif/*__DRUMGIZMO_WIDGET_H__*/
+} // GUI::