~aleteoryx/muditaos

ref: 4b75b67442cbc7293fb780178aa2c3d50db9dd0e muditaos/module-gui/gui/widgets/status-bar/Time.hpp -rw-r--r-- 1.1 KiB
4b75b674 — Marcin Smoczyński changelog: add changelog for v0.70.1 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::status_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::status_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::status_bar