HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
ttauri
widgets
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
10
namespace
tt {
11
class
tab_widget;
12
13
class
tab_delegate
{
14
public
:
15
using
callback_type
=
std::function
<void()>;
16
using
callback_ptr_type
=
std::shared_ptr<callback_type>
;
17
18
virtual
~tab_delegate
() =
default
;
19
virtual
void
init(
tab_widget
&sender)
noexcept
{}
20
virtual
void
deinit(
tab_widget
&sender)
noexcept
{}
21
22
virtual
callback_ptr_type
subscribe(
tab_widget
&sender,
callback_ptr_type
const
&callback_ptr)
noexcept
23
{
24
return
callback_ptr;
25
}
26
27
virtual
void
unsubscribe(
tab_widget
&sender,
callback_ptr_type
const
&callback_ptr)
noexcept
28
{
29
}
30
33
template
<
typename
Callback>
34
requires
(std::is_invocable_v<Callback>) [[nodiscard]]
callback_ptr_type
35
subscribe
(
tab_widget
&sender, Callback &&callback)
noexcept
36
{
37
return
subscribe(sender, std::make_shared<callback_type>(std::forward<Callback>(callback)));
38
}
39
40
virtual
void
add_tab(
tab_widget
&sender,
size_t
key,
size_t
index)
noexcept
41
{
42
}
43
44
virtual
ssize_t index(tab_widget &sender)
noexcept
45
{
46
return
-1;
47
}
48
};
49
50
}
// namespace tt
tt::tab_delegate
Definition
tab_delegate.hpp:13
tt::tab_delegate::subscribe
callback_ptr_type subscribe(tab_widget &sender, Callback &&callback) noexcept
Subscribe a callback for notifying the widget of a data change.
Definition
tab_delegate.hpp:35
tt::tab_widget
A graphical element that shows only one of a predefined set of mutually exclusive child widgets.
Definition
tab_widget.hpp:32
std::function< void()>
std::shared_ptr< callback_type >
Generated on Mon Apr 22 2024 12:53:32 for HikoGUI by
1.10.0