forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cel.h
89 lines (72 loc) · 2.58 KB
/
cel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Aseprite Document Library
// Copyright (c) 2019-2023 Igara Studio S.A.
// Copyright (c) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_CEL_H_INCLUDED
#define DOC_CEL_H_INCLUDED
#pragma once
#include "base/disable_copying.h"
#include "doc/cel_data.h"
#include "doc/frame.h"
#include "doc/image_ref.h"
#include "doc/object.h"
#include "gfx/fwd.h"
#include "gfx/point.h"
namespace doc {
class Document;
class Grid;
class LayerImage;
class Sprite;
class Cel : public Object {
public:
Cel(frame_t frame, const ImageRef& image);
Cel(frame_t frame, const CelDataRef& celData);
static Cel* MakeCopy(const frame_t newFrame, const Cel* other);
static Cel* MakeLink(const frame_t newFrame, const Cel* other);
frame_t frame() const { return m_frame; }
int x() const { return m_data->position().x; }
int y() const { return m_data->position().y; }
gfx::Point position() const { return m_data->position(); }
const gfx::Rect& bounds() const { return m_data->bounds(); }
const gfx::RectF& boundsF() const { return m_data->boundsF(); }
int opacity() const { return m_data->opacity(); }
int zIndex() const { return m_zIndex; }
gfx::Rect imageBounds() const { return m_data->imageBounds(); }
LayerImage* layer() const { return m_layer; }
Image* image() const { return m_data->image(); }
ImageRef imageRef() const { return m_data->imageRef(); }
CelData* data() const { return const_cast<CelData*>(m_data.get()); }
CelDataRef dataRef() const { return m_data; }
Document* document() const;
Sprite* sprite() const;
Cel* link() const;
std::size_t links() const;
// You should change the frame only if the cel isn't member of a
// layer. If the cel is already in a layer, you should use
// LayerImage::moveCel() member function.
void setFrame(frame_t frame);
void setDataRef(const CelDataRef& celData);
void setPosition(int x, int y);
void setPosition(const gfx::Point& pos);
void setBounds(const gfx::Rect& bounds);
void setBoundsF(const gfx::RectF& bounds);
void setOpacity(int opacity);
void setZIndex(int zindex);
virtual int getMemSize() const override {
return sizeof(Cel) + m_data->getMemSize();
}
void setParentLayer(LayerImage* layer);
Grid grid() const;
private:
void fixupImage();
LayerImage* m_layer;
frame_t m_frame; // Frame position
CelDataRef m_data;
int m_zIndex = 0;
Cel();
DISABLE_COPYING(Cel);
};
} // namespace doc
#endif