Debian Codegraph @

plugins/dm.editing/AIEditingPanel.h

raw
1 #pragma once
2
3 #include <map>
4 #include "ientity.h"
5 #include <memory>
6
7 #include <sigc++/connection.h>
8 #include <sigc++/trackable.h>
9
10 #include "wxutil/DockablePanel.h"
11 #include "wxutil/event/SingleIdleCallback.h"
12
13 class ISelectable;
14 class Entity;
15 class wxStaticText;
16 class wxScrolledWindow;
17 class wxSizer;
18
19 namespace ui
20 {
21
22 class AIEditingPanel;
23 typedef std::shared_ptr<AIEditingPanel> AIEditingPanelPtr;
24
25 class SpawnargLinkedCheckbox;
26 class SpawnargLinkedSpinButton;
27
28 class AIEditingPanel :
29 public wxutil::DockablePanel,
30 public Entity::Observer,
31 public sigc::trackable,
32 public wxutil::SingleIdleCallback
33 {
34 private:
35 sigc::connection _selectionChangedSignal;
36
37 wxScrolledWindow* _mainPanel;
38
39 typedef std::map<std::string, SpawnargLinkedCheckbox*> CheckboxMap;
40 CheckboxMap _checkboxes;
41
42 typedef std::map<std::string, SpawnargLinkedSpinButton*> SpinButtonMap;
43 SpinButtonMap _spinButtons;
44
45 typedef std::map<std::string, wxStaticText*> LabelMap;
46 LabelMap _labels;
47
48 Entity* _entity;
49
50 sigc::connection _undoHandler;
51 sigc::connection _redoHandler;
52
53 bool _rescanSelectionOnIdle;
54
55 public:
56 AIEditingPanel(wxWindow* parent);
57 ~AIEditingPanel() override;
58
59 void onKeyInsert(const std::string& key, EntityKeyValue& value) override;
60 void onKeyChange(const std::string& key, const std::string& val) override;
61 void onKeyErase(const std::string& key, EntityKeyValue& value) override;
62
63 void postUndo();
64 void postRedo();
65
66 protected:
67 void onIdle() override;
68 void onBrowseButton(wxCommandEvent& ev, const std::string& key);
69
70 void onPanelActivated() override;
71 void onPanelDeactivated() override;
72
73 private:
74 void connectListeners();
75 void disconnectListeners();
76
77 void constructWidgets();
78 wxSizer* createSpinButtonHbox(SpawnargLinkedSpinButton* spinButton);
79 wxStaticText* createSectionLabel(const std::string& text);
80 void createChooserRow(wxSizer* table, const std::string& rowLabel,
81 const std::string& buttonLabel, const std::string& buttonIcon,
82 const std::string& key);
83
84 void onSelectionChanged(const ISelectable& selectable);
85
86 void rescanSelection();
87
88 Entity* getEntityFromSelection();
89 void updateWidgetsFromSelection();
90 void updatePanelSensitivity();
91 };
92
93 } // namespace