2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
|
|
|
|
// Copyright (C) 2001-2015 David Capello
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
// published by the Free Software Foundation.
|
2014-08-08 07:19:31 +08:00
|
|
|
|
|
|
|
|
#ifndef APP_DOCUMENT_RANGE_H_INCLUDED
|
|
|
|
|
#define APP_DOCUMENT_RANGE_H_INCLUDED
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
#include "doc/frame.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/layer_index.h"
|
2014-08-08 07:19:31 +08:00
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
2015-02-09 22:40:43 +08:00
|
|
|
namespace doc {
|
|
|
|
|
class Cel;
|
|
|
|
|
class Sprite;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-08 07:19:31 +08:00
|
|
|
namespace app {
|
2014-10-21 09:21:31 +08:00
|
|
|
using namespace doc;
|
2014-08-08 07:19:31 +08:00
|
|
|
|
|
|
|
|
class DocumentRange {
|
|
|
|
|
public:
|
|
|
|
|
enum Type { kNone, kCels, kFrames, kLayers };
|
|
|
|
|
|
2015-02-09 22:40:43 +08:00
|
|
|
DocumentRange();
|
|
|
|
|
DocumentRange(Cel* cel);
|
2014-08-08 07:19:31 +08:00
|
|
|
|
|
|
|
|
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); }
|
2014-12-29 07:39:11 +08:00
|
|
|
frame_t frameBegin() const { return std::min(m_frameBegin, m_frameEnd); }
|
|
|
|
|
frame_t frameEnd() const { return std::max(m_frameBegin, m_frameEnd); }
|
2014-08-08 07:19:31 +08:00
|
|
|
|
|
|
|
|
int layers() const { return layerEnd() - layerBegin() + 1; }
|
2014-12-29 07:39:11 +08:00
|
|
|
frame_t frames() const { return frameEnd() - frameBegin() + 1; }
|
2014-08-08 07:19:31 +08:00
|
|
|
void setLayers(int layers);
|
2014-12-29 07:39:11 +08:00
|
|
|
void setFrames(frame_t frames);
|
2014-08-08 07:19:31 +08:00
|
|
|
void displace(int layerDelta, int frameDelta);
|
|
|
|
|
|
|
|
|
|
bool inRange(LayerIndex layer) const;
|
2014-12-29 07:39:11 +08:00
|
|
|
bool inRange(frame_t frame) const;
|
|
|
|
|
bool inRange(LayerIndex layer, frame_t frame) const;
|
2014-08-08 07:19:31 +08:00
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
void startRange(LayerIndex layer, frame_t frame, Type type);
|
|
|
|
|
void endRange(LayerIndex layer, frame_t frame);
|
2014-08-08 07:19:31 +08:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-09 22:40:43 +08:00
|
|
|
bool convertToCels(Sprite* sprite);
|
|
|
|
|
|
2014-08-08 07:19:31 +08:00
|
|
|
private:
|
|
|
|
|
Type m_type;
|
|
|
|
|
LayerIndex m_layerBegin;
|
|
|
|
|
LayerIndex m_layerEnd;
|
2014-12-29 07:39:11 +08:00
|
|
|
frame_t m_frameBegin;
|
|
|
|
|
frame_t m_frameEnd;
|
2014-08-08 07:19:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace app
|
|
|
|
|
|
|
|
|
|
#endif
|