新增根据帧数控制可见性
This commit is contained in:
@@ -16,7 +16,7 @@ public:
|
||||
static constexpr const char* kProjectIndexFileName = "project.json";
|
||||
static constexpr const char* kAssetsDirName = "assets";
|
||||
// 写入 project.json 的 version 字段;仍可读 version 1(内嵌实体 + 可选 .anim)。
|
||||
static constexpr int kProjectIndexFormatVersion = 2;
|
||||
static constexpr int kProjectIndexFormatVersion = 3;
|
||||
|
||||
ProjectWorkspace() = default;
|
||||
|
||||
@@ -47,10 +47,17 @@ public:
|
||||
|
||||
// 写入 project.json 的 name 字段(可 undo)
|
||||
bool setProjectTitle(const QString& title);
|
||||
// 时间轴范围(写入 project.json,可 undo)。start 必须 >=0;end 会被归一化为 >= start
|
||||
bool setProjectFrameRange(int start, int end);
|
||||
// 自动扩展 end(用于“无限延伸”):仅在 end 变大时写盘;recordHistory=false 时不占用 undo 栈
|
||||
bool ensureProjectFrameEndAtLeast(int end, bool recordHistory = false);
|
||||
|
||||
Project& project() { return m_project; }
|
||||
const Project& project() const { return m_project; }
|
||||
|
||||
// 仅写盘(project.json + payload 同步)。动画 UI 直接编辑 Project 后可调用此函数持久化。
|
||||
bool save();
|
||||
|
||||
// 历史操作(最多 30 步),类似 Blender:维护 undo/redo 栈
|
||||
bool canUndo() const;
|
||||
bool canRedo() const;
|
||||
@@ -74,11 +81,27 @@ public:
|
||||
bool saveDepthMapPngBytes(const QByteArray& pngBytes, QString* outError = nullptr);
|
||||
|
||||
const QVector<Project::Entity>& entities() const { return m_project.entities(); }
|
||||
const QVector<Project::Tool>& tools() const { return m_project.tools(); }
|
||||
|
||||
bool addTool(const Project::Tool& tool);
|
||||
bool setToolVisible(const QString& id, bool on);
|
||||
bool setToolText(const QString& id, const QString& text);
|
||||
bool setToolBubblePointerT01(const QString& id, double t01);
|
||||
bool setToolFontPx(const QString& id, int fontPx);
|
||||
bool setToolAlign(const QString& id, core::Project::Tool::TextAlign align);
|
||||
bool setToolVisibilityKey(const QString& id, int frame, bool visible);
|
||||
bool removeToolVisibilityKey(const QString& id, int frame);
|
||||
bool setToolParent(const QString& id, const QString& parentId, const QPointF& parentOffsetWorld);
|
||||
bool moveToolBy(const QString& id, const QPointF& delta, int currentFrame, bool autoKeyLocation);
|
||||
bool addEntity(const Project::Entity& entity, const QImage& image);
|
||||
bool setEntityVisible(const QString& id, bool on);
|
||||
bool setEntityVisibilityKey(const QString& id, int frame, bool visible);
|
||||
bool removeEntityVisibilityKey(const QString& id, int frame);
|
||||
bool setEntityDisplayName(const QString& id, const QString& displayName);
|
||||
/// keyframeAtFrame >= 0 时同时写入该帧的 userScale 关键帧(与画布 sampleUserScale 一致)
|
||||
bool setEntityUserScale(const QString& id, double userScale, int keyframeAtFrame = -1);
|
||||
bool setEntityIgnoreDistanceScale(const QString& id, bool on);
|
||||
bool setEntityParent(const QString& id, const QString& parentId, const QPointF& parentOffsetWorld);
|
||||
// 将多边形质心平移到 targetCentroidWorld(整体平移);sTotal 须与画布一致
|
||||
bool moveEntityCentroidTo(const QString& id, int frame, const QPointF& targetCentroidWorld, double sTotal,
|
||||
bool autoKeyLocation);
|
||||
@@ -119,17 +142,25 @@ private:
|
||||
static QJsonObject entityToJson(const Project::Entity& e);
|
||||
static bool entityFromJsonV1(const QJsonObject& o, Project::Entity& out);
|
||||
static bool entityStubFromJsonV2(const QJsonObject& o, Project::Entity& out);
|
||||
static QJsonObject toolToJson(const Project::Tool& t);
|
||||
static bool toolFromJsonV2(const QJsonObject& o, Project::Tool& out);
|
||||
|
||||
struct Operation {
|
||||
enum class Type { ImportBackground, SetEntities, SetProjectTitle };
|
||||
enum class Type { ImportBackground, SetEntities, SetTools, SetProjectTitle, SetProjectFrameRange };
|
||||
Type type {Type::ImportBackground};
|
||||
QString label;
|
||||
QString beforeBackgroundPath;
|
||||
QString afterBackgroundPath;
|
||||
QVector<Project::Entity> beforeEntities;
|
||||
QVector<Project::Entity> afterEntities;
|
||||
QVector<Project::Tool> beforeTools;
|
||||
QVector<Project::Tool> afterTools;
|
||||
QString beforeProjectTitle;
|
||||
QString afterProjectTitle;
|
||||
int beforeFrameStart = 0;
|
||||
int afterFrameStart = 0;
|
||||
int beforeFrameEnd = 600;
|
||||
int afterFrameEnd = 600;
|
||||
};
|
||||
|
||||
static constexpr int kMaxHistorySteps = 30;
|
||||
@@ -137,6 +168,7 @@ private:
|
||||
|
||||
bool applyBackgroundPath(const QString& relativePath, bool recordHistory, const QString& label);
|
||||
bool applyEntities(const QVector<Project::Entity>& entities, bool recordHistory, const QString& label);
|
||||
bool applyTools(const QVector<Project::Tool>& tools, bool recordHistory, const QString& label);
|
||||
QString copyIntoAssetsAsBackground(const QString& sourceFilePath, const QRect& cropRectInSourceImage);
|
||||
bool writeDepthMap(const QImage& depth8);
|
||||
bool writeDepthMapBytes(const QByteArray& pngBytes);
|
||||
|
||||
Reference in New Issue
Block a user