Kage Studio 0.7.240121
A Simple Free and Open Source 2D Animation Software
Loading...
Searching...
No Matches
scene.h
Go to the documentation of this file.
1/*
2 * Kage Studio - a simple free and open source vector-based 2D animation software
3 * Copyright (C) 2011~2024 Mj Mendoza IV
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA. Or, see <https://www.gnu.org/licenses/>.
19 *
20 */
21#ifndef GTKMM_KAGE_SCENE_H
22 #define GTKMM_KAGE_SCENE_H
23
24 #include <vector>
25 #include "color.h"
26
27 #include "frame.h"
28 #include "layer.h"
29 #include "../vectordatamanager.h"
30
32
33 #include <gdkmm/color.h>
34 //class Kage; //forward declaration
35
36 class KageFrame; //forward declaration
37 class KageLayer; //forward declaration
38
39 class KageDocument; //forward declaration
40
41 class KageScene {
42 public:
43 void init(KageDocument *p_document, unsigned int p_sceneID);
44
45 unsigned int sceneID;
47 bool _saved;
48 unsigned int _activeLayerID;
49 unsigned int _activeLayerIndex;
50 unsigned int _activeLayer; //effectively _activeLayerIndex+1
51
52 unsigned int layerCtr;
53
54 std::string _label; //Scene label
55
56 static bool LOADING_MODE;
57 KageScene(KageDocument *p_document, unsigned int p_sceneID, std::string p_filepath);
58 KageScene operator=(const KageScene &p_scene);
59
60 unsigned int getID();
61
62 std::vector<KageLayer *> Layers;
64
65 bool open(std::string p_filepath);
66 bool save();
67
68 void setSelected(bool p_selected);
69 bool isSelected();
70 bool isSaved();
71
72 KageScene(KageDocument *p_document, unsigned int p_sceneID);
73 KageScene(KageDocument *p_document, unsigned int p_sceneID, KageScene *p_scene);
74 virtual ~KageScene();
75 void addLayer();
76 void deleteLayer(unsigned int p_layerID);
77 bool removeLayerAt(unsigned int p_layerIndex);
78 bool addLayerFrame();
79 bool extendLayerFrame();
81 bool removeLayerFrame();
82 void setLayerCurrentFrame(unsigned int p_frame, bool p_addSelected);
83 void setCurrentFrameByID(unsigned int p_frameID);
84 unsigned int getCurrentFrame();
85 void setCurrentLayer(unsigned int p_currentLayer, bool p_addSelected);
86 void setCurrentLayerByID(unsigned int p_layerID);
87 unsigned int getCurrentLayer(); //currently used by getFrame()
88 unsigned int frameCount();
89 void selectAllLayerFrame(bool p_selectAll);
91 KageFrame *getFrameAt(unsigned int p_frame);
93 KageLayer *getLayerAt(unsigned int p_layer);
94
95 bool removeAllFrames();
96
97 bool moveToTop();
98 bool moveUp();
99 bool moveDown();
100 bool moveToBottom();
101
102 std::vector<unsigned int> raiseSelectedShape(std::vector<unsigned int> p_selectedShapes);
103 std::vector<unsigned int> lowerSelectedShape(std::vector<unsigned int> p_selectedShapes);
104 std::vector<unsigned int> raiseToTopSelectedShape(std::vector<unsigned int> p_selectedShapes);
105 std::vector<unsigned int> lowerToBottomSelectedShape(std::vector<unsigned int> p_selectedShapes);
106 std::vector<unsigned int> groupSelectedShapes(std::vector<unsigned int> p_selectedShapes);
107 std::vector<unsigned int> ungroupSelectedShapes(std::vector<unsigned int> p_selectedShapes);
108 std::vector<unsigned int> duplicateShapes(std::vector<unsigned int> p_selectedShapes);
109 bool flipHorizontalSelectedShape(std::vector<unsigned int> p_selectedShapes);
110 bool flipVerticalSelectedShape(std::vector<unsigned int> p_selectedShapes);
111
112 bool recenterRotationPoint(std::vector<unsigned int> p_selectedShapes);
113
115 bool setFrameData(VectorDataManager p_vectorsData);
117 VectorDataManager getFrameDataAt(unsigned int p_frame, bool p_frameOnion, bool p_layerOnion);
118
119 bool forceSetTween(unsigned int p_tween);
120 bool setTween(unsigned int p_tween);
121 unsigned int getTween();
122
124 bool layerSwitchToPreviousFrame(unsigned int p_frameID);
126 bool layerSwitchToNextFrame(unsigned int p_frameID);
127
128 void setFrameExtension(KageFrame::extension p_extension);
129
130 void extendFrameAt(unsigned int p_layerIndex, unsigned int p_frameIndex, unsigned int p_frameCount);
131 //Kage *_kage;
134
135 unsigned int getActiveLayerID();
136 std::string getLayerLabel();
137 void setLayerLabel(std::string p_label);
139 bool isLayerVisible();
140 void setLayerVisible(bool p_visible);
141 void toggleLayerLock();
142 bool isLayerLocked();
143 void setLayerLocked(bool p_locked);
144
145 std::string getLabel();
146 void setLabel(std::string p_label);
148 static std::vector<unsigned int> sceneStack;
149 };
150#endif //GTKMM_KAGE_SCENE_H
Definition document.h:69
Definition frame.h:34
extension
Definition frame.h:36
Definition layer.h:37
std::vector< unsigned int > duplicateShapes(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:610
unsigned int _activeLayerID
Definition scene.h:48
bool forceSetTween(unsigned int p_tween)
NOTE: "Frame" – NOT "frame ID".
Definition scene.cpp:700
bool layerSwitchToNextFrame()
Called by KageFrame for navigating to Previous Frame.
Definition scene.cpp:761
bool setFrameData(VectorDataManager p_vectorsData)
Definition scene.cpp:673
void setFrameExtension(KageFrame::extension p_extension)
Called by KageFrame for navigating to Next Frame.
Definition scene.cpp:809
void setCurrentLayer(unsigned int p_currentLayer, bool p_addSelected)
Definition scene.cpp:265
KageScene * _parent
Definition scene.h:133
bool isLayerVisible()
Definition scene.cpp:856
std::vector< unsigned int > raiseToTopSelectedShape(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:560
std::vector< unsigned int > lowerSelectedShape(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:548
void toggleLayerLock()
Definition scene.cpp:863
void addLayer()
Definition scene.cpp:138
std::vector< KageLayer * > Layers
Definition scene.h:62
void setCurrentLayerByID(unsigned int p_layerID)
Definition scene.cpp:313
std::vector< unsigned int > ungroupSelectedShapes(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:597
bool removeLayerAt(unsigned int p_layerIndex)
Definition scene.cpp:154
bool removeLayerFrame()
Definition scene.cpp:201
void setLayerLabel(std::string p_label)
Definition scene.cpp:849
bool recenterRotationPoint(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:648
void setCurrentFrameByID(unsigned int p_frameID)
Definition scene.cpp:381
bool flipHorizontalSelectedShape(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:623
std::vector< unsigned int > raiseSelectedShape(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:536
VectorDataManager getFrameDataAt(unsigned int p_frame, bool p_frameOnion, bool p_layerOnion)
Definition scene.cpp:696
std::string getLabel()
Definition scene.cpp:873
void toggleLayerVisibility()
Definition scene.cpp:853
bool moveToBottom()
Definition scene.cpp:519
bool flipVerticalSelectedShape(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:635
void setLabel(std::string p_label)
Definition scene.cpp:876
unsigned int getID()
Definition scene.cpp:88
unsigned int _activeLayerIndex
Definition scene.h:49
KageLayer * getLayer()
Definition scene.cpp:441
unsigned int getActiveLayerID()
Definition scene.cpp:842
bool layerSwitchToPreviousFrame()
Definition scene.cpp:712
bool moveDown()
Definition scene.cpp:501
void setSelected(bool p_selected)
Definition scene.cpp:103
static std::vector< unsigned int > sceneStack
Definition scene.h:114
bool _isAsset
Definition scene.h:147
KageScene(KageDocument *p_document, unsigned int p_sceneID, std::string p_filepath)
Definition scene.cpp:25
unsigned int frameCount()
Definition scene.cpp:130
bool addLayerFrame()
Definition scene.cpp:167
KageFrame * getFrameAt(unsigned int p_frame)
Definition scene.cpp:427
bool moveToTop()
Definition scene.cpp:462
unsigned int layerCtr
Definition scene.h:52
static bool LOADING_MODE
Definition scene.h:56
KageDocument * _document
Definition scene.h:132
unsigned int sceneID
Definition scene.h:45
KageLayer * getLayerAt(unsigned int p_layer)
Definition scene.cpp:449
unsigned int _activeLayer
Definition scene.h:50
KageLayer * _layerPtr
Definition scene.h:63
bool _saved
Definition scene.h:47
bool isLayerLocked()
Definition scene.cpp:866
bool _selected
Definition scene.h:46
virtual ~KageScene()
Definition scene.cpp:124
bool removeAllFrames()
Definition scene.cpp:226
void setLayerCurrentFrame(unsigned int p_frame, bool p_addSelected)
Definition scene.cpp:347
std::vector< unsigned int > groupSelectedShapes(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:585
void selectAllLayerFrame(bool p_selectAll)
Definition scene.cpp:406
bool save()
Definition scene.cpp:97
std::string _label
will be used to create Unique LayerUI IDs
Definition scene.h:54
void setLayerVisible(bool p_visible)
Definition scene.cpp:859
bool duplicateLayerFrame()
Definition scene.cpp:184
void init(KageDocument *p_document, unsigned int p_sceneID)
Definition scene.cpp:71
unsigned int getTween()
Definition scene.cpp:708
void setLayerLocked(bool p_locked)
Definition scene.cpp:869
bool setTween(unsigned int p_tween)
Definition scene.cpp:704
unsigned int getCurrentLayer()
Definition scene.cpp:243
bool isSaved()
Definition scene.cpp:109
KageScene operator=(const KageScene &p_scene)
Definition scene.cpp:30
bool open(std::string p_filepath)
Definition scene.cpp:92
bool addDataToFrame(VectorDataManager p_vectorsData)
Definition scene.cpp:661
bool isSelected()
Definition scene.cpp:106
void deleteLayer(unsigned int p_layerID)
Definition scene.cpp:148
unsigned int getCurrentFrame()
Definition scene.cpp:337
KageFrame * getFrame()
Definition scene.cpp:413
bool extendLayerFrame()
Definition scene.cpp:215
void extendFrameAt(unsigned int p_layerIndex, unsigned int p_frameIndex, unsigned int p_frameCount)
will be called from KageTimeline from mouse gesture of stretching the frame
Definition scene.cpp:825
bool moveUp()
Definition scene.cpp:483
std::string getLayerLabel()
Definition scene.cpp:846
VectorDataManager getFrameData()
Definition scene.cpp:684
std::vector< unsigned int > lowerToBottomSelectedShape(std::vector< unsigned int > p_selectedShapes)
Definition scene.cpp:572
Definition vectordatamanager.h:35