/
MouseToolManager.h
65 lines (48 loc) · 1.71 KB
/
MouseToolManager.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
#pragma once
#include <map>
#include "imousetool.h"
#include "imousetoolmanager.h"
#include "xmlutil/Node.h"
#include "MouseToolGroup.h"
#include "ModifierHintPopup.h"
#include <wx/event.h>
#include <wx/timer.h>
namespace ui
{
/**
* Implementation of the IMouseToolManager interface.
* This is used by the GlobalXYWnd and GlobalCamera instances.
*/
class MouseToolManager :
public wxEvtHandler,
public IMouseToolManager
{
protected:
typedef std::map<IMouseToolGroup::Type, MouseToolGroupPtr> GroupMap;
GroupMap _mouseToolGroups;
unsigned int _activeModifierState;
wxTimer _hintCloseTimer;
std::unique_ptr<ModifierHintPopup> _hintPopup;
public:
MouseToolManager();
// RegisterableModule implementation
const std::string& getName() const;
const StringSet& getDependencies() const;
void initialiseModule(const IApplicationContext& ctx);
void shutdownModule();
// Get the group defined by the given enum. This always succeeds, if the group
// is not existing yet, a new one will be created internally.
MouseToolGroup& getGroup(IMouseToolGroup::Type group);
// Iterate over each group using the given visitor function
void foreachGroup(const std::function<void(IMouseToolGroup&)>& functor);
MouseToolStack getMouseToolsForEvent(IMouseToolGroup::Type group, unsigned int mouseState);
void updateStatusbar(unsigned int newState);
void resetBindingsToDefault();
private:
void onMainFrameConstructed();
void loadToolMappings();
void loadGroupMapping(MouseToolGroup::Type type, const xml::NodeList& userMappings, const xml::NodeList& defaultMappings);
void saveToolMappings();
void onCloseTimerIntervalReached(wxTimerEvent& ev);
};
} // namespace