1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef TrenchBroom_TextureBrowser 21 #define TrenchBroom_TextureBrowser 22 23 #include "StringUtils.h" 24 #include "Assets/TextureManager.h" 25 #include "View/ViewTypes.h" 26 27 #include <wx/panel.h> 28 29 class wxChoice; 30 class wxToggleButton; 31 class wxSearchCtrl; 32 class wxScrollBar; 33 34 namespace TrenchBroom { 35 namespace Assets { 36 class Texture; 37 } 38 39 namespace IO { 40 class Path; 41 } 42 43 namespace View { 44 class GLContextManager; 45 class TextureBrowserView; 46 class TextureSelectedCommand; 47 48 class TextureBrowser : public wxPanel { 49 private: 50 MapDocumentWPtr m_document; 51 wxChoice* m_sortOrderChoice; 52 wxToggleButton* m_groupButton; 53 wxToggleButton* m_usedButton; 54 wxSearchCtrl* m_filterBox; 55 wxScrollBar* m_scrollBar; 56 TextureBrowserView* m_view; 57 public: 58 TextureBrowser(wxWindow* parent, MapDocumentWPtr document, GLContextManager& contextManager); 59 ~TextureBrowser(); 60 61 Assets::Texture* selectedTexture() const; 62 void setSelectedTexture(Assets::Texture* selectedTexture); 63 64 void setSortOrder(Assets::TextureManager::SortOrder sortOrder); 65 void setGroup(bool group); 66 void setHideUnused(bool hideUnused); 67 void setFilterText(const String& filterText); 68 69 void OnSortOrderChanged(wxCommandEvent& event); 70 void OnGroupButtonToggled(wxCommandEvent& event); 71 void OnUsedButtonToggled(wxCommandEvent& event); 72 void OnFilterPatternChanged(wxCommandEvent& event); 73 void OnTextureSelected(TextureSelectedCommand& event); 74 private: 75 void createGui(GLContextManager& contextManager); 76 void bindEvents(); 77 78 void bindObservers(); 79 void unbindObservers(); 80 81 void documentWasNewed(MapDocument* document); 82 void documentWasLoaded(MapDocument* document); 83 void nodesWereAdded(const Model::NodeList& nodes); 84 void nodesWereRemoved(const Model::NodeList& nodes); 85 void nodesDidChange(const Model::NodeList& nodes); 86 void brushFacesDidChange(const Model::BrushFaceList& faces); 87 void textureCollectionsDidChange(); 88 void preferenceDidChange(const IO::Path& path); 89 90 void reload(); 91 }; 92 } 93 } 94 95 #endif /* defined(TrenchBroom_TextureBrowser) */ 96