1.10
buttongroup.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_BUTTONGROUP_H
7#define EGT_BUTTONGROUP_H
8
14#include <egt/detail/meta.h>
15#include <functional>
16#include <memory>
17#include <vector>
18
19namespace egt
20{
21inline namespace v1
22{
23
24class Button;
25
38class EGT_API ButtonGroup
39{
40public:
41
46 explicit ButtonGroup(bool imperative = false, bool exclusive = true) noexcept;
47
48 ButtonGroup(const ButtonGroup&) = delete;
49 ButtonGroup& operator=(const ButtonGroup&) = delete;
51 ButtonGroup& operator=(ButtonGroup&&) = default;
52
60 void exclusive(bool exclusive);
61
65 EGT_NODISCARD bool exclusive() const;
66
74 void imperative(bool imperative);
75
79 EGT_NODISCARD bool imperative() const;
80
84 void add(const std::shared_ptr<Button>& button);
85
89 void remove(Button* button);
90
92 using CheckedCallback = std::function<void (Button& button)>;
93
102 void foreach_checked(const CheckedCallback& callback);
103
104 ~ButtonGroup() noexcept;
105
106protected:
107
109 void checked_state_change(Button& button, bool checked) const;
110
112 using ButtonArray = std::vector<std::weak_ptr<Button>>;
113
117 ButtonArray m_buttons;
118
122 bool m_exclusive{false};
123
127 bool m_imperative{true};
128
129 friend class Button;
130};
131
132}
133
134}
135
136#endif
Button group.
Definition buttongroup.h:39
ButtonGroup(bool imperative=false, bool exclusive=true) noexcept
std::function< void(Button &button)> CheckedCallback
Definition buttongroup.h:92
Basic button control.
Definition button.h:65
EGT framework namespace.
Definition animation.h:24