TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_reorderable_subsystem.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <functional>
5#include <vector>
6
7#include <gui_core/gui_id.h>
11
12namespace tachyon
13{
16
18 enum class ReorderDirection : uint8_t { Horizontal, Vertical };
19
45
70
80
81 class FramePipeline;
82 struct FrameContext;
83
87 {
88 public:
90
91 ReorderableDragState& Drag() { return m_drag; }
92 ReorderableConstructionState& Construction() { return m_construction; }
93 ReorderableFocusFollow& FocusFollow() { return m_focusFollow; }
94
96 bool IsBalanced() const { return m_construction.groupID == tachyon::ID::Invalid(); }
97
98 private:
99 void OnPreConstruct(FrameContext& ctx);
100 void OnEndFrame();
101
102 ReorderableDragState m_drag{};
103 ReorderableConstructionState m_construction{};
104 ReorderableFocusFollow m_focusFollow{};
105 };
107}
Stage callbacks run in registration order (no priorities): if A must run before B,...
Definition gui_frame_pipeline.h:74
ReorderableDragState & Drag()
the drag in progress
Definition gui_reorderable_subsystem.h:91
ReorderableSubsystem(FramePipeline &frame)
bool IsBalanced() const
True iff every BeginReorderableGroup was matched by EndReorderableGroup.
Definition gui_reorderable_subsystem.h:96
ReorderableFocusFollow & FocusFollow()
after a keyboard move
Definition gui_reorderable_subsystem.h:93
ReorderableConstructionState & Construction()
the group being built
Definition gui_reorderable_subsystem.h:92
ReorderDirection
Main axis of a reorderable group.
Definition gui_reorderable_subsystem.h:18
@ Vertical
Definition gui_reorderable_subsystem.h:18
@ Horizontal
Definition gui_reorderable_subsystem.h:18
Definition gui_logging.h:24
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:127
static constexpr ElementRef Invalid()
Definition gui_element.h:135
Per-frame values plus references to long-lived managers, passed to every stage callback.
Definition gui_frame_pipeline.h:32
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
Definition gui_base_types.h:407
One press on an element that may become a drag.
Definition gui_pointer_drag.h:41
ID id
the element pressed; Invalid when there is no press
Definition gui_pointer_drag.h:42
int2 pressLocal
pointer at the press, in the space of the element's rect
Definition gui_pointer_drag.h:45
bool dragging
moved the drag distance (or a drag from the press on)
Definition gui_pointer_drag.h:46
Construction state of the current reorderable group.
Definition gui_reorderable_subsystem.h:49
tachyon::ID groupID
Definition gui_reorderable_subsystem.h:50
ReorderDirection direction
Definition gui_reorderable_subsystem.h:51
std::function< void(int, int)> onReorder
from index, to index
Definition gui_reorderable_subsystem.h:54
std::vector< tachyon::ElementRef > itemRefs
Definition gui_reorderable_subsystem.h:64
tachyon::ID dropAreaID
Counts as the group while an item is dragged (a tab bar's TabBarOptions::dropArea); Invalid: the grou...
Definition gui_reorderable_subsystem.h:63
bool isWrapped
Definition gui_reorderable_subsystem.h:52
tachyon::ElementRef groupRef
Definition gui_reorderable_subsystem.h:60
std::function< void(int, tachyon::int2)> dragVisualizer
Draws a ghost for the dragged item (index, cursor) while it is outside the group.
Definition gui_reorderable_subsystem.h:58
bool reorderApplied
the dragged item was moved in storage this frame
Definition gui_reorderable_subsystem.h:53
int nextItemIndex
Definition gui_reorderable_subsystem.h:59
std::function< void(int, tachyon::int2)> onDragOut
Item index and screen cursor when an item is released outside the group.
Definition gui_reorderable_subsystem.h:56
int keyboardFrom
Alt + an arrow along the group with the focus in item keyboardFrom: moved by keyboardStep in EndReord...
Definition gui_reorderable_subsystem.h:67
int keyboardStep
Definition gui_reorderable_subsystem.h:68
Persistent drag state; one drag at a time application-wide.
Definition gui_reorderable_subsystem.h:22
bool isWrapped
the group wraps its items onto several lines
Definition gui_reorderable_subsystem.h:26
int insertionIndex
slot it would drop into
Definition gui_reorderable_subsystem.h:29
tachyon::ID groupID
Definition gui_reorderable_subsystem.h:27
std::vector< tachyon::IntRect > originalRects
item rects at drag start, layout space
Definition gui_reorderable_subsystem.h:31
ReorderDirection direction
Definition gui_reorderable_subsystem.h:35
tachyon::int2 cursorLocal
latest pointer, layout space (like originalRects, groupRect)
Definition gui_reorderable_subsystem.h:24
tachyon::int2 cursorScreen
latest pointer, screen pixels
Definition gui_reorderable_subsystem.h:25
PointerDrag press
the item's press; a drag once it moves the drag distance
Definition gui_reorderable_subsystem.h:23
std::vector< tachyon::ID > originalIDs
Child IDs at drag start, in slot order, so MouseUp can resolve slots by ID (storage is already visual...
Definition gui_reorderable_subsystem.h:34
tachyon::IntRect groupRect
group bounds at drag start, layout space
Definition gui_reorderable_subsystem.h:36
int draggedIndex
slot the item was dragged from
Definition gui_reorderable_subsystem.h:28
bool IsPressed() const
An item is pressed (maybe not yet dragged).
Definition gui_reorderable_subsystem.h:39
int itemCount
the group's items, the slots (other children aren't)
Definition gui_reorderable_subsystem.h:30
tachyon::int2 Offset() const
The pointer's travel since the press, layout space.
Definition gui_reorderable_subsystem.h:43
bool IsDragging() const
An item is pressed and has moved the drag distance.
Definition gui_reorderable_subsystem.h:41
After a keyboard move: where the focus was in the moved item, to put it back there next frame,...
Definition gui_reorderable_subsystem.h:74
int toSlot
Definition gui_reorderable_subsystem.h:76
tachyon::ID groupID
Definition gui_reorderable_subsystem.h:75
tachyon::ID focusID
Definition gui_reorderable_subsystem.h:77
std::vector< uint32_t > path
child positions from the item down to the focused element
Definition gui_reorderable_subsystem.h:78
Integer 2D vector.
Definition gui_base_types.h:19