~aleteoryx/muditaos

ref: 1340e6949c0762585b0de844863c91c859fb19b1 muditaos/module-apps/apps-common/widgets/TextSpinnerBoxWithLabel.cpp -rw-r--r-- 1.8 KiB
1340e694 — Bartosz Revert "[MOS-578] Fix incorrect logic with SMS notifications" 2 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
43
44
45
46
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "TextSpinnerBoxWithLabel.hpp"

namespace gui
{
    TextSpinnerBoxWithLabel::TextSpinnerBoxWithLabel(Item *parent,
                                                     const std::string &description,
                                                     const std::vector<UTF8> &data,
                                                     Boundaries boundaries)
        : VBox(parent)
    {
        setEdges(RectangleEdge::None);
        descriptionLabel = new gui::Label(this, 0, 0, 0, 0);
        descriptionLabel->setMinimumSize(style::window::default_body_width, style::text_spinner_label::label_h);
        descriptionLabel->setEdges(gui::RectangleEdge::None);
        descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
        descriptionLabel->setFont(style::window::font::small);
        descriptionLabel->activeItem = false;
        descriptionLabel->setText(description);

        optionSpinner = new gui::TextSpinnerBox(this, data, boundaries);
        optionSpinner->setMinimumSize(style::window::default_body_width, style::text_spinner_label::spinner_h);

        focusChangedCallback = [&](gui::Item &item) {
            setFocusItem(focus ? optionSpinner : nullptr);
            return true;
        };
    }

    void TextSpinnerBoxWithLabel::setData(const std::vector<UTF8> &data)
    {
        optionSpinner->setData(data);
    }

    UTF8 TextSpinnerBoxWithLabel::getCurrentValue() const noexcept
    {
        return optionSpinner->getCurrentValue();
    }

    void TextSpinnerBoxWithLabel::setCurrentValue(UTF8 val)
    {
        optionSpinner->setCurrentValue(val);
    }
} // namespace gui