/
LightInspector.h
119 lines (90 loc) · 3.11 KB
/
LightInspector.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
#pragma once
#include "icommandsystem.h"
#include "iundo.h"
#include "iradiant.h"
#include "ui/common/ShaderSelector.h"
#include "wxutil/window/TransientWindow.h"
#include "wxutil/XmlResourceBasedWidget.h"
#include <map>
#include <string>
#include <sigc++/connection.h>
/* FORWARD DECLS */
class Entity;
class wxColourPickerEvent;
namespace ui
{
/** Dialog to allow adjustment of properties on lights, including the conversion
* between projected and point lights.
*/
class LightInspector;
typedef std::shared_ptr<LightInspector> LightInspectorPtr;
class LightInspector
: public wxutil::TransientWindow,
public ShaderSelector::Client,
public UndoSystem::Observer,
private wxutil::XmlResourceBasedWidget
{
private:
// Projected light flag
bool _isProjected;
// Texture selection combo
ShaderSelector* _texSelector;
// The light entity to edit
typedef std::vector<Entity*> EntityList;
EntityList _lightEntities;
// Table of original value keys, to avoid replacing them with defaults
typedef std::map<std::string, std::string> StringMap;
StringMap _valueMap;
// Disables callbacks if set to TRUE (during widget updates)
bool _updateActive;
sigc::connection _selectionChanged;
private:
// This is where the static shared_ptr of the singleton instance is held.
static LightInspectorPtr& InstancePtr();
// Constructor creates GTK widgets
LightInspector();
// TransientWindow callbacks
virtual void _preShow();
virtual void _preHide();
// Widget construction functions
void setupPointLightPanel();
void setupProjectedPanel();
void setupOptionsPanel();
void setupTextureWidgets();
// Callbacks
void _onProjToggle(wxCommandEvent& ev);
void _onPointToggle(wxCommandEvent& ev);
void _onOK(wxCommandEvent& ev);
void _onColourChange(wxColourPickerEvent& ev);
void _onOptionsToggle(wxCommandEvent& ev);
// Update the dialog widgets from keyvals on the first selected entity
void getValuesFromEntity();
// Write the widget contents to the given entity
void setValuesOnEntity(Entity* entity);
// Write contents to all light entities
void writeToAllEntities();
// Set the given key/value pair on ALL entities in the list of lights
void setKeyValueAllLights(const std::string& k, const std::string& v);
/** greebo: Gets called when the shader selection gets changed, so that
* the displayed texture info can be updated.
*/
void shaderSelectionChanged(const std::string& shader, wxutil::TreeModel& listStore);
public:
// Gets called by the SelectionSystem when the selection is changed
void selectionChanged(const scene::INodePtr& node, bool isComponent);
/** Toggle the visibility of the dialog instance, constructing it if necessary.
*/
static void toggleInspector(const cmd::ArgumentList& args);
/** greebo: This is the actual home of the static instance
*/
static LightInspector& Instance();
// Update the sensitivity of the widgets
void update();
// UndoSystem::Observer implementation
void postUndo();
void postRedo();
// Safely disconnects this dialog from all the systems
// and saves the window size/position to the registry
void onRadiantShutdown();
};
} // namespace