#pragma once #include "ActionItem.h" #include #include namespace NAction { // 图层位置 struct CLayerLocation { CString layer; // 图层本身路径,通过它的路径名可能定位具体层级;这里不叫 layerPath 是为了和旧风格保持一致 CString prevLayer; // 前一图层名字,通过它前面的路径名,可以定位它在同一层级第几个元素,为空时表示它在最前面 }; /** * 图层拖动和恢复 */ class CActionLayerDragDropItem : public CActionItem { public: CActionLayerDragDropItem(); CActionLayerDragDropItem(CSigmaDoc* ppDoc, const CLayerLocation &oldLocation, const CLayerLocation &newLocation); std::string GetActionName() const override { return typeid(*this).name(); } void Undo() override; void Redo() override; void accept(CActionVisitor& visitor) override; friend class BlobSerializer; private: // layer 子层中第一个成员 POSITION GetFirstChildLayerPosition(CString layer); POSITION GetLayerPosition(CString strLayer); POSITION GetMatchPosition(CString strLayer, std::function pred); /** * 从一个位置移动到另一个位置 * * \param oldLocation 旧位置 * \param newLocation 新位置 */ void Move(const CLayerLocation& oldLocation, const CLayerLocation& newLocation); CLayerLocation m_oldLocation; // 原来的位置 CLayerLocation m_newLocation; // 被拖动到的位置 }; }