~aleteoryx/muditaos

ref: 2a53becd2524fc0dba7260632d3ec409eb3a61fd muditaos/module-gui/gui/widgets/RawText.hpp -rw-r--r-- 903 bytes
2a53becd — Maciej Janicki [BH-1136] Fix bootloop after low power 4 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
// 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 <Item.hpp>
#include <RawFont.hpp>
#include <Color.hpp>
#include <utf8/UTF8.hpp>

namespace gui
{
    class RawText : public Item
    {
      private:
        Color color   = {0, 0};
        RawFont *font = nullptr;
        UTF8 text     = "";

        UTF8 stripNewlineToDraw();

      public:
        RawText(UTF8 text, RawFont *font, Color color);

        const UTF8 &getText() const noexcept
        {
            return text;
        }

        unsigned int getTextLength() const noexcept
        {
            return text.length();
        }

        RawFont *getFont() const noexcept
        {
            return font;
        }

        void buildDrawListImplementation(std::list<Command> &commands) override;
    };
} // namespace gui