blob: aa3331a6b28b11a3e2ddeac19164f7f54604c146 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#pragma once
#include "UiEventArgs.h"
#include <cru/base/Event.h>
namespace cru::ui::events {
// TEventArgs must not be a reference type. This class help add reference.
// EventArgs must be reference because the IsHandled property must be settable.
template <typename TEventArgs>
class CRU_UI_API RoutedEvent {
public:
static_assert(std::is_base_of_v<UiEventArgs, TEventArgs>,
"TEventArgs must be subclass of UiEventArgs.");
static_assert(!std::is_reference_v<TEventArgs>,
"TEventArgs must not be reference.");
using EventArgs = TEventArgs&;
IEvent<TEventArgs&>* Direct() { return &direct_; }
IEvent<TEventArgs&>* Bubble() { return &bubble_; }
IEvent<TEventArgs&>* Tunnel() { return &tunnel_; }
private:
Event<TEventArgs&> direct_;
Event<TEventArgs&> bubble_;
Event<TEventArgs&> tunnel_;
};
} // namespace cru::ui::event
|