TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::PointerDrag Struct Reference

One press on an element that may become a drag. More...

#include <gui_core/input/gui_pointer_drag.h>

Public Types

enum class  Ended : uint8_t { No , Click , Drag }
 How a press ended. More...

Public Member Functions

bool IsHeld () const noexcept
 A press is held, on any element.
bool IsPressed (ID element) const noexcept
 A press of element is held.
bool IsDragging (ID element) const noexcept
 A press of element is held and has become a drag.
bool Press (const ElementEvent &e, const ElementStorage &storage, MouseButtons button=MouseButtons::Left, bool atOnce=false)
 Starts tracking e when it is button going down: true then.
bool Move (const ElementEvent &e, int32_t distance)
 For a move of the held press: true when it is a drag move, the one that goes past distance pixels (see IsDragTravel) included.
Ended Release (const ElementEvent &e)
 For the held button coming up on e.id: how the press ended. There is no press after.
bool Cancel (ID element) noexcept
 Drops the press of element (Escape, a lost capture): true when there was one.
void Reset () noexcept
 Drops any press.
int2 ScreenDelta (const InputState &s) const noexcept
 Pointer travel since the press, in screen pixels.
int2 LocalDelta (const ElementEvent &e, const ElementStorage &storage) const
 Pointer travel since the press, in the space of the element's rect (follows zoom).

Public Attributes

ID id = ID::Invalid()
 the element pressed; Invalid when there is no press
MouseButtons button = MouseButtons::None
 the button held
int2 pressScreen { 0, 0 }
 pointer at the press, screen pixels
int2 pressLocal { 0, 0 }
 pointer at the press, in the space of the element's rect
bool dragging = false
 moved the drag distance (or a drag from the press on)

Detailed Description

One press on an element that may become a drag.

A control keeps it in its own state and gives it that element's events: Press when a button goes down, Move on each move, Release when the button comes up and Cancel on Escape. What the drag changes, and the value to put back on a cancel, stay with the control.

The element that returns true for the press gets the mouse capture, so the moves and the release come to it wherever the pointer goes.

Member Enumeration Documentation

◆ Ended

enum class tachyon::PointerDrag::Ended : uint8_t
strong

How a press ended.

Enumerator
No 

not the release of the held press

Click 

released before it became a drag

Drag 

released after dragging

Member Function Documentation

◆ IsHeld()

bool tachyon::PointerDrag::IsHeld ( ) const
inlinenoexcept

A press is held, on any element.

◆ IsPressed()

bool tachyon::PointerDrag::IsPressed ( ID element) const
inlinenoexcept

A press of element is held.

◆ IsDragging()

bool tachyon::PointerDrag::IsDragging ( ID element) const
inlinenoexcept

A press of element is held and has become a drag.

◆ Press()

bool tachyon::PointerDrag::Press ( const ElementEvent & e,
const ElementStorage & storage,
MouseButtons button = MouseButtons::Left,
bool atOnce = false )

Starts tracking e when it is button going down: true then.

With atOnce the press is a drag from the start (a sizer, a scrollbar thumb) and never a click.

◆ Move()

bool tachyon::PointerDrag::Move ( const ElementEvent & e,
int32_t distance )

For a move of the held press: true when it is a drag move, the one that goes past distance pixels (see IsDragTravel) included.

False for another element, without a press, or while the press is still under the distance.

◆ Release()

Ended tachyon::PointerDrag::Release ( const ElementEvent & e)

For the held button coming up on e.id: how the press ended. There is no press after.

◆ Cancel()

bool tachyon::PointerDrag::Cancel ( ID element)
noexcept

Drops the press of element (Escape, a lost capture): true when there was one.

◆ Reset()

void tachyon::PointerDrag::Reset ( )
inlinenoexcept

Drops any press.

◆ ScreenDelta()

int2 tachyon::PointerDrag::ScreenDelta ( const InputState & s) const
inlinenoexcept

Pointer travel since the press, in screen pixels.

◆ LocalDelta()

int2 tachyon::PointerDrag::LocalDelta ( const ElementEvent & e,
const ElementStorage & storage ) const

Pointer travel since the press, in the space of the element's rect (follows zoom).

Member Data Documentation

◆ id

ID tachyon::PointerDrag::id = ID::Invalid()

the element pressed; Invalid when there is no press

◆ button

MouseButtons tachyon::PointerDrag::button = MouseButtons::None

the button held

◆ pressScreen

int2 tachyon::PointerDrag::pressScreen { 0, 0 }

pointer at the press, screen pixels

◆ pressLocal

int2 tachyon::PointerDrag::pressLocal { 0, 0 }

pointer at the press, in the space of the element's rect

◆ dragging

bool tachyon::PointerDrag::dragging = false

moved the drag distance (or a drag from the press on)


The documentation for this struct was generated from the following file: