| 1 | // Aseprite |
| 2 | // Copyright (C) 2020 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_PREVIEW_EDITOR_H_INCLUDED |
| 9 | #define APP_UI_PREVIEW_EDITOR_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "app/ui/doc_view.h" |
| 13 | #include "app/ui/editor/editor_observer.h" |
| 14 | #include "doc/frame.h" |
| 15 | #include "app/pref/preferences.h" |
| 16 | #include "ui/window.h" |
| 17 | |
| 18 | namespace app { |
| 19 | class MiniCenterButton; |
| 20 | class MiniPlayButton; |
| 21 | |
| 22 | class PreviewEditorWindow : public ui::Window |
| 23 | , public EditorObserver |
| 24 | , public DocViewPreviewDelegate { |
| 25 | public: |
| 26 | PreviewEditorWindow(); |
| 27 | ~PreviewEditorWindow(); |
| 28 | |
| 29 | bool isPreviewEnabled() const { return m_isEnabled; } |
| 30 | void setPreviewEnabled(bool state); |
| 31 | void pressPlayButton(); |
| 32 | |
| 33 | void updateUsingEditor(Editor* editor); |
| 34 | Editor* previewEditor() const; |
| 35 | Editor* relatedEditor() const { return m_relatedEditor; } |
| 36 | |
| 37 | // EditorObserver impl |
| 38 | void onStateChanged(Editor* editor) override; |
| 39 | void onScrollChanged(Editor* editor) override; |
| 40 | void onZoomChanged(Editor* editor) override; |
| 41 | |
| 42 | // DocViewPreviewDelegate impl |
| 43 | void onScrollOtherEditor(Editor* editor) override; |
| 44 | void onDisposeOtherEditor(Editor* editor) override; |
| 45 | void onPreviewOtherEditor(Editor* editor) override; |
| 46 | void onTagChangeEditor(Editor* editor, DocEvent& ev) override; |
| 47 | |
| 48 | protected: |
| 49 | bool onProcessMessage(ui::Message* msg) override; |
| 50 | void onInitTheme(ui::InitThemeEvent& ev) override; |
| 51 | void onClose(ui::CloseEvent& ev) override; |
| 52 | void onWindowResize() override; |
| 53 | |
| 54 | private: |
| 55 | void uncheckCenterButton(); |
| 56 | bool hasDocument() const; |
| 57 | DocumentPreferences& docPref(); |
| 58 | void onCenterClicked(); |
| 59 | void onPlayClicked(); |
| 60 | void (); |
| 61 | void hideWindow(); |
| 62 | void destroyDocView(); |
| 63 | void saveScrollPref(); |
| 64 | void adjustPlayingTag(); |
| 65 | |
| 66 | bool m_isEnabled; |
| 67 | DocView* m_docView; |
| 68 | MiniCenterButton* m_centerButton; |
| 69 | MiniPlayButton* m_playButton; |
| 70 | doc::frame_t m_refFrame; |
| 71 | double m_aniSpeed; |
| 72 | Editor* m_relatedEditor; |
| 73 | }; |
| 74 | |
| 75 | } // namespace app |
| 76 | |
| 77 | #endif |
| 78 | |