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
void
init(
tab_widget
&sender)
noexcept
{}
19
virtual
void
deinit(
tab_widget
&sender)
noexcept
{}
20
21
virtual
callback_ptr_type
subscribe(
tab_widget
&sender,
callback_ptr_type
const
&callback_ptr)
noexcept
22
{
23
return
callback_ptr;
24
}
25
26
virtual
void
unsubscribe(
tab_widget
&sender,
callback_ptr_type
const
&callback_ptr)
noexcept
27
{
28
}
29
32
template
<
typename
Callback>
33
requires
(std::is_invocable_v<Callback>) [[nodiscard]]
callback_ptr_type
34
subscribe
(
tab_widget
&sender, Callback &&callback)
noexcept
35
{
36
return
subscribe(sender, std::make_shared<callback_type>(std::forward<Callback>(callback)));
37
}
38
39
virtual
void
add_tab(
tab_widget
&sender,
size_t
key,
size_t
index)
noexcept
40
{
41
}
42
43
virtual
ssize_t index(tab_widget &sender)
noexcept
44
{
45
return
-1;
46
}
47
};
48
49
}
// 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:34
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:39 for HikoGUI by
1.10.0