~aleteoryx/muditaos

muditaos/module-gui/gui/widgets/Image.hpp -rw-r--r-- 1.6 KiB
a405cad6Aleteoryx trim readme 6 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
// 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 <list>

#include "Rect.hpp"
#include "../core/DrawCommand.hpp"
#include "../core/PixMap.hpp"
#include "utf8/UTF8.hpp"

namespace gui
{
    /// image element on screen, it will automatically set it's size to fit space of selected image
    class Image : public Rect
    {
      public:
        Image();
        /// create new Image element and resize it to size needed by selected Image
        explicit Image(const UTF8 &imageName, ImageTypeSpecifier specifier = ImageTypeSpecifier::None);
        Image(Item *parent, const UTF8 &imageName, ImageTypeSpecifier specifier = ImageTypeSpecifier::None);
        /// Create new Image element on position x,y w&h will be *ignored*
        Image(Item *parent,
              std::uint32_t x,
              std::uint32_t y,
              std::uint32_t w,
              std::uint32_t h,
              const UTF8 &imageName = UTF8{""});
        Image(Item *parent, std::uint32_t x, std::uint32_t y, const UTF8 &imageName = UTF8{""})
            : Image(parent, x, y, 0U, 0U, imageName)
        {}

        bool set(std::uint32_t id);
        void set(const UTF8 &name, ImageTypeSpecifier specifier = ImageTypeSpecifier::None);

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

      protected:
        /// internal representation of the image
        ImageMap *imageMap = nullptr;
    };
} /* namespace gui */