1// Aseprite
2// Copyright (c) 2001-2018 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifndef DOC_SPRITE_POSITION_H_INCLUDED
8#define DOC_SPRITE_POSITION_H_INCLUDED
9#pragma once
10
11#include "doc/frame.h"
12#include "doc/layer.h"
13#include "doc/object.h"
14#include "doc/object_id.h"
15
16namespace app {
17
18 class SpritePosition {
19 public:
20 SpritePosition()
21 : m_layerId(doc::NullId)
22 , m_frame(0) {
23 }
24
25 SpritePosition(const doc::Layer* layer, doc::frame_t frame)
26 : m_layerId(layer ? layer->id(): doc::NullId)
27 , m_frame(frame) {
28 }
29
30 doc::Layer* layer() const { return doc::get<doc::Layer>(m_layerId); }
31 doc::ObjectId layerId() const { return m_layerId; }
32 doc::frame_t frame() const { return m_frame; }
33
34 void layer(doc::Layer* layer) {
35 m_layerId = (layer ? layer->id(): doc::NullId);
36 }
37
38 void layerId(doc::ObjectId layerId) {
39 m_layerId = layerId;
40 }
41
42 void frame(doc::frame_t frame) {
43 m_frame = frame;
44 }
45
46 bool operator==(const SpritePosition& o) const { return m_layerId == o.m_layerId && m_frame == o.m_frame; }
47 bool operator!=(const SpritePosition& o) const { return m_layerId != o.m_layerId || m_frame != o.m_frame; }
48
49 private:
50 doc::ObjectId m_layerId;
51 doc::frame_t m_frame;
52 };
53
54} // namespace app
55
56#endif
57