~aleteoryx/muditaos

ref: a405cad694b867fcd2498984830bd97d4b9bde2f muditaos/module-apps/apps-common/widgets/BellSideListItem.cpp -rw-r--r-- 1.8 KiB
a405cad6Aleteoryx trim readme 8 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
45
46
47
48
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include "TextFixedSize.hpp"
#include "BellSideListItem.hpp"
#include "Style.hpp"

namespace gui
{
    BellSideListItem::BellSideListItem(BellBaseLayout::LayoutType type)
    {
        setMinimumSize(style::sidelistview::list_item::w, style::sidelistview::list_item::h);
        setEdges(RectangleEdge::None);
        body = new BellBaseLayout(this, 0, 0, 0, 0, type);
    }

    void BellSideListItem::setBottomDescriptionText(const std::string &description)
    {
        if (bottomText != nullptr) {
            bottomText->setText(description);
        }
    }

    void BellSideListItem::setupTopTextBox(const std::string &description)
    {
        auto topText = new TextFixedSize(body->firstBox);
        setupTextBox(topText, style::bell_sidelist_item::title_font, description);
    }

    void BellSideListItem::setupBottomTextBox(const std::string &description)
    {
        bottomText = new TextFixedSize(body->lastBox);
        setupTextBox(bottomText, style::bell_sidelist_item::description_font, description);
    }

    void BellSideListItem::setupTextBox(TextFixedSize *textBox,
                                        const std::string &fontName,
                                        const std::string &description)
    {
        textBox->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::outer_layouts_h);
        textBox->setFont(fontName);
        textBox->setEdges(gui::RectangleEdge::None);
        textBox->activeItem = false;
        textBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        textBox->setRichText(description);
        textBox->drawUnderline(false);
    }
} /* namespace gui */