/
MediaBrowser.h
151 lines (117 loc) · 3.54 KB
/
MediaBrowser.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once
#include "iradiant.h"
#include "imodule.h"
#include "icommandsystem.h"
#include "wxutil/TreeView.h"
#include "wxutil/menu/PopupMenu.h"
#include <wx/event.h>
class wxWindow;
class wxTreeCtrl;
class wxFrame;
class wxDataViewTreeStore;
class wxTreeEvent;
namespace ui
{
class TexturePreviewCombo;
/**
* \brief Media Browser page of the group dialog.
*
* This page allows browsing of individual textures by name and loading them
* into the texture window or applying directly to map geometry.
*/
class MediaBrowser :
public RegisterableModule,
public wxEvtHandler,
public ModuleObserver // to monitor the MaterialManager module
{
public:
struct TreeColumns :
public wxutil::TreeModel::ColumnRecord
{
TreeColumns() :
iconAndName(add(wxutil::TreeModel::Column::IconText)),
leafName(add(wxutil::TreeModel::Column::String)),
fullName(add(wxutil::TreeModel::Column::String)),
isFolder(add(wxutil::TreeModel::Column::Boolean)),
isOtherMaterialsFolder(add(wxutil::TreeModel::Column::Boolean))
{}
wxutil::TreeModel::Column iconAndName;
wxutil::TreeModel::Column leafName; // no parent folders
wxutil::TreeModel::Column fullName;
wxutil::TreeModel::Column isFolder;
wxutil::TreeModel::Column isOtherMaterialsFolder;
};
class PopulatorFinishedEvent; // wxEvent type
static std::string GROUPDIALOG_TAB_NAME;
private:
wxFrame* _tempParent;
wxWindow* _mainWidget;
wxutil::TreeView* _treeView;
TreeColumns _columns;
wxutil::TreeModel::Ptr _treeStore;
// Populates the Media Browser in its own thread
class Populator;
std::unique_ptr<Populator> _populator;
// Context menu
wxutil::PopupMenuPtr _popupMenu;
// Texture preview combo (GL widget and info table)
TexturePreviewCombo* _preview;
// false, if the tree is not yet initialised.
bool _isPopulated;
private:
void construct();
/* wxutil::PopupMenu callbacks */
bool _testSingleTexSel();
bool _testLoadInTexView();
void _onApplyToSel();
void _onLoadInTexView();
void _onShowShaderDefinition();
void _onSelectItems(bool select);
/* wx CALLBACKS */
void _onExpose(wxPaintEvent& ev);
void _onSelectionChanged(wxTreeEvent& ev);
void _onContextMenu(wxDataViewEvent& ev);
void handleSelectionChange();
/* Tree selection query functions */
bool isDirectorySelected(); // is a directory selected
std::string getSelectedName(); // return name of selection
// Populates the treeview
void populate();
void onTreeStorePopulationFinished(wxutil::TreeModel::PopulationFinishedEvent& ev);
public:
/** Return the singleton instance.
*/
static MediaBrowser& getInstance();
/** Constructor creates widgets.
*/
MediaBrowser();
/** Set the given path as the current selection, highlighting it
* in the tree view.
*
* @param selection
* The fullname of the item to select, or the empty string if there
* should be no selection.
*/
void setSelection(const std::string& selection);
// ModuleObserver implementation, these are called when the MaterialManager
// is emitting realise signals
void unrealise();
void realise();
const std::string& getName() const override;
const StringSet& getDependencies() const override;
void initialiseModule(const ApplicationContext& ctx) override;
void shutdownModule() override;
private:
// Radiant Event Listener
void onRadiantStartup();
void onRadiantShutdown();
/**
* greebo: Registers the preference page and the commands
*/
void registerCommandsAndPreferences();
/**
* greebo: Command target for toggling the mediabrowser tab in the groupdialog.
*/
void Toggle(const cmd::ArgumentList& args);
};
}