axmol/cocos/ui/UIButton.cpp

980 lines
26 KiB
C++
Raw Normal View History

2014-03-11 17:13:54 +08:00
/****************************************************************************
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2014-03-11 17:13:54 +08:00
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "ui/UIButton.h"
#include "ui/UIScale9Sprite.h"
2014-06-04 14:26:21 +08:00
#include "2d/CCLabel.h"
#include "2d/CCSprite.h"
#include "2d/CCActionInterval.h"
2014-06-18 11:11:08 +08:00
#include "platform/CCFileUtils.h"
2015-01-19 16:58:46 +08:00
#include "ui/UIHelper.h"
2015-05-20 17:42:48 +08:00
#include <algorithm>
2014-03-11 17:13:54 +08:00
NS_CC_BEGIN
namespace ui {
static const int NORMAL_RENDERER_Z = (-2);
static const int PRESSED_RENDERER_Z = (-2);
static const int DISABLED_RENDERER_Z = (-2);
static const int TITLE_RENDERER_Z = (-1);
2014-10-09 17:19:43 +08:00
static const float ZOOM_ACTION_TIME_STEP = 0.05f;
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
IMPLEMENT_CLASS_GUI_INFO(Button)
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
Button::Button():
_buttonNormalRenderer(nullptr),
_buttonClickedRenderer(nullptr),
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer(nullptr),
2014-03-11 17:13:54 +08:00
_titleRenderer(nullptr),
_zoomScale(0.1f),
2014-03-11 17:13:54 +08:00
_prevIgnoreSize(true),
_scale9Enabled(false),
2015-04-14 14:23:10 +08:00
_pressedActionEnabled(false),
2014-03-11 17:13:54 +08:00
_capInsetsNormal(Rect::ZERO),
_capInsetsPressed(Rect::ZERO),
_capInsetsDisabled(Rect::ZERO),
_normalTextureSize(_contentSize),
_pressedTextureSize(_contentSize),
_disabledTextureSize(_contentSize),
2014-03-11 17:13:54 +08:00
_normalTextureLoaded(false),
_pressedTextureLoaded(false),
2014-04-17 14:08:25 +08:00
_disabledTextureLoaded(false),
_normalTextureAdaptDirty(true),
_pressedTextureAdaptDirty(true),
2014-06-15 15:55:46 +08:00
_disabledTextureAdaptDirty(true),
2018-05-14 10:34:56 +08:00
_normalFileName(""),
_clickedFileName(""),
_disabledFileName(""),
_normalTexType(TextureResType::LOCAL),
_pressedTexType(TextureResType::LOCAL),
_disabledTexType(TextureResType::LOCAL),
_fontName("")
2014-03-11 17:13:54 +08:00
{
2014-06-24 15:51:14 +08:00
setTouchEnabled(true);
2014-03-11 17:13:54 +08:00
}
Button::~Button()
{
}
Button* Button::create()
{
Button* widget = new (std::nothrow) Button();
2014-03-11 17:13:54 +08:00
if (widget && widget->init())
{
widget->autorelease();
return widget;
}
CC_SAFE_DELETE(widget);
return nullptr;
}
2015-04-14 14:23:10 +08:00
Button* Button::create(const std::string &normalImage,
const std::string& selectedImage ,
const std::string& disableImage,
TextureResType texType)
{
Button *btn = new (std::nothrow) Button;
if (btn && btn->init(normalImage,selectedImage,disableImage,texType))
{
btn->autorelease();
return btn;
}
CC_SAFE_DELETE(btn);
return nullptr;
}
2015-04-14 14:23:10 +08:00
bool Button::init(const std::string &normalImage,
const std::string& selectedImage ,
const std::string& disableImage,
TextureResType texType)
{
2015-04-14 14:23:10 +08:00
// invoke an overridden init() at first
if (!Widget::init()) {
return false;
}
loadTextures(normalImage, selectedImage, disableImage, texType);
return true;
}
2014-03-11 17:13:54 +08:00
bool Button::init()
{
if (Widget::init())
{
return true;
}
return false;
}
void Button::initRenderer()
{
2014-07-30 15:19:39 +08:00
_buttonNormalRenderer = Scale9Sprite::create();
_buttonClickedRenderer = Scale9Sprite::create();
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer = Scale9Sprite::create();
_buttonClickedRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
_buttonNormalRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
_buttonDisabledRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
2014-03-11 17:13:54 +08:00
2014-03-24 15:25:44 +08:00
addProtectedChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
addProtectedChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
2015-09-14 14:27:51 +08:00
addProtectedChild(_buttonDisabledRenderer, DISABLED_RENDERER_Z, -1);
2015-04-14 14:23:10 +08:00
}
bool Button::createTitleRendererIfNull() {
if( !_titleRenderer ) {
createTitleRenderer();
return true;
}
return false;
}
2015-04-14 14:23:10 +08:00
void Button::createTitleRenderer()
{
_titleRenderer = Label::create();
_titleRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
2014-03-24 15:25:44 +08:00
addProtectedChild(_titleRenderer, TITLE_RENDERER_Z, -1);
2014-03-11 17:13:54 +08:00
}
Scale9Sprite refactor (#16891) * Squashed commit of the following: commit 026eee59c9ece7fc59d71fead41104f375f72eb5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 21:45:12 2016 -0800 yay! everything works! commit a645c99d44f0d7674e6238afae7628d8d2a030b1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 14:55:31 2016 -0800 more fixes in Scale9Sprite commit 3a688f4ea70c0abe311232c65ed14a7e9acc7611 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 23:06:45 2016 -0800 rotated sprites commit 45e2085df3aa4b52236c817f7db7c1f6602c1e95 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 17:10:44 2016 -0800 android patch 9: fixes is not 100% backward compatible since the previous version had some artifacts. fixed the artifacts. now it renders ok commit 4655d894387fa40a7e63b074a36bfed20e41d5f9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 16:31:29 2016 -0800 sprite: correct size for "fake scale9" commit cb98aba27cc1c82a986268d5b74afb55b6cca2f3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 21:55:51 2016 -0800 sprite: adds setStrechEnabled for backward compatibility and other fixes commit c0fe67aac54cd62e3846810d56f87133f3a7343b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:49:42 2016 -0800 implemts missing functions in scale9sprite commit e471ef318725ccabc9eca2c062e285e9ca4f9a81 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:42:30 2016 -0800 "batched" works commit 33124bfb14d1f275d4b0ffca8989975625a8a76d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:59:38 2016 -0800 more fixes commit 149f8206269843af63a1739885c00ed8d94c239c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:37:12 2016 -0800 scale 9 rotated not fixed yet. but making progress commit 27f98275d94ce00c8d5ff0b6f74b5c22723cc3c3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 15:32:57 2016 -0800 sprite: streching works ok with normal sprites commit 2519498cac8b77a32dee5bdf1805be56fbda5ed6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 12:12:28 2016 -0800 somes fixes... still not working commit 43580d0b4aa976b0200717611a286bf1035c472d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 23:15:22 2016 -0800 more bug fixes related to untrimmed setCenterRect... ...in SCale9Sprite commit 407247616e506afaa0415c58ad7fce38efed0cd9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 22:13:38 2016 -0800 spritecale9: untrimmed vs. trimmed capInsets WIP. there still a few bugs commit 3d845b2af3500be287fabb04bb6ba0ec04dbb401 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 23:11:17 2016 -0800 started progressbar commit 0a44b00daf723869b7105689890f29cd53a62608 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 17:43:23 2016 -0800 adds EditBox test commit 330304bd9b2e762de95c2f27f1ae3ceee83b2fbf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 16:57:08 2016 -0800 adds elastic to scroll view commit a06a35f8691ff56a143953c44acd947b519150b6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:58:29 2016 -0800 yay! scrollview works commit 37748a885c62eca8c00d2c9c11ee103f1d95e71c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:33:58 2016 -0800 yet more scrollview fixes commit a6e563b497adef7b141ac7c92c844d479b244c59 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 14:48:28 2016 -0800 initial scroll view commit 4243edd7548e5533ca03c26d5042f8dc5517445a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 8 17:50:15 2016 -0800 sanity check in frames. missing files commit 159d88603ad22f3c01761b60bacec98d52b9041d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 19:21:00 2016 -0800 three buttons working commit 6764cfc7937a1a81d6993d5e32a21f17457b8e0d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:50:22 2016 -0800 missing files commit 11c1fa3812e706a7d34137fe2626f05ab73ee3e6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:49:59 2016 -0800 button works! commit 26b6de4c28fc973e332dd51fcd763a6249c0b4c2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:19:47 2016 -0800 Scale9: more fixes. complies with odd Rect::ZERO behavior commit ce561268096afe322f25034eeab3508a60027afd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 11:50:42 2016 -0800 label: setTitleLabel commit 51b5536cd2af36896002621f75c7310960c3f5e7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 17:41:08 2016 -0700 UIButton kind of working commit 7562a49a761ef70c383a99d2addefc63d77e279f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 11:11:42 2016 -0700 missing resoruces commit a9890dee5da0104bff6872cc04e8786a6c0a9018 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 10:54:55 2016 -0700 setCenterRect to .cpp file commit c9c4bb55ed3fc55709eca46c43d1bfe5301c317f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 00:19:51 2016 -0700 removed unused paramter commit e47732934cca79c08e6fe96e46ebdf075508e568 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 18:19:31 2016 -0700 flipping works! commit c9769bacd321aeddf84e1772dd270f12194d2f04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 17:57:53 2016 -0700 spirte flip fixes... not finished yet commit 1cbdc8e12cc6d0d2728c06dfabaada001784a178 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:53:16 2016 -0700 centerRect changes commit aeb1b14c00331dabba640f52d79ab0e255fa3407 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:10:41 2016 -0700 changes from v3 commit e7a61c4a20d786c2bc1d6f57e33bf3ac95cb6f21 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 17:01:15 2016 -0700 sprite: rotated slice 9 works as expected commit 91049389426051deb49a9d951364bf60abaf4532 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 15:39:54 2016 -0700 more bug fixes in scale9sprite support commit 9feb12449078441c439df16dc7bcfb4506c7a226 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 13:22:52 2016 -0700 Android's Patch 9 works as expected commit 1cf46afe3e7f7f5f714d30779caefc25a9bb1b3b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 10:18:47 2016 -0700 Sprite: uses capInsets instead of centerRect just to share the same API as Scale9Sprite commit e944fa0248a7eb58012aacb229de1a9b814e0aef Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 18:59:42 2016 -0700 scale9sprite support fixes commit b08765740d480b6ae1491800161b40d88f458767 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:38:47 2016 -0700 more scale9sprite fixes commit 388a34d93de5e6007a2cecea959c929f26427cab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:20:01 2016 -0700 UI::Scale9Sprite refactoring subclass of Sprite... much cleaner! commit c84ec8ee654f74d4b38be2d0a3d7ffe6adbc6faf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 20:58:36 2016 -0700 supports tiled sprites commit d2b18eb47a647b29319488bd53edac9f304acb84 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 19:21:57 2016 -0700 testing tiled sprite commit b4832ab2facc01cbb624db587ede01fe7acf23e8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:53:19 2016 -0700 using correct top-left coordinates for setCenterRect commit 29d8de86a71cc597b2338f59f7951a28ee0c93b2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:46:13 2016 -0700 fixes from scale_sprite9 branch commit ccbe1063bea7db75397ecaf9046aac3dd977a621 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 19:01:50 2016 -0700 updated example commit 24f7f85d4eba80f8e543810dcbc1a02447900bdc Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:47:28 2016 -0700 more fixes in nine slice commit df3358fae68f2d81baf3a8cbe033a4c400ea50da Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:22:14 2016 -0700 anchor point fixes commit 4ac7409bc72425abb0dc747b956ec346fbd1b2fa Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 17:01:48 2016 -0700 support for slice-9 from creator commit a3221375d3a9defc2e03df0b1c2da1b36dfdd491 Merge: 73e5389 d7490d9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 14:13:38 2016 -0700 Merge branch 'sprite_scale9' into creator_cpp_support commit d7490d94896ad0ce8705dc0695252cee34329b5e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 13 14:34:52 2016 -0700 Adds slice9 support for Sprite. how to use it: // points coords sprite->setCenterRect(Rect(x,y,w,h)); // normalized coords sprite->setCenterRectNormalized(Rect(x,y,w,h)); starts scale9sprite in sprite more slice 9 changes sprite 9 slice works? kind of works correct anchor point slice 9 works, at least with non-rotated atlases streched works ok better Y invert code. cleaner, compatible with the previous code yay, scaling workings... need a better api now sets scale correctly yay! works as expected! more fixes and tests better test for box setContentSize() changes size in non-9-slice mode sprites as well setCenterRect() -> setCenterRectNormalized() yet another test adds setPositionNormalized() adds setCenterRect() tests remove devel team from xcode tests: add one more tests fun test! improved test yet another test for slice 9 commit 73e5389ef719880096067d0f7d0bffd6e1f3cfd1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Sun Oct 9 18:54:22 2016 -0700 kind of ProgressBar support commit 4db5e9e7369e93ceba1d9512ab88c26b843c43d5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 7 16:23:54 2016 -0700 new generatred ui files commit 75aa06f3d39df8c6aa898d5e6810b3cd8015c07b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 6 10:44:59 2016 -0700 bette canvas support commit 89beacac478fc7f58ef930963b6393f3da4a743c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 21:47:11 2016 -0700 sprites tests commit 5fe930ad50c2c1b6d868982709c7b659176f9889 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:35:44 2016 -0700 more label tests commit d3f615a097d080d78f2ebd95f3e2388da45f92db Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:08:24 2016 -0700 label tests commit 2a4018922ce8d36117f7092fc324e37cf75fdeab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 21:52:56 2016 -0700 label fixes commit 41fafbd023de63e376d014311605f2b156add307 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 19:14:58 2016 -0700 updated test commit 06919fc28fffbc5a20cd14bdcc2ad2ff997e0da1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 18:50:45 2016 -0700 creator tests: works commit 6e362e7cc7f68dc216b569a7f7f90aaa110c0e4a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Sep 27 23:15:56 2016 -0700 autogen: new data commit e78078b2ad84b4e364827a66f1c459de7384a91d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Sep 26 18:18:57 2016 -0700 fix: initial test for CPP support for Creator * adds more documentation * adds more documentation
2016-11-24 09:59:00 +08:00
/** replaces the current Label node with a new one */
void Button::setTitleLabel(Label* label)
{
if (_titleRenderer != label) {
CC_SAFE_RELEASE(_titleRenderer);
_titleRenderer = label;
CC_SAFE_RETAIN(_titleRenderer);
addProtectedChild(_titleRenderer, TITLE_RENDERER_Z, -1);
updateTitleLocation();
}
}
/** returns the current Label being used */
Label* Button::getTitleLabel() const
{
return _titleRenderer;
}
2014-03-11 17:13:54 +08:00
void Button::setScale9Enabled(bool able)
{
if (_scale9Enabled == able)
{
return;
}
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
_scale9Enabled = able;
2015-04-14 14:23:10 +08:00
if (_scale9Enabled) {
_buttonNormalRenderer->setRenderingType(Scale9Sprite::RenderingType::SLICE);
_buttonClickedRenderer->setRenderingType(Scale9Sprite::RenderingType::SLICE);
_buttonDisabledRenderer->setRenderingType(Scale9Sprite::RenderingType::SLICE);
}else{
_buttonNormalRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
_buttonClickedRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
_buttonDisabledRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
}
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
if (_scale9Enabled)
{
bool ignoreBefore = _ignoreSize;
ignoreContentAdaptWithSize(false);
_prevIgnoreSize = ignoreBefore;
}
else
{
ignoreContentAdaptWithSize(_prevIgnoreSize);
}
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
setCapInsetsNormalRenderer(_capInsetsNormal);
setCapInsetsPressedRenderer(_capInsetsPressed);
setCapInsetsDisabledRenderer(_capInsetsDisabled);
2015-04-14 14:23:10 +08:00
2014-07-30 15:19:39 +08:00
_brightStyle = BrightStyle::NONE;
2014-03-11 17:13:54 +08:00
setBright(_bright);
_normalTextureAdaptDirty = true;
_pressedTextureAdaptDirty = true;
_disabledTextureAdaptDirty = true;
2014-03-11 17:13:54 +08:00
}
2014-05-27 11:06:32 +08:00
bool Button::isScale9Enabled()const
2014-03-11 17:13:54 +08:00
{
return _scale9Enabled;
}
void Button::ignoreContentAdaptWithSize(bool ignore)
{
2014-10-09 18:28:09 +08:00
if (_unifySize)
{
2014-10-24 17:38:32 +08:00
this->updateContentSize();
2014-10-09 18:28:09 +08:00
return;
}
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
if (!_scale9Enabled || (_scale9Enabled && !ignore))
{
Widget::ignoreContentAdaptWithSize(ignore);
_prevIgnoreSize = ignore;
}
}
void Button::loadTextures(const std::string& normal,
const std::string& selected,
const std::string& disabled,
TextureResType texType)
2014-03-11 17:13:54 +08:00
{
loadTextureNormal(normal,texType);
loadTexturePressed(selected,texType);
loadTextureDisabled(disabled,texType);
}
void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
2014-03-11 17:13:54 +08:00
{
_normalFileName = normal;
_normalTexType = texType;
bool textureLoaded = true;
if (normal.empty())
2014-03-11 17:13:54 +08:00
{
_buttonNormalRenderer->resetRender();
textureLoaded = false;
}
else
{
switch (texType)
{
2014-07-30 15:19:39 +08:00
case TextureResType::LOCAL:
_buttonNormalRenderer->initWithFile(normal);
break;
case TextureResType::PLIST:
_buttonNormalRenderer->initWithSpriteFrameName(normal);
break;
default:
break;
}
2014-03-11 17:13:54 +08:00
}
//FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249
2015-12-14 11:53:09 +08:00
if (!_ignoreSize && _customSize.equals(Size::ZERO)) {
_customSize = _buttonNormalRenderer->getContentSize();
}
this->setupNormalTexture(textureLoaded);
2015-04-14 14:23:10 +08:00
}
void Button::setupNormalTexture(bool textureLoaded)
2015-04-14 14:23:10 +08:00
{
2014-03-11 17:13:54 +08:00
_normalTextureSize = _buttonNormalRenderer->getContentSize();
2015-04-14 14:23:10 +08:00
this->updateChildrenDisplayedRGBA();
2015-04-14 14:23:10 +08:00
2014-10-24 17:38:32 +08:00
if (_unifySize )
{
if (!_scale9Enabled)
{
updateContentSizeWithTextureSize(this->getNormalSize());
}
}
else
{
updateContentSizeWithTextureSize(_normalTextureSize);
}
_normalTextureLoaded = textureLoaded;
2014-04-17 14:08:25 +08:00
_normalTextureAdaptDirty = true;
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
void Button::loadTextureNormal(SpriteFrame* normalSpriteFrame)
{
_buttonNormalRenderer->initWithSpriteFrame(normalSpriteFrame);
this->setupNormalTexture(nullptr != normalSpriteFrame);
2015-04-14 14:23:10 +08:00
}
void Button::loadTexturePressed(const std::string& selected,TextureResType texType)
2014-03-11 17:13:54 +08:00
{
_clickedFileName = selected;
_pressedTexType = texType;
2017-01-20 09:58:29 +08:00
bool textureLoaded = true;
if (selected.empty())
{
_buttonClickedRenderer->resetRender();
2017-01-20 09:58:29 +08:00
textureLoaded = false;
}
else
2014-03-11 17:13:54 +08:00
{
switch (texType)
{
2014-07-30 15:19:39 +08:00
case TextureResType::LOCAL:
_buttonClickedRenderer->initWithFile(selected);
break;
case TextureResType::PLIST:
_buttonClickedRenderer->initWithSpriteFrameName(selected);
break;
default:
break;
}
2014-03-11 17:13:54 +08:00
}
2017-01-20 09:58:29 +08:00
this->setupPressedTexture(textureLoaded);
2015-04-14 14:23:10 +08:00
}
void Button::setupPressedTexture(bool textureLoaded)
2015-04-14 14:23:10 +08:00
{
2014-03-11 17:13:54 +08:00
_pressedTextureSize = _buttonClickedRenderer->getContentSize();
2015-04-14 14:23:10 +08:00
this->updateChildrenDisplayedRGBA();
_pressedTextureLoaded = textureLoaded;
2014-04-17 14:08:25 +08:00
_pressedTextureAdaptDirty = true;
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
void Button::loadTexturePressed(SpriteFrame* pressedSpriteFrame)
{
_buttonClickedRenderer->initWithSpriteFrame(pressedSpriteFrame);
this->setupPressedTexture(nullptr != pressedSpriteFrame);
2015-04-14 14:23:10 +08:00
}
void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType)
2014-03-11 17:13:54 +08:00
{
_disabledFileName = disabled;
_disabledTexType = texType;
bool textureLoaded = true;
if (disabled.empty())
{
_buttonDisabledRenderer->resetRender();
textureLoaded = false;
}
else
2014-03-11 17:13:54 +08:00
{
switch (texType)
{
2014-07-30 15:19:39 +08:00
case TextureResType::LOCAL:
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->initWithFile(disabled);
2014-07-30 15:19:39 +08:00
break;
case TextureResType::PLIST:
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->initWithSpriteFrameName(disabled);
2014-07-30 15:19:39 +08:00
break;
default:
break;
}
2014-03-11 17:13:54 +08:00
}
this->setupDisabledTexture(textureLoaded);
2015-04-14 14:23:10 +08:00
}
2014-07-30 15:19:39 +08:00
void Button::setupDisabledTexture(bool textureLoaded)
2015-04-14 14:23:10 +08:00
{
2015-09-14 14:27:51 +08:00
_disabledTextureSize = _buttonDisabledRenderer->getContentSize();
2015-04-14 14:23:10 +08:00
this->updateChildrenDisplayedRGBA();
_disabledTextureLoaded = textureLoaded;
2014-04-17 14:08:25 +08:00
_disabledTextureAdaptDirty = true;
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
void Button::loadTextureDisabled(SpriteFrame* disabledSpriteFrame)
{
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->initWithSpriteFrame(disabledSpriteFrame);
this->setupDisabledTexture(nullptr != disabledSpriteFrame);
2015-04-14 14:23:10 +08:00
}
2014-03-11 17:13:54 +08:00
void Button::setCapInsets(const Rect &capInsets)
{
setCapInsetsNormalRenderer(capInsets);
setCapInsetsPressedRenderer(capInsets);
setCapInsetsDisabledRenderer(capInsets);
}
2014-03-11 17:13:54 +08:00
void Button::setCapInsetsNormalRenderer(const Rect &capInsets)
{
_capInsetsNormal = Helper::restrictCapInsetRect(capInsets, this->_normalTextureSize);
2015-04-14 14:23:10 +08:00
//for performance issue
2014-03-11 17:13:54 +08:00
if (!_scale9Enabled)
{
return;
}
_buttonNormalRenderer->setCapInsets(_capInsetsNormal);
2014-03-11 17:13:54 +08:00
}
void Button::setCapInsetsPressedRenderer(const Rect &capInsets)
{
_capInsetsPressed = Helper::restrictCapInsetRect(capInsets, this->_pressedTextureSize);
2015-04-14 14:23:10 +08:00
//for performance issue
2014-03-11 17:13:54 +08:00
if (!_scale9Enabled)
{
return;
}
_buttonClickedRenderer->setCapInsets(_capInsetsPressed);
2014-03-11 17:13:54 +08:00
}
void Button::setCapInsetsDisabledRenderer(const Rect &capInsets)
{
_capInsetsDisabled = Helper::restrictCapInsetRect(capInsets, this->_disabledTextureSize);
2015-04-14 14:23:10 +08:00
//for performance issue
2014-03-11 17:13:54 +08:00
if (!_scale9Enabled)
{
return;
}
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->setCapInsets(_capInsetsDisabled);
2014-03-11 17:13:54 +08:00
}
const Rect& Button::getCapInsetsNormalRenderer()const
{
return _capInsetsNormal;
}
2015-04-14 14:23:10 +08:00
const Rect& Button::getCapInsetsPressedRenderer()const
{
return _capInsetsPressed;
}
2015-04-14 14:23:10 +08:00
2014-05-27 11:06:32 +08:00
const Rect& Button::getCapInsetsDisabledRenderer()const
2014-03-11 17:13:54 +08:00
{
return _capInsetsDisabled;
}
void Button::onPressStateChangedToNormal()
{
_buttonNormalRenderer->setVisible(true);
_buttonClickedRenderer->setVisible(false);
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->setVisible(false);
2014-12-23 15:03:31 +08:00
_buttonNormalRenderer->setState(Scale9Sprite::State::NORMAL);
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
if (_pressedTextureLoaded)
{
if (_pressedActionEnabled)
{
2014-09-13 22:08:02 +08:00
_buttonNormalRenderer->stopAllActions();
_buttonClickedRenderer->stopAllActions();
2015-04-14 14:23:10 +08:00
2015-01-21 14:54:37 +08:00
// Action *zoomAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, _normalTextureScaleXInSize, _normalTextureScaleYInSize);
//fixme: the zoomAction will run in the next frame which will cause the _buttonNormalRenderer to a wrong scale
_buttonNormalRenderer->setScale(1.0);
_buttonClickedRenderer->setScale(1.0);
2015-04-14 14:23:10 +08:00
Scale9Sprite refactor (#16891) * Squashed commit of the following: commit 026eee59c9ece7fc59d71fead41104f375f72eb5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 21:45:12 2016 -0800 yay! everything works! commit a645c99d44f0d7674e6238afae7628d8d2a030b1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 14:55:31 2016 -0800 more fixes in Scale9Sprite commit 3a688f4ea70c0abe311232c65ed14a7e9acc7611 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 23:06:45 2016 -0800 rotated sprites commit 45e2085df3aa4b52236c817f7db7c1f6602c1e95 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 17:10:44 2016 -0800 android patch 9: fixes is not 100% backward compatible since the previous version had some artifacts. fixed the artifacts. now it renders ok commit 4655d894387fa40a7e63b074a36bfed20e41d5f9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 16:31:29 2016 -0800 sprite: correct size for "fake scale9" commit cb98aba27cc1c82a986268d5b74afb55b6cca2f3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 21:55:51 2016 -0800 sprite: adds setStrechEnabled for backward compatibility and other fixes commit c0fe67aac54cd62e3846810d56f87133f3a7343b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:49:42 2016 -0800 implemts missing functions in scale9sprite commit e471ef318725ccabc9eca2c062e285e9ca4f9a81 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:42:30 2016 -0800 "batched" works commit 33124bfb14d1f275d4b0ffca8989975625a8a76d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:59:38 2016 -0800 more fixes commit 149f8206269843af63a1739885c00ed8d94c239c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:37:12 2016 -0800 scale 9 rotated not fixed yet. but making progress commit 27f98275d94ce00c8d5ff0b6f74b5c22723cc3c3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 15:32:57 2016 -0800 sprite: streching works ok with normal sprites commit 2519498cac8b77a32dee5bdf1805be56fbda5ed6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 12:12:28 2016 -0800 somes fixes... still not working commit 43580d0b4aa976b0200717611a286bf1035c472d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 23:15:22 2016 -0800 more bug fixes related to untrimmed setCenterRect... ...in SCale9Sprite commit 407247616e506afaa0415c58ad7fce38efed0cd9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 22:13:38 2016 -0800 spritecale9: untrimmed vs. trimmed capInsets WIP. there still a few bugs commit 3d845b2af3500be287fabb04bb6ba0ec04dbb401 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 23:11:17 2016 -0800 started progressbar commit 0a44b00daf723869b7105689890f29cd53a62608 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 17:43:23 2016 -0800 adds EditBox test commit 330304bd9b2e762de95c2f27f1ae3ceee83b2fbf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 16:57:08 2016 -0800 adds elastic to scroll view commit a06a35f8691ff56a143953c44acd947b519150b6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:58:29 2016 -0800 yay! scrollview works commit 37748a885c62eca8c00d2c9c11ee103f1d95e71c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:33:58 2016 -0800 yet more scrollview fixes commit a6e563b497adef7b141ac7c92c844d479b244c59 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 14:48:28 2016 -0800 initial scroll view commit 4243edd7548e5533ca03c26d5042f8dc5517445a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 8 17:50:15 2016 -0800 sanity check in frames. missing files commit 159d88603ad22f3c01761b60bacec98d52b9041d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 19:21:00 2016 -0800 three buttons working commit 6764cfc7937a1a81d6993d5e32a21f17457b8e0d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:50:22 2016 -0800 missing files commit 11c1fa3812e706a7d34137fe2626f05ab73ee3e6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:49:59 2016 -0800 button works! commit 26b6de4c28fc973e332dd51fcd763a6249c0b4c2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:19:47 2016 -0800 Scale9: more fixes. complies with odd Rect::ZERO behavior commit ce561268096afe322f25034eeab3508a60027afd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 11:50:42 2016 -0800 label: setTitleLabel commit 51b5536cd2af36896002621f75c7310960c3f5e7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 17:41:08 2016 -0700 UIButton kind of working commit 7562a49a761ef70c383a99d2addefc63d77e279f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 11:11:42 2016 -0700 missing resoruces commit a9890dee5da0104bff6872cc04e8786a6c0a9018 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 10:54:55 2016 -0700 setCenterRect to .cpp file commit c9c4bb55ed3fc55709eca46c43d1bfe5301c317f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 00:19:51 2016 -0700 removed unused paramter commit e47732934cca79c08e6fe96e46ebdf075508e568 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 18:19:31 2016 -0700 flipping works! commit c9769bacd321aeddf84e1772dd270f12194d2f04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 17:57:53 2016 -0700 spirte flip fixes... not finished yet commit 1cbdc8e12cc6d0d2728c06dfabaada001784a178 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:53:16 2016 -0700 centerRect changes commit aeb1b14c00331dabba640f52d79ab0e255fa3407 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:10:41 2016 -0700 changes from v3 commit e7a61c4a20d786c2bc1d6f57e33bf3ac95cb6f21 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 17:01:15 2016 -0700 sprite: rotated slice 9 works as expected commit 91049389426051deb49a9d951364bf60abaf4532 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 15:39:54 2016 -0700 more bug fixes in scale9sprite support commit 9feb12449078441c439df16dc7bcfb4506c7a226 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 13:22:52 2016 -0700 Android's Patch 9 works as expected commit 1cf46afe3e7f7f5f714d30779caefc25a9bb1b3b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 10:18:47 2016 -0700 Sprite: uses capInsets instead of centerRect just to share the same API as Scale9Sprite commit e944fa0248a7eb58012aacb229de1a9b814e0aef Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 18:59:42 2016 -0700 scale9sprite support fixes commit b08765740d480b6ae1491800161b40d88f458767 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:38:47 2016 -0700 more scale9sprite fixes commit 388a34d93de5e6007a2cecea959c929f26427cab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:20:01 2016 -0700 UI::Scale9Sprite refactoring subclass of Sprite... much cleaner! commit c84ec8ee654f74d4b38be2d0a3d7ffe6adbc6faf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 20:58:36 2016 -0700 supports tiled sprites commit d2b18eb47a647b29319488bd53edac9f304acb84 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 19:21:57 2016 -0700 testing tiled sprite commit b4832ab2facc01cbb624db587ede01fe7acf23e8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:53:19 2016 -0700 using correct top-left coordinates for setCenterRect commit 29d8de86a71cc597b2338f59f7951a28ee0c93b2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:46:13 2016 -0700 fixes from scale_sprite9 branch commit ccbe1063bea7db75397ecaf9046aac3dd977a621 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 19:01:50 2016 -0700 updated example commit 24f7f85d4eba80f8e543810dcbc1a02447900bdc Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:47:28 2016 -0700 more fixes in nine slice commit df3358fae68f2d81baf3a8cbe033a4c400ea50da Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:22:14 2016 -0700 anchor point fixes commit 4ac7409bc72425abb0dc747b956ec346fbd1b2fa Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 17:01:48 2016 -0700 support for slice-9 from creator commit a3221375d3a9defc2e03df0b1c2da1b36dfdd491 Merge: 73e5389 d7490d9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 14:13:38 2016 -0700 Merge branch 'sprite_scale9' into creator_cpp_support commit d7490d94896ad0ce8705dc0695252cee34329b5e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 13 14:34:52 2016 -0700 Adds slice9 support for Sprite. how to use it: // points coords sprite->setCenterRect(Rect(x,y,w,h)); // normalized coords sprite->setCenterRectNormalized(Rect(x,y,w,h)); starts scale9sprite in sprite more slice 9 changes sprite 9 slice works? kind of works correct anchor point slice 9 works, at least with non-rotated atlases streched works ok better Y invert code. cleaner, compatible with the previous code yay, scaling workings... need a better api now sets scale correctly yay! works as expected! more fixes and tests better test for box setContentSize() changes size in non-9-slice mode sprites as well setCenterRect() -> setCenterRectNormalized() yet another test adds setPositionNormalized() adds setCenterRect() tests remove devel team from xcode tests: add one more tests fun test! improved test yet another test for slice 9 commit 73e5389ef719880096067d0f7d0bffd6e1f3cfd1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Sun Oct 9 18:54:22 2016 -0700 kind of ProgressBar support commit 4db5e9e7369e93ceba1d9512ab88c26b843c43d5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 7 16:23:54 2016 -0700 new generatred ui files commit 75aa06f3d39df8c6aa898d5e6810b3cd8015c07b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 6 10:44:59 2016 -0700 bette canvas support commit 89beacac478fc7f58ef930963b6393f3da4a743c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 21:47:11 2016 -0700 sprites tests commit 5fe930ad50c2c1b6d868982709c7b659176f9889 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:35:44 2016 -0700 more label tests commit d3f615a097d080d78f2ebd95f3e2388da45f92db Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:08:24 2016 -0700 label tests commit 2a4018922ce8d36117f7092fc324e37cf75fdeab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 21:52:56 2016 -0700 label fixes commit 41fafbd023de63e376d014311605f2b156add307 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 19:14:58 2016 -0700 updated test commit 06919fc28fffbc5a20cd14bdcc2ad2ff997e0da1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 18:50:45 2016 -0700 creator tests: works commit 6e362e7cc7f68dc216b569a7f7f90aaa110c0e4a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Sep 27 23:15:56 2016 -0700 autogen: new data commit e78078b2ad84b4e364827a66f1c459de7384a91d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Sep 26 18:18:57 2016 -0700 fix: initial test for CPP support for Creator * adds more documentation * adds more documentation
2016-11-24 09:59:00 +08:00
if (nullptr != _titleRenderer)
{
2015-04-14 14:23:10 +08:00
_titleRenderer->stopAllActions();
if (_unifySize)
{
Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1.0f, 1.0f);
_titleRenderer->runAction(zoomTitleAction);
}
else
{
_titleRenderer->setScaleX(1.0f);
_titleRenderer->setScaleY(1.0f);
}
}
2014-03-11 17:13:54 +08:00
}
}
else
{
2014-12-23 15:03:31 +08:00
_buttonNormalRenderer->stopAllActions();
_buttonNormalRenderer->setScale(1.0);
2015-04-14 14:23:10 +08:00
Scale9Sprite refactor (#16891) * Squashed commit of the following: commit 026eee59c9ece7fc59d71fead41104f375f72eb5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 21:45:12 2016 -0800 yay! everything works! commit a645c99d44f0d7674e6238afae7628d8d2a030b1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 14:55:31 2016 -0800 more fixes in Scale9Sprite commit 3a688f4ea70c0abe311232c65ed14a7e9acc7611 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 23:06:45 2016 -0800 rotated sprites commit 45e2085df3aa4b52236c817f7db7c1f6602c1e95 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 17:10:44 2016 -0800 android patch 9: fixes is not 100% backward compatible since the previous version had some artifacts. fixed the artifacts. now it renders ok commit 4655d894387fa40a7e63b074a36bfed20e41d5f9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 16:31:29 2016 -0800 sprite: correct size for "fake scale9" commit cb98aba27cc1c82a986268d5b74afb55b6cca2f3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 21:55:51 2016 -0800 sprite: adds setStrechEnabled for backward compatibility and other fixes commit c0fe67aac54cd62e3846810d56f87133f3a7343b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:49:42 2016 -0800 implemts missing functions in scale9sprite commit e471ef318725ccabc9eca2c062e285e9ca4f9a81 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:42:30 2016 -0800 "batched" works commit 33124bfb14d1f275d4b0ffca8989975625a8a76d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:59:38 2016 -0800 more fixes commit 149f8206269843af63a1739885c00ed8d94c239c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:37:12 2016 -0800 scale 9 rotated not fixed yet. but making progress commit 27f98275d94ce00c8d5ff0b6f74b5c22723cc3c3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 15:32:57 2016 -0800 sprite: streching works ok with normal sprites commit 2519498cac8b77a32dee5bdf1805be56fbda5ed6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 12:12:28 2016 -0800 somes fixes... still not working commit 43580d0b4aa976b0200717611a286bf1035c472d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 23:15:22 2016 -0800 more bug fixes related to untrimmed setCenterRect... ...in SCale9Sprite commit 407247616e506afaa0415c58ad7fce38efed0cd9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 22:13:38 2016 -0800 spritecale9: untrimmed vs. trimmed capInsets WIP. there still a few bugs commit 3d845b2af3500be287fabb04bb6ba0ec04dbb401 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 23:11:17 2016 -0800 started progressbar commit 0a44b00daf723869b7105689890f29cd53a62608 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 17:43:23 2016 -0800 adds EditBox test commit 330304bd9b2e762de95c2f27f1ae3ceee83b2fbf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 16:57:08 2016 -0800 adds elastic to scroll view commit a06a35f8691ff56a143953c44acd947b519150b6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:58:29 2016 -0800 yay! scrollview works commit 37748a885c62eca8c00d2c9c11ee103f1d95e71c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:33:58 2016 -0800 yet more scrollview fixes commit a6e563b497adef7b141ac7c92c844d479b244c59 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 14:48:28 2016 -0800 initial scroll view commit 4243edd7548e5533ca03c26d5042f8dc5517445a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 8 17:50:15 2016 -0800 sanity check in frames. missing files commit 159d88603ad22f3c01761b60bacec98d52b9041d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 19:21:00 2016 -0800 three buttons working commit 6764cfc7937a1a81d6993d5e32a21f17457b8e0d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:50:22 2016 -0800 missing files commit 11c1fa3812e706a7d34137fe2626f05ab73ee3e6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:49:59 2016 -0800 button works! commit 26b6de4c28fc973e332dd51fcd763a6249c0b4c2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:19:47 2016 -0800 Scale9: more fixes. complies with odd Rect::ZERO behavior commit ce561268096afe322f25034eeab3508a60027afd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 11:50:42 2016 -0800 label: setTitleLabel commit 51b5536cd2af36896002621f75c7310960c3f5e7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 17:41:08 2016 -0700 UIButton kind of working commit 7562a49a761ef70c383a99d2addefc63d77e279f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 11:11:42 2016 -0700 missing resoruces commit a9890dee5da0104bff6872cc04e8786a6c0a9018 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 10:54:55 2016 -0700 setCenterRect to .cpp file commit c9c4bb55ed3fc55709eca46c43d1bfe5301c317f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 00:19:51 2016 -0700 removed unused paramter commit e47732934cca79c08e6fe96e46ebdf075508e568 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 18:19:31 2016 -0700 flipping works! commit c9769bacd321aeddf84e1772dd270f12194d2f04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 17:57:53 2016 -0700 spirte flip fixes... not finished yet commit 1cbdc8e12cc6d0d2728c06dfabaada001784a178 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:53:16 2016 -0700 centerRect changes commit aeb1b14c00331dabba640f52d79ab0e255fa3407 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:10:41 2016 -0700 changes from v3 commit e7a61c4a20d786c2bc1d6f57e33bf3ac95cb6f21 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 17:01:15 2016 -0700 sprite: rotated slice 9 works as expected commit 91049389426051deb49a9d951364bf60abaf4532 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 15:39:54 2016 -0700 more bug fixes in scale9sprite support commit 9feb12449078441c439df16dc7bcfb4506c7a226 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 13:22:52 2016 -0700 Android's Patch 9 works as expected commit 1cf46afe3e7f7f5f714d30779caefc25a9bb1b3b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 10:18:47 2016 -0700 Sprite: uses capInsets instead of centerRect just to share the same API as Scale9Sprite commit e944fa0248a7eb58012aacb229de1a9b814e0aef Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 18:59:42 2016 -0700 scale9sprite support fixes commit b08765740d480b6ae1491800161b40d88f458767 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:38:47 2016 -0700 more scale9sprite fixes commit 388a34d93de5e6007a2cecea959c929f26427cab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:20:01 2016 -0700 UI::Scale9Sprite refactoring subclass of Sprite... much cleaner! commit c84ec8ee654f74d4b38be2d0a3d7ffe6adbc6faf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 20:58:36 2016 -0700 supports tiled sprites commit d2b18eb47a647b29319488bd53edac9f304acb84 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 19:21:57 2016 -0700 testing tiled sprite commit b4832ab2facc01cbb624db587ede01fe7acf23e8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:53:19 2016 -0700 using correct top-left coordinates for setCenterRect commit 29d8de86a71cc597b2338f59f7951a28ee0c93b2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:46:13 2016 -0700 fixes from scale_sprite9 branch commit ccbe1063bea7db75397ecaf9046aac3dd977a621 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 19:01:50 2016 -0700 updated example commit 24f7f85d4eba80f8e543810dcbc1a02447900bdc Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:47:28 2016 -0700 more fixes in nine slice commit df3358fae68f2d81baf3a8cbe033a4c400ea50da Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:22:14 2016 -0700 anchor point fixes commit 4ac7409bc72425abb0dc747b956ec346fbd1b2fa Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 17:01:48 2016 -0700 support for slice-9 from creator commit a3221375d3a9defc2e03df0b1c2da1b36dfdd491 Merge: 73e5389 d7490d9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 14:13:38 2016 -0700 Merge branch 'sprite_scale9' into creator_cpp_support commit d7490d94896ad0ce8705dc0695252cee34329b5e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 13 14:34:52 2016 -0700 Adds slice9 support for Sprite. how to use it: // points coords sprite->setCenterRect(Rect(x,y,w,h)); // normalized coords sprite->setCenterRectNormalized(Rect(x,y,w,h)); starts scale9sprite in sprite more slice 9 changes sprite 9 slice works? kind of works correct anchor point slice 9 works, at least with non-rotated atlases streched works ok better Y invert code. cleaner, compatible with the previous code yay, scaling workings... need a better api now sets scale correctly yay! works as expected! more fixes and tests better test for box setContentSize() changes size in non-9-slice mode sprites as well setCenterRect() -> setCenterRectNormalized() yet another test adds setPositionNormalized() adds setCenterRect() tests remove devel team from xcode tests: add one more tests fun test! improved test yet another test for slice 9 commit 73e5389ef719880096067d0f7d0bffd6e1f3cfd1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Sun Oct 9 18:54:22 2016 -0700 kind of ProgressBar support commit 4db5e9e7369e93ceba1d9512ab88c26b843c43d5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 7 16:23:54 2016 -0700 new generatred ui files commit 75aa06f3d39df8c6aa898d5e6810b3cd8015c07b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 6 10:44:59 2016 -0700 bette canvas support commit 89beacac478fc7f58ef930963b6393f3da4a743c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 21:47:11 2016 -0700 sprites tests commit 5fe930ad50c2c1b6d868982709c7b659176f9889 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:35:44 2016 -0700 more label tests commit d3f615a097d080d78f2ebd95f3e2388da45f92db Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:08:24 2016 -0700 label tests commit 2a4018922ce8d36117f7092fc324e37cf75fdeab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 21:52:56 2016 -0700 label fixes commit 41fafbd023de63e376d014311605f2b156add307 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 19:14:58 2016 -0700 updated test commit 06919fc28fffbc5a20cd14bdcc2ad2ff997e0da1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 18:50:45 2016 -0700 creator tests: works commit 6e362e7cc7f68dc216b569a7f7f90aaa110c0e4a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Sep 27 23:15:56 2016 -0700 autogen: new data commit e78078b2ad84b4e364827a66f1c459de7384a91d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Sep 26 18:18:57 2016 -0700 fix: initial test for CPP support for Creator * adds more documentation * adds more documentation
2016-11-24 09:59:00 +08:00
if (nullptr != _titleRenderer)
2015-04-14 14:23:10 +08:00
{
_titleRenderer->stopAllActions();
_titleRenderer->setScaleX(1.0f);
_titleRenderer->setScaleY(1.0f);
}
2014-03-11 17:13:54 +08:00
}
}
void Button::onPressStateChangedToPressed()
{
2014-12-23 15:03:31 +08:00
_buttonNormalRenderer->setState(Scale9Sprite::State::NORMAL);
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
if (_pressedTextureLoaded)
{
_buttonNormalRenderer->setVisible(false);
_buttonClickedRenderer->setVisible(true);
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->setVisible(false);
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
if (_pressedActionEnabled)
{
2014-09-13 22:08:02 +08:00
_buttonNormalRenderer->stopAllActions();
_buttonClickedRenderer->stopAllActions();
2015-04-14 14:23:10 +08:00
2014-12-23 15:03:31 +08:00
Action *zoomAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP,
1.0f + _zoomScale,
1.0f + _zoomScale);
2014-09-13 22:08:02 +08:00
_buttonClickedRenderer->runAction(zoomAction);
2015-04-14 14:23:10 +08:00
_buttonNormalRenderer->setScale(1.0f + _zoomScale,
1.0f + _zoomScale);
2015-04-14 14:23:10 +08:00
Scale9Sprite refactor (#16891) * Squashed commit of the following: commit 026eee59c9ece7fc59d71fead41104f375f72eb5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 21:45:12 2016 -0800 yay! everything works! commit a645c99d44f0d7674e6238afae7628d8d2a030b1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 14:55:31 2016 -0800 more fixes in Scale9Sprite commit 3a688f4ea70c0abe311232c65ed14a7e9acc7611 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 23:06:45 2016 -0800 rotated sprites commit 45e2085df3aa4b52236c817f7db7c1f6602c1e95 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 17:10:44 2016 -0800 android patch 9: fixes is not 100% backward compatible since the previous version had some artifacts. fixed the artifacts. now it renders ok commit 4655d894387fa40a7e63b074a36bfed20e41d5f9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 16:31:29 2016 -0800 sprite: correct size for "fake scale9" commit cb98aba27cc1c82a986268d5b74afb55b6cca2f3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 21:55:51 2016 -0800 sprite: adds setStrechEnabled for backward compatibility and other fixes commit c0fe67aac54cd62e3846810d56f87133f3a7343b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:49:42 2016 -0800 implemts missing functions in scale9sprite commit e471ef318725ccabc9eca2c062e285e9ca4f9a81 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:42:30 2016 -0800 "batched" works commit 33124bfb14d1f275d4b0ffca8989975625a8a76d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:59:38 2016 -0800 more fixes commit 149f8206269843af63a1739885c00ed8d94c239c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:37:12 2016 -0800 scale 9 rotated not fixed yet. but making progress commit 27f98275d94ce00c8d5ff0b6f74b5c22723cc3c3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 15:32:57 2016 -0800 sprite: streching works ok with normal sprites commit 2519498cac8b77a32dee5bdf1805be56fbda5ed6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 12:12:28 2016 -0800 somes fixes... still not working commit 43580d0b4aa976b0200717611a286bf1035c472d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 23:15:22 2016 -0800 more bug fixes related to untrimmed setCenterRect... ...in SCale9Sprite commit 407247616e506afaa0415c58ad7fce38efed0cd9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 22:13:38 2016 -0800 spritecale9: untrimmed vs. trimmed capInsets WIP. there still a few bugs commit 3d845b2af3500be287fabb04bb6ba0ec04dbb401 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 23:11:17 2016 -0800 started progressbar commit 0a44b00daf723869b7105689890f29cd53a62608 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 17:43:23 2016 -0800 adds EditBox test commit 330304bd9b2e762de95c2f27f1ae3ceee83b2fbf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 16:57:08 2016 -0800 adds elastic to scroll view commit a06a35f8691ff56a143953c44acd947b519150b6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:58:29 2016 -0800 yay! scrollview works commit 37748a885c62eca8c00d2c9c11ee103f1d95e71c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:33:58 2016 -0800 yet more scrollview fixes commit a6e563b497adef7b141ac7c92c844d479b244c59 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 14:48:28 2016 -0800 initial scroll view commit 4243edd7548e5533ca03c26d5042f8dc5517445a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 8 17:50:15 2016 -0800 sanity check in frames. missing files commit 159d88603ad22f3c01761b60bacec98d52b9041d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 19:21:00 2016 -0800 three buttons working commit 6764cfc7937a1a81d6993d5e32a21f17457b8e0d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:50:22 2016 -0800 missing files commit 11c1fa3812e706a7d34137fe2626f05ab73ee3e6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:49:59 2016 -0800 button works! commit 26b6de4c28fc973e332dd51fcd763a6249c0b4c2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:19:47 2016 -0800 Scale9: more fixes. complies with odd Rect::ZERO behavior commit ce561268096afe322f25034eeab3508a60027afd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 11:50:42 2016 -0800 label: setTitleLabel commit 51b5536cd2af36896002621f75c7310960c3f5e7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 17:41:08 2016 -0700 UIButton kind of working commit 7562a49a761ef70c383a99d2addefc63d77e279f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 11:11:42 2016 -0700 missing resoruces commit a9890dee5da0104bff6872cc04e8786a6c0a9018 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 10:54:55 2016 -0700 setCenterRect to .cpp file commit c9c4bb55ed3fc55709eca46c43d1bfe5301c317f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 00:19:51 2016 -0700 removed unused paramter commit e47732934cca79c08e6fe96e46ebdf075508e568 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 18:19:31 2016 -0700 flipping works! commit c9769bacd321aeddf84e1772dd270f12194d2f04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 17:57:53 2016 -0700 spirte flip fixes... not finished yet commit 1cbdc8e12cc6d0d2728c06dfabaada001784a178 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:53:16 2016 -0700 centerRect changes commit aeb1b14c00331dabba640f52d79ab0e255fa3407 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:10:41 2016 -0700 changes from v3 commit e7a61c4a20d786c2bc1d6f57e33bf3ac95cb6f21 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 17:01:15 2016 -0700 sprite: rotated slice 9 works as expected commit 91049389426051deb49a9d951364bf60abaf4532 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 15:39:54 2016 -0700 more bug fixes in scale9sprite support commit 9feb12449078441c439df16dc7bcfb4506c7a226 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 13:22:52 2016 -0700 Android's Patch 9 works as expected commit 1cf46afe3e7f7f5f714d30779caefc25a9bb1b3b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 10:18:47 2016 -0700 Sprite: uses capInsets instead of centerRect just to share the same API as Scale9Sprite commit e944fa0248a7eb58012aacb229de1a9b814e0aef Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 18:59:42 2016 -0700 scale9sprite support fixes commit b08765740d480b6ae1491800161b40d88f458767 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:38:47 2016 -0700 more scale9sprite fixes commit 388a34d93de5e6007a2cecea959c929f26427cab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:20:01 2016 -0700 UI::Scale9Sprite refactoring subclass of Sprite... much cleaner! commit c84ec8ee654f74d4b38be2d0a3d7ffe6adbc6faf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 20:58:36 2016 -0700 supports tiled sprites commit d2b18eb47a647b29319488bd53edac9f304acb84 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 19:21:57 2016 -0700 testing tiled sprite commit b4832ab2facc01cbb624db587ede01fe7acf23e8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:53:19 2016 -0700 using correct top-left coordinates for setCenterRect commit 29d8de86a71cc597b2338f59f7951a28ee0c93b2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:46:13 2016 -0700 fixes from scale_sprite9 branch commit ccbe1063bea7db75397ecaf9046aac3dd977a621 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 19:01:50 2016 -0700 updated example commit 24f7f85d4eba80f8e543810dcbc1a02447900bdc Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:47:28 2016 -0700 more fixes in nine slice commit df3358fae68f2d81baf3a8cbe033a4c400ea50da Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:22:14 2016 -0700 anchor point fixes commit 4ac7409bc72425abb0dc747b956ec346fbd1b2fa Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 17:01:48 2016 -0700 support for slice-9 from creator commit a3221375d3a9defc2e03df0b1c2da1b36dfdd491 Merge: 73e5389 d7490d9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 14:13:38 2016 -0700 Merge branch 'sprite_scale9' into creator_cpp_support commit d7490d94896ad0ce8705dc0695252cee34329b5e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 13 14:34:52 2016 -0700 Adds slice9 support for Sprite. how to use it: // points coords sprite->setCenterRect(Rect(x,y,w,h)); // normalized coords sprite->setCenterRectNormalized(Rect(x,y,w,h)); starts scale9sprite in sprite more slice 9 changes sprite 9 slice works? kind of works correct anchor point slice 9 works, at least with non-rotated atlases streched works ok better Y invert code. cleaner, compatible with the previous code yay, scaling workings... need a better api now sets scale correctly yay! works as expected! more fixes and tests better test for box setContentSize() changes size in non-9-slice mode sprites as well setCenterRect() -> setCenterRectNormalized() yet another test adds setPositionNormalized() adds setCenterRect() tests remove devel team from xcode tests: add one more tests fun test! improved test yet another test for slice 9 commit 73e5389ef719880096067d0f7d0bffd6e1f3cfd1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Sun Oct 9 18:54:22 2016 -0700 kind of ProgressBar support commit 4db5e9e7369e93ceba1d9512ab88c26b843c43d5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 7 16:23:54 2016 -0700 new generatred ui files commit 75aa06f3d39df8c6aa898d5e6810b3cd8015c07b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 6 10:44:59 2016 -0700 bette canvas support commit 89beacac478fc7f58ef930963b6393f3da4a743c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 21:47:11 2016 -0700 sprites tests commit 5fe930ad50c2c1b6d868982709c7b659176f9889 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:35:44 2016 -0700 more label tests commit d3f615a097d080d78f2ebd95f3e2388da45f92db Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:08:24 2016 -0700 label tests commit 2a4018922ce8d36117f7092fc324e37cf75fdeab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 21:52:56 2016 -0700 label fixes commit 41fafbd023de63e376d014311605f2b156add307 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 19:14:58 2016 -0700 updated test commit 06919fc28fffbc5a20cd14bdcc2ad2ff997e0da1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 18:50:45 2016 -0700 creator tests: works commit 6e362e7cc7f68dc216b569a7f7f90aaa110c0e4a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Sep 27 23:15:56 2016 -0700 autogen: new data commit e78078b2ad84b4e364827a66f1c459de7384a91d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Sep 26 18:18:57 2016 -0700 fix: initial test for CPP support for Creator * adds more documentation * adds more documentation
2016-11-24 09:59:00 +08:00
if (nullptr != _titleRenderer)
2015-04-14 14:23:10 +08:00
{
_titleRenderer->stopAllActions();
Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP,
1.0f + _zoomScale, 1.0f + _zoomScale);
_titleRenderer->runAction(zoomTitleAction);
}
2014-03-11 17:13:54 +08:00
}
}
else
{
_buttonNormalRenderer->setVisible(true);
_buttonClickedRenderer->setVisible(true);
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->setVisible(false);
2015-04-14 14:23:10 +08:00
2014-12-23 15:03:31 +08:00
_buttonNormalRenderer->stopAllActions();
_buttonNormalRenderer->setScale(1.0f +_zoomScale, 1.0f + _zoomScale);
2015-04-14 14:23:10 +08:00
Scale9Sprite refactor (#16891) * Squashed commit of the following: commit 026eee59c9ece7fc59d71fead41104f375f72eb5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 21:45:12 2016 -0800 yay! everything works! commit a645c99d44f0d7674e6238afae7628d8d2a030b1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 14:55:31 2016 -0800 more fixes in Scale9Sprite commit 3a688f4ea70c0abe311232c65ed14a7e9acc7611 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 23:06:45 2016 -0800 rotated sprites commit 45e2085df3aa4b52236c817f7db7c1f6602c1e95 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 17:10:44 2016 -0800 android patch 9: fixes is not 100% backward compatible since the previous version had some artifacts. fixed the artifacts. now it renders ok commit 4655d894387fa40a7e63b074a36bfed20e41d5f9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 16:31:29 2016 -0800 sprite: correct size for "fake scale9" commit cb98aba27cc1c82a986268d5b74afb55b6cca2f3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 21:55:51 2016 -0800 sprite: adds setStrechEnabled for backward compatibility and other fixes commit c0fe67aac54cd62e3846810d56f87133f3a7343b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:49:42 2016 -0800 implemts missing functions in scale9sprite commit e471ef318725ccabc9eca2c062e285e9ca4f9a81 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:42:30 2016 -0800 "batched" works commit 33124bfb14d1f275d4b0ffca8989975625a8a76d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:59:38 2016 -0800 more fixes commit 149f8206269843af63a1739885c00ed8d94c239c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:37:12 2016 -0800 scale 9 rotated not fixed yet. but making progress commit 27f98275d94ce00c8d5ff0b6f74b5c22723cc3c3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 15:32:57 2016 -0800 sprite: streching works ok with normal sprites commit 2519498cac8b77a32dee5bdf1805be56fbda5ed6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 12:12:28 2016 -0800 somes fixes... still not working commit 43580d0b4aa976b0200717611a286bf1035c472d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 23:15:22 2016 -0800 more bug fixes related to untrimmed setCenterRect... ...in SCale9Sprite commit 407247616e506afaa0415c58ad7fce38efed0cd9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 22:13:38 2016 -0800 spritecale9: untrimmed vs. trimmed capInsets WIP. there still a few bugs commit 3d845b2af3500be287fabb04bb6ba0ec04dbb401 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 23:11:17 2016 -0800 started progressbar commit 0a44b00daf723869b7105689890f29cd53a62608 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 17:43:23 2016 -0800 adds EditBox test commit 330304bd9b2e762de95c2f27f1ae3ceee83b2fbf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 16:57:08 2016 -0800 adds elastic to scroll view commit a06a35f8691ff56a143953c44acd947b519150b6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:58:29 2016 -0800 yay! scrollview works commit 37748a885c62eca8c00d2c9c11ee103f1d95e71c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:33:58 2016 -0800 yet more scrollview fixes commit a6e563b497adef7b141ac7c92c844d479b244c59 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 14:48:28 2016 -0800 initial scroll view commit 4243edd7548e5533ca03c26d5042f8dc5517445a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 8 17:50:15 2016 -0800 sanity check in frames. missing files commit 159d88603ad22f3c01761b60bacec98d52b9041d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 19:21:00 2016 -0800 three buttons working commit 6764cfc7937a1a81d6993d5e32a21f17457b8e0d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:50:22 2016 -0800 missing files commit 11c1fa3812e706a7d34137fe2626f05ab73ee3e6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:49:59 2016 -0800 button works! commit 26b6de4c28fc973e332dd51fcd763a6249c0b4c2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:19:47 2016 -0800 Scale9: more fixes. complies with odd Rect::ZERO behavior commit ce561268096afe322f25034eeab3508a60027afd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 11:50:42 2016 -0800 label: setTitleLabel commit 51b5536cd2af36896002621f75c7310960c3f5e7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 17:41:08 2016 -0700 UIButton kind of working commit 7562a49a761ef70c383a99d2addefc63d77e279f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 11:11:42 2016 -0700 missing resoruces commit a9890dee5da0104bff6872cc04e8786a6c0a9018 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 10:54:55 2016 -0700 setCenterRect to .cpp file commit c9c4bb55ed3fc55709eca46c43d1bfe5301c317f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 00:19:51 2016 -0700 removed unused paramter commit e47732934cca79c08e6fe96e46ebdf075508e568 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 18:19:31 2016 -0700 flipping works! commit c9769bacd321aeddf84e1772dd270f12194d2f04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 17:57:53 2016 -0700 spirte flip fixes... not finished yet commit 1cbdc8e12cc6d0d2728c06dfabaada001784a178 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:53:16 2016 -0700 centerRect changes commit aeb1b14c00331dabba640f52d79ab0e255fa3407 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:10:41 2016 -0700 changes from v3 commit e7a61c4a20d786c2bc1d6f57e33bf3ac95cb6f21 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 17:01:15 2016 -0700 sprite: rotated slice 9 works as expected commit 91049389426051deb49a9d951364bf60abaf4532 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 15:39:54 2016 -0700 more bug fixes in scale9sprite support commit 9feb12449078441c439df16dc7bcfb4506c7a226 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 13:22:52 2016 -0700 Android's Patch 9 works as expected commit 1cf46afe3e7f7f5f714d30779caefc25a9bb1b3b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 10:18:47 2016 -0700 Sprite: uses capInsets instead of centerRect just to share the same API as Scale9Sprite commit e944fa0248a7eb58012aacb229de1a9b814e0aef Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 18:59:42 2016 -0700 scale9sprite support fixes commit b08765740d480b6ae1491800161b40d88f458767 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:38:47 2016 -0700 more scale9sprite fixes commit 388a34d93de5e6007a2cecea959c929f26427cab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:20:01 2016 -0700 UI::Scale9Sprite refactoring subclass of Sprite... much cleaner! commit c84ec8ee654f74d4b38be2d0a3d7ffe6adbc6faf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 20:58:36 2016 -0700 supports tiled sprites commit d2b18eb47a647b29319488bd53edac9f304acb84 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 19:21:57 2016 -0700 testing tiled sprite commit b4832ab2facc01cbb624db587ede01fe7acf23e8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:53:19 2016 -0700 using correct top-left coordinates for setCenterRect commit 29d8de86a71cc597b2338f59f7951a28ee0c93b2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:46:13 2016 -0700 fixes from scale_sprite9 branch commit ccbe1063bea7db75397ecaf9046aac3dd977a621 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 19:01:50 2016 -0700 updated example commit 24f7f85d4eba80f8e543810dcbc1a02447900bdc Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:47:28 2016 -0700 more fixes in nine slice commit df3358fae68f2d81baf3a8cbe033a4c400ea50da Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:22:14 2016 -0700 anchor point fixes commit 4ac7409bc72425abb0dc747b956ec346fbd1b2fa Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 17:01:48 2016 -0700 support for slice-9 from creator commit a3221375d3a9defc2e03df0b1c2da1b36dfdd491 Merge: 73e5389 d7490d9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 14:13:38 2016 -0700 Merge branch 'sprite_scale9' into creator_cpp_support commit d7490d94896ad0ce8705dc0695252cee34329b5e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 13 14:34:52 2016 -0700 Adds slice9 support for Sprite. how to use it: // points coords sprite->setCenterRect(Rect(x,y,w,h)); // normalized coords sprite->setCenterRectNormalized(Rect(x,y,w,h)); starts scale9sprite in sprite more slice 9 changes sprite 9 slice works? kind of works correct anchor point slice 9 works, at least with non-rotated atlases streched works ok better Y invert code. cleaner, compatible with the previous code yay, scaling workings... need a better api now sets scale correctly yay! works as expected! more fixes and tests better test for box setContentSize() changes size in non-9-slice mode sprites as well setCenterRect() -> setCenterRectNormalized() yet another test adds setPositionNormalized() adds setCenterRect() tests remove devel team from xcode tests: add one more tests fun test! improved test yet another test for slice 9 commit 73e5389ef719880096067d0f7d0bffd6e1f3cfd1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Sun Oct 9 18:54:22 2016 -0700 kind of ProgressBar support commit 4db5e9e7369e93ceba1d9512ab88c26b843c43d5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 7 16:23:54 2016 -0700 new generatred ui files commit 75aa06f3d39df8c6aa898d5e6810b3cd8015c07b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 6 10:44:59 2016 -0700 bette canvas support commit 89beacac478fc7f58ef930963b6393f3da4a743c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 21:47:11 2016 -0700 sprites tests commit 5fe930ad50c2c1b6d868982709c7b659176f9889 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:35:44 2016 -0700 more label tests commit d3f615a097d080d78f2ebd95f3e2388da45f92db Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:08:24 2016 -0700 label tests commit 2a4018922ce8d36117f7092fc324e37cf75fdeab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 21:52:56 2016 -0700 label fixes commit 41fafbd023de63e376d014311605f2b156add307 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 19:14:58 2016 -0700 updated test commit 06919fc28fffbc5a20cd14bdcc2ad2ff997e0da1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 18:50:45 2016 -0700 creator tests: works commit 6e362e7cc7f68dc216b569a7f7f90aaa110c0e4a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Sep 27 23:15:56 2016 -0700 autogen: new data commit e78078b2ad84b4e364827a66f1c459de7384a91d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Sep 26 18:18:57 2016 -0700 fix: initial test for CPP support for Creator * adds more documentation * adds more documentation
2016-11-24 09:59:00 +08:00
if (nullptr != _titleRenderer)
2015-04-14 14:23:10 +08:00
{
_titleRenderer->stopAllActions();
_titleRenderer->setScaleX(1.0f + _zoomScale);
_titleRenderer->setScaleY(1.0f + _zoomScale);
}
2014-03-11 17:13:54 +08:00
}
}
void Button::onPressStateChangedToDisabled()
{
2014-12-23 15:03:31 +08:00
//if disable resource is null
if (!_disabledTextureLoaded)
{
if (_normalTextureLoaded)
{
_buttonNormalRenderer->setState(Scale9Sprite::State::GRAY);
}
}
else
{
_buttonNormalRenderer->setVisible(false);
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->setVisible(true);
2014-12-23 15:03:31 +08:00
}
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
_buttonClickedRenderer->setVisible(false);
_buttonNormalRenderer->setScale(1.0);
_buttonClickedRenderer->setScale(1.0);
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
2014-04-17 14:08:25 +08:00
void Button::updateTitleLocation()
2014-03-11 17:13:54 +08:00
{
_titleRenderer->setPosition(_contentSize.width * 0.5f, _contentSize.height * 0.5f);
2014-03-11 17:13:54 +08:00
}
2014-10-11 12:13:04 +08:00
void Button::updateContentSize()
{
2014-10-24 17:38:32 +08:00
if (_unifySize)
{
if (_scale9Enabled)
{
ProtectedNode::setContentSize(_customSize);
}
else
{
Size s = getNormalSize();
ProtectedNode::setContentSize(s);
}
onSizeChanged();
return;
}
2015-04-14 14:23:10 +08:00
if (_ignoreSize)
{
2014-10-24 17:38:32 +08:00
this->setContentSize(getVirtualRendererSize());
}
2014-10-11 12:13:04 +08:00
}
2014-03-11 17:13:54 +08:00
void Button::onSizeChanged()
{
Widget::onSizeChanged();
Scale9Sprite refactor (#16891) * Squashed commit of the following: commit 026eee59c9ece7fc59d71fead41104f375f72eb5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 21:45:12 2016 -0800 yay! everything works! commit a645c99d44f0d7674e6238afae7628d8d2a030b1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 22 14:55:31 2016 -0800 more fixes in Scale9Sprite commit 3a688f4ea70c0abe311232c65ed14a7e9acc7611 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 23:06:45 2016 -0800 rotated sprites commit 45e2085df3aa4b52236c817f7db7c1f6602c1e95 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 17:10:44 2016 -0800 android patch 9: fixes is not 100% backward compatible since the previous version had some artifacts. fixed the artifacts. now it renders ok commit 4655d894387fa40a7e63b074a36bfed20e41d5f9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 21 16:31:29 2016 -0800 sprite: correct size for "fake scale9" commit cb98aba27cc1c82a986268d5b74afb55b6cca2f3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 21:55:51 2016 -0800 sprite: adds setStrechEnabled for backward compatibility and other fixes commit c0fe67aac54cd62e3846810d56f87133f3a7343b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:49:42 2016 -0800 implemts missing functions in scale9sprite commit e471ef318725ccabc9eca2c062e285e9ca4f9a81 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Nov 18 18:42:30 2016 -0800 "batched" works commit 33124bfb14d1f275d4b0ffca8989975625a8a76d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:59:38 2016 -0800 more fixes commit 149f8206269843af63a1739885c00ed8d94c239c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 18:37:12 2016 -0800 scale 9 rotated not fixed yet. but making progress commit 27f98275d94ce00c8d5ff0b6f74b5c22723cc3c3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 15:32:57 2016 -0800 sprite: streching works ok with normal sprites commit 2519498cac8b77a32dee5bdf1805be56fbda5ed6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 16 12:12:28 2016 -0800 somes fixes... still not working commit 43580d0b4aa976b0200717611a286bf1035c472d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 23:15:22 2016 -0800 more bug fixes related to untrimmed setCenterRect... ...in SCale9Sprite commit 407247616e506afaa0415c58ad7fce38efed0cd9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 15 22:13:38 2016 -0800 spritecale9: untrimmed vs. trimmed capInsets WIP. there still a few bugs commit 3d845b2af3500be287fabb04bb6ba0ec04dbb401 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 23:11:17 2016 -0800 started progressbar commit 0a44b00daf723869b7105689890f29cd53a62608 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 14 17:43:23 2016 -0800 adds EditBox test commit 330304bd9b2e762de95c2f27f1ae3ceee83b2fbf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 16:57:08 2016 -0800 adds elastic to scroll view commit a06a35f8691ff56a143953c44acd947b519150b6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:58:29 2016 -0800 yay! scrollview works commit 37748a885c62eca8c00d2c9c11ee103f1d95e71c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 15:33:58 2016 -0800 yet more scrollview fixes commit a6e563b497adef7b141ac7c92c844d479b244c59 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 9 14:48:28 2016 -0800 initial scroll view commit 4243edd7548e5533ca03c26d5042f8dc5517445a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Nov 8 17:50:15 2016 -0800 sanity check in frames. missing files commit 159d88603ad22f3c01761b60bacec98d52b9041d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 19:21:00 2016 -0800 three buttons working commit 6764cfc7937a1a81d6993d5e32a21f17457b8e0d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:50:22 2016 -0800 missing files commit 11c1fa3812e706a7d34137fe2626f05ab73ee3e6 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:49:59 2016 -0800 button works! commit 26b6de4c28fc973e332dd51fcd763a6249c0b4c2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 18:19:47 2016 -0800 Scale9: more fixes. complies with odd Rect::ZERO behavior commit ce561268096afe322f25034eeab3508a60027afd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Nov 7 11:50:42 2016 -0800 label: setTitleLabel commit 51b5536cd2af36896002621f75c7310960c3f5e7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 17:41:08 2016 -0700 UIButton kind of working commit 7562a49a761ef70c383a99d2addefc63d77e279f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 11:11:42 2016 -0700 missing resoruces commit a9890dee5da0104bff6872cc04e8786a6c0a9018 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 10:54:55 2016 -0700 setCenterRect to .cpp file commit c9c4bb55ed3fc55709eca46c43d1bfe5301c317f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Nov 2 00:19:51 2016 -0700 removed unused paramter commit e47732934cca79c08e6fe96e46ebdf075508e568 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 18:19:31 2016 -0700 flipping works! commit c9769bacd321aeddf84e1772dd270f12194d2f04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 17:57:53 2016 -0700 spirte flip fixes... not finished yet commit 1cbdc8e12cc6d0d2728c06dfabaada001784a178 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:53:16 2016 -0700 centerRect changes commit aeb1b14c00331dabba640f52d79ab0e255fa3407 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 28 09:10:41 2016 -0700 changes from v3 commit e7a61c4a20d786c2bc1d6f57e33bf3ac95cb6f21 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 17:01:15 2016 -0700 sprite: rotated slice 9 works as expected commit 91049389426051deb49a9d951364bf60abaf4532 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 15:39:54 2016 -0700 more bug fixes in scale9sprite support commit 9feb12449078441c439df16dc7bcfb4506c7a226 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 13:22:52 2016 -0700 Android's Patch 9 works as expected commit 1cf46afe3e7f7f5f714d30779caefc25a9bb1b3b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 26 10:18:47 2016 -0700 Sprite: uses capInsets instead of centerRect just to share the same API as Scale9Sprite commit e944fa0248a7eb58012aacb229de1a9b814e0aef Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 18:59:42 2016 -0700 scale9sprite support fixes commit b08765740d480b6ae1491800161b40d88f458767 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:38:47 2016 -0700 more scale9sprite fixes commit 388a34d93de5e6007a2cecea959c929f26427cab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 25 17:20:01 2016 -0700 UI::Scale9Sprite refactoring subclass of Sprite... much cleaner! commit c84ec8ee654f74d4b38be2d0a3d7ffe6adbc6faf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 20:58:36 2016 -0700 supports tiled sprites commit d2b18eb47a647b29319488bd53edac9f304acb84 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 19:21:57 2016 -0700 testing tiled sprite commit b4832ab2facc01cbb624db587ede01fe7acf23e8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:53:19 2016 -0700 using correct top-left coordinates for setCenterRect commit 29d8de86a71cc597b2338f59f7951a28ee0c93b2 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Oct 24 16:46:13 2016 -0700 fixes from scale_sprite9 branch commit ccbe1063bea7db75397ecaf9046aac3dd977a621 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 19:01:50 2016 -0700 updated example commit 24f7f85d4eba80f8e543810dcbc1a02447900bdc Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:47:28 2016 -0700 more fixes in nine slice commit df3358fae68f2d81baf3a8cbe033a4c400ea50da Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 18:22:14 2016 -0700 anchor point fixes commit 4ac7409bc72425abb0dc747b956ec346fbd1b2fa Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 17:01:48 2016 -0700 support for slice-9 from creator commit a3221375d3a9defc2e03df0b1c2da1b36dfdd491 Merge: 73e5389 d7490d9 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 20 14:13:38 2016 -0700 Merge branch 'sprite_scale9' into creator_cpp_support commit d7490d94896ad0ce8705dc0695252cee34329b5e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 13 14:34:52 2016 -0700 Adds slice9 support for Sprite. how to use it: // points coords sprite->setCenterRect(Rect(x,y,w,h)); // normalized coords sprite->setCenterRectNormalized(Rect(x,y,w,h)); starts scale9sprite in sprite more slice 9 changes sprite 9 slice works? kind of works correct anchor point slice 9 works, at least with non-rotated atlases streched works ok better Y invert code. cleaner, compatible with the previous code yay, scaling workings... need a better api now sets scale correctly yay! works as expected! more fixes and tests better test for box setContentSize() changes size in non-9-slice mode sprites as well setCenterRect() -> setCenterRectNormalized() yet another test adds setPositionNormalized() adds setCenterRect() tests remove devel team from xcode tests: add one more tests fun test! improved test yet another test for slice 9 commit 73e5389ef719880096067d0f7d0bffd6e1f3cfd1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Sun Oct 9 18:54:22 2016 -0700 kind of ProgressBar support commit 4db5e9e7369e93ceba1d9512ab88c26b843c43d5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Oct 7 16:23:54 2016 -0700 new generatred ui files commit 75aa06f3d39df8c6aa898d5e6810b3cd8015c07b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Oct 6 10:44:59 2016 -0700 bette canvas support commit 89beacac478fc7f58ef930963b6393f3da4a743c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 21:47:11 2016 -0700 sprites tests commit 5fe930ad50c2c1b6d868982709c7b659176f9889 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:35:44 2016 -0700 more label tests commit d3f615a097d080d78f2ebd95f3e2388da45f92db Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Oct 5 18:08:24 2016 -0700 label tests commit 2a4018922ce8d36117f7092fc324e37cf75fdeab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 21:52:56 2016 -0700 label fixes commit 41fafbd023de63e376d014311605f2b156add307 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 19:14:58 2016 -0700 updated test commit 06919fc28fffbc5a20cd14bdcc2ad2ff997e0da1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Oct 4 18:50:45 2016 -0700 creator tests: works commit 6e362e7cc7f68dc216b569a7f7f90aaa110c0e4a Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Sep 27 23:15:56 2016 -0700 autogen: new data commit e78078b2ad84b4e364827a66f1c459de7384a91d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Sep 26 18:18:57 2016 -0700 fix: initial test for CPP support for Creator * adds more documentation * adds more documentation
2016-11-24 09:59:00 +08:00
if (nullptr != _titleRenderer)
2015-04-14 14:23:10 +08:00
{
updateTitleLocation();
}
2014-04-17 14:08:25 +08:00
_normalTextureAdaptDirty = true;
_pressedTextureAdaptDirty = true;
_disabledTextureAdaptDirty = true;
}
2015-04-14 14:23:10 +08:00
2014-04-17 14:08:25 +08:00
void Button::adaptRenderers()
{
if (_normalTextureAdaptDirty)
{
normalTextureScaleChangedWithSize();
_normalTextureAdaptDirty = false;
}
2015-04-14 14:23:10 +08:00
2014-04-17 14:08:25 +08:00
if (_pressedTextureAdaptDirty)
{
pressedTextureScaleChangedWithSize();
_pressedTextureAdaptDirty = false;
}
2015-04-14 14:23:10 +08:00
2014-04-17 14:08:25 +08:00
if (_disabledTextureAdaptDirty)
{
disabledTextureScaleChangedWithSize();
_disabledTextureAdaptDirty = false;
}
2014-03-11 17:13:54 +08:00
}
2014-09-12 14:39:22 +08:00
Size Button::getVirtualRendererSize() const
2014-03-11 17:13:54 +08:00
{
2014-10-25 18:00:57 +08:00
if (_unifySize)
{
return this->getNormalSize();
}
2015-04-14 14:23:10 +08:00
if (nullptr != _titleRenderer)
{
2015-04-14 14:23:10 +08:00
Size titleSize = _titleRenderer->getContentSize();
2020-08-18 14:29:09 +08:00
if (!_normalTextureLoaded && !_titleRenderer->getString().empty())
2015-04-14 14:23:10 +08:00
{
return titleSize;
}
2014-09-12 13:50:13 +08:00
}
2014-03-11 17:13:54 +08:00
return _normalTextureSize;
}
Node* Button::getVirtualRenderer()
{
if (_bright)
{
switch (_brightStyle)
{
case BrightStyle::NORMAL:
2014-03-11 17:13:54 +08:00
return _buttonNormalRenderer;
case BrightStyle::HIGHLIGHT:
2014-03-11 17:13:54 +08:00
return _buttonClickedRenderer;
default:
return nullptr;
}
}
else
{
2015-09-14 14:27:51 +08:00
return _buttonDisabledRenderer;
2014-03-11 17:13:54 +08:00
}
}
void Button::normalTextureScaleChangedWithSize()
{
_buttonNormalRenderer->setPreferredSize(_contentSize);
2014-09-15 09:28:56 +08:00
2014-04-17 14:08:25 +08:00
_buttonNormalRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
2014-03-11 17:13:54 +08:00
}
void Button::pressedTextureScaleChangedWithSize()
{
_buttonClickedRenderer->setPreferredSize(_contentSize);
2014-10-24 17:38:32 +08:00
2014-04-17 14:08:25 +08:00
_buttonClickedRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
2014-03-11 17:13:54 +08:00
}
void Button::disabledTextureScaleChangedWithSize()
{
_buttonDisabledRenderer->setPreferredSize(_contentSize);
2015-09-14 14:27:51 +08:00
_buttonDisabledRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
2014-03-11 17:13:54 +08:00
}
void Button::setPressedActionEnabled(bool enabled)
{
_pressedActionEnabled = enabled;
}
void Button::setTitleAlignment(TextHAlignment hAlignment)
{
createTitleRendererIfNull();
_titleRenderer->setAlignment(hAlignment);
}
void Button::setTitleAlignment(TextHAlignment hAlignment, TextVAlignment vAlignment)
{
createTitleRendererIfNull();
_titleRenderer->setAlignment(hAlignment, vAlignment);
}
2014-03-11 17:13:54 +08:00
void Button::setTitleText(const std::string& text)
{
if (text.compare(getTitleText()) == 0) {
return;
}
createTitleRendererIfNull();
if(getTitleFontSize() <= 0) {
setTitleFontSize(CC_DEFAULT_FONT_LABEL_SIZE);
2015-04-14 14:23:10 +08:00
}
2014-03-11 17:13:54 +08:00
_titleRenderer->setString(text);
2014-10-11 12:13:04 +08:00
updateContentSize();
2015-09-15 13:37:32 +08:00
updateTitleLocation();
2014-03-11 17:13:54 +08:00
}
std::string Button::getTitleText() const
2014-03-11 17:13:54 +08:00
{
if(!_titleRenderer) {
2015-04-14 14:23:10 +08:00
return "";
}
2014-03-11 17:13:54 +08:00
return _titleRenderer->getString();
}
void Button::setTitleColor(const Color3B& color)
{
createTitleRendererIfNull();
2014-12-25 16:04:28 +08:00
_titleRenderer->setTextColor(Color4B(color));
2014-03-11 17:13:54 +08:00
}
2014-12-25 16:04:28 +08:00
Color3B Button::getTitleColor() const
2014-03-11 17:13:54 +08:00
{
2015-04-14 14:23:10 +08:00
if(nullptr == _titleRenderer)
{
return Color3B::WHITE;
}
2014-12-25 16:04:28 +08:00
return Color3B(_titleRenderer->getTextColor());
2014-03-11 17:13:54 +08:00
}
void Button::setTitleFontSize(float size)
{
createTitleRendererIfNull();
Label::LabelType titleLabelType = _titleRenderer->getLabelType();
if(titleLabelType == Label::LabelType::TTF) {
2014-06-15 15:55:46 +08:00
TTFConfig config = _titleRenderer->getTTFConfig();
config.fontSize = size;
2014-06-15 15:55:46 +08:00
_titleRenderer->setTTFConfig(config);
} else if (titleLabelType == Label::LabelType::STRING_TEXTURE) {
// the system font
_titleRenderer->setSystemFontSize(size);
}
2015-05-27 16:58:52 +08:00
//we can't change font size of BMFont.
if(titleLabelType != Label::LabelType::BMFONT) {
2015-05-27 16:58:52 +08:00
updateContentSize();
}
2014-03-11 17:13:54 +08:00
}
float Button::getTitleFontSize() const {
if(_titleRenderer) {
return _titleRenderer->getRenderingFontSize();
}
return -1;
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
void Button::setZoomScale(float scale)
{
_zoomScale = scale;
}
2015-04-14 14:23:10 +08:00
float Button::getZoomScale()const
{
return _zoomScale;
}
2014-03-11 17:13:54 +08:00
2014-04-03 10:31:10 +08:00
void Button::setTitleFontName(const std::string& fontName)
2014-03-11 17:13:54 +08:00
{
createTitleRendererIfNull();
if(FileUtils::getInstance()->isFileExist(fontName)) {
std::string lowerCasedFontName = fontName;
std::transform(lowerCasedFontName.begin(), lowerCasedFontName.end(), lowerCasedFontName.begin(), ::tolower);
if (lowerCasedFontName.find(".fnt") != std::string::npos) {
_titleRenderer->setBMFontFilePath(fontName);
} else {
TTFConfig config = _titleRenderer->getTTFConfig();
config.fontFilePath = fontName;
_titleRenderer->setTTFConfig(config);
}
} else {
2014-06-15 15:55:46 +08:00
_titleRenderer->setSystemFontName(fontName);
}
_fontName = fontName;
updateContentSize();
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
Label* Button::getTitleRenderer()const
{
return _titleRenderer;
}
2014-03-11 17:13:54 +08:00
std::string Button::getTitleFontName() const
2014-03-11 17:13:54 +08:00
{
if (_titleRenderer) {
Label::LabelType titleLabelType = _titleRenderer->getLabelType();
if (titleLabelType == Label::LabelType::STRING_TEXTURE) {
2015-04-14 15:34:15 +08:00
return _titleRenderer->getSystemFontName();
} else if (titleLabelType == Label::LabelType::TTF) {
2015-04-14 15:34:15 +08:00
return _titleRenderer->getTTFConfig().fontFilePath;
} else if (titleLabelType == Label::LabelType::BMFONT) {
return _titleRenderer->getBMFontFilePath();
}
2015-04-14 14:23:10 +08:00
}
return "";
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
2014-03-11 17:13:54 +08:00
std::string Button::getDescription() const
{
return "Button";
}
Widget* Button::createCloneInstance()
{
return Button::create();
}
void Button::copySpecialProperties(Widget *widget)
{
Button* button = dynamic_cast<Button*>(widget);
if (button)
{
_prevIgnoreSize = button->_prevIgnoreSize;
setScale9Enabled(button->_scale9Enabled);
// clone the inner sprite: https://github.com/cocos2d/cocos2d-x/issues/16924
button->_buttonNormalRenderer->copyTo(_buttonNormalRenderer);
_normalFileName = button->_normalFileName;
_normalTextureSize = button->_normalTextureSize;
_normalTexType = button->_normalTexType;
_normalTextureLoaded = button->_normalTextureLoaded;
setupNormalTexture(!_normalFileName.empty());
button->_buttonClickedRenderer->copyTo(_buttonClickedRenderer);
_clickedFileName = button->_clickedFileName;
_pressedTextureSize = button->_pressedTextureSize;
_pressedTexType = button->_pressedTexType;
_pressedTextureLoaded = button->_pressedTextureLoaded;
setupPressedTexture(!_clickedFileName.empty());
button->_buttonDisabledRenderer->copyTo(_buttonDisabledRenderer);
_disabledFileName = button->_disabledFileName;
_disabledTextureSize = button->_disabledTextureSize;
_disabledTexType = button->_disabledTexType;
_disabledTextureLoaded = button->_disabledTextureLoaded;
setupDisabledTexture(!_disabledFileName.empty());
2014-03-11 17:13:54 +08:00
setCapInsetsNormalRenderer(button->_capInsetsNormal);
setCapInsetsPressedRenderer(button->_capInsetsPressed);
setCapInsetsDisabledRenderer(button->_capInsetsDisabled);
2015-04-16 14:38:00 +08:00
if(nullptr != button->getTitleRenderer())
{
setTitleText(button->getTitleText());
setTitleFontName(button->getTitleFontName());
setTitleFontSize(button->getTitleFontSize());
setTitleColor(button->getTitleColor());
}
2014-03-11 17:13:54 +08:00
setPressedActionEnabled(button->_pressedActionEnabled);
setZoomScale(button->_zoomScale);
2014-03-11 17:13:54 +08:00
}
2015-04-14 14:23:10 +08:00
2014-10-24 17:38:32 +08:00
}
2014-10-25 18:00:57 +08:00
Size Button::getNormalSize() const
2014-10-24 17:38:32 +08:00
{
Size titleSize;
if (_titleRenderer != nullptr)
{
titleSize = _titleRenderer->getContentSize();
}
Size imageSize;
if (_buttonNormalRenderer != nullptr)
{
imageSize = _buttonNormalRenderer->getContentSize();
}
float width = titleSize.width > imageSize.width ? titleSize.width : imageSize.width;
float height = titleSize.height > imageSize.height ? titleSize.height : imageSize.height;
return Size(width,height);
2014-03-11 17:13:54 +08:00
}
2015-01-19 16:58:46 +08:00
Size Button::getNormalTextureSize() const
{
return _normalTextureSize;
}
void Button::resetNormalRender()
{
_normalFileName = "";
_normalTexType = TextureResType::LOCAL;
_normalTextureSize = Size(0, 0);
_normalTextureLoaded = false;
_normalTextureAdaptDirty = false;
_buttonNormalRenderer->resetRender();
}
void Button::resetPressedRender()
{
_clickedFileName = "";
_pressedTexType = TextureResType::LOCAL;
_pressedTextureSize = Size(0, 0);
_pressedTextureLoaded = false;
_pressedTextureAdaptDirty = false;
_buttonClickedRenderer->resetRender();
}
void Button::resetDisabledRender()
{
_disabledFileName = "";
_disabledTexType = TextureResType::LOCAL;
_disabledTextureSize = Size(0, 0);
_disabledTextureLoaded = false;
_disabledTextureAdaptDirty = false;
_buttonDisabledRenderer->resetRender();
}
ResourceData Button::getNormalFile()
{
ResourceData rData;
rData.type = (int)_normalTexType;
rData.file = _normalFileName;
return rData;
}
ResourceData Button::getPressedFile()
{
ResourceData rData;
rData.type = (int)_pressedTexType;
rData.file = _clickedFileName;
return rData;
}
ResourceData Button::getDisabledFile()
{
ResourceData rData;
rData.type = (int)_disabledTexType;
rData.file = _disabledFileName;
return rData;
}
2014-03-11 17:13:54 +08:00
}
NS_CC_END