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 APP_UTIL_CLIPBOARD_H_INCLUDED
8 #define APP_UTIL_CLIPBOARD_H_INCLUDED
9 #pragma once
10 
11 #include "gfx/point.h"
12 #include "gfx/size.h"
13 #include "ui/base.h"
14 #include "ui/clipboard_delegate.h"
15 
16 namespace doc {
17   class Image;
18   class Mask;
19   class Palette;
20   class PalettePicks;
21 }
22 
23 namespace app {
24   class Doc;
25   class ContextReader;
26   class ContextWriter;
27   class DocRange;
28 
29   namespace clipboard {
30     using namespace doc;
31 
32     enum ClipboardFormat {
33       ClipboardNone,
34       ClipboardImage,
35       ClipboardDocRange,
36       ClipboardPaletteEntries,
37     };
38 
39     // TODO Horrible API: refactor it (maybe a merge with she::clipboard).
40 
41     class ClipboardManager : public ui::ClipboardDelegate {
42     public:
43       static ClipboardManager* instance();
44 
45       ClipboardManager();
46       ~ClipboardManager();
47 
48       void setClipboardText(const std::string& text) override;
49       bool getClipboardText(std::string& text) override;
50     private:
51       std::string m_text; // Text used when the native clipboard is disabled
52     };
53 
54     ClipboardFormat get_current_format();
55     void get_document_range_info(Doc** document, DocRange* range);
56 
57     void clear_content();
58     void cut(ContextWriter& context);
59     void copy(const ContextReader& context);
60     void copy_merged(const ContextReader& context);
61     void copy_range(const ContextReader& context, const DocRange& range);
62     void copy_image(const Image* image, const Mask* mask, const Palette* palette);
63     void copy_palette(const Palette* palette, const PalettePicks& picks);
64     void paste();
65 
66     // Returns true and fills the specified "size"" with the image's
67     // size in the clipboard, or return false in case that the clipboard
68     // doesn't contain an image at all.
69     bool get_image_size(gfx::Size& size);
70 
71     Palette* get_palette();
72     const PalettePicks& get_palette_picks();
73 
74   } // namespace clipboard
75 } // namespace app
76 
77 #endif
78