/
SkinChooser.h
101 lines (76 loc) · 2.55 KB
/
SkinChooser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#include <sigc++/connection.h>
#include "imodel.h"
#include "modelskin.h"
#include "wxutil/dialog/DialogBase.h"
#include "wxutil/preview/ModelPreview.h"
#include "wxutil/decl/DeclFileInfo.h"
#include <string>
#include "wxutil/dataview/TreeModel.h"
#include "wxutil/dataview/DeclarationTreeView.h"
#include "wxutil/dataview/ResourceTreeViewToolbar.h"
#include "ui/modelselector/MaterialsList.h"
namespace wxutil { class TreeView; }
namespace ui
{
class SkinChooser;
typedef std::shared_ptr<SkinChooser> SkinChooserPtr;
/** Dialog to allow selection of skins for a model entity. Skins are grouped
* into two toplevel categories - matching skins which are associated with the
* model, and all skins available.
*/
class SkinChooser :
public wxutil::DialogBase
{
private:
wxutil::DeclarationTreeView::Columns _columns;
wxutil::TreeModel::Ptr _treeStore;
wxutil::DeclarationTreeView* _treeView;
wxutil::ResourceTreeViewToolbar* _treeViewToolbar;
MaterialsList* _materialsList;
wxutil::DeclFileInfo* _fileInfo;
// The model name to use for skin matching
std::string _model;
// The last skin selected, and the original (previous) skin
std::string _lastSkin;
std::string _prevSkin;
// Model preview widget
wxutil::ModelPreviewPtr _preview;
wxDataViewItem _allSkinsItem;
wxDataViewItem _matchingSkinsItem;
sigc::connection _modelLoadedConn;
private:
// Constructor creates widgets
SkinChooser();
// Widget creation functions
void populateWindow();
// Populate the tree with skins
void populateSkins();
// callbacks
void _onSelChanged(wxDataViewEvent& ev);
void _onTreeViewPopulationFinished(wxutil::ResourceTreeView::PopulationFinishedEvent& ev);
// Retrieve the currently selected skin
std::string getSelectedSkin();
void setSelectedSkin(const std::string& skin);
void handleSelectionChange();
void updateMaterialsList();
void _onItemActivated( wxDataViewEvent& ev );
void _onPreviewModelLoaded(const model::ModelNodePtr& model);
public:
// Override Dialogbase
int ShowModal();
/** Display the dialog and return the skin chosen by the user, or an empty
* string if no selection was made. This static method enters are recursive
* main loop during skin selection.
*
* @param model
* The full VFS path of the model for which matching skins should be found.
*
* @param prevSkin
* The current skin set on the model, so that the original can be returned
* if the dialog is cancelled.
*/
static std::string chooseSkin(const std::string& model,
const std::string& prevSkin);
};
}