TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_default_handlers.h File Reference
#include <gui_core/input/gui_input_state.h>
#include <gui_core/input/gui_input_handler_func.h>
#include <gui_core/input/gui_pointer_drag.h>
#include <gui_core/state/gui_state_manager.h>
#include <gui_core/style/gui_style_ref.h>
#include <gui_core/style/gui_style_text.h>
#include <gui_core/text/gui_numeric_field_config.h>
#include <gui_controls/gui_type_dimensions.h>
#include <gui_controls/gui_widget_state_types.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <memory>
#include <stdint.h>
#include <type_traits>

Go to the source code of this file.

Classes

struct  tachyon::SizerState
 Per-element state of the sizer handlers (element data store); internal. More...
struct  tachyon::SliderState
 Per-element state of MakeSliderHandler and the integer slider (element data store); internal. More...
struct  tachyon::DragLabelState
 Per-element state of a draggable label (element data store); internal. More...
struct  tachyon::LabelGroupVisualState
 Shared by all labels in a group, so the edge highlight is synchronized. More...
struct  tachyon::ScrollbarDragState
 Per-element state of MakeScrollbarHandler (element data store); internal. More...

Namespaces

namespace  tachyon

Enumerations

enum class  tachyon::SliderPress : uint8_t { tachyon::SliderPress::Edit , tachyon::SliderPress::Jump }
 What pressing a slider does: Edit - a click (no drag) opens its value for typing; Jump - the value moves to the cursor at once and follows it while held. More...

Functions

bool tachyon::IsActivationKey (const ElementEvent &event)
 True for a KeyDown of Return, keypad Enter or Space.
bool tachyon::TextEditorUsesKey (const InputState &state, bool readOnly)
 Whether a focused text editor acts on this key (KeyDown/KeyUp), so its handler takes it; the rest reach the app's shortcuts.
EventHandler tachyon::MakeTextBoxHandler (GUIStateManager &guiStateManager)
 Text box handler: a left click focuses it for editing; while focused it takes text input and the keys its editor uses.
EventHandler tachyon::MakeHorizontalSizerHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage, int &sizeValue, int minSize, int maxSize, std::function< void(int)> onChanged=nullptr, std::function< int()> onAutoSize=nullptr, bool invertMouseDelta=false, float pixelsPerUnit=1.0f)
 Sizer handler that drags sizeValue within [minSize, maxSize], calling onChanged with each new size.
EventHandler tachyon::MakeVerticalSizerHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage, int &sizeValue, int minSize, int maxSize, std::function< void(int)> onChanged=nullptr, std::function< int()> onAutoSize=nullptr, bool invertMouseDelta=false, float pixelsPerUnit=1.0f)
 Y-axis counterpart of MakeHorizontalSizerHandler; invertMouseDelta grows the size when dragging up.
EventHandler tachyon::MakeSliderHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage, float *value, int elementWidth, std::function< void()> onChanged=nullptr, float minVal=0.0f, float maxVal=1.0f, SliderPress press=SliderPress::Edit)
 Slider handler for *value in [minVal, maxVal]; elementWidth (pixels, <= 0 is treated as 1) maps drag distance onto that range.
EventHandler tachyon::MakeDraggableLabelHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage)
 Turns mouse drags on a label into LabelDrag* events sent to the next sibling element.
EventHandler tachyon::MakeLabelHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage)
 Label handler: a left click focuses the control bound to the label (else the label).
EventHandler tachyon::MakeGroupLabelHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage, LabelGroupVisualState groupVisual)
 Label group variants: the right edge resizes the shared label width.
EventHandler tachyon::MakeGroupDraggableLabelHandler (GUIStateManager &guiStateManager, const ElementStorage &elementStorage, LabelGroupVisualState groupVisual)
EventHandler tachyon::MakeButtonHandler (GUIStateManager &guiStateManager, std::function< void()> onClick)
 Button handler: a left click, or an activation key while focused, calls onClick.
EventHandler tachyon::MakeMouseWheelScrollHandler (ScrollManagement &scrollManagement, float wheelStep)
 Wheel handler that scrolls the element's own scroll offset by wheelStep pixels per notch (StyleManager::Px(kWheelScrollStep)).
EventHandler tachyon::MakeScrollbarHandler (GUIStateManager &guiStateManager, ElementStorage &elementStorage, ID containerID, bool vertical, int32_t trackLength=0)
 Scrollbar track/thumb handler; writes the scroll offset of containerID (the scrollable parent).
EventHandler tachyon::MakeDragSourceHandler (GUIStateManager &guiStateManager, uint32_t payloadType, std::function< uintptr_t()> getPayloadValue=nullptr, std::function< std::any()> getPayload=nullptr, DragVisualizer sourceVisualizer={})
 Drag source handler: a left press starts a drag of payloadType, with the value from getPayloadValue (else 0) and the payload from getPayload (else that value).
EventHandler tachyon::MakeDropTargetHandler (uint32_t acceptedPayloadType, std::function< void(uintptr_t payloadValue, ID sourceID)> onDrop, std::function< bool(uintptr_t payloadValue)> canDrop=nullptr)
 Drop target handler for acceptedPayloadType; onDrop gets the payload value and the source ID.
double tachyon::LabelDragSpeedScale (const InputState &state)
 Label-drag speed multiplier: 0.1 with Ctrl, 10 with Shift (which wins), else 1.
template<typename T>
EventHandler tachyon::ReportingChanges (GUIStateManager &guiStateManager, T *value, EventHandler inner)
 Wraps a handler that writes *value: it runs during input, after the control's call returned, so a change marks the element clicked and the next call reports it (Interaction().HasBeenClicked(id)).
template<typename T>
EventHandler tachyon::MakeNumericalBoxHandler (GUIStateManager &guiStateManager, T &value, NumericFieldConfig< T > config={})
 Numeric field handler: a left click focuses it for typing, and LabelDrag* events from its label drag value (a cancelled drag restores the start value).
template<typename T>
EventHandler tachyon::MakeMultiDimDragHandler (GUIStateManager &guiStateManager, T &value, NumericFieldConfig< typename TypeDimensions< T >::ComponentType > config={})
 Applies LabelDrag* events to all components (multi-dimensional Field groups).

Variables

constexpr int32_t tachyon::kScrollbarMinThumbLength = 20
 Minimum thumb length in CSS pixels (scale with StyleManager::Px), so the thumb stays clickable over huge content.