forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocuments.h
More file actions
73 lines (55 loc) · 2.12 KB
/
documents.h
File metadata and controls
73 lines (55 loc) · 2.12 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
71
72
73
// Aseprite Document Library
// 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_DOCUMENTS_H_INCLUDED
#define DOC_DOCUMENTS_H_INCLUDED
#pragma once
#include "base/disable_copying.h"
#include "doc/color_mode.h"
#include "doc/documents_observer.h"
#include "doc/object_id.h"
#include "obs/observable.h"
#include <vector>
namespace doc {
class Context;
class Document;
class Documents : public obs::observable<DocumentsObserver> {
public:
typedef std::vector<Document*>::iterator iterator;
typedef std::vector<Document*>::const_iterator const_iterator;
Documents(Context* ctx);
~Documents();
iterator begin() { return m_docs.begin(); }
iterator end() { return m_docs.end(); }
const_iterator begin() const { return m_docs.begin(); }
const_iterator end() const { return m_docs.end(); }
Document* front() const { return m_docs.front(); }
Document* back() const { return m_docs.back(); }
Document* lastAdded() const { return front(); }
int size() const { return (int)m_docs.size(); }
bool empty() const { return m_docs.empty(); }
// Add a new documents to the list.
Document* add(int width, int height, ColorMode mode = ColorMode::RGB, int ncolors = 256);
Document* add(Document* doc);
// Removes a document from the list without deleting it. You must
// to delete the document after removing it.
void remove(Document* doc);
// Moves the document to the given location in the same
// list. E.g. It is used to reorder documents when they are
// selected as active.
void move(Document* doc, int index);
Document* operator[](int index) const { return m_docs[index]; }
Document* getById(ObjectId id) const;
Document* getByName(const std::string& name) const;
Document* getByFileName(const std::string& filename) const;
private:
// Deletes all documents in the list (calling "delete" operation).
void deleteAll();
Context* m_ctx;
std::vector<Document*> m_docs;
DISABLE_COPYING(Documents);
};
} // namespace doc
#endif