1 /*!
2 	@file
3 	@author		Albert Semenov
4 	@date		08/2010
5 */
6 #include "Precompiled.h"
7 #include "BackgroundControl.h"
8 #include "SettingsManager.h"
9 
10 namespace tools
11 {
12 
BackgroundControl()13 	BackgroundControl::BackgroundControl() :
14 		mBackground(nullptr),
15 		mCanvas(nullptr)
16 	{
17 	}
18 
~BackgroundControl()19 	BackgroundControl::~BackgroundControl()
20 	{
21 		SettingsManager::getInstance().eventSettingsChanged.disconnect(this);
22 	}
23 
OnInitialise(Control * _parent,MyGUI::Widget * _place,const std::string & _layoutName)24 	void BackgroundControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
25 	{
26 		Control::OnInitialise(_parent, _place, "BackgroundControl.layout");
27 
28 		assignWidget(mBackground, "Background");
29 		assignWidget(mCanvas, "Canvas");
30 
31 		mColourValueName = "ColourBackground";
32 		MyGUI::Colour colour = SettingsManager::getInstance().getValue<MyGUI::Colour>("Workspace/Colours/" + mColourValueName);
33 		setColour(colour);
34 
35 		SettingsManager::getInstance().eventSettingsChanged.connect(this, &BackgroundControl::notifySettingsChanged);
36 	}
37 
setColour(const MyGUI::Colour & _colour)38 	void BackgroundControl::setColour(const MyGUI::Colour& _colour)
39 	{
40 		mBackground->setColour(_colour);
41 		mBackground->setAlpha(_colour.alpha);
42 	}
43 
getCanvas()44 	MyGUI::Widget* BackgroundControl::getCanvas()
45 	{
46 		return mCanvas;
47 	}
48 
notifySettingsChanged(const std::string & _path)49 	void BackgroundControl::notifySettingsChanged(const std::string& _path)
50 	{
51 		MyGUI::Colour colour = SettingsManager::getInstance().getValue<MyGUI::Colour>("Workspace/Colours/" + mColourValueName);
52 		setColour(colour);
53 	}
54 
55 }
56