UIAbstractCheckButton.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #include "ui/UIAbstractCheckButton.h"
  22. #include "2d/CCSprite.h"
  23. #include "editor-support/cocostudio/CocosStudioExtension.h"
  24. NS_CC_BEGIN
  25. namespace ui {
  26. static const int BACKGROUNDBOX_RENDERER_Z = (-1);
  27. static const int BACKGROUNDSELECTEDBOX_RENDERER_Z = (-1);
  28. static const int FRONTCROSS_RENDERER_Z = (-1);
  29. static const int BACKGROUNDBOXDISABLED_RENDERER_Z = (-1);
  30. static const int FRONTCROSSDISABLED_RENDERER_Z = (-1);
  31. AbstractCheckButton::AbstractCheckButton():
  32. _backGroundBoxRenderer(nullptr),
  33. _backGroundSelectedBoxRenderer(nullptr),
  34. _frontCrossRenderer(nullptr),
  35. _backGroundBoxDisabledRenderer(nullptr),
  36. _frontCrossDisabledRenderer(nullptr),
  37. _isSelected(true),
  38. _isBackgroundSelectedTextureLoaded(false),
  39. _isBackgroundDisabledTextureLoaded(false),
  40. _isFrontCrossDisabledTextureLoaded(false),
  41. _backGroundTexType(TextureResType::LOCAL),
  42. _backGroundSelectedTexType(TextureResType::LOCAL),
  43. _frontCrossTexType(TextureResType::LOCAL),
  44. _backGroundDisabledTexType(TextureResType::LOCAL),
  45. _frontCrossDisabledTexType(TextureResType::LOCAL),
  46. _zoomScale(0.1f),
  47. _backgroundTextureScaleX(1.0),
  48. _backgroundTextureScaleY(1.0),
  49. _backGroundFileName(""),
  50. _backGroundSelectedFileName(""),
  51. _frontCrossFileName(""),
  52. _backGroundDisabledFileName(""),
  53. _frontCrossDisabledFileName(""),
  54. _backGroundBoxRendererAdaptDirty(true),
  55. _backGroundSelectedBoxRendererAdaptDirty(true),
  56. _frontCrossRendererAdaptDirty(true),
  57. _backGroundBoxDisabledRendererAdaptDirty(true),
  58. _frontCrossDisabledRendererAdaptDirty(true)
  59. {
  60. setTouchEnabled(true);
  61. }
  62. AbstractCheckButton::~AbstractCheckButton()
  63. {
  64. }
  65. bool AbstractCheckButton::init(const std::string& backGround,
  66. const std::string& backGroundSelected,
  67. const std::string& cross,
  68. const std::string& backGroundDisabled,
  69. const std::string& frontCrossDisabled,
  70. TextureResType texType)
  71. {
  72. bool ret = true;
  73. do
  74. {
  75. if (!Widget::init())
  76. {
  77. ret = false;
  78. break;
  79. }
  80. setSelected(false);
  81. loadTextures(backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType);
  82. } while (0);
  83. return ret;
  84. }
  85. bool AbstractCheckButton::init()
  86. {
  87. if (Widget::init())
  88. {
  89. setSelected(false);
  90. return true;
  91. }
  92. return false;
  93. }
  94. void AbstractCheckButton::initRenderer()
  95. {
  96. _backGroundBoxRenderer = Sprite::create();
  97. _backGroundSelectedBoxRenderer = Sprite::create();
  98. _frontCrossRenderer = Sprite::create();
  99. _backGroundBoxDisabledRenderer = Sprite::create();
  100. _frontCrossDisabledRenderer = Sprite::create();
  101. addProtectedChild(_backGroundBoxRenderer, BACKGROUNDBOX_RENDERER_Z, -1);
  102. addProtectedChild(_backGroundSelectedBoxRenderer, BACKGROUNDSELECTEDBOX_RENDERER_Z, -1);
  103. addProtectedChild(_frontCrossRenderer, FRONTCROSS_RENDERER_Z, -1);
  104. addProtectedChild(_backGroundBoxDisabledRenderer, BACKGROUNDBOXDISABLED_RENDERER_Z, -1);
  105. addProtectedChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLED_RENDERER_Z, -1);
  106. }
  107. void AbstractCheckButton::loadTextures(const std::string& backGround,
  108. const std::string& backGroundSelected,
  109. const std::string& cross,
  110. const std::string& backGroundDisabled,
  111. const std::string& frontCrossDisabled,
  112. TextureResType texType)
  113. {
  114. loadTextureBackGround(backGround,texType);
  115. loadTextureBackGroundSelected(backGroundSelected,texType);
  116. loadTextureFrontCross(cross,texType);
  117. loadTextureBackGroundDisabled(backGroundDisabled,texType);
  118. loadTextureFrontCrossDisabled(frontCrossDisabled,texType);
  119. }
  120. void AbstractCheckButton::loadTextureBackGround(const std::string& backGround,TextureResType texType)
  121. {
  122. _backGroundFileName = backGround;
  123. _backGroundTexType = texType;
  124. switch (_backGroundTexType)
  125. {
  126. case TextureResType::LOCAL:
  127. _backGroundBoxRenderer->setTexture(backGround);
  128. break;
  129. case TextureResType::PLIST:
  130. _backGroundBoxRenderer->setSpriteFrame(backGround);
  131. break;
  132. default:
  133. break;
  134. }
  135. this->setupBackgroundTexture();
  136. }
  137. void AbstractCheckButton::setupBackgroundTexture()
  138. {
  139. this->updateChildrenDisplayedRGBA();
  140. updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize());
  141. _backGroundBoxRendererAdaptDirty = true;
  142. }
  143. void AbstractCheckButton::loadTextureBackGround(SpriteFrame* spriteFrame)
  144. {
  145. _backGroundBoxRenderer->setSpriteFrame(spriteFrame);
  146. this->setupBackgroundTexture();
  147. }
  148. void AbstractCheckButton::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType)
  149. {
  150. _backGroundSelectedFileName = backGroundSelected;
  151. _isBackgroundSelectedTextureLoaded = !backGroundSelected.empty();
  152. _backGroundSelectedTexType = texType;
  153. switch (_backGroundSelectedTexType)
  154. {
  155. case TextureResType::LOCAL:
  156. _backGroundSelectedBoxRenderer->setTexture(backGroundSelected);
  157. break;
  158. case TextureResType::PLIST:
  159. _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected);
  160. break;
  161. default:
  162. break;
  163. }
  164. this->setupBackgroundSelectedTexture();
  165. }
  166. void AbstractCheckButton::loadTextureBackGroundSelected(SpriteFrame* spriteframe)
  167. {
  168. this->_backGroundSelectedBoxRenderer->setSpriteFrame(spriteframe);
  169. this->setupBackgroundSelectedTexture();
  170. }
  171. void AbstractCheckButton::setupBackgroundSelectedTexture()
  172. {
  173. this->updateChildrenDisplayedRGBA();
  174. _backGroundSelectedBoxRendererAdaptDirty = true;
  175. }
  176. void AbstractCheckButton::loadTextureFrontCross(const std::string& cross,TextureResType texType)
  177. {
  178. _frontCrossFileName = cross;
  179. _frontCrossTexType = texType;
  180. switch (_frontCrossTexType)
  181. {
  182. case TextureResType::LOCAL:
  183. _frontCrossRenderer->setTexture(cross);
  184. break;
  185. case TextureResType::PLIST:
  186. _frontCrossRenderer->setSpriteFrame(cross);
  187. break;
  188. default:
  189. break;
  190. }
  191. this->setupFrontCrossTexture();
  192. }
  193. void AbstractCheckButton::loadTextureFrontCross(SpriteFrame* spriteFrame)
  194. {
  195. this->_frontCrossRenderer->setSpriteFrame(spriteFrame);
  196. this->setupFrontCrossTexture();
  197. }
  198. void AbstractCheckButton::setupFrontCrossTexture()
  199. {
  200. this->updateChildrenDisplayedRGBA();
  201. _frontCrossRendererAdaptDirty = true;
  202. }
  203. void AbstractCheckButton::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType)
  204. {
  205. _backGroundDisabledFileName = backGroundDisabled;
  206. _isBackgroundDisabledTextureLoaded = !backGroundDisabled.empty();
  207. _backGroundDisabledTexType = texType;
  208. switch (_backGroundDisabledTexType)
  209. {
  210. case TextureResType::LOCAL:
  211. _backGroundBoxDisabledRenderer->setTexture(backGroundDisabled);
  212. break;
  213. case TextureResType::PLIST:
  214. _backGroundBoxDisabledRenderer->setSpriteFrame(backGroundDisabled);
  215. break;
  216. default:
  217. break;
  218. }
  219. this->setupBackgroundDisable();
  220. }
  221. void AbstractCheckButton::loadTextureBackGroundDisabled(SpriteFrame* spriteframe)
  222. {
  223. this->_backGroundBoxDisabledRenderer->setSpriteFrame(spriteframe);
  224. this->setupBackgroundDisable();
  225. }
  226. void AbstractCheckButton::setupBackgroundDisable()
  227. {
  228. this->updateChildrenDisplayedRGBA();
  229. _backGroundBoxDisabledRendererAdaptDirty = true;
  230. }
  231. void AbstractCheckButton::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType)
  232. {
  233. _frontCrossDisabledFileName = frontCrossDisabled;
  234. _isFrontCrossDisabledTextureLoaded = !frontCrossDisabled.empty();
  235. _frontCrossDisabledTexType = texType;
  236. switch (_frontCrossDisabledTexType)
  237. {
  238. case TextureResType::LOCAL:
  239. _frontCrossDisabledRenderer->setTexture(frontCrossDisabled);
  240. break;
  241. case TextureResType::PLIST:
  242. _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled);
  243. break;
  244. default:
  245. break;
  246. }
  247. this->setupFrontCrossDisableTexture();
  248. }
  249. void AbstractCheckButton::loadTextureFrontCrossDisabled(SpriteFrame* spriteframe)
  250. {
  251. this->_frontCrossDisabledRenderer->setSpriteFrame(spriteframe);
  252. this->setupFrontCrossDisableTexture();
  253. }
  254. void AbstractCheckButton::setupFrontCrossDisableTexture()
  255. {
  256. this->updateChildrenDisplayedRGBA();
  257. _frontCrossDisabledRendererAdaptDirty = true;
  258. }
  259. void AbstractCheckButton::onPressStateChangedToNormal()
  260. {
  261. _backGroundBoxRenderer->setVisible(true);
  262. _backGroundSelectedBoxRenderer->setVisible(false);
  263. _backGroundBoxDisabledRenderer->setVisible(false);
  264. _frontCrossDisabledRenderer->setVisible(false);
  265. _backGroundBoxRenderer->setGLProgramState(this->getNormalGLProgramState(_backGroundBoxRenderer->getTexture()));
  266. _frontCrossRenderer->setGLProgramState(this->getNormalGLProgramState(_frontCrossRenderer->getTexture()));
  267. _backGroundBoxRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
  268. _frontCrossRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
  269. if (_isSelected)
  270. {
  271. _frontCrossRenderer->setVisible(true);
  272. _frontCrossRendererAdaptDirty = true;
  273. }
  274. }
  275. void AbstractCheckButton::onPressStateChangedToPressed()
  276. {
  277. _backGroundBoxRenderer->setGLProgramState(this->getNormalGLProgramState(_backGroundBoxRenderer->getTexture()));
  278. _frontCrossRenderer->setGLProgramState(this->getNormalGLProgramState(_frontCrossRenderer->getTexture()));
  279. if (!_isBackgroundSelectedTextureLoaded)
  280. {
  281. _backGroundBoxRenderer->setScale(_backgroundTextureScaleX + _zoomScale,
  282. _backgroundTextureScaleY + _zoomScale);
  283. _frontCrossRenderer->setScale(_backgroundTextureScaleX + _zoomScale,
  284. _backgroundTextureScaleY + _zoomScale);
  285. }
  286. else
  287. {
  288. _backGroundBoxRenderer->setVisible(false);
  289. _backGroundSelectedBoxRenderer->setVisible(true);
  290. _backGroundBoxDisabledRenderer->setVisible(false);
  291. _frontCrossDisabledRenderer->setVisible(false);
  292. }
  293. }
  294. void AbstractCheckButton::onPressStateChangedToDisabled()
  295. {
  296. if (!_isBackgroundDisabledTextureLoaded
  297. || !_isFrontCrossDisabledTextureLoaded)
  298. {
  299. _backGroundBoxRenderer->setGLProgramState(this->getGrayGLProgramState(_backGroundBoxRenderer->getTexture()));
  300. _frontCrossRenderer->setGLProgramState(this->getGrayGLProgramState(_backGroundBoxRenderer->getTexture()));
  301. }
  302. else
  303. {
  304. _backGroundBoxRenderer->setVisible(false);
  305. _backGroundBoxDisabledRenderer->setVisible(true);
  306. }
  307. _backGroundSelectedBoxRenderer->setVisible(false);
  308. _frontCrossRenderer->setVisible(false);
  309. _backGroundBoxRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
  310. _frontCrossRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
  311. if (_isSelected)
  312. {
  313. _frontCrossDisabledRenderer->setVisible(true);
  314. _frontCrossDisabledRendererAdaptDirty = true;
  315. }
  316. }
  317. void AbstractCheckButton::setZoomScale(float scale)
  318. {
  319. _zoomScale = scale;
  320. }
  321. float AbstractCheckButton::getZoomScale()const
  322. {
  323. return _zoomScale;
  324. }
  325. void AbstractCheckButton::setSelected(bool selected)
  326. {
  327. if (selected == _isSelected)
  328. {
  329. return;
  330. }
  331. _isSelected = selected;
  332. _frontCrossRenderer->setVisible(_isSelected);
  333. }
  334. bool AbstractCheckButton::isSelected()const
  335. {
  336. return _isSelected;
  337. }
  338. void AbstractCheckButton::onSizeChanged()
  339. {
  340. Widget::onSizeChanged();
  341. _backGroundBoxRendererAdaptDirty = true;
  342. _backGroundSelectedBoxRendererAdaptDirty = true;
  343. _frontCrossRendererAdaptDirty = true;
  344. _backGroundBoxDisabledRendererAdaptDirty = true;
  345. _frontCrossDisabledRendererAdaptDirty = true;
  346. }
  347. void AbstractCheckButton::adaptRenderers()
  348. {
  349. if (_backGroundBoxRendererAdaptDirty)
  350. {
  351. backGroundTextureScaleChangedWithSize();
  352. _backGroundBoxRendererAdaptDirty = false;
  353. }
  354. if (_backGroundSelectedBoxRendererAdaptDirty)
  355. {
  356. backGroundSelectedTextureScaleChangedWithSize();
  357. _backGroundSelectedBoxRendererAdaptDirty = false;
  358. }
  359. if (_frontCrossRendererAdaptDirty)
  360. {
  361. frontCrossTextureScaleChangedWithSize();
  362. _frontCrossRendererAdaptDirty = false;
  363. }
  364. if (_backGroundBoxDisabledRendererAdaptDirty)
  365. {
  366. backGroundDisabledTextureScaleChangedWithSize();
  367. _backGroundBoxDisabledRendererAdaptDirty = false;
  368. }
  369. if (_frontCrossDisabledRendererAdaptDirty)
  370. {
  371. frontCrossDisabledTextureScaleChangedWithSize();
  372. _frontCrossDisabledRendererAdaptDirty = false;
  373. }
  374. }
  375. Size AbstractCheckButton::getVirtualRendererSize() const
  376. {
  377. return _backGroundBoxRenderer->getContentSize();
  378. }
  379. Node* AbstractCheckButton::getVirtualRenderer()
  380. {
  381. return _backGroundBoxRenderer;
  382. }
  383. void AbstractCheckButton::backGroundTextureScaleChangedWithSize()
  384. {
  385. if (_ignoreSize)
  386. {
  387. _backGroundBoxRenderer->setScale(1.0f);
  388. _backgroundTextureScaleX = _backgroundTextureScaleY = 1.0f;
  389. }
  390. else
  391. {
  392. Size textureSize = _backGroundBoxRenderer->getContentSize();
  393. if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
  394. {
  395. _backGroundBoxRenderer->setScale(1.0f);
  396. _backgroundTextureScaleX = _backgroundTextureScaleY = 1.0f;
  397. return;
  398. }
  399. float scaleX = _contentSize.width / textureSize.width;
  400. float scaleY = _contentSize.height / textureSize.height;
  401. _backgroundTextureScaleX = scaleX;
  402. _backgroundTextureScaleY = scaleY;
  403. _backGroundBoxRenderer->setScaleX(scaleX);
  404. _backGroundBoxRenderer->setScaleY(scaleY);
  405. }
  406. _backGroundBoxRenderer->setPosition(_contentSize.width / 2, _contentSize.height / 2);
  407. }
  408. void AbstractCheckButton::backGroundSelectedTextureScaleChangedWithSize()
  409. {
  410. if (_ignoreSize)
  411. {
  412. _backGroundSelectedBoxRenderer->setScale(1.0f);
  413. }
  414. else
  415. {
  416. Size textureSize = _backGroundSelectedBoxRenderer->getContentSize();
  417. if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
  418. {
  419. _backGroundSelectedBoxRenderer->setScale(1.0f);
  420. return;
  421. }
  422. float scaleX = _contentSize.width / textureSize.width;
  423. float scaleY = _contentSize.height / textureSize.height;
  424. _backGroundSelectedBoxRenderer->setScaleX(scaleX);
  425. _backGroundSelectedBoxRenderer->setScaleY(scaleY);
  426. }
  427. _backGroundSelectedBoxRenderer->setPosition(_contentSize.width / 2, _contentSize.height / 2);
  428. }
  429. void AbstractCheckButton::frontCrossTextureScaleChangedWithSize()
  430. {
  431. if (_ignoreSize)
  432. {
  433. _frontCrossRenderer->setScale(1.0f);
  434. }
  435. else
  436. {
  437. Size textureSize = _frontCrossRenderer->getContentSize();
  438. if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
  439. {
  440. _frontCrossRenderer->setScale(1.0f);
  441. return;
  442. }
  443. float scaleX = _contentSize.width / textureSize.width;
  444. float scaleY = _contentSize.height / textureSize.height;
  445. _frontCrossRenderer->setScaleX(scaleX);
  446. _frontCrossRenderer->setScaleY(scaleY);
  447. }
  448. _frontCrossRenderer->setPosition(_contentSize.width / 2, _contentSize.height / 2);
  449. }
  450. void AbstractCheckButton::backGroundDisabledTextureScaleChangedWithSize()
  451. {
  452. if (_ignoreSize)
  453. {
  454. _backGroundBoxDisabledRenderer->setScale(1.0f);
  455. }
  456. else
  457. {
  458. Size textureSize = _backGroundBoxDisabledRenderer->getContentSize();
  459. if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
  460. {
  461. _backGroundBoxDisabledRenderer->setScale(1.0f);
  462. return;
  463. }
  464. float scaleX = _contentSize.width / textureSize.width;
  465. float scaleY = _contentSize.height / textureSize.height;
  466. _backGroundBoxDisabledRenderer->setScaleX(scaleX);
  467. _backGroundBoxDisabledRenderer->setScaleY(scaleY);
  468. }
  469. _backGroundBoxDisabledRenderer->setPosition(_contentSize.width / 2, _contentSize.height / 2);
  470. }
  471. void AbstractCheckButton::frontCrossDisabledTextureScaleChangedWithSize()
  472. {
  473. if (_ignoreSize)
  474. {
  475. _frontCrossDisabledRenderer->setScale(1.0f);
  476. }
  477. else
  478. {
  479. Size textureSize = _frontCrossDisabledRenderer->getContentSize();
  480. if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
  481. {
  482. _frontCrossDisabledRenderer->setScale(1.0f);
  483. return;
  484. }
  485. float scaleX = _contentSize.width / textureSize.width;
  486. float scaleY = _contentSize.height / textureSize.height;
  487. _frontCrossDisabledRenderer->setScaleX(scaleX);
  488. _frontCrossDisabledRenderer->setScaleY(scaleY);
  489. }
  490. _frontCrossDisabledRenderer->setPosition(_contentSize.width / 2, _contentSize.height / 2);
  491. }
  492. void AbstractCheckButton::copySpecialProperties(Widget *widget)
  493. {
  494. AbstractCheckButton* abstractCheckButton = dynamic_cast<AbstractCheckButton*>(widget);
  495. if (abstractCheckButton)
  496. {
  497. loadTextureBackGround(abstractCheckButton->_backGroundBoxRenderer->getSpriteFrame());
  498. loadTextureBackGroundSelected(abstractCheckButton->_backGroundSelectedBoxRenderer->getSpriteFrame());
  499. loadTextureFrontCross(abstractCheckButton->_frontCrossRenderer->getSpriteFrame());
  500. loadTextureBackGroundDisabled(abstractCheckButton->_backGroundBoxDisabledRenderer->getSpriteFrame());
  501. loadTextureFrontCrossDisabled(abstractCheckButton->_frontCrossDisabledRenderer->getSpriteFrame());
  502. setSelected(abstractCheckButton->_isSelected);
  503. _zoomScale = abstractCheckButton->_zoomScale;
  504. _backgroundTextureScaleX = abstractCheckButton->_backgroundTextureScaleX;
  505. _backgroundTextureScaleY = abstractCheckButton->_backgroundTextureScaleY;
  506. _isBackgroundSelectedTextureLoaded = abstractCheckButton->_isBackgroundSelectedTextureLoaded;
  507. _isBackgroundDisabledTextureLoaded = abstractCheckButton->_isBackgroundDisabledTextureLoaded;
  508. _isFrontCrossDisabledTextureLoaded = abstractCheckButton->_isFrontCrossDisabledTextureLoaded;
  509. }
  510. }
  511. ResourceData AbstractCheckButton::getBackNormalFile()
  512. {
  513. ResourceData rData;
  514. rData.type = (int)_backGroundTexType;
  515. rData.file = _backGroundFileName;
  516. return rData;
  517. }
  518. ResourceData AbstractCheckButton::getBackPressedFile()
  519. {
  520. ResourceData rData;
  521. rData.type = (int)_backGroundSelectedTexType;
  522. rData.file = _backGroundSelectedFileName;
  523. return rData;
  524. }
  525. ResourceData AbstractCheckButton::getBackDisabledFile()
  526. {
  527. ResourceData rData;
  528. rData.type = (int)_backGroundDisabledTexType;
  529. rData.file = _backGroundDisabledFileName;
  530. return rData;
  531. }
  532. ResourceData AbstractCheckButton::getCrossNormalFile()
  533. {
  534. ResourceData rData;
  535. rData.type = (int)_frontCrossTexType;
  536. rData.file = _frontCrossFileName;
  537. return rData;
  538. }
  539. ResourceData AbstractCheckButton::getCrossDisabledFile()
  540. {
  541. ResourceData rData;
  542. rData.type = (int)_frontCrossDisabledTexType;
  543. rData.file = _frontCrossDisabledFileName;
  544. return rData;
  545. }
  546. }
  547. NS_CC_END