ttx 0.1.0
Loading...
Searching...
No Matches
focus_event.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/reflect/field.h"
4#include "di/reflect/prelude.h"
5
6namespace ttx {
7class FocusEvent {
8public:
9 constexpr static auto focus_in() -> FocusEvent { return FocusEvent { true }; }
10 constexpr static auto focus_out() -> FocusEvent { return FocusEvent { false }; }
11
12 constexpr explicit FocusEvent(bool gained_focus) : m_gained_focus(gained_focus) {}
13
14 constexpr auto is_focus_in() const { return m_gained_focus; }
15 constexpr auto is_focus_out() const { return !m_gained_focus; }
16
17 auto operator==(FocusEvent const&) const -> bool = default;
18
19private:
20 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<FocusEvent>) {
21 return di::make_fields<"FocusEvent">(di::field<"gained_focus", &FocusEvent::m_gained_focus>);
22 }
23
24 bool m_gained_focus { false };
25};
26}
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< FocusEvent >)
Definition focus_event.h:20
auto operator==(FocusEvent const &) const -> bool=default
static constexpr auto focus_out() -> FocusEvent
Definition focus_event.h:10
static constexpr auto focus_in() -> FocusEvent
Definition focus_event.h:9
constexpr auto is_focus_out() const
Definition focus_event.h:15
constexpr auto is_focus_in() const
Definition focus_event.h:14
constexpr FocusEvent(bool gained_focus)
Definition focus_event.h:12
Definition cursor_style.h:5