HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
tab_delegate.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include <memory>
8#include <functional>
9
10namespace hi::inline v1 {
11class tab_widget;
12
14public:
15 virtual ~tab_delegate() = default;
16 virtual void init(tab_widget &sender) noexcept {}
17 virtual void deinit(tab_widget &sender) noexcept {}
18
21 auto subscribe(tab_widget& sender, callback_flags flags, std::invocable<> auto&& callback) noexcept
22 {
23 return _notifier.subscribe(flags, hi_forward(callback));
24 }
25
28 auto subscribe(tab_widget& sender, std::invocable<> auto&& callback) noexcept
29 {
30 return subscribe(sender, callback_flags::synchronous, hi_forward(callback));
31 }
32
33 virtual void add_tab(tab_widget& sender, std::size_t key, std::size_t index) noexcept {}
34
35 virtual ssize_t index(tab_widget &sender) noexcept
36 {
37 return -1;
38 }
39
40protected:
41 notifier<> _notifier;
42};
43
44} // namespace hi::inline v1
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition required.hpp:29
Definition tab_delegate.hpp:13
auto subscribe(tab_widget &sender, std::invocable<> auto &&callback) noexcept
Subscribe a callback for notifying the widget of a data change.
Definition tab_delegate.hpp:28
auto subscribe(tab_widget &sender, callback_flags flags, std::invocable<> auto &&callback) noexcept
Subscribe a callback for notifying the widget of a data change.
Definition tab_delegate.hpp:21
A graphical element that shows only one of a predefined set of mutually exclusive child widgets.
Definition tab_widget.hpp:32