diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-02-15 20:31:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-02-15 20:31:52 +0300 |
commit | 29f929794c7519b049de0be3af635f05d7e83be6 (patch) | |
tree | 5627bfcb7f19a349f065c207476c871bc5c3aa40 /src/render/graphics.h | |
parent | 41d545176ffad2fb33158ca3415d2a0a983fffdb (diff) | |
download | manaplus-29f929794c7519b049de0be3af635f05d7e83be6.tar.gz manaplus-29f929794c7519b049de0be3af635f05d7e83be6.tar.bz2 manaplus-29f929794c7519b049de0be3af635f05d7e83be6.tar.xz manaplus-29f929794c7519b049de0be3af635f05d7e83be6.zip |
move some methods from base/graphics into render/graphics.
Remove base/graphcs.
Diffstat (limited to 'src/render/graphics.h')
-rw-r--r-- | src/render/graphics.h | 163 |
1 files changed, 146 insertions, 17 deletions
diff --git a/src/render/graphics.h b/src/render/graphics.h index 93d46b475..53eb4af12 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -20,6 +20,49 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Guichan nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef RENDER_GRAPHICS_H #define RENDER_GRAPHICS_H @@ -29,13 +72,15 @@ #include "render/renderers.h" +#include "gui/base/cliprectangle.hpp" #include "gui/base/color.hpp" -#include "gui/base/graphics.hpp" #ifdef USE_SDL2 #include <SDL_render.h> #endif +#include <stack> + #include "localconsts.h" class Image; @@ -94,7 +139,7 @@ class ImageRect final /** * A central point of control for graphics. */ -class Graphics : public gcn::Graphics +class Graphics { public: A_DELETE_COPY(Graphics) @@ -104,6 +149,16 @@ class Graphics : public gcn::Graphics */ virtual ~Graphics(); + /** + * Alignments for text drawing. + */ + enum Alignment + { + LEFT = 0, + CENTER, + RIGHT + }; + void setWindow(SDL_Window *const window, const int width, const int height) { @@ -145,14 +200,6 @@ class Graphics : public gcn::Graphics */ virtual bool resizeScreen(const int width, const int height); - // override unused abstract function - void drawImage(const gcn::Image* image A_UNUSED, - int srcX A_UNUSED, int srcY A_UNUSED, - int dstX A_UNUSED, int dstY A_UNUSED, - int width A_UNUSED, int height A_UNUSED) override final - { - } - /** * Draws a resclaled version of the image */ @@ -211,8 +258,7 @@ class Graphics : public gcn::Graphics const int w, const int h, const ImageRect &imgRect) = 0; - virtual void fillRectangle(const gcn::Rectangle& rectangle) - override = 0; + virtual void fillRectangle(const gcn::Rectangle& rectangle) = 0; /** * Updates the screen. This is done by either copying the buffer to the @@ -246,9 +292,6 @@ class Graphics : public gcn::Graphics const int x2, const int y2, const int width, const int height); - const gcn::Font *getFont() const A_WARN_UNUSED - { return mFont; } - gcn::ClipRectangle &getTopClip() A_WARN_UNUSED { return mClipStack.top(); } @@ -288,7 +331,7 @@ class Graphics : public gcn::Graphics virtual void initArrays() { } - void setColor(const gcn::Color &color) override + virtual void setColor(const gcn::Color &color) { mColor = color; mColor2 = color; @@ -305,7 +348,7 @@ class Graphics : public gcn::Graphics mAlpha = (color.a != 255); } - const gcn::Color &getColor() const override + const gcn::Color &getColor() const { return mColor; } const gcn::Color &getColor2() const @@ -353,6 +396,87 @@ class Graphics : public gcn::Graphics void setScale(int scale); + /** + * Pushes a clip area onto the stack. The x and y coordinates in the + * rectangle is relative to the last pushed clip area. + * If the new area falls outside the current clip area, it will be + * clipped as necessary. + * + * If a clip area is outside of the top clip area a clip area with + * zero width and height will be pushed. + * + * @param area The clip area to be pushed onto the stack. + * @return False if the the new area lays outside the current clip + * area. + */ + virtual bool pushClipArea(gcn::Rectangle area); + + /** + * Removes the top most clip area from the stack. + * + * @throws Exception if the stack is empty. + */ + virtual void popClipArea(); + + /** + * Ddraws a line. + * + * @param x1 The first x coordinate. + * @param y1 The first y coordinate. + * @param x2 The second x coordinate. + * @param y2 The second y coordinate. + */ + virtual void drawLine(int x1, int y1, int x2, int y2) = 0; + + /** + * Draws a simple, non-filled, rectangle with a one pixel width. + * + * @param rectangle The rectangle to draw. + */ + virtual void drawRectangle(const gcn::Rectangle &rectangle) = 0; + + /** + * Gets the current clip area. Usefull if you want to do drawing + * bypassing Graphics. + * + * @return The current clip area. + */ + virtual const gcn::ClipRectangle *getCurrentClipArea() const; + + /** + * Draws a single point/pixel. + * + * @param x The x coordinate. + * @param y The y coordinate. + */ + virtual void drawPoint(int x, int y) = 0; + + /** + * Initializes drawing. Called by the Gui when Gui::draw() is called. + * It is needed by some implementations of Graphics to perform + * preparations before drawing. An example of such an implementation + * is the OpenGLGraphics. + * + * NOTE: You will never need to call this function yourself, unless + * you use a Graphics object outside of Guichan. + * + * @see _endDraw, Gui::draw + */ + virtual void _beginDraw() + { } + + /** + * Deinitializes drawing. Called by the Gui when a Gui::draw() is done. + * done. It should reset any state changes made by _beginDraw(). + * + * NOTE: You will never need to call this function yourself, unless + * you use a Graphics object outside of Guichan. + * + * @see _beginDraw, Gui::draw + */ + virtual void _endDraw() + { } + int mWidth; int mHeight; int mActualWidth; @@ -382,6 +506,11 @@ class Graphics : public gcn::Graphics bool videoInfo(); + /** + * Holds the clip area stack. + */ + std::stack<gcn::ClipRectangle> mClipStack; + SDL_Window *mWindow; #ifdef USE_SDL2 |