/
LayerControlDialog.h
106 lines (78 loc) · 2.33 KB
/
LayerControlDialog.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
#pragma once
#include "imap.h"
#include "icommandsystem.h"
#include "wxutil/window/TransientWindow.h"
#include <wx/panel.h>
#include <sigc++/connection.h>
#include "wxutil/dataview/TreeModel.h"
namespace wxutil
{
class TreeView;
}
class wxButton;
class wxFlexGridSizer;
class wxWindow;
class wxCommandEvent;
namespace ui
{
class LayerControlDialog :
public wxutil::TransientWindow
{
private:
struct TreeColumns :
public wxutil::TreeModel::ColumnRecord
{
TreeColumns() :
id(add(wxutil::TreeModel::Column::Integer)),
visible(add(wxutil::TreeModel::Column::Boolean)),
name(add(wxutil::TreeModel::Column::String)),
selectionIsPartOfLayer(add(wxutil::TreeModel::Column::Boolean))
{}
wxutil::TreeModel::Column id;
wxutil::TreeModel::Column visible;
wxutil::TreeModel::Column name;
wxutil::TreeModel::Column selectionIsPartOfLayer;
};
wxutil::TreeView* _layersView;
TreeColumns _columns;
wxutil::TreeModel::Ptr _layerStore;
std::map<int, wxDataViewItem> _layerItemMap;
wxButton* _showAllLayers;
wxButton* _hideAllLayers;
bool _rescanSelectionOnIdle;
sigc::connection _selectionChangedSignal;
sigc::connection _layersChangedSignal;
sigc::connection _layerVisibilityChangedSignal;
sigc::connection _nodeLayerMembershipChangedSignal;
sigc::connection _mapEventSignal;
public:
LayerControlDialog();
// Re-populates the window
void refresh();
// Updates the state of all LayerControls
void update();
// Command target (registered in the event manager)
static void ToggleDialog(const cmd::ArgumentList& args);
// Checks if dialog should be shown after startup
static void onMainFrameConstructed();
static LayerControlDialog& Instance();
private:
static std::shared_ptr<LayerControlDialog>& InstancePtr();
void onMainFrameShuttingDown();
// TransientWindow events
void _preShow() override;
void _postHide() override;
void populateWindow();
void clearControls();
// Update the usage colours on the controls
void updateLayerUsage();
// Creates the option buttons
void createButtons();
void onShowAllLayers(wxCommandEvent& ev);
void onHideAllLayers(wxCommandEvent& ev);
void onIdle();
void onMapEvent(IMap::MapEvent ev);
void connectToMapRoot();
void disconnectFromMapRoot();
};
} // namespace ui