diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-02-12 11:07:22 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-02-12 11:07:22 +0100 |
commit | cec1d9ea562e3d52c98f1219db5e186943f2f0d6 (patch) | |
tree | 3a66ff06ef16cce96e215644032e6c9fac2cbe8a /plugingui/widget.h | |
parent | dc33f15a6b968139779c2b7d2003d3ef6e7d5748 (diff) |
Refactor/introduce widget and windiow redraw/dirty mechanism to eradicate unnecessary rendering passes during event handling.
Diffstat (limited to 'plugingui/widget.h')
-rw-r--r-- | plugingui/widget.h | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/plugingui/widget.h b/plugingui/widget.h index 4ea79e9..0485c32 100644 --- a/plugingui/widget.h +++ b/plugingui/widget.h @@ -52,25 +52,22 @@ public: virtual void show(); virtual void hide(); + void setVisible(bool visible); + bool visible() const; + + //! Mark widget dirty and shedule redraw on next window redraw. + void redraw(); // From LayoutItem virtual void resize(std::size_t width, std::size_t height) override; virtual void move(int x, int y) override; - virtual int x() override; - virtual int y() override; - virtual std::size_t width() override; - virtual std::size_t height() override; + virtual int x() const override; + virtual int y() const override; + virtual std::size_t width() const override; + virtual std::size_t height() const override; // From Canvas PixelBufferAlpha& GetPixelBuffer() override; - void beginPaint() override; - void endPaint() override; - - //! Translate x-coordinate from parent-space to window-space. - virtual size_t windowX(); - - //! Translate y-coordinate from parent-space to window-space. - virtual size_t windowY(); virtual bool isFocusable() { return false; } virtual bool catchMouse() { return false; } @@ -97,14 +94,17 @@ public: bool hasKeyboardFocus(); - bool visible(); - void setVisible(bool visible); - Notifier<std::size_t, std::size_t> sizeChangeNotifier; // (width, height) Notifier<int, int> positionChangeNotifier; // (x, y) protected: - void repaintChildren(RepaintEvent* repaintEvent); + friend class EventHandler; + + //! Translate x-coordinate from parent-space to window-space. + virtual std::size_t translateToWindowX(); + + //! Translate y-coordinate from parent-space to window-space. + virtual std::size_t translateToWindowY(); PixelBufferAlpha pixbuf{0,0}; @@ -119,6 +119,8 @@ protected: std::size_t _height{0}; bool _visible{true}; + + bool dirty{true}; }; } // GUI:: |