1// Aseprite
2// Copyright (C) 2020 Igara Studio S.A.
3// Copyright (C) 2001-2015 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif
11
12#include "app/tools/ink_type.h"
13#include "app/i18n/strings.h"
14
15namespace app {
16namespace tools {
17
18std::string ink_type_to_string(InkType inkType)
19{
20 switch (inkType) {
21 case tools::InkType::SIMPLE: return Strings::inks_simple_ink();
22 case tools::InkType::ALPHA_COMPOSITING: return Strings::inks_alpha_compositing();
23 case tools::InkType::COPY_COLOR: return Strings::inks_copy_color();
24 case tools::InkType::LOCK_ALPHA: return Strings::inks_lock_alpha();
25 case tools::InkType::SHADING: return Strings::inks_shading();
26 }
27 return Strings::general_unknown();
28}
29
30std::string ink_type_to_string_id(InkType inkType)
31{
32 switch (inkType) {
33 case tools::InkType::SIMPLE: return "simple";
34 case tools::InkType::ALPHA_COMPOSITING: return "alpha_compositing";
35 case tools::InkType::COPY_COLOR: return "copy_color";
36 case tools::InkType::LOCK_ALPHA: return "lock_alpha";
37 case tools::InkType::SHADING: return "shading";
38 }
39 return "unknown";
40}
41
42InkType string_id_to_ink_type(const std::string& s)
43{
44 if (s == "simple")
45 return tools::InkType::SIMPLE;
46
47 if (s == "alpha_compositing" ||
48 s == "alpha-compositing")
49 return tools::InkType::ALPHA_COMPOSITING;
50
51 if (s == "copy_color" ||
52 s == "copy-color")
53 return tools::InkType::COPY_COLOR;
54
55 if (s == "lock_alpha" ||
56 s == "lock-alpha")
57 return tools::InkType::LOCK_ALPHA;
58
59 if (s == "shading")
60 return tools::InkType::SHADING;
61
62 return tools::InkType::DEFAULT;
63}
64
65} // namespace tools
66} // namespace app
67