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_SmartColorEditor 21 #define TrenchBroom_SmartColorEditor 22 23 #include "SharedPointer.h" 24 #include "StringUtils.h" 25 #include "Model/ModelTypes.h" 26 #include "View/SmartAttributeEditor.h" 27 #include "View/ViewTypes.h" 28 29 #include <wx/colour.h> 30 31 class wxColourPickerCtrl; 32 class wxColourPickerEvent; 33 class wxCommandEvent; 34 class wxPanel; 35 class wxRadioButton; 36 class wxWindow; 37 38 namespace TrenchBroom { 39 namespace View { 40 class ColorTable; 41 class ColorTableSelectedCommand; 42 43 class SmartColorEditor : public SmartAttributeEditor { 44 private: 45 static const size_t ColorHistoryCellSize = 15; 46 typedef std::vector<wxColour> wxColorList; 47 48 wxPanel* m_panel; 49 wxRadioButton* m_floatRadio; 50 wxRadioButton* m_byteRadio; 51 wxColourPickerCtrl* m_colorPicker; 52 ColorTable* m_colorHistory; 53 public: 54 SmartColorEditor(View::MapDocumentWPtr document); 55 56 void OnFloatRangeRadioButton(wxCommandEvent& event); 57 void OnByteRangeRadioButton(wxCommandEvent& event); 58 void OnColorPickerChanged(wxColourPickerEvent& event); 59 void OnColorTableSelected(ColorTableSelectedCommand& event); 60 private: 61 wxWindow* doCreateVisual(wxWindow* parent); 62 void doDestroyVisual(); 63 void doUpdateVisual(const Model::AttributableNodeList& attributables); 64 65 class CollectColorVisitor; 66 void updateColorRange(const Model::AttributableNodeList& attributables); 67 void updateColorHistory(); 68 69 void setColor(const wxColor& wxColor) const; 70 }; 71 } 72 } 73 74 #endif /* defined(TrenchBroom_SmartColorEditor) */ 75