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 #include <QUndoCommand> 0009 0010 #include "model/shapes/shape.hpp" 0011 #include "object_list_commands.hpp" 0012 0013 namespace glaxnimate::model { class Group; } 0014 0015 namespace glaxnimate::command { 0016 0017 using AddShape = AddObject<model::ShapeElement, model::ShapeListProperty>; 0018 using RemoveShape = RemoveObject<model::ShapeElement, model::ShapeListProperty>; 0019 using MoveShape = MoveObject<model::ShapeElement, model::ShapeListProperty>; 0020 0021 namespace detail { 0022 0023 class RedoInCtor : public QUndoCommand 0024 { 0025 public: 0026 void undo() override; 0027 void redo() override; 0028 0029 protected: 0030 using QUndoCommand::QUndoCommand; 0031 0032 private: 0033 bool did = true; 0034 }; 0035 0036 } // namespace detail 0037 0038 class GroupShapes : public detail::RedoInCtor 0039 { 0040 public: 0041 struct Data 0042 { 0043 std::vector<model::ShapeElement*> elements; 0044 model::ShapeListProperty* parent = nullptr; 0045 }; 0046 0047 GroupShapes(const Data& data); 0048 0049 static Data collect_shapes(const std::vector<model::VisualNode *>& selection); 0050 0051 0052 private: 0053 model::Group* group = nullptr; 0054 }; 0055 0056 class UngroupShapes : public detail::RedoInCtor 0057 { 0058 public: 0059 UngroupShapes(model::Group* group); 0060 0061 }; 0062 0063 AddShape* duplicate_shape(model::ShapeElement* shape); 0064 0065 } // namespace glaxnimate::command