1 #ifndef __DRAWINGCONTEXT_H__
2 #define __DRAWINGCONTEXT_H__
12 // some constants for predefined layer values
14 LAYER_BACKGROUND0 = -300,
15 LAYER_BACKGROUND1 = -200,
16 LAYER_BACKGROUNDTILES = -100,
19 LAYER_FOREGROUNDTILES = 200,
20 LAYER_FOREGROUND0 = 300,
21 LAYER_FOREGROUND1 = 400
28 : red(0), green(0), blue(0), alpha(0)
31 Color(Uint8 red_, Uint8 green_, Uint8 blue_, Uint8 alpha_ = 0)
32 : red(red_), green(green_), blue(blue_), alpha(alpha_)
36 : red(o.red), green(o.green), blue(o.blue), alpha(o.alpha)
39 Uint8 red, green, blue, alpha;
43 * This class provides functions for drawing things on screen. It also
44 * maintains a stack of transforms that are applied to graphics.
52 /** Adds a drawing request for a surface into the request list */
53 void draw_surface(const Surface* surface, const Vector& position, int layer);
54 /** Adds a drawing request for part of a surface */
55 void draw_surface_part(const Surface* surface, const Vector& source,
56 const Vector& size, const Vector& dest, int layer);
58 void draw_text(Font* font, const std::string& text, const Vector& position,
60 /** draws aligned text */
61 void draw_text_center(Font* font, const std::string& text,
62 const Vector& position, int layer);
63 /** draws a color gradient onto the whole screen */
64 void draw_gradient(Color from, Color to, int layer);
65 /** fills a rectangle */
66 void draw_filled_rect(const Vector& topleft, const Vector& downright,
67 Color color, int layer);
69 /** Processes all pending drawing requests and flushes the list */
72 const Vector& get_translation() const
73 { return transform.translation; }
74 void set_translation(const Vector& newtranslation)
75 { transform.translation = newtranslation; }
77 void push_transform();
84 Vector translation; // only translation for now...
86 Vector apply(const Vector& v) const
88 return v - translation;
92 /// the transform stack
93 std::vector<Transform> transformstack;
94 /// the currently active transform
99 SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT
102 struct SurfacePartRequest
104 const Surface* surface;
114 struct GradientRequest
120 struct FillRectRequest
126 struct DrawingRequest
135 bool operator<(const DrawingRequest& other) const
137 return layer < other.layer;
141 void draw_surface_part(DrawingRequest& request);
142 void draw_text(DrawingRequest& request);
143 void draw_gradient(DrawingRequest& request);
144 void draw_filled_rect(DrawingRequest& request);
146 typedef std::vector<DrawingRequest> DrawingRequests;
147 DrawingRequests drawingrequests;