~aleteoryx/muditaos

muditaos/module-gui/gui/core/renderers/RectangleRenderer.hpp -rw-r--r-- 5.1 KiB
a405cad6Aleteoryx trim readme 7 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include "Color.hpp"
#include "Common.hpp"

#include "DrawCommand.hpp"

namespace gui
{
    class Context;
} // namespace gui

namespace gui::renderer
{
    class RectangleRenderer
    {
      public:
        struct DrawableStyle
        {
            Length borderWidth{1};
            Length radius{0};
            Length yapSize{0};
            RectangleEdge edges{RectangleEdge::All};
            RectangleFlatEdge flatEdges{RectangleFlatEdge::None};
            RectangleRoundedCorner roundedCorners{RectangleRoundedCorner::None};
            RectangleYap yaps{RectangleYap::None};
            Color borderColor{ColorFullBlack};
            Color fillColor{ColorNoColor};

            static auto from(const DrawRectangle &command) -> DrawableStyle;
        };

        static void drawFlat(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style);

        static void draw(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style);

      private:
        static void fillFlatRectangle(Context *ctx, Point position, Length width, Length height, Color color);
        static void fill(Context *ctx, Point startPosition, Color borderColor, Color fillColor);

        static void drawSides(Context *ctx,
                              Point position,
                              Length width,
                              Length height,
                              Length penWidth,
                              Color color,
                              RectangleEdge sides);
        static void drawSides(Context *ctx,
                              Point position,
                              Length width,
                              Length height,
                              Length radius,
                              Length yapSize,
                              Length penWidth,
                              RectangleFlatEdge flats,
                              RectangleYap yaps,
                              Color borderColor,
                              RectangleEdge sides);

        static void drawCorners(Context *ctx,
                                Point position,
                                Length width,
                                Length height,
                                Length radius,
                                Length penWidth,
                                Color borderColor,
                                RectangleRoundedCorner rounded,
                                RectangleFlatEdge flats,
                                RectangleYap yaps);

        static void drawTopSide(Context *ctx, Point position, Length width, Length penWidth, Color color);
        static void drawTopSide(Context *ctx,
                                Point position,
                                Length width,
                                Length radius,
                                Length yapSize,
                                Length penWidth,
                                RectangleFlatEdge flat,
                                RectangleYap yaps,
                                Color borderColor);

        static void drawRightSide(
            Context *ctx, Point position, Length width, Length height, Length penWidth, Color color);
        static void drawRightSide(Context *ctx,
                                  Point position,
                                  Length width,
                                  Length height,
                                  Length radius,
                                  Length yapSize,
                                  Length penWidth,
                                  RectangleFlatEdge flat,
                                  RectangleYap yaps,
                                  Color borderColor);

        static void drawBottomSide(
            Context *ctx, Point position, Length width, Length height, Length penWidth, Color color);
        static void drawBottomSide(Context *ctx,
                                   Point position,
                                   Length width,
                                   Length height,
                                   Length radius,
                                   Length yapSize,
                                   Length penWidth,
                                   RectangleFlatEdge flat,
                                   RectangleYap yaps,
                                   Color borderColor);

        static void drawLeftSide(Context *ctx, Point position, Length height, Length penWidth, Color color);
        static void drawLeftSide(Context *ctx,
                                 Point position,
                                 Length height,
                                 Length radius,
                                 Length yapSize,
                                 Length penWidth,
                                 RectangleFlatEdge flat,
                                 RectangleYap yaps,
                                 Color borderColor);
    };
} // namespace gui::renderer