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, std::invocable<> auto &&callback) noexcept
22 {
23 return _notifier.subscribe(hi_forward(callback));
24 }
25
26 virtual void add_tab(tab_widget &sender, std::size_t key, std::size_t index) noexcept {}
27
28 virtual ssize_t index(tab_widget &sender) noexcept
29 {
30 return -1;
31 }
32
33protected:
34 notifier<> _notifier;
35};
36
37} // 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:21
A graphical element that shows only one of a predefined set of mutually exclusive child widgets.
Definition tab_widget.hpp:32