| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2dnode.h"
 | 
					
						
							|  |  |  |  | #include "..\e2dmanager.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 17:08:41 +08:00
										 |  |  |  | #define SAFE_SET(pointer, func, ...) if (pointer) { pointer->##func(__VA_ARGS__); }
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:38:50 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Button::Button() | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	: _Callback(nullptr) | 
					
						
							|  |  |  |  | 	, _eBtnState(ButtonState::NORMAL) | 
					
						
							|  |  |  |  | 	, _bEnable(true) | 
					
						
							|  |  |  |  | 	, _bIsSelected(false) | 
					
						
							|  |  |  |  | 	, _pNormal(nullptr) | 
					
						
							|  |  |  |  | 	, _pMouseover(nullptr) | 
					
						
							|  |  |  |  | 	, _pSelected(nullptr) | 
					
						
							|  |  |  |  | 	, _pDisabled(nullptr) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | e2d::Button::Button(Node * normal, const Function& func) | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	: _Callback(nullptr) | 
					
						
							|  |  |  |  | 	, _eBtnState(ButtonState::NORMAL) | 
					
						
							|  |  |  |  | 	, _bEnable(true) | 
					
						
							|  |  |  |  | 	, _bIsSelected(false) | 
					
						
							|  |  |  |  | 	, _pNormal(nullptr) | 
					
						
							|  |  |  |  | 	, _pMouseover(nullptr) | 
					
						
							|  |  |  |  | 	, _pSelected(nullptr) | 
					
						
							|  |  |  |  | 	, _pDisabled(nullptr) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setNormal(normal); | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	this->setClickFunc(func); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | e2d::Button::Button(Node * normal, Node * selected, const Function& func) | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	: _Callback(nullptr) | 
					
						
							|  |  |  |  | 	, _eBtnState(ButtonState::NORMAL) | 
					
						
							|  |  |  |  | 	, _bEnable(true) | 
					
						
							|  |  |  |  | 	, _bIsSelected(false) | 
					
						
							|  |  |  |  | 	, _pNormal(nullptr) | 
					
						
							|  |  |  |  | 	, _pMouseover(nullptr) | 
					
						
							|  |  |  |  | 	, _pSelected(nullptr) | 
					
						
							|  |  |  |  | 	, _pDisabled(nullptr) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setNormal(normal); | 
					
						
							|  |  |  |  | 	this->setSelected(selected); | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	this->setClickFunc(func); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func) | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	: _Callback(nullptr) | 
					
						
							|  |  |  |  | 	, _eBtnState(ButtonState::NORMAL) | 
					
						
							|  |  |  |  | 	, _bEnable(true) | 
					
						
							|  |  |  |  | 	, _bIsSelected(false) | 
					
						
							|  |  |  |  | 	, _pNormal(nullptr) | 
					
						
							|  |  |  |  | 	, _pMouseover(nullptr) | 
					
						
							|  |  |  |  | 	, _pSelected(nullptr) | 
					
						
							|  |  |  |  | 	, _pDisabled(nullptr) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setNormal(normal); | 
					
						
							|  |  |  |  | 	this->setMouseOver(mouseover); | 
					
						
							|  |  |  |  | 	this->setSelected(selected); | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	this->setClickFunc(func); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func) | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	: _Callback(nullptr) | 
					
						
							|  |  |  |  | 	, _eBtnState(ButtonState::NORMAL) | 
					
						
							|  |  |  |  | 	, _bEnable(true) | 
					
						
							|  |  |  |  | 	, _bIsSelected(false) | 
					
						
							|  |  |  |  | 	, _pNormal(nullptr) | 
					
						
							|  |  |  |  | 	, _pMouseover(nullptr) | 
					
						
							|  |  |  |  | 	, _pSelected(nullptr) | 
					
						
							|  |  |  |  | 	, _pDisabled(nullptr) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setNormal(normal); | 
					
						
							|  |  |  |  | 	this->setMouseOver(mouseover); | 
					
						
							|  |  |  |  | 	this->setSelected(selected); | 
					
						
							|  |  |  |  | 	this->setDisabled(disabled); | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	this->setClickFunc(func); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | bool e2d::Button::isEnable() const | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	return _bEnable; | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::setNormal(Node * normal) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (normal != _pNormal) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20>Ƴ<EFBFBD><C6B3>ɵ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_pNormal) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			this->removeChild(_pNormal); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		if (normal) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			this->addChild(normal); | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | 			this->setSize(normal->getWidth(), normal->getHeight()); | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_pNormal = normal; | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		_updateVisiable(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::setMouseOver(Node * mouseover) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (mouseover != _pNormal) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20>Ƴ<EFBFBD><C6B3>ɵ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_pMouseover) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			this->removeChild(_pMouseover); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		if (mouseover) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			this->addChild(mouseover); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_pMouseover = mouseover; | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		_updateVisiable(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::setSelected(Node * selected) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (selected != _pNormal) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20>Ƴ<EFBFBD><C6B3>ɵ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_pSelected) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			this->removeChild(_pSelected); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		if (selected) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			this->addChild(selected); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_pSelected = selected; | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		_updateVisiable(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::setDisabled(Node * disabled) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (disabled != _pNormal) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20>Ƴ<EFBFBD><C6B3>ɵ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_pDisabled) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			this->removeChild(_pDisabled); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		if (disabled) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			this->addChild(disabled); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_pDisabled = disabled; | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		_updateVisiable(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  |  | void e2d::Button::setEnable(bool enable) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (_bEnable != enable) | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_bEnable = enable; | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 		_updateVisiable(); | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | void e2d::Button::setClickFunc(const Function& func) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	WARN_IF(_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed."); | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	_Callback = func; | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::onFixedUpdate() | 
					
						
							| 
									
										
										
										
											2017-12-16 15:49:48 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	if (SceneManager::isTransitioning()) | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (_bEnable && _bVisiable && _pNormal) | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 		if (Input::isMouseLButtonRelease()) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̧<EFBFBD><CCA7>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڰ<EFBFBD>ť<EFBFBD>ڲ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			if (_bIsSelected && | 
					
						
							|  |  |  |  | 				_pNormal->isPointIn(Input::getMousePos())) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				_runCallback(); | 
					
						
							|  |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			// <20><><EFBFBD><EFBFBD> _bIsSelected Ϊ false
 | 
					
						
							|  |  |  |  | 			_bIsSelected = false; | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 		if (Input::isMouseLButtonPress()) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			if (_pNormal->isPointIn(Input::getMousePos())) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 				// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD>λ<EFBFBD>ڰ<EFBFBD>ť<EFBFBD><C5A5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> _bIsSelected Ϊ true
 | 
					
						
							|  |  |  |  | 				_bIsSelected = true; | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 				return; | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_bIsSelected && Input::isMouseLButtonDown()) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			if (_pNormal->isPointIn(Input::getMousePos())) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  |  | 				_setState(ButtonState::SELECTED); | 
					
						
							| 
									
										
										
										
											2018-05-07 17:03:59 +08:00
										 |  |  |  | 				Window::setCursor(Cursor::HAND); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 				return; | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		else if (_pNormal->isPointIn(Input::getMousePos())) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  |  | 			_setState(ButtonState::MOUSEOVER); | 
					
						
							| 
									
										
										
										
											2018-05-07 17:03:59 +08:00
										 |  |  |  | 			Window::setCursor(Cursor::HAND); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 			return; | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  |  | 		_setState(ButtonState::NORMAL); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-07 17:03:59 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (_bVisiable && !_bEnable && _pNormal && _pNormal->isPointIn(Input::getMousePos())) | 
					
						
							| 
									
										
										
										
											2018-05-07 17:03:59 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		Window::setCursor(Cursor::NO); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-16 15:49:48 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  |  | void e2d::Button::_setState(ButtonState state) | 
					
						
							| 
									
										
										
										
											2018-02-04 21:24:27 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (_eBtnState != state) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_eBtnState = state; | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		_updateVisiable(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::_updateVisiable() | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	SAFE_SET(_pNormal, setVisiable, false); | 
					
						
							|  |  |  |  | 	SAFE_SET(_pMouseover, setVisiable, false); | 
					
						
							|  |  |  |  | 	SAFE_SET(_pSelected, setVisiable, false); | 
					
						
							|  |  |  |  | 	SAFE_SET(_pDisabled, setVisiable, false); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (_bEnable) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_eBtnState == ButtonState::SELECTED && _pSelected) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			_pSelected->setVisiable(true); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		else if (_eBtnState == ButtonState::MOUSEOVER && _pMouseover) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			_pMouseover->setVisiable(true); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		else | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			if (_pNormal) _pNormal->setVisiable(true); | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		if (_pDisabled) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			_pDisabled->setVisiable(true); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | 		else | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 			if (_pNormal) _pNormal->setVisiable(true); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Button::_runCallback() | 
					
						
							| 
									
										
										
										
											2017-11-07 22:20:46 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 	if (_Callback) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  |  | 		_Callback(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } |