~aleteoryx/muditaos

ref: 1f157e411df916e18c974c2176e3ff7c5e54e7a0 muditaos/module-gui/gui/widgets/Arc.hpp -rw-r--r-- 2.1 KiB
1f157e41 — Bartosz [MOS-59] Fix weird behaviour of indicators on popups 2 years 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <list>
#include <cstdint>

#include <Math.hpp>

#include "Common.hpp"
#include "Item.hpp"
#include "Style.hpp"

namespace gui
{
    class Arc : public Item
    {
      public:
        class ShapeParams
        {
          public:
            ShapeParams &setCenterPoint(Point _center) noexcept;
            ShapeParams &setRadius(Length _radius) noexcept;
            ShapeParams &setStartAngle(trigonometry::Degrees _angle) noexcept;
            ShapeParams &setSweepAngle(trigonometry::Degrees _angle) noexcept;
            ShapeParams &setBorderColor(Color _color) noexcept;
            ShapeParams &setPenWidth(std::uint8_t _width) noexcept;
            ShapeParams &setFocusPenWidth(std::uint8_t _width) noexcept;

          private:
            Point center;
            Length radius{0U};
            trigonometry::Degrees start{0U};
            trigonometry::Degrees sweep{0U};
            Color borderColor;
            std::uint8_t penWidth{1U};
            std::uint8_t focusPenWidth{style::window::default_border_focus_w};

            friend class Arc;
        };

        Arc(Item *parent, const ShapeParams &params);

        void setCenter(Point point) noexcept;
        void setStartAngle(trigonometry::Degrees angle) noexcept;
        void setSweepAngle(trigonometry::Degrees angle) noexcept;
        trigonometry::Degrees getSweepAngle() const noexcept;
        trigonometry::Degrees getStartAngle() const noexcept;

        void buildDrawListImplementation(std::list<Command> &commands) override;

      protected:
        Arc(Item *parent,
            Point _center,
            Length _radius,
            trigonometry::Degrees _start,
            trigonometry::Degrees _sweep,
            Color _color,
            std::uint8_t _penWidth,
            std::uint8_t _focusPenWidth);

        Point center;
        Length radius;
        trigonometry::Degrees start;
        trigonometry::Degrees sweep;
        Color color;
        std::uint8_t penWidth;
        std::uint8_t focusPenWidth;
    };
} // namespace gui