TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_input_handler_func.h
Go to the documentation of this file.
1#pragma once
2
3#include <gui_core/gui_id.h>
4#include <gui_core/gui_base_types.h> // int2
6#include <functional>
7
8namespace tachyon
9{
12
13 struct ElementRect; // gui_core/elements/gui_element.h
14 struct ElementRef; // gui_core/elements/gui_element.h
15 class ElementStorage; // gui_core/elements/gui_element_storage.h
16 struct InputState; // gui_core/input/gui_input_state.h
17
32
35 using EventHandler = std::function<bool(ElementEvent&& input)>;
36
39 {
40 return [f = std::move(first), s = std::move(second)](ElementEvent&& event) -> bool
41 {
42 if (f && f(ElementEvent{ event })) return true;
43 if (s && s(std::move(event))) return true;
44 return false;
45 };
46 }
47
48}
The frame's element tree.
Definition gui_element_storage.h:100
EventType
The kind of input event the GUI dispatches to element handlers.
Definition gui_input_enums.h:75
std::function< bool(ElementEvent &&input)> EventHandler
Element-level input handler used by the immediate-mode dispatcher; returns true when it consumed the ...
Definition gui_input_handler_func.h:35
EventHandler Chain(EventHandler first, EventHandler second)
A handler that tries first, then second when first returns false.
Definition gui_input_handler_func.h:38
Definition gui_logging.h:24
An input event delivered to an element's EventHandler.
Definition gui_input_handler_func.h:20
EventType type
Definition gui_input_handler_func.h:22
const InputState & state
the input snapshot of this event
Definition gui_input_handler_func.h:23
const ElementRef & elementRef
Definition gui_input_handler_func.h:25
const ElementRect * rect
the element's layout rects
Definition gui_input_handler_func.h:24
int2 LocalCursor(const ElementStorage &storage) const
Cursor in the space rect->rect is stored in (inverse of ancestor contentTransforms).
tachyon::ID id
the targeted element
Definition gui_input_handler_func.h:21
Definition gui_element.h:57
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:127
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Snapshot of input state for a single recorded OS event.
Definition gui_input_state.h:17
Integer 2D vector.
Definition gui_base_types.h:19