File indexing completed on 2024-12-15 04:01:01
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <memory> 0010 #include <QUndoCommand> 0011 0012 #include "model/document_node.hpp" 0013 #include "model/shapes/shape.hpp" 0014 0015 namespace glaxnimate::command { 0016 0017 class DeferredCommandBase : public QUndoCommand 0018 { 0019 public: 0020 ~DeferredCommandBase(); 0021 0022 void undo() override; 0023 void redo() override; 0024 0025 bool has_action() const; 0026 0027 protected: 0028 DeferredCommandBase(const QString& name, std::unique_ptr<QUndoCommand> d = {}) 0029 : QUndoCommand(name), d(std::move(d)) 0030 {} 0031 0032 std::unique_ptr<QUndoCommand> d; 0033 }; 0034 0035 class ReorderCommand : public DeferredCommandBase 0036 { 0037 public: 0038 enum SpecialPosition 0039 { 0040 MoveUp = -1, 0041 MoveDown = -2, 0042 MoveTop = -3, 0043 MoveBottom = -4, 0044 }; 0045 0046 static bool resolve_position(model::ShapeElement* node, int& position); 0047 0048 ReorderCommand(model::ShapeElement* node, int new_position); 0049 0050 private: 0051 static QString name(model::DocumentNode* node); 0052 }; 0053 0054 } // namespace glaxnimate::command