mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-19 22:49:06 -04:00
[EGD-7612] Add alarm popup
Added alarm popup window. Added ImageBoxWithText widget.
This commit is contained in:
committed by
Wojciech Rzepecki
parent
b82c29fa39
commit
4c19fa16b3
52
module-gui/gui/widgets/ImageBoxWithText.cpp
Normal file
52
module-gui/gui/widgets/ImageBoxWithText.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "ImageBoxWithText.hpp"
|
||||
|
||||
using namespace gui;
|
||||
|
||||
ImageBoxWithText::ImageBoxWithText(Item *parent,
|
||||
const Position &x,
|
||||
const Position &y,
|
||||
const Length &w,
|
||||
const Length &h,
|
||||
Image *image,
|
||||
const UTF8 &description)
|
||||
: ImageBox(parent, x, y, w, h, image)
|
||||
{
|
||||
setText(description);
|
||||
setMinimumSize(imageBoxWithText::wh, imageBoxWithText::wh);
|
||||
image->setEdges(RectangleEdge::All);
|
||||
|
||||
focusChangedCallback = [&](Item &item) {
|
||||
if (focus) {
|
||||
setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
|
||||
}
|
||||
else {
|
||||
setEdges(RectangleEdge::None);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
ImageBoxWithText::ImageBoxWithText(Item *parent, Image *image, const UTF8 &description)
|
||||
: ImageBoxWithText(parent, 0, 0, 0, 0, image, description)
|
||||
{}
|
||||
|
||||
void ImageBoxWithText::setText(const UTF8 &description)
|
||||
{
|
||||
text = new TextFixedSize(this);
|
||||
text->drawUnderline(false);
|
||||
text->setMargins(Margins(0, imageBoxWithText::text_margin, 0, imageBoxWithText::text_margin));
|
||||
text->setFont(imageBoxWithText::font);
|
||||
text->setText(description);
|
||||
text->setMinimumWidthToFitText(description);
|
||||
text->setMinimumHeightToFitText();
|
||||
}
|
||||
|
||||
void ImageBoxWithText::setMinimumSizeToFitImage()
|
||||
{
|
||||
auto minW = std::max(image->getWidth(), text->widgetMinimumArea.w);
|
||||
auto minH = image->getHeight() + imageBoxWithText::text_margin + text->widgetMinimumArea.h;
|
||||
setMinimumSize(minW, minH);
|
||||
}
|
||||
Reference in New Issue
Block a user