update
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/domain/Project.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
// TimelineEditorModel:把时间轴的“可视数据 + 选择状态 + 命中测试结果”从 Widget 拆出来,
|
||||
// 便于支持多轨、统一交互逻辑,并降低 TimelineWidget 的复杂度。
|
||||
//
|
||||
// 阶段1最小实现:仅负责存储轨道视图数据与选择状态;Widget 仍自行处理鼠标事件,
|
||||
// 但数据不再用固定 4 条 QVector<int> 传递。
|
||||
|
||||
class TimelineEditorModel final {
|
||||
public:
|
||||
enum class TrackKind { Location, UserScale, Image, Visibility };
|
||||
|
||||
struct KeyRef {
|
||||
TrackKind kind {TrackKind::Location};
|
||||
int frame {-1};
|
||||
};
|
||||
|
||||
struct TrackView {
|
||||
TrackKind kind {TrackKind::Location};
|
||||
QString label;
|
||||
QColor color;
|
||||
QVector<int> keyframes; // sorted unique frames
|
||||
};
|
||||
|
||||
void clear() {
|
||||
m_tracks.clear();
|
||||
clearSelection();
|
||||
clearInterval();
|
||||
}
|
||||
|
||||
void setTracks(QVector<TrackView> tracks) { m_tracks = std::move(tracks); }
|
||||
const QVector<TrackView>& tracks() const { return m_tracks; }
|
||||
|
||||
void clearSelection() { m_hasSelectedKey = false; m_selected = {}; }
|
||||
void setSelectedKey(const KeyRef& ref) { m_hasSelectedKey = (ref.frame >= 0); m_selected = ref; }
|
||||
bool hasSelectedKey() const { return m_hasSelectedKey; }
|
||||
const KeyRef& selectedKey() const { return m_selected; }
|
||||
|
||||
void clearInterval() { m_selStart = -1; m_selEnd = -1; }
|
||||
void setInterval(int a, int b) {
|
||||
if (a < 0 || b < 0) { clearInterval(); return; }
|
||||
m_selStart = std::min(a, b);
|
||||
m_selEnd = std::max(a, b);
|
||||
}
|
||||
int intervalStart() const { return m_selStart; }
|
||||
int intervalEnd() const { return m_selEnd; }
|
||||
|
||||
private:
|
||||
QVector<TrackView> m_tracks;
|
||||
bool m_hasSelectedKey {false};
|
||||
KeyRef m_selected;
|
||||
int m_selStart {-1};
|
||||
int m_selEnd {-1};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user