载入中...
搜索中...
未找到
ActionTimelineWidget.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10
11#include <optional>
12#include <string>
13#include <string_view>
14#include <vector>
15
16namespace eve::editor {
17
19enum class TimelineHitPart : std::uint8_t { Body, StartHandle, EndHandle };
20
22enum class TimelineDragStatus : std::uint8_t { Idle, Active };
23
25enum class TimelineItemVisual : std::uint8_t {
28 Damage,
29 Vfx,
30 Audio,
31 Prefab,
32 Camera,
33 Hitbox,
34 Defense,
35 Input,
38 Curve,
39 Custom
40};
41
47[[nodiscard]] EVENGINE_API_EDITORS std::string_view timelineItemVisualName(TimelineItemVisual visual) noexcept;
48
54 bool state = false;
55 bool selected = false;
56 float minimumX = 0.0f;
57 float maximumX = 0.0f;
58 float minimumY = 0.0f;
59 float maximumY = 0.0f;
61 std::string displayName;
63 std::string detail;
66};
67
71 float x = 0.0f;
72 bool major = false;
73};
74
80
83 float width = 0.0f;
84 float height = 0.0f;
85 float playheadX = 0.0f;
88 std::vector<TimelineItemGeometry> items;
89 std::vector<TimelineRulerTick> rulerTicks;
90};
91
93enum class TimelineWidgetCommand : std::uint8_t {
94 Copy,
95 Paste,
97 Undo,
98 Redo,
102};
103
111
120public:
123
125 [[nodiscard]] Result<void> setViewport(float width, float rowHeight, float labelWidth = 120.0f);
127 [[nodiscard]] Result<void> setSnapInterval(Duration interval);
129 [[nodiscard]] Result<void> setVisibleRange(Duration start, Duration end);
131 [[nodiscard]] Result<void> zoom(double factor, double normalizedAnchor = 0.5);
133 [[nodiscard]] Result<void> pan(Duration delta);
135 [[nodiscard]] TimelineWidgetLayout layout() const;
137 void draw(IEditorOverlay& overlay) const;
139 [[nodiscard]] std::optional<TimelineHit> hitTest(float x, float y) const;
140
142 [[nodiscard]] Result<void> pointerDown(float x, float y, bool additiveSelection = false);
144 [[nodiscard]] Result<void> pointerMove(float x);
146 [[nodiscard]] Result<void> pointerUp(float x);
148 void cancelPointer() noexcept { drag_.reset(); }
151 return drag_ ? TimelineDragStatus::Active : TimelineDragStatus::Idle;
152 }
153
155 [[nodiscard]] Result<void> seek(float x);
157 [[nodiscard]] Duration timeAt(float x) const noexcept { return xToTime(x); }
159 [[nodiscard]] Result<void> inspectSelection(IEditorInspector& inspector);
160
162 [[nodiscard]] std::vector<TimelineWidgetCommandDescriptor> commands() const;
164 [[nodiscard]] Result<void> invoke(TimelineWidgetCommand command);
166 [[nodiscard]] Result<void> handleShortcut(std::string_view shortcut);
167
169 [[nodiscard]] std::vector<action::ActionNotifyDescriptor> insertableTypes(action::ActionNotifyShape shape) const;
171 [[nodiscard]] Result<void> addNotifyAtCursor(const LogicalId& trackId, std::string_view type,
174 [[nodiscard]] Result<void> addStateAtCursor(const LogicalId& trackId, std::string_view type,
176
177private:
178 struct DragState {
180 TimelineHitPart part = TimelineHitPart::Body;
181 Duration anchorTime;
182 Duration originalStart;
183 Duration originalEnd;
184 Duration previewStart;
185 Duration previewEnd;
186 bool state = false;
187 };
188
189 [[nodiscard]] float timeToX(Duration time) const noexcept;
190 [[nodiscard]] Duration xToTime(float x) const noexcept;
191 [[nodiscard]] std::optional<Duration> magneticSnap(Duration candidate,
192 const LogicalId& excludedItem) const noexcept;
193 [[nodiscard]] Result<void> updateDrag(float x);
194 [[nodiscard]] LogicalId generatedItemId();
195
196 ActionTimelineEditor& editor_;
197 const action::ActionNotifyRegistry& registry_;
198 float width_ = 800.0f;
199 float rowHeight_ = 24.0f;
200 float labelWidth_ = 120.0f;
201 Duration snapInterval_ = Duration::zero();
202 Duration visibleStart_ = Duration::zero();
203 Duration visibleEnd_ = Duration::zero();
204 std::optional<DragState> drag_;
205 std::optional<Duration> clipboardAnchor_;
206 std::uint64_t generatedSequence_ = 0;
207};
208
209} // namespace eve::editor
Extensible notify descriptors, validation and runtime routing.
UI-neutral transactional action timeline editor and preview model.
LogicalId trackId
Value::Object payload
Duration start
LogicalId itemId
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float duration
#define EVENGINE_API_EDITORS
Definition Export.h:112
std::string layout
ShaderImageInput shape
std::uint32_t width
MeshVfxBatchedDraw draw
float zoom
std::vector< VegetationPresetCommand > commands
Signed, fixed-resolution simulation duration in nanoseconds.
Definition Time.h:43
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:411
Move-only operation result carrying either a value or Status.
Definition Result.h:155
std::map< std::string, Value > Object
Definition Value.h:34
Canonical notify descriptor owner and runtime handler router.
Timeline editing controller shared by developer and in-game editors.
Interactive timeline adapter shared by developer and in-game editor hosts.
TimelineDragStatus dragStatus() const noexcept
Current pointer-drag lifecycle state.
Duration timeAt(float x) const noexcept
Convert a host-space coordinate to its snapped authoritative timeline time.
void cancelPointer() noexcept
Cancel a drag without mutating the timeline.
UI-independent property editor used by tools to expose settings.
Sink implemented by a 2D or 3D viewport to render tool feedback.
ActionNotifyShape
Declares whether a notify is instantaneous or an enter/exit state.
TimelineWidgetCommand
Standard context-menu and keyboard actions exposed by the widget.
std::string_view timelineItemVisualName(TimelineItemVisual visual) noexcept
Return the stable script-facing name for a timeline visual kind.
TimelineItemVisual
Stable semantic thumbnail kind projected for one timeline block.
TimelineHitPart
Interactive portion of a projected timeline item.
TimelineDragStatus
Observable pointer-drag lifecycle state.
Result of widget hit testing.
Owning geometry projected for one timeline item.
std::string detail
Compact owning payload summary suitable for a tooltip or block subtitle.
std::string displayName
Registry-owned display name copied into this frame projection.
TimelineItemVisual visual
Semantic mini-preview selected from the registered type, never persisted.
One deterministic ruler tick projected into host coordinates.
Complete renderer-neutral layout for one widget frame.
std::vector< TimelineRulerTick > rulerTicks
std::vector< TimelineItemGeometry > items
bool audioWaveformsAvailable
Whether an audio module currently provides waveform projection.