~aleteoryx/muditaos

ref: cd0cc6dc1a24355eb8637e8b3af1c07dde272c3e muditaos/module-gui/gui/widgets/ImageBox.cpp -rw-r--r-- 766 bytes
cd0cc6dc — Mateusz Piesta [BH-890] Home screen alarm popups 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ImageBox.hpp"

using namespace gui;

ImageBox::ImageBox(
    Item *parent, const uint32_t &x, const uint32_t &y, const uint32_t &w, const uint32_t &h, Image *image)
    : HBox(parent, x, y, w, h), image(image)
{
    setEdges(RectangleEdge::None);
    setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
    addWidget(image);
}

void ImageBox::showImage(bool show)
{
    image->setVisible(show);
}

void ImageBox::setImage(const UTF8 &name)
{
    image->set(name);
}

void ImageBox::setMinimumSizeToFitImage()
{
    setMinimumSize(image->getWidth(), image->getHeight());
}