~aleteoryx/muditaos

ref: 42ca53a732487f7dabf5e06ee4c03f73c329882b muditaos/module-apps/application-settings/widgets/apps/SettingsSoundItem.cpp -rw-r--r-- 1.6 KiB
42ca53a7 — Maciej-Mudita [MOS-686] Fix the accessibility of user files by MTP 3 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SettingsSoundItem.hpp"

#include <TextFixedSize.hpp>

namespace gui
{

    SettingsSoundItem::SettingsSoundItem(const std::string &soundName, bool selected)
    {
        setMinimumSize(style::window::default_body_width, style::window::label::big_h);
        setMargins(Margins(0, style::margins::big, 0, 0));

        mMainBox = new HBox(this, 0, 0, 0, 0);
        mMainBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        mMainBox->setEdges(RectangleEdge::None);

        TextFixedSize *soundTitle = new TextFixedSize(mMainBox, 0, 0, 0, 0);
        soundTitle->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
        soundTitle->setMaximumSize(style::window::default_body_width, style::window::label::big_h);
        soundTitle->setMargins(Margins(10, 0, 0, 0));
        soundTitle->setEdges(RectangleEdge::All);
        soundTitle->drawUnderline(false);
        soundTitle->setFont(style::window::font::big);
        soundTitle->setText(soundName); // setRichText??

        if (selected) {
            mIsSelected = new gui::Image(mMainBox, 0, 0, 0, 0, "small_tick_32px_W_M");
            mIsSelected->setMargins(Margins(style::margins::big, 0, 0, 0));
        }

        dimensionChangedCallback = [&]([[maybe_unused]] gui::Item &item, const BoundingBox &newDim) -> bool {
            mMainBox->setArea({0, 0, newDim.w, newDim.h});
            return true;
        };
    }
} // namespace gui