-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColourManager.cpp
98 lines (79 loc) · 2.73 KB
/
ColourManager.cpp
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
/*!
@file
@author Albert Semenov
@date 09/2010
*/
#include "Precompiled.h"
#include "ColourManager.h"
#include "CommandManager.h"
#include "SettingsManager.h"
template <> tools::ColourManager* MyGUI::Singleton<tools::ColourManager>::msInstance = nullptr;
template <> const char* MyGUI::Singleton<tools::ColourManager>::mClassTypeName("ColourManager");
namespace tools
{
ColourManager::ColourManager() :
mColourPanel(nullptr)
{
CommandManager::getInstance().registerCommand("Command_ChangeColourBackground", MyGUI::newDelegate(this, &ColourManager::commandChangeColourBackground));
CommandManager::getInstance().registerCommand("Command_ChangeColourSelector", MyGUI::newDelegate(this, &ColourManager::commandChangeColourSelector));
CommandManager::getInstance().registerCommand("Command_ChangeColourSelectorInactive", MyGUI::newDelegate(this, &ColourManager::commandChangeColourSelectorInactive));
}
ColourManager::~ColourManager()
{
}
void ColourManager::initialise()
{
mColourPanel = new ColourPanel();
mColourPanel->eventEndDialog = MyGUI::newDelegate(this, &ColourManager::notifyEndDialog);
mColourPanel->eventPreviewColour = MyGUI::newDelegate(this, &ColourManager::notifyPreviewColour);
}
void ColourManager::shutdown()
{
delete mColourPanel;
mColourPanel = nullptr;
}
void ColourManager::commandChangeColourBackground(const MyGUI::UString& _commandName, bool& _result)
{
mCurrentColourType = "ColourBackground";
showColourDialog();
_result = true;
}
void ColourManager::commandChangeColourSelector(const MyGUI::UString& _commandName, bool& _result)
{
mCurrentColourType = "ColourSelector";
showColourDialog();
_result = true;
}
void ColourManager::commandChangeColourSelectorInactive(const MyGUI::UString& _commandName, bool& _result)
{
mCurrentColourType = "ColourSelectorInactive";
showColourDialog();
_result = true;
}
void ColourManager::notifyEndDialog(Dialog* _sender, bool _result)
{
mColourPanel->endModal();
if (_result)
setColour(mColourPanel->getColour());
else
setColour(mPreviewColour);
}
void ColourManager::notifyPreviewColour(const MyGUI::Colour& _value)
{
setColour(_value);
}
void ColourManager::showColourDialog()
{
mPreviewColour = getColour();
mColourPanel->setColour(mPreviewColour);
mColourPanel->doModal();
}
void ColourManager::setColour(const MyGUI::Colour& _color)
{
SettingsManager::getInstance().getSector("Settings")->setPropertyValue(mCurrentColourType, _color);
}
MyGUI::Colour ColourManager::getColour()
{
return SettingsManager::getInstance().getSector("Settings")->getPropertyValue<MyGUI::Colour>(mCurrentColourType);
}
} // namespace tools