forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocument_range.h
More file actions
70 lines (54 loc) · 1.89 KB
/
document_range.h
File metadata and controls
70 lines (54 loc) · 1.89 KB
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
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_DOCUMENT_RANGE_H_INCLUDED
#define APP_DOCUMENT_RANGE_H_INCLUDED
#pragma once
#include "doc/frame.h"
#include "doc/layer_index.h"
#include <algorithm>
namespace doc {
class Cel;
class Sprite;
}
namespace app {
using namespace doc;
class DocumentRange {
public:
enum Type { kNone, kCels, kFrames, kLayers };
DocumentRange();
DocumentRange(Cel* cel);
Type type() const { return m_type; }
bool enabled() const { return m_type != kNone; }
LayerIndex layerBegin() const { return std::min(m_layerBegin, m_layerEnd); }
LayerIndex layerEnd() const { return std::max(m_layerBegin, m_layerEnd); }
frame_t frameBegin() const { return std::min(m_frameBegin, m_frameEnd); }
frame_t frameEnd() const { return std::max(m_frameBegin, m_frameEnd); }
int layers() const { return layerEnd() - layerBegin() + 1; }
frame_t frames() const { return frameEnd() - frameBegin() + 1; }
void setLayers(int layers);
void setFrames(frame_t frames);
void displace(int layerDelta, int frameDelta);
bool inRange(LayerIndex layer) const;
bool inRange(frame_t frame) const;
bool inRange(LayerIndex layer, frame_t frame) const;
void startRange(LayerIndex layer, frame_t frame, Type type);
void endRange(LayerIndex layer, frame_t frame);
void disableRange();
bool operator==(const DocumentRange& o) const {
return m_type == o.m_type &&
layerBegin() == o.layerBegin() && layerEnd() == o.layerEnd() &&
frameBegin() == o.frameBegin() && frameEnd() == o.frameEnd();
}
bool convertToCels(Sprite* sprite);
private:
Type m_type;
LayerIndex m_layerBegin;
LayerIndex m_layerEnd;
frame_t m_frameBegin;
frame_t m_frameEnd;
};
} // namespace app
#endif