~aleteoryx/muditaos

ref: 48d31b876cf6fed438676e4fa73b6e16b1f6b3a7 muditaos/module-apps/popups/VolumeWindow.hpp -rw-r--r-- 1.7 KiB
48d31b87 — tomaszkrosnowski [EGD-6311] Audio settings windows 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "Application.hpp"
#include "widgets/BarGraph.hpp"
#include "WindowWithTimer.hpp"
#include <functional>

namespace style::window::volume
{
    constexpr inline auto title_height = 33;
    constexpr inline auto base_title_key  = "app_popup_volume_text";
    constexpr inline auto music_title_key = "app_popup_music_volume_text";
    constexpr inline auto call_title_key  = "app_popup_call_volume_text";
    constexpr inline auto mute_title_key  = "app_popup_muted_text";

    namespace bar
    {
        constexpr inline auto volume_levels = 10;
        constexpr inline auto top_offset    = 179;
    } // namespace bar

} // namespace style::window::volume
namespace gui
{
    class VolumeWindow : public WindowWithTimer
    {
        using AudioContext = std::pair<audio::Profile::Type, audio::PlaybackType>;

      private:
        audio::Volume volume = 0;
        AudioContext audioContext;

        void showProperText(const AudioContext &audioContext, const audio::Volume volume) noexcept;
        void showMultimediaPlayback() noexcept;
        void showCalling() noexcept;
        void showMuted() noexcept;

      protected:
        Label *volumeText    = nullptr;
        VBarGraph *volumeBar = nullptr;

      public:
        VolumeWindow(app::Application *app, const std::string &name);

        void addVolumeText();
        void addVolumeBar();
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        bool onInput(const gui::InputEvent &inputEvent) override;
    };
} // namespace gui