X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fvideo%2Fdrawing_context.h;h=7ef8de954c368e9c25fd1f5deec0d4fea87000be;hb=133d94d5b145f325c38c8c15c9ea561bfffb092d;hp=b200e7bdf4c4d1caade491e3f7ecaeec6605924f;hpb=edaacb3651cf0560314dd008d7243be4b3b2f8c6;p=supertux.git diff --git a/lib/video/drawing_context.h b/lib/video/drawing_context.h index b200e7bdf..7ef8de954 100644 --- a/lib/video/drawing_context.h +++ b/lib/video/drawing_context.h @@ -47,6 +47,7 @@ namespace SuperTux LAYER_GUI = 500 }; + /// Handles drawing of things. /** * This class provides functions for drawing things on screen. It also * maintains a stack of transforms that are applied to graphics. @@ -57,56 +58,69 @@ namespace SuperTux DrawingContext(); ~DrawingContext(); - /** Adds a drawing request for a surface into the request list */ + /// Adds a drawing request for a surface into the request list. void draw_surface(const Surface* surface, const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT); - /** Adds a drawing request for part of a surface */ + /// Adds a drawing request for part of a surface. void draw_surface_part(const Surface* surface, const Vector& source, const Vector& size, const Vector& dest, int layer, Uint32 drawing_effect = NONE_EFFECT); - /** draws a text */ + /// Draws a text. void draw_text(Font* font, const std::string& text, const Vector& position, - int layer, Uint32 drawing_effect = NONE_EFFECT); - /** draws aligned text */ - void draw_text_center(Font* font, const std::string& text, - const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT); - /** draws a color gradient onto the whole screen */ + int allignment, int layer, + Uint32 drawing_effect = NONE_EFFECT); + + /// Draws text on screen center (feed Vector.x with a 0). + /// This is the same as draw_text() with a screen->w/2 position and + /// allignment set to LEFT_ALLIGN + void draw_center_text(Font* font, const std::string& text, + const Vector& position, int layer, + Uint32 drawing_effect = NONE_EFFECT); + /// Draws a color gradient onto the whole screen */ void draw_gradient(Color from, Color to, int layer); - /** fills a rectangle */ + /// Fills a rectangle. void draw_filled_rect(const Vector& topleft, const Vector& size, Color color, int layer); - /** Processes all pending drawing requests and flushes the list */ + /// Processes all pending drawing requests and flushes the list. void do_drawing(); const Vector& get_translation() const - { - return transform.translation; - } + { return transform.translation; } + Uint32 get_drawing_effect() const + { return transform.drawing_effect; } + void set_translation(const Vector& newtranslation) - { - transform.translation = newtranslation; - } + { transform.translation = newtranslation; } void push_transform(); void pop_transform(); - /** apply that effect in the next draws (effects are listed on surface.h) */ + /// Apply that effect in the next draws (effects are listed on surface.h). void set_drawing_effect(int effect); + /// apply that zoom in the next draws */ + void set_zooming(float zoom); + /// apply that alpha in the next draws */ + void set_alpha(int alpha); private: class Transform - { - public: - Vector translation; // only translation for now... + { + public: + Vector translation; + Uint32 drawing_effect; + float zoom; + int alpha; - Vector apply(const Vector& v) const - { - return v - translation; - } + Transform() + : drawing_effect(NONE_EFFECT), zoom(1), alpha(255) + { } - int draw_effect; - }; + Vector apply(const Vector& v) const + { + return v - translation; + } + }; /// the transform stack std::vector transformstack; @@ -128,6 +142,7 @@ namespace SuperTux { Font* font; std::string text; + int allignment; }; struct GradientRequest @@ -144,11 +159,13 @@ namespace SuperTux struct DrawingRequest { + RequestType type; + Vector pos; + int layer; Uint32 drawing_effect; - - RequestType type; - Vector pos; + float zoom; + int alpha; void* request_data; @@ -160,6 +177,7 @@ namespace SuperTux void draw_surface_part(DrawingRequest& request); void draw_text(DrawingRequest& request); + void draw_text_center(DrawingRequest& request); void draw_gradient(DrawingRequest& request); void draw_filled_rect(DrawingRequest& request);