/
AuiLayout.h
91 lines (64 loc) · 2.72 KB
/
AuiLayout.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
#pragma once
#include <memory>
#include "camera/CamWnd.h"
#include "AuiManager.h"
#include "PropertyNotebook.h"
namespace ui
{
constexpr const char* const AUI_LAYOUT_NAME = "Dockable";
class AuiFloatingFrame;
/// Layout based on wxWidgets AUI (dock widget interface)
class AuiLayout
{
// Main AUI manager
AuiManager _auiMgr;
PropertyNotebook* _propertyNotebook;
struct PaneInfo
{
std::string paneName;
std::string controlName;
wxWindow* control;
};
// List of panes managed by the AUI manager
std::list<PaneInfo> _panes;
std::map<std::string, IMainFrame::ControlSettings> _defaultControlSettings;
// Stored floating window locations
std::map<std::string, std::string> _floatingPaneLocations;
// Stored last known locations of docked panes
std::map<std::string, std::string> _dockedPaneLocations;
public:
AuiLayout();
void activate();
void deactivate();
void saveStateToRegistry();
void restoreStateFromRegistry();
void createFloatingControl(const std::string& controlName);
void registerControl(const std::string& controlName, const IMainFrame::ControlSettings& defaultSettings);
// Creates the named control at its registered default location
void createControl(const std::string& controlName);
void focusControl(const std::string& controlName);
void toggleControl(const std::string& controlName);
void toggleMainControl(const std::string& controlName);
void ensureControlIsActive(wxWindow* control);
void ensureControlIsInactive(wxWindow* control);
// Internally used by the AuiManager implementation
void convertFloatingPaneToPropertyTab(AuiFloatingFrame* floatingWindow);
private:
// Add a pane to the wxAuiManager and store it in the list
void addPane(const std::string& controlName, wxWindow* window, const wxAuiPaneInfo& info);
void addPane(const std::string& controlName, const std::string& paneName, wxWindow* window, const wxAuiPaneInfo& info);
void createPane(const std::string& controlName, const std::string& paneName,
const std::function<void(wxAuiPaneInfo&)>& setupPane);
void onPaneClose(wxAuiManagerEvent& ev);
void handlePaneClosed(wxAuiPaneInfo& paneInfo);
void removeNonOrthoCenterPanes();
void savePaneLocation(wxAuiPaneInfo& paneInfo);
void restorePaneLocation(wxAuiPaneInfo& paneInfo);
bool paneNameExists(const std::string& name) const;
// Returns true if the control is loaded in the notebook or in a pane
bool controlExists(const std::string& controlName) const;
std::string generateUniquePaneName(const std::string& controlName);
void convertPaneToPropertyTab(const std::string& paneName);
void ensureVisibleCenterPane();
};
} // namespace