Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
Draggable.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
10#pragma once
11
12#include "../../core/Types.hpp"
14#include "../../math/Math.hpp"
15
16namespace esengine::ecs {
17
18// Not marked public yet: it has just become an engine component and its
19// bounds fields changed shape in doing so. It earns that once it has held.
21struct Draggable {
22 ES_PROPERTY(tooltip="Whether this entity can be dragged at all.")
23 bool enabled{true};
24
25 // Screen pixels the pointer must travel before a press becomes a drag. Below
26 // it the press is still a click, which is what makes a draggable button work.
27 ES_PROPERTY(min=0, unit=px, tooltip="Pointer travel before a press becomes a drag.")
29
30 ES_PROPERTY(category=Axis, tooltip="Pin the X axis; the drag only moves in Y.")
31 bool lockX{false};
32
33 ES_PROPERTY(category=Axis, tooltip="Pin the Y axis; the drag only moves in X.")
34 bool lockY{false};
35
36 // A bound and a flag rather than an optional value: zero is a perfectly good
37 // limit, so it cannot double as "no limit".
38 ES_PROPERTY(category=Bounds, tooltip="Apply the lower bound below.")
39 bool constrainMin{false};
40
41 ES_PROPERTY(category=Bounds, tooltip="Lowest world position the drag may reach.")
42 glm::vec2 constraintMin{0.0f, 0.0f};
43
44 ES_PROPERTY(category=Bounds, tooltip="Apply the upper bound below.")
45 bool constrainMax{false};
46
47 ES_PROPERTY(category=Bounds, tooltip="Highest world position the drag may reach.")
48 glm::vec2 constraintMax{0.0f, 0.0f};
49};
50
51} // namespace esengine::ecs
Math utilities and GLM configuration for ESEngine.
Reflection and metadata system for automatic binding generation.
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Core type definitions and utilities for ESEngine.
float f32
32-bit floating point
Definition Types.hpp:59