| 1 | // Aseprite | 
|---|---|
| 2 | // Copyright (C) 2001-2016 David Capello | 
| 3 | // | 
| 4 | // This program is distributed under the terms of | 
| 5 | // the End-User License Agreement for Aseprite. | 
| 6 | |
| 7 | #ifndef APP_UI_DEVCONSOLE_VIEW_H_INCLUDED | 
| 8 | #define APP_UI_DEVCONSOLE_VIEW_H_INCLUDED | 
| 9 | #pragma once | 
| 10 | |
| 11 | #ifndef ENABLE_SCRIPTING | 
| 12 | #error ENABLE_SCRIPTING must be defined | 
| 13 | #endif | 
| 14 | |
| 15 | #include "app/script/engine.h" | 
| 16 | #include "app/ui/tabs.h" | 
| 17 | #include "app/ui/workspace_view.h" | 
| 18 | #include "ui/box.h" | 
| 19 | #include "ui/label.h" | 
| 20 | #include "ui/textbox.h" | 
| 21 | #include "ui/view.h" | 
| 22 | |
| 23 | namespace app { | 
| 24 | class DevConsoleView : public ui::Box | 
| 25 | , public TabView | 
| 26 | , public WorkspaceView | 
| 27 | , public script::EngineDelegate { | 
| 28 | public: | 
| 29 | DevConsoleView(); | 
| 30 | ~DevConsoleView(); | 
| 31 | |
| 32 | // TabView implementation | 
| 33 | std::string getTabText() override; | 
| 34 | TabIcon getTabIcon() override; | 
| 35 | gfx::Color getTabColor() override; | 
| 36 | |
| 37 | // WorkspaceView implementation | 
| 38 | ui::Widget* getContentWidget() override { return this; } | 
| 39 | bool canCloneWorkspaceView() override { return true; } | 
| 40 | WorkspaceView* cloneWorkspaceView() override; | 
| 41 | void onWorkspaceViewSelected() override; | 
| 42 | bool onCloseView(Workspace* workspace, bool quitting) override; | 
| 43 | void onTabPopup(Workspace* workspace) override; | 
| 44 | |
| 45 | // EngineDelegate impl | 
| 46 | virtual void onConsoleError(const char* text) override; | 
| 47 | virtual void onConsolePrint(const char* text) override; | 
| 48 | |
| 49 | protected: | 
| 50 | bool onProcessMessage(ui::Message* msg) override; | 
| 51 | void onExecuteCommand(const std::string& cmd); | 
| 52 | |
| 53 | private: | 
| 54 | class CommmandEntry; | 
| 55 | |
| 56 | ui::View m_view; | 
| 57 | ui::TextBox m_textBox; | 
| 58 | ui::HBox m_bottomBox; | 
| 59 | ui::Label m_label; | 
| 60 | CommmandEntry* m_entry; | 
| 61 | script::Engine* m_engine; | 
| 62 | }; | 
| 63 | |
| 64 | } // namespace app | 
| 65 | |
| 66 | #endif | 
| 67 | 
