|
FifeGUI 0.3.0
A C++ GUI library designed for games.
|
#include <graphics.hpp>
Public Member Functions | |
| void | _beginDraw () override |
| void | _endDraw () override |
| void | drawBezier (PointVector const &points, int steps, unsigned int width) override |
| void | drawCircle (Point const &p, unsigned int radius) override |
| void | drawCircleSegment (Point const &p, unsigned int radius, int sangle, int eangle) override |
| void | drawFillCircle (Point const &p, unsigned int radius) override |
| void | drawFillCircleSegment (Point const &p, unsigned int radius, int sangle, int eangle) override |
| void | drawImage (fcn::Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height) override |
| void | drawImage (fcn::opengl::Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height) |
| virtual void | drawImage (Image const *image, int dstX, int dstY) |
| void | drawLine (int x1, int y1, int x2, int y2) override |
| void | drawLine (int x1, int y1, int x2, int y2, unsigned int width) override |
| void | drawPoint (int x, int y) override |
| void | drawPolyLine (PointVector const &points, unsigned int width) override |
| void | drawRectangle (Rectangle const &rectangle) override |
| void | fillRectangle (Rectangle const &rectangle) override |
| Color const & | getColor () const override |
| Graphics () | |
| Graphics (int width, int height) | |
| void | popClipArea () override |
| bool | pushClipArea (Rectangle area) override |
| void | setColor (Color const &color) override |
| void | setTargetPlane (int width, int height) |
| Public Member Functions inherited from fcn::Graphics | |
| virtual std::shared_ptr< Font > | createFont (std::string const &filename, int size) |
| void | drawRectangle (int x, int y, int width, int height) |
| virtual void | drawRoundStroke (int x1, int y1, int x2, int y2, unsigned int width) |
| void | drawText (std::string const &text, int x, int y) |
| virtual void | drawText (std::string const &text, int x, int y, Alignment alignment) |
| void | fillRectangle (int x, int y, int width, int height) |
| virtual ClipRectangle const & | getCurrentClipArea () |
| Graphics (Graphics &&)=delete | |
| Graphics (Graphics const &)=delete | |
| Graphics & | operator= (Graphics &&)=delete |
| Graphics & | operator= (Graphics const &)=delete |
| virtual void | setFont (Font *font) |
Protected Member Functions | |
| virtual int | getTargetPlaneHeight () const |
| virtual int | getTargetPlaneWidth () const |
| virtual void | setTargetPlaneImpl (int width, int height) |
Protected Attributes | |
| bool | mAlpha {} |
| Color | mColor |
| int | mHeight {} |
| int | mWidth {} |
| Protected Attributes inherited from fcn::Graphics | |
| std::stack< ClipRectangle > | mClipStack |
| Font * | mFont {nullptr} |
Additional Inherited Members | |
| Public Types inherited from fcn::Graphics | |
| enum class | Alignment : uint8_t { Left = 0 , Center , Right } |
| enum class | VerticalAlignment : uint8_t { Top = 0 , Center , Bottom } |
OpenGL-specific implementation of the Graphics interface.
Definition at line 23 of file backends/opengl/graphics.hpp.
| fcn::opengl::Graphics::Graphics | ( | ) |
Constructor.
Definition at line 28 of file backends/opengl/graphics.cpp.
| fcn::opengl::Graphics::Graphics | ( | int | width, |
| int | height ) |
Constructor.
| width | the width of the logical drawing surface. Should be the same as the screen resolution. |
| height | the height ot the logical drawing surface. Should be the same as the screen resolution. |
Definition at line 32 of file backends/opengl/graphics.cpp.
|
overridevirtualdefault |
Reimplemented from fcn::Graphics.
|
overridevirtual |
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.
Reimplemented from fcn::Graphics.
Definition at line 43 of file backends/opengl/graphics.cpp.
References mHeight, mWidth, and pushClipArea().
|
overridevirtual |
Deinitializes the drawing process.
Called by the GUI when Gui::draw() is complete. It should reset any state changes made by _beginDraw().
Reimplemented from fcn::Graphics.
Definition at line 80 of file backends/opengl/graphics.cpp.
References popClipArea().
|
overridevirtual |
Draws a bezier curve.
| points | The coordinates as points in a vector. |
| steps | The steps for each line between two points. |
| width | The line width. |
Implements fcn::Graphics.
Definition at line 239 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a simple, non-filled circle with a one pixel width.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
Implements fcn::Graphics.
Definition at line 278 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a simple, non-filled circle segment with a one pixel width.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
| sangle | The start angle of the segment. |
| eangle | The end angle of the segment. |
Implements fcn::Graphics.
Definition at line 288 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a filled circle.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
Implements fcn::Graphics.
Definition at line 283 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a filled circle segment.
| p | The circle center coordinate as point. |
| radius | The circle radius. |
| sangle | The start angle of the segment. |
| eangle | The end angle of the segment. |
Implements fcn::Graphics.
Definition at line 293 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a part of an image.
| image | The image to draw. |
| srcX | The source image x coordinate. |
| srcY | The source image y coordinate. |
| dstX | The destination x coordinate. |
| dstY | The destination y coordinate. |
| width | The width of the piece. |
| height | The height of the piece. |
Implements fcn::Graphics.
Definition at line 130 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, fcn::throwException(), fcn::ClipRectangle::xOffset, and fcn::ClipRectangle::yOffset.
| void fcn::opengl::Graphics::drawImage | ( | fcn::opengl::Image const * | image, |
| int | srcX, | ||
| int | srcY, | ||
| int | dstX, | ||
| int | dstY, | ||
| int | width, | ||
| int | height ) |
Draws an OpenGL-specific image.
| image | Pointer to the OpenGL image to draw. |
| srcX | Source X coordinate. |
| srcY | Source Y coordinate. |
| dstX | Destination X coordinate. |
| dstY | Destination Y coordinate. |
| width | Width of the region to draw. |
| height | Height of the region to draw. |
References drawBezier(), drawCircle(), drawCircleSegment(), drawFillCircle(), drawFillCircleSegment(), drawLine(), drawPoint(), drawPolyLine(), drawRectangle(), fillRectangle(), getColor(), getTargetPlaneHeight(), getTargetPlaneWidth(), setColor(), and setTargetPlaneImpl().
|
virtual |
Draws an image.
A simplified version of the other drawImage. It will draw a whole image at the coordinate you specify.
| image | The image to draw. |
| dstX | The destination x coordinate. |
| dstY | The destination y coordinate. |
Reimplemented from fcn::Graphics.
Definition at line 200 of file graphics.cpp.
|
overridevirtual |
Draws a line.
| x1 | The first x coordinate. |
| y1 | The first y coordinate. |
| x2 | The second x coordinate. |
| y2 | The second y coordinate. |
Implements fcn::Graphics.
Definition at line 201 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, fcn::throwException(), fcn::ClipRectangle::xOffset, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Draws a thick line.
| x1 | The first x coordinate. |
| y1 | The first y coordinate. |
| x2 | The second x coordinate. |
| y2 | The second y coordinate. |
| width | The line width. |
Implements fcn::Graphics.
Definition at line 229 of file backends/opengl/graphics.cpp.
|
overridevirtual |
Draws a single point/pixel.
| x | The x coordinate. |
| y | The y coordinate. |
Implements fcn::Graphics.
Definition at line 184 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, fcn::throwException(), fcn::ClipRectangle::xOffset, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Draws lines between points with given width.
| points | Contains the points that are used for drawing. |
| width | The line width. |
Implements fcn::Graphics.
Definition at line 234 of file backends/opengl/graphics.cpp.
Referenced by drawImage().
|
overridevirtual |
Draws a simple, non-filled rectangle with a one pixel width.
| rectangle | The rectangle to draw. |
Implements fcn::Graphics.
Definition at line 244 of file backends/opengl/graphics.cpp.
References fcn::Rectangle::height, fcn::Graphics::mClipStack, fcn::throwException(), fcn::Rectangle::width, fcn::Rectangle::x, fcn::ClipRectangle::xOffset, fcn::Rectangle::y, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Draws a filled rectangle.
| rectangle | The filled rectangle to draw. |
Implements fcn::Graphics.
Definition at line 261 of file backends/opengl/graphics.cpp.
References fcn::Rectangle::height, fcn::Graphics::mClipStack, fcn::throwException(), fcn::Rectangle::width, fcn::Rectangle::x, fcn::ClipRectangle::xOffset, fcn::Rectangle::y, and fcn::ClipRectangle::yOffset.
Referenced by drawImage().
|
overridevirtual |
Gets the color to use when drawing.
Implements fcn::Graphics.
Definition at line 314 of file backends/opengl/graphics.cpp.
References mColor.
Referenced by drawImage().
|
protectedvirtual |
Gets the target plane height.
Definition at line 324 of file backends/opengl/graphics.cpp.
References mHeight.
Referenced by drawImage().
|
protectedvirtual |
Gets the target plane width.
Definition at line 319 of file backends/opengl/graphics.cpp.
References mWidth.
Referenced by drawImage().
|
overridevirtual |
Removes the top most clip area from the stack.
| Exception | if the stack is empty. |
Reimplemented from fcn::Graphics.
Definition at line 109 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, mHeight, and fcn::Graphics::popClipArea().
Referenced by _endDraw().
|
overridevirtual |
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.
| area | The clip area to be pushed onto the stack. |
Reimplemented from fcn::Graphics.
Definition at line 96 of file backends/opengl/graphics.cpp.
References fcn::Graphics::mClipStack, mHeight, and fcn::Graphics::pushClipArea().
Referenced by _beginDraw().
|
overridevirtual |
Sets the color to use when drawing.
| color | A color. |
Implements fcn::Graphics.
Definition at line 298 of file backends/opengl/graphics.cpp.
References fcn::Color::a, fcn::Color::b, fcn::Color::g, mAlpha, mColor, and fcn::Color::r.
Referenced by drawImage().
| void fcn::opengl::Graphics::setTargetPlane | ( | int | width, |
| int | height ) |
Sets the target plane on where to draw.
| width | the width of the logical drawing surface. Should be the same as the screen resolution. |
| height | the height ot the logical drawing surface. Should be the same as the screen resolution. |
Definition at line 36 of file backends/opengl/graphics.cpp.
References setTargetPlaneImpl().
|
protectedvirtual |
Backend hook that actually applies the logical target plane size.
Subclasses may override to update platform or API specific state.
| width | Logical plane width in pixels. |
| height | Logical plane height in pixels. |
Definition at line 124 of file backends/opengl/graphics.cpp.
References mHeight, and mWidth.
Referenced by drawImage(), and setTargetPlane().
|
protected |
Whether alpha blending is enabled.
Definition at line 140 of file backends/opengl/graphics.hpp.
Referenced by setColor().
|
protected |
Current drawing color.
Definition at line 143 of file backends/opengl/graphics.hpp.
Referenced by getColor(), and setColor().
|
protected |
Height of the logical target plane.
Definition at line 137 of file backends/opengl/graphics.hpp.
Referenced by _beginDraw(), getTargetPlaneHeight(), Graphics(), Graphics(), popClipArea(), pushClipArea(), and setTargetPlaneImpl().
|
protected |
Width of the logical target plane.
Definition at line 134 of file backends/opengl/graphics.hpp.
Referenced by _beginDraw(), getTargetPlaneWidth(), Graphics(), Graphics(), and setTargetPlaneImpl().