From a65ca7af57feaf7a4ea73f7e071a72eb9b3a1e24 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 7 Nov 2015 10:39:46 +0100 Subject: Refactored Painter. --- plugingui/painter.h | 89 +++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 47 deletions(-) (limited to 'plugingui/painter.h') diff --git a/plugingui/painter.h b/plugingui/painter.h index 0a93f50..40747a7 100644 --- a/plugingui/painter.h +++ b/plugingui/painter.h @@ -24,8 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_PAINTER_H__ -#define __DRUMGIZMO_PAINTER_H__ +#pragma once #include @@ -39,59 +38,55 @@ namespace GUI { class Painter { public: - Painter(Widget *widget); - ~Painter(); + Painter(Widget& widget); + ~Painter(); - void flush(); + void flush(); - void setColour(Colour colour); + void setColour(const Colour& colour); - void drawLine(int x1, int y1, int x2, int y2); - void drawText(int x, int y, Font &font, std::string text, - bool nocolour = false); - void drawRectangle(int x1, int y1, int x2, int y2); - void drawFilledRectangle(int x1, int y1, int x2, int y2); - void drawPoint(int x, int y); - void drawCircle(int x, int y, double r); - void drawFilledCircle(int x, int y, int r); - void drawImage(int x, int y, Image *image); - void drawImageStretched(int x0, int y0, GUI::Image *image, - int width, int height); + void drawLine(int x1, int y1, int x2, int y2); + void drawText(int x, int y, const Font &font, const std::string& text, + bool nocolour = false); + void drawRectangle(int x1, int y1, int x2, int y2); + void drawFilledRectangle(int x1, int y1, int x2, int y2); + void drawPoint(int x, int y); + void drawCircle(int x, int y, double r); + void drawFilledCircle(int x, int y, int r); + void drawImage(int x, int y, const Image& image); + void drawImageStretched(int x, int y, const Image& image, + int width, int height); - typedef struct { - Image *topLeft; - Image *top; - Image *topRight; - Image *left; - Image *right; - Image *bottomLeft; - Image *bottom; - Image *bottomRight; - Image *center; - } Box; - void drawBox(int x, int y, Box *box, int width, int height); + typedef struct { + Image *topLeft; + Image *top; + Image *topRight; + Image *left; + Image *right; + Image *bottomLeft; + Image *bottom; + Image *bottomRight; + Image *center; + } Box; + void drawBox(int x, int y, const Box& box, int width, int height); - typedef struct { - Image *left; - Image *right; - Image *center; - } Bar; - void drawBar(int x, int y, Bar *bar, int width, int height); + typedef struct { + Image *left; + Image *right; + Image *center; + } Bar; + void drawBar(int x, int y, const Bar& bar, int width, int height); - void clear(); + void clear(); private: - void plot(int x, int y, double c); - double ipart(double x); - double round(double x); - double fpart(double x); - double rfpart(double x); + void plot(int x, int y, double c); + double fpart(double x); + double rfpart(double x); - Widget *widget; - PixelBufferAlpha *pixbuf; - Colour colour; + Widget& widget; + PixelBufferAlpha* pixbuf; + Colour colour; }; -}; - -#endif/*__DRUMGIZMO_PAINTER_H__*/ +} // GUI:: -- cgit v1.2.3