1 | // Aseprite |
2 | // Copyright (C) 2018-2022 Igara Studio S.A. |
3 | // Copyright (C) 2001-2018 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifndef APP_UI_MAIN_WINDOW_H_INCLUDED |
9 | #define APP_UI_MAIN_WINDOW_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include "app/ui/tabs.h" |
13 | #include "ui/window.h" |
14 | |
15 | #include "main_window.xml.h" |
16 | |
17 | namespace ui { |
18 | class Splitter; |
19 | class TooltipManager; |
20 | } |
21 | |
22 | namespace app { |
23 | |
24 | #ifdef ENABLE_UPDATER |
25 | class CheckUpdateDelegate; |
26 | #endif |
27 | |
28 | class BrowserView; |
29 | class ColorBar; |
30 | class ContextBar; |
31 | class DevConsoleView; |
32 | class DocView; |
33 | class HomeView; |
34 | class INotificationDelegate; |
35 | class MainMenuBar; |
36 | class Notifications; |
37 | class PreviewEditorWindow; |
38 | class StatusBar; |
39 | class Timeline; |
40 | class Workspace; |
41 | class WorkspaceTabs; |
42 | |
43 | namespace crash { |
44 | class DataRecovery; |
45 | } |
46 | |
47 | class MainWindow : public app::gen::MainWindow |
48 | , public TabsDelegate { |
49 | public: |
50 | enum Mode { |
51 | NormalMode, |
52 | ContextBarAndTimelineMode, |
53 | EditorOnlyMode |
54 | }; |
55 | |
56 | MainWindow(); |
57 | ~MainWindow(); |
58 | |
59 | MainMenuBar* getMenuBar() { return m_menuBar; } |
60 | ContextBar* getContextBar() { return m_contextBar; } |
61 | StatusBar* statusBar() { return m_statusBar; } |
62 | WorkspaceTabs* getTabsBar() { return m_tabsBar; } |
63 | Timeline* getTimeline() { return m_timeline; } |
64 | Workspace* getWorkspace() { return m_workspace; } |
65 | PreviewEditorWindow* getPreviewEditor() { return m_previewEditor; } |
66 | #ifdef ENABLE_UPDATER |
67 | CheckUpdateDelegate* getCheckUpdateDelegate(); |
68 | #endif |
69 | #if ENABLE_SENTRY |
70 | void updateConsentCheckbox(); |
71 | #endif |
72 | |
73 | void start(); |
74 | void showNotification(INotificationDelegate* del); |
75 | void showHomeOnOpen(); |
76 | void showHome(); |
77 | void showDefaultStatusBar(); |
78 | void showDevConsole(); |
79 | void showBrowser(const std::string& filename, |
80 | const std::string& section = std::string()); |
81 | bool isHomeSelected() const; |
82 | |
83 | Mode getMode() const { return m_mode; } |
84 | void setMode(Mode mode); |
85 | |
86 | bool getTimelineVisibility() const; |
87 | void setTimelineVisibility(bool visible); |
88 | void popTimeline(); |
89 | |
90 | // When crash::DataRecovery finish to search for sessions, this |
91 | // function is called. |
92 | void dataRecoverySessionsAreReady(); |
93 | |
94 | // TabsDelegate implementation. |
95 | bool isTabModified(Tabs* tabs, TabView* tabView) override; |
96 | bool canCloneTab(Tabs* tabs, TabView* tabView) override; |
97 | void onSelectTab(Tabs* tabs, TabView* tabView) override; |
98 | void onCloseTab(Tabs* tabs, TabView* tabView) override; |
99 | void onCloneTab(Tabs* tabs, TabView* tabView, int pos) override; |
100 | void onContextMenuTab(Tabs* tabs, TabView* tabView) override; |
101 | void onTabsContainerDoubleClicked(Tabs* tabs) override; |
102 | void onMouseOverTab(Tabs* tabs, TabView* tabView) override; |
103 | void onMouseLeaveTab() override; |
104 | DropViewPreviewResult onFloatingTab(Tabs* tabs, |
105 | TabView* tabView, |
106 | const gfx::Point& screenPos) override; |
107 | void onDockingTab(Tabs* tabs, TabView* tabView) override; |
108 | DropTabResult onDropTab(Tabs* tabs, |
109 | TabView* tabView, |
110 | const gfx::Point& screenPos, |
111 | const bool clone) override; |
112 | |
113 | protected: |
114 | bool onProcessMessage(ui::Message* msg) override; |
115 | void onInitTheme(ui::InitThemeEvent& ev) override; |
116 | void onSaveLayout(ui::SaveLayoutEvent& ev) override; |
117 | void onResize(ui::ResizeEvent& ev) override; |
118 | void onActiveViewChange(); |
119 | void onLanguageChange(); |
120 | |
121 | private: |
122 | DocView* getDocView(); |
123 | HomeView* getHomeView(); |
124 | void configureWorkspaceLayout(); |
125 | |
126 | ui::TooltipManager* m_tooltipManager; |
127 | MainMenuBar* m_menuBar; |
128 | StatusBar* m_statusBar; |
129 | ColorBar* m_colorBar; |
130 | ContextBar* m_contextBar; |
131 | ui::Widget* m_toolBar; |
132 | WorkspaceTabs* m_tabsBar; |
133 | Mode m_mode; |
134 | Timeline* m_timeline; |
135 | Workspace* m_workspace; |
136 | PreviewEditorWindow* m_previewEditor; |
137 | HomeView* m_homeView; |
138 | Notifications* m_notifications; |
139 | INotificationDelegate* m_scalePanic; |
140 | BrowserView* m_browserView; |
141 | #ifdef ENABLE_SCRIPTING |
142 | DevConsoleView* m_devConsoleView; |
143 | #endif |
144 | }; |
145 | |
146 | } |
147 | |
148 | #endif |
149 | |