-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
document_view.h
112 lines (94 loc) · 3.45 KB
/
document_view.h
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Aseprite
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_UI_DOCUMENT_VIEW_H_INCLUDED
#define APP_UI_DOCUMENT_VIEW_H_INCLUDED
#pragma once
#include "app/ui/input_chain_element.h"
#include "app/ui/tabs.h"
#include "app/ui/workspace_view.h"
#include "doc/document_observer.h"
#include "ui/box.h"
namespace doc {
class Site;
}
namespace ui {
class View;
}
namespace app {
class Document;
class Editor;
class DocumentViewPreviewDelegate {
public:
virtual ~DocumentViewPreviewDelegate() { }
virtual void onScrollOtherEditor(Editor* editor) = 0;
virtual void onDisposeOtherEditor(Editor* editor) = 0;
virtual void onPreviewOtherEditor(Editor* editor) = 0;
};
class DocumentView : public ui::Box
, public TabView
, public doc::DocumentObserver
, public WorkspaceView
, public app::InputChainElement {
public:
enum Type {
Normal,
Preview
};
DocumentView(Document* document, Type type,
DocumentViewPreviewDelegate* previewDelegate);
~DocumentView();
Document* document() const { return m_document; }
Editor* editor() { return m_editor; }
ui::View* viewWidget() const { return m_view; }
void getSite(doc::Site* site) const;
bool isPreview() { return m_type == Preview; }
// TabView implementation
std::string getTabText() override;
TabIcon getTabIcon() override;
// WorkspaceView implementation
ui::Widget* getContentWidget() override { return this; }
bool canCloneWorkspaceView() override { return true; }
WorkspaceView* cloneWorkspaceView() override;
void onWorkspaceViewSelected() override;
void onClonedFrom(WorkspaceView* from) override;
bool onCloseView(Workspace* workspace, bool quitting) override;
void onTabPopup(Workspace* workspace) override;
InputChainElement* onGetInputChainElement() override { return this; }
// DocumentObserver implementation
void onGeneralUpdate(doc::DocumentEvent& ev) override;
void onSpritePixelsModified(doc::DocumentEvent& ev) override;
void onLayerMergedDown(doc::DocumentEvent& ev) override;
void onAddLayer(doc::DocumentEvent& ev) override;
void onBeforeRemoveLayer(doc::DocumentEvent& ev) override;
void onAddFrame(doc::DocumentEvent& ev) override;
void onRemoveFrame(doc::DocumentEvent& ev) override;
void onAddCel(doc::DocumentEvent& ev) override;
void onRemoveCel(doc::DocumentEvent& ev) override;
void onTotalFramesChanged(doc::DocumentEvent& ev) override;
void onLayerRestacked(doc::DocumentEvent& ev) override;
// InputChainElement impl
void onNewInputPriority(InputChainElement* element,
const ui::Message* msg) override;
bool onCanCut(Context* ctx) override;
bool onCanCopy(Context* ctx) override;
bool onCanPaste(Context* ctx) override;
bool onCanClear(Context* ctx) override;
bool onCut(Context* ctx) override;
bool onCopy(Context* ctx) override;
bool onPaste(Context* ctx) override;
bool onClear(Context* ctx) override;
void onCancel(Context* ctx) override;
protected:
bool onProcessMessage(ui::Message* msg) override;
private:
Type m_type;
Document* m_document;
ui::View* m_view;
DocumentViewPreviewDelegate* m_previewDelegate;
Editor* m_editor;
};
} // namespace app
#endif