~aleteoryx/muditaos

ref: ac2c954d93e63b0218a2234d565133bba878a966 muditaos/module-gui/gui/GuiCommon.cpp -rw-r--r-- 1.2 KiB
ac2c954d — Bartosz Cichocki [EGD-3772] added HSP sink and source (#918) 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
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

/*
 * Common.cpp
 *
 *  Created on: 8 maj 2019
 *      Author: robert
 */
#include <cstdint>
#include <type_traits>
#include "Common.hpp"

namespace gui
{

    static timeSecondsFunctionPtr timeSecondsFunction = nullptr;

    bool operator&(const gui::RectangleEdge &lhs, const gui::RectangleEdge &rhs)
    {
        using T = std::underlying_type_t<RectangleEdge>;
        return static_cast<bool>(static_cast<T>(lhs) & static_cast<T>(rhs));
    }

    RectangleEdge operator|(const RectangleEdge &lhs, const RectangleEdge &rhs)
    {
        using T = std::underlying_type_t<RectangleEdge>;
        return static_cast<RectangleEdge>(static_cast<T>(lhs) | static_cast<T>(rhs));
    }

    RectangleEdge operator|=(RectangleEdge &lhs, const RectangleEdge &rhs)
    {
        lhs = lhs | rhs;
        return lhs;
    }

    uint32_t getTime()
    {
        if (timeSecondsFunction != nullptr)
            return timeSecondsFunction();
        return 0;
    }

    void setTimeFunction(timeSecondsFunctionPtr fptr)
    {
        timeSecondsFunction = fptr;
    }

} // namespace gui