~aleteoryx/muditaos

ref: 2276ceed679b93a3a891e4f5739ade9e13991c5a muditaos/module-apps/application-settings-new/widgets/Toggle.hpp -rw-r--r-- 872 bytes
2276ceed — Radoslaw Wicik [EGD-3743] Update copyrights in fies 5 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-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <BoxLayout.hpp>
#include <i18/i18.hpp>
#include <utf8/UTF8.hpp>
#include <Label.hpp>

namespace style::toggle
{
    const gui::Position toggle_x = 408;
    const gui::Position toggle_y = 24;
} // namespace style::toggle

namespace gui
{
    class Toggle : public HBox
    {
      public:
        Toggle(Item *parent, int x, int y, int w, int h, UTF8 text, bool defaultState);
        ~Toggle() override = default;

        void doToggle();
        bool getState() const noexcept;

      private:
        void buildToggle();

        UTF8 text;

        Label *label     = nullptr;
        Label *indicator = nullptr;

        bool state;
        static constexpr uint toggle_width = 40;
    };
} // namespace gui