1 | // Aseprite Document Library |
---|---|
2 | // Copyright (c) 2001-2018 David Capello |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "doc/document.h" |
12 | |
13 | #include "base/fs.h" |
14 | #include "doc/sprite.h" |
15 | |
16 | namespace doc { |
17 | |
18 | Document::Document() |
19 | : Object(ObjectType::Document) |
20 | , m_sprites(this) |
21 | { |
22 | } |
23 | |
24 | Document::~Document() |
25 | { |
26 | } |
27 | |
28 | int Document::width() const |
29 | { |
30 | return sprite()->width(); |
31 | } |
32 | |
33 | int Document::height() const |
34 | { |
35 | return sprite()->height(); |
36 | } |
37 | |
38 | ColorMode Document::colorMode() const |
39 | { |
40 | return (ColorMode)sprite()->pixelFormat(); |
41 | } |
42 | |
43 | std::string Document::name() const |
44 | { |
45 | return base::get_file_name(m_filename); |
46 | } |
47 | |
48 | void Document::setFilename(const std::string& filename) |
49 | { |
50 | // Normalize the path (if the filename has a path) |
51 | if (!base::get_file_path(filename).empty()) |
52 | m_filename = base::normalize_path(filename); |
53 | else |
54 | m_filename = filename; |
55 | |
56 | onFileNameChange(); |
57 | } |
58 | |
59 | void Document::onFileNameChange() |
60 | { |
61 | // Do nothing |
62 | } |
63 | |
64 | } // namespace doc |
65 |