| 1 | /* ---------------------------------------------------------------------- * |
| 2 | * src/gui/PainterSDL/PainterSDL.hpp |
| 3 | * This file is part of Lincity-NG. |
| 4 | * |
| 5 | * Copyright (C) 2005 Matthias Braun <[email protected]> |
| 6 | * Copyright (C) 2025 David Bears <[email protected]> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | ** ---------------------------------------------------------------------- */ |
| 22 | |
| 23 | #ifndef __PAINTERSDL_HPP__ |
| 24 | #define __PAINTERSDL_HPP__cxx . . $ `src/gui/PainterSDL/PainterSDL.hpp:24:9`! |
| 25 | |
| 26 | #include <SDL3/SDL.h> // for SDL_Renderer |
| 27 | #include <cmath> // for INFINITY |
| 28 | #include <deque> // for deque |
| 29 | #include <vector> // for vector |
| 30 | |
| 31 | #include "../Color.hpp"cxx . . $ `<file>/src/gui/Color.hpp`/ // for Color |
| 32 | #include "../Painter.hpp"cxx . . $ `<file>/src/gui/Painter.hpp`/ // for Painter |
| 33 | #include "../Vector2.hpp"cxx . . $ `<file>/src/gui/Vector2.hpp`/ // for Vector2 |
| 34 | #include "../Rect2D.hpp"cxx . . $ `<file>/src/gui/Rect2D.hpp`/ // for Rect2D |
| 35 | |
| 36 | class TextureSDLcxx . . $ TextureSDL#; |
| 37 | |
| 38 | /** |
| 39 | * This class is needed to perform drawing operations. It contains a stack of |
| 40 | * trasnformations (currently only translation) which is applied to the drawing |
| 41 | * operations. This is usefull for child widgets in the gui-component tree. |
| 42 | */ |
| 43 | class PainterSDLcxx . . $ PainterSDL# : public Paintercxx . . $ Painter# |
| 44 | { |
| 45 | public: |
| 46 | PainterSDLcxx . . $ PainterSDL#PainterSDL(8a04ec9ed224ca6d).(SDL_Renderer* target); |
| 47 | virtual ~cxx . . $ PainterSDL#`~PainterSDL`(ced63f7c635d850d).PainterSDLcxx . . $ PainterSDL#(); |
| 48 | |
| 49 | void drawTexturecxx . . $ PainterSDL#drawTexture(f9d74ff5239b05dd).(const Texturecxx . . $ Texture#* texture, Vector2cxx . . $ Vector2# pos) override; |
| 50 | void drawStretchTexturecxx . . $ PainterSDL#drawStretchTexture(b96435c415c175f0).(const Texturecxx . . $ Texture# *texture, const Rect2Dcxx . . $ Rect2D#& rect) override; |
| 51 | void fillRectanglecxx . . $ PainterSDL#fillRectangle(eb2ef952f66af730).(const Rect2Dcxx . . $ Rect2D#& rect) override; |
| 52 | void drawRectanglecxx . . $ PainterSDL#drawRectangle(eb2ef952f66af730).(const Rect2Dcxx . . $ Rect2D#& rect) override; |
| 53 | void fillPolygoncxx . . $ PainterSDL#fillPolygon(af3d0cab395a8337).(int numberPoints, const Vector2cxx . . $ Vector2#* points) override; |
| 54 | void drawPolygoncxx . . $ PainterSDL#drawPolygon(af3d0cab395a8337).(int numberPoints, const Vector2cxx . . $ Vector2#* points) override; |
| 55 | void drawLinecxx . . $ PainterSDL#drawLine(744ccc1d5f859316).(Vector2cxx . . $ Vector2# pointA, Vector2cxx . . $ Vector2# pointB) override; |
| 56 | void clearcxx . . $ PainterSDL#clear(49f6e7a06ebc5aa8).() override; |
| 57 | |
| 58 | void setFillColorcxx . . $ PainterSDL#setFillColor(aedfd3d682d1d534).(Colorcxx . . $ Color# color) override; |
| 59 | void setLineColorcxx . . $ PainterSDL#setLineColor(aedfd3d682d1d534).(Colorcxx . . $ Color# color) override; |
| 60 | |
| 61 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Texturecxx . . $ Texture#> createTargetTexturecxx . . $ PainterSDL#createTargetTexture(1e9c38423da2fa6a).(int w, int h) override; |
| 62 | void pushRenderTargetcxx . . $ PainterSDL#pushRenderTarget(6192829ae6c7d0c2).(Texturecxx . . $ Texture# *target) override; |
| 63 | void popRenderTargetcxx . . $ PainterSDL#popRenderTarget(49f6e7a06ebc5aa8).() override; |
| 64 | |
| 65 | void updateScreencxx . . $ PainterSDL#updateScreen(49f6e7a06ebc5aa8).() override; |
| 66 | |
| 67 | void translatecxx . . $ PainterSDL#translate(26fade7a38b9983c).(Vector2cxx . . $ Vector2# tl) override; |
| 68 | void pushTransformcxx . . $ PainterSDL#pushTransform(49f6e7a06ebc5aa8).() override; |
| 69 | void popTransformcxx . . $ PainterSDL#popTransform(49f6e7a06ebc5aa8).() override; |
| 70 | |
| 71 | void pushClipRectcxx . . $ PainterSDL#pushClipRect(eb2ef952f66af730).(const Rect2Dcxx . . $ Rect2D#& region) override; |
| 72 | void popClipRectcxx . . $ PainterSDL#popClipRect(49f6e7a06ebc5aa8).() override; |
| 73 | |
| 74 | |
| 75 | private: |
| 76 | SDL_Renderer* renderercxx . . $ PainterSDL#renderer.; |
| 77 | |
| 78 | struct Transformcxx . . $ PainterSDL#Transform# { |
| 79 | Vector2cxx . . $ Vector2# translationcxx . . $ PainterSDL#Transform#translation.; |
| 80 | |
| 81 | Vector2cxx . . $ Vector2# applycxx . . $ PainterSDL#Transform#apply(7b55b1a58aad87e1).(const Vector2cxx . . $ Vector2#& v) const { |
| 82 | return v -cxx . . $ Vector2#operator-(7b55b1a58aad87e1). translationcxx . . $ PainterSDL#Transform#translation.; |
| 83 | } |
| 84 | }; |
| 85 | // the stack used by push-/popTransform |
| 86 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Transformcxx . . $ PainterSDL#Transform#> transformStackcxx . . $ PainterSDL#transformStack.; |
| 87 | // the currently active transform |
| 88 | Transformcxx . . $ PainterSDL#Transform# transformcxx . . $ PainterSDL#transform.; |
| 89 | |
| 90 | stdcxx . . $ std/::dequecxx . . $ std/deque#<TextureSDLcxx . . $ TextureSDL# *> targetStackcxx . . $ PainterSDL#targetStack.; |
| 91 | |
| 92 | stdcxx . . $ std/::dequecxx . . $ std/deque#<Rect2Dcxx . . $ Rect2D#> cliprectStackcxx . . $ PainterSDL#cliprectStack.; |
| 93 | void updateClipRectcxx . . $ PainterSDL#updateClipRect(49f6e7a06ebc5aa8).(); |
| 94 | static constexpr Rect2Dcxx . . $ Rect2D# CR_NONEcxx . . $ PainterSDL#CR_NONE. = Rect2Dcxx . . $ Rect2D#Rect2D(7e9a355db6148521).(0,0,INFINITYcxx . . $ `<external>/11263917310783833665/math.h:92:12`!,INFINITYcxx . . $ `<external>/11263917310783833665/math.h:92:12`!); |
| 95 | |
| 96 | Colorcxx . . $ Color# fillColorcxx . . $ PainterSDL#fillColor.,lineColorcxx . . $ PainterSDL#lineColor.; |
| 97 | }; |
| 98 | |
| 99 | #endif |
| 100 | |
| 101 | /** @file gui/PainterSDL/PainterSDL.hpp */ |