| 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_UI_FILE_SELECTOR_H_INCLUDED |
| 8 | #define APP_UI_FILE_SELECTOR_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "app/file_selector.h" |
| 12 | #include "ui/window.h" |
| 13 | |
| 14 | #include "file_selector.xml.h" |
| 15 | |
| 16 | #include <string> |
| 17 | |
| 18 | namespace ui { |
| 19 | class Button; |
| 20 | class ComboBox; |
| 21 | class Entry; |
| 22 | } |
| 23 | |
| 24 | namespace app { |
| 25 | class FileList; |
| 26 | class FileListView; |
| 27 | class IFileItem; |
| 28 | |
| 29 | class FileSelector : public app::gen::FileSelector { |
| 30 | public: |
| 31 | FileSelector(FileSelectorType type); |
| 32 | ~FileSelector(); |
| 33 | |
| 34 | void setDefaultExtension(const std::string& extension); |
| 35 | |
| 36 | void goBack(); |
| 37 | void goForward(); |
| 38 | void goUp(); |
| 39 | void goInsideFolder(); |
| 40 | void refreshCurrentFolder(); |
| 41 | |
| 42 | // Shows the dialog to select a file in the program. |
| 43 | bool show(const std::string& title, |
| 44 | const std::string& initialPath, |
| 45 | const base::paths& extensions, |
| 46 | base::paths& output); |
| 47 | |
| 48 | private: |
| 49 | bool onProcessMessage(ui::Message* msg) override; |
| 50 | |
| 51 | void updateLocation(); |
| 52 | void updateNavigationButtons(); |
| 53 | void addInNavigationHistory(IFileItem* folder); |
| 54 | void onGoBack(); |
| 55 | void onGoForward(); |
| 56 | void onGoUp(); |
| 57 | void onNewFolder(); |
| 58 | void onChangeViewType(); |
| 59 | void onLocationCloseListBox(); |
| 60 | void onFileTypeChange(); |
| 61 | void onFileListFileSelected(); |
| 62 | void onFileListFileAccepted(); |
| 63 | void onFileListCurrentFolderChanged(); |
| 64 | void onRefreshFolder(); |
| 65 | std::string getSelectedExtension() const; |
| 66 | |
| 67 | class ArrowNavigator; |
| 68 | class CustomFileNameItem; |
| 69 | class CustomFolderNameItem; |
| 70 | class CustomFileNameEntry; |
| 71 | class CustomFileExtensionItem; |
| 72 | |
| 73 | FileSelectorType m_type; |
| 74 | std::string m_defExtension; |
| 75 | CustomFileNameEntry* m_fileName; |
| 76 | FileList* m_fileList; |
| 77 | FileListView* m_fileView; |
| 78 | |
| 79 | // If true the navigation_history isn't |
| 80 | // modified if the current folder changes |
| 81 | // (used when the back/forward buttons |
| 82 | // are pushed) |
| 83 | bool m_navigationLocked; |
| 84 | }; |
| 85 | |
| 86 | } // namespace app |
| 87 | |
| 88 | #endif |
| 89 | |