~aleteoryx/muditaos

ref: 3c69244f4db9f310c328687052326659aad29146 muditaos/module-gui/gui/widgets/TopBar/Time.hpp -rw-r--r-- 1.1 KiB
3c69244f — Przemyslaw Brudny [EGD-6773] Added light BarGraph type and updated UpdateProgress 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
// 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 "StatusBarWidgetBase.hpp"
#include <time/time_conversion.hpp>
#include <Label.hpp>

namespace gui::top_bar
{

    /// Sets time mode (12h/24h) for Time widget
    class TimeConfiguration : public StatusBarVisitor
    {
      public:
        enum class TimeMode
        {
            Time12h, /// 12h time format
            Time24h  /// 24h time format
        };

        explicit TimeConfiguration(TimeMode mode);

        [[nodiscard]] TimeMode getMode() const noexcept;
        void visit(gui::top_bar::Time &widget) const override;

      private:
        TimeMode mode;
    };

    class Time : public StatusBarWidgetBase<Label>
    {
        utils::time::Timestamp _time;
        void setFormat(const std::string &format);
        friend class TimeConfiguration;

      public:
        Time(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
        void update();
        void acceptStatusBarVisitor(StatusBarVisitor &visitor) override;
    };
} // namespace gui::top_bar