mirror of https://github.com/axmolengine/axmol.git
Feature #4236: Refactor is/setFlipX/Y to is/setFlippedX/Y in gui classes
This commit is contained in:
parent
76961b799a
commit
364317b532
|
@ -33,7 +33,7 @@ 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);
|
||||
|
||||
|
||||
Button::Button():
|
||||
_buttonNormalRenderer(nullptr),
|
||||
_buttonClickedRenderer(nullptr),
|
||||
|
@ -63,7 +63,7 @@ _normalTextureLoaded(false),
|
|||
_pressedTextureLoaded(false),
|
||||
_disabledTextureLoaded(false)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Button::~Button()
|
||||
|
@ -97,7 +97,7 @@ void Button::initRenderer()
|
|||
_buttonClickedRenderer = Sprite::create();
|
||||
_buttonDisableRenderer = Sprite::create();
|
||||
_titleRenderer = LabelTTF::create();
|
||||
|
||||
|
||||
Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
|
||||
Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
|
||||
Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1);
|
||||
|
@ -152,7 +152,7 @@ void Button::setScale9Enabled(bool able)
|
|||
setCapInsetsDisabledRenderer(_capInsetsDisabled);
|
||||
setBright(_bright);
|
||||
}
|
||||
|
||||
|
||||
bool Button::isScale9Enabled()
|
||||
{
|
||||
return _scale9Enabled;
|
||||
|
@ -331,7 +331,7 @@ void Button::setCapInsetsNormalRenderer(const Rect &capInsets)
|
|||
}
|
||||
static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setCapInsets(capInsets);
|
||||
}
|
||||
|
||||
|
||||
const Rect& Button::getCapInsetsNormalRenderer()
|
||||
{
|
||||
return _capInsetsNormal;
|
||||
|
@ -346,7 +346,7 @@ void Button::setCapInsetsPressedRenderer(const Rect &capInsets)
|
|||
}
|
||||
static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setCapInsets(capInsets);
|
||||
}
|
||||
|
||||
|
||||
const Rect& Button::getCapInsetsPressedRenderer()
|
||||
{
|
||||
return _capInsetsPressed;
|
||||
|
@ -361,7 +361,7 @@ void Button::setCapInsetsDisabledRenderer(const Rect &capInsets)
|
|||
}
|
||||
static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setCapInsets(capInsets);
|
||||
}
|
||||
|
||||
|
||||
const Rect& Button::getCapInsetsDisabledRenderer()
|
||||
{
|
||||
return _capInsetsDisabled;
|
||||
|
@ -425,31 +425,31 @@ void Button::onPressStateChangedToDisabled()
|
|||
_buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize);
|
||||
}
|
||||
|
||||
void Button::setFlipX(bool flipX)
|
||||
void Button::setFlippedX(bool flippedX)
|
||||
{
|
||||
_titleRenderer->setFlippedX(flipX);
|
||||
_titleRenderer->setFlippedX(flippedX);
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static_cast<Sprite*>(_buttonNormalRenderer)->setFlippedX(flipX);
|
||||
static_cast<Sprite*>(_buttonClickedRenderer)->setFlippedX(flipX);
|
||||
static_cast<Sprite*>(_buttonDisableRenderer)->setFlippedX(flipX);
|
||||
static_cast<Sprite*>(_buttonNormalRenderer)->setFlippedX(flippedX);
|
||||
static_cast<Sprite*>(_buttonClickedRenderer)->setFlippedX(flippedX);
|
||||
static_cast<Sprite*>(_buttonDisableRenderer)->setFlippedX(flippedX);
|
||||
}
|
||||
|
||||
void Button::setFlipY(bool flipY)
|
||||
void Button::setFlippedY(bool flippedY)
|
||||
{
|
||||
_titleRenderer->setFlippedY(flipY);
|
||||
_titleRenderer->setFlippedY(flippedY);
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static_cast<Sprite*>(_buttonNormalRenderer)->setFlippedY(flipY);
|
||||
static_cast<Sprite*>(_buttonClickedRenderer)->setFlippedY(flipY);
|
||||
static_cast<Sprite*>(_buttonDisableRenderer)->setFlippedY(flipY);
|
||||
static_cast<Sprite*>(_buttonNormalRenderer)->setFlippedY(flippedY);
|
||||
static_cast<Sprite*>(_buttonClickedRenderer)->setFlippedY(flippedY);
|
||||
static_cast<Sprite*>(_buttonDisableRenderer)->setFlippedY(flippedY);
|
||||
}
|
||||
|
||||
bool Button::isFlipX()
|
||||
bool Button::isFlippedX()
|
||||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
|
@ -458,7 +458,7 @@ bool Button::isFlipX()
|
|||
return static_cast<Sprite*>(_buttonNormalRenderer)->isFlippedX();
|
||||
}
|
||||
|
||||
bool Button::isFlipY()
|
||||
bool Button::isFlippedY()
|
||||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
|
@ -677,7 +677,7 @@ void Button::copySpecialProperties(Widget *widget)
|
|||
{
|
||||
Button* button = dynamic_cast<Button*>(widget);
|
||||
if (button)
|
||||
{
|
||||
{
|
||||
_prevIgnoreSize = button->_prevIgnoreSize;
|
||||
setScale9Enabled(button->_scale9Enabled);
|
||||
loadTextureNormal(button->_normalFileName.c_str(), button->_normalTexType);
|
||||
|
|
|
@ -42,17 +42,17 @@ public:
|
|||
* Default constructor
|
||||
*/
|
||||
Button();
|
||||
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
*/
|
||||
virtual ~Button();
|
||||
|
||||
|
||||
/**
|
||||
* Allocates and initializes.
|
||||
*/
|
||||
static Button* create();
|
||||
|
||||
|
||||
/**
|
||||
* Load textures for button.
|
||||
*
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextures(const char* normal,const char* selected,const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load normal state texture for button.
|
||||
*
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureNormal(const char* normal, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load selected state texture for button.
|
||||
*
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTexturePressed(const char* selected, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load dark state texture for button.
|
||||
*
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureDisabled(const char* disabled, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Sets capinsets for button, if button is using scale9 renderer.
|
||||
*
|
||||
|
@ -106,67 +106,76 @@ public:
|
|||
* @param capInsets capinsets for button
|
||||
*/
|
||||
void setCapInsetsNormalRenderer(const Rect &capInsets);
|
||||
|
||||
|
||||
const Rect& getCapInsetsNormalRenderer();
|
||||
|
||||
|
||||
/**
|
||||
* Sets capinsets for button, if button is using scale9 renderer.
|
||||
*
|
||||
* @param capInsets capinsets for button
|
||||
*/
|
||||
void setCapInsetsPressedRenderer(const Rect &capInsets);
|
||||
|
||||
|
||||
const Rect& getCapInsetsPressedRenderer();
|
||||
|
||||
|
||||
/**
|
||||
* Sets capinsets for button, if button is using scale9 renderer.
|
||||
*
|
||||
* @param capInsets capinsets for button
|
||||
*/
|
||||
void setCapInsetsDisabledRenderer(const Rect &capInsets);
|
||||
|
||||
|
||||
const Rect& getCapInsetsDisabledRenderer();
|
||||
|
||||
|
||||
//override "setAnchorPoint" of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
|
||||
/**
|
||||
* Sets if button is using scale9 renderer.
|
||||
*
|
||||
* @param true that using scale9 renderer, false otherwise.
|
||||
*/
|
||||
virtual void setScale9Enabled(bool able);
|
||||
|
||||
|
||||
bool isScale9Enabled();
|
||||
|
||||
//override "setFlipX" of widget.
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" of widget.
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" of widget.
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" of widget.
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
|
||||
//override "setFlippedX" of widget.
|
||||
virtual void setFlippedX(bool flippedX) override;
|
||||
|
||||
//override "setFlippedY" of widget.
|
||||
virtual void setFlippedY(bool flippedY) override;
|
||||
|
||||
//override "isFlippedX" of widget.
|
||||
virtual bool isFlippedX() override;
|
||||
|
||||
//override "isFlippedY" of widget.
|
||||
virtual bool isFlippedY() override;
|
||||
|
||||
/** @deprecated Use isFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); };
|
||||
/** @deprecated Use setFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flipX) { setFlippedX(flipX); };
|
||||
/** @deprecated Use isFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); };
|
||||
/** @deprecated Use setFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flipY) { setFlippedY(flipY); };
|
||||
|
||||
/**
|
||||
* Changes if button can be clicked zoom effect.
|
||||
*
|
||||
* @param true that can be clicked zoom effect, false otherwise.
|
||||
*/
|
||||
void setPressedActionEnabled(bool enabled);
|
||||
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
||||
|
||||
/**
|
||||
* Sets color to widget
|
||||
*
|
||||
|
@ -175,12 +184,12 @@ public:
|
|||
* @param color
|
||||
*/
|
||||
virtual void setColor(const Color3B &color) override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
|
||||
void setTitleText(const std::string& text);
|
||||
const std::string& getTitleText() const;
|
||||
void setTitleColor(const Color3B& color);
|
||||
|
@ -197,7 +206,7 @@ protected:
|
|||
virtual void onPressStateChangedToPressed() override;
|
||||
virtual void onPressStateChangedToDisabled() override;
|
||||
virtual void onSizeChanged() override;
|
||||
|
||||
|
||||
void normalTextureScaleChangedWithSize();
|
||||
void pressedTextureScaleChangedWithSize();
|
||||
void disabledTextureScaleChangedWithSize();
|
||||
|
|
|
@ -322,30 +322,30 @@ void CheckBox::addEventListenerCheckBox(Ref *target, SEL_SelectedStateEvent sele
|
|||
_checkBoxEventSelector = selector;
|
||||
}
|
||||
|
||||
void CheckBox::setFlipX(bool flipX)
|
||||
void CheckBox::setFlippedX(bool flippedX)
|
||||
{
|
||||
_backGroundBoxRenderer->setFlippedX(flipX);
|
||||
_backGroundSelectedBoxRenderer->setFlippedX(flipX);
|
||||
_frontCrossRenderer->setFlippedX(flipX);
|
||||
_backGroundBoxDisabledRenderer->setFlippedX(flipX);
|
||||
_frontCrossDisabledRenderer->setFlippedX(flipX);
|
||||
_backGroundBoxRenderer->setFlippedX(flippedX);
|
||||
_backGroundSelectedBoxRenderer->setFlippedX(flippedX);
|
||||
_frontCrossRenderer->setFlippedX(flippedX);
|
||||
_backGroundBoxDisabledRenderer->setFlippedX(flippedX);
|
||||
_frontCrossDisabledRenderer->setFlippedX(flippedX);
|
||||
}
|
||||
|
||||
void CheckBox::setFlipY(bool flipY)
|
||||
void CheckBox::setFlippedY(bool flippedY)
|
||||
{
|
||||
_backGroundBoxRenderer->setFlippedY(flipY);
|
||||
_backGroundSelectedBoxRenderer->setFlippedY(flipY);
|
||||
_frontCrossRenderer->setFlippedY(flipY);
|
||||
_backGroundBoxDisabledRenderer->setFlippedY(flipY);
|
||||
_frontCrossDisabledRenderer->setFlippedY(flipY);
|
||||
_backGroundBoxRenderer->setFlippedY(flippedY);
|
||||
_backGroundSelectedBoxRenderer->setFlippedY(flippedY);
|
||||
_frontCrossRenderer->setFlippedY(flippedY);
|
||||
_backGroundBoxDisabledRenderer->setFlippedY(flippedY);
|
||||
_frontCrossDisabledRenderer->setFlippedY(flippedY);
|
||||
}
|
||||
|
||||
bool CheckBox::isFlipX()
|
||||
bool CheckBox::isFlippedX()
|
||||
{
|
||||
return _backGroundBoxRenderer->isFlippedX();
|
||||
}
|
||||
|
||||
bool CheckBox::isFlipY()
|
||||
bool CheckBox::isFlippedY()
|
||||
{
|
||||
return _backGroundBoxRenderer->isFlippedY();
|
||||
}
|
||||
|
|
|
@ -51,17 +51,17 @@ public:
|
|||
* Default constructor
|
||||
*/
|
||||
CheckBox();
|
||||
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
*/
|
||||
virtual ~CheckBox();
|
||||
|
||||
|
||||
/**
|
||||
* Allocates and initializes.
|
||||
*/
|
||||
static CheckBox* create();
|
||||
|
||||
|
||||
/**
|
||||
* Load textures for checkbox.
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextures(const char* backGround,const char* backGroundSelected,const char* cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load backGround texture for checkbox.
|
||||
*
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureBackGround(const char* backGround,TextureResType type = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load backGroundSelected texture for checkbox.
|
||||
*
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureBackGroundSelected(const char* backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load cross texture for checkbox.
|
||||
*
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureFrontCross(const char* cross,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load backGroundDisabled texture for checkbox.
|
||||
*
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureBackGroundDisabled(const char* backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Load frontCrossDisabled texture for checkbox.
|
||||
*
|
||||
|
@ -121,48 +121,57 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureFrontCrossDisabled(const char* frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Sets selcted state for checkbox.
|
||||
*
|
||||
* @param selected true that checkbox is selected, false otherwise.
|
||||
*/
|
||||
void setSelectedState(bool selected);
|
||||
|
||||
|
||||
/**
|
||||
* Gets selcted state of checkbox.
|
||||
*
|
||||
* @return selected true that checkbox is selected, false otherwise.
|
||||
*/
|
||||
bool getSelectedState();
|
||||
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
|
||||
//add a call back function would called when checkbox is selected or unselected.
|
||||
void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector);
|
||||
|
||||
//override "setFlipX" method of widget.
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" method of widget.
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" method of widget.
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" method of widget.
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
|
||||
//override "setFlippedX" method of widget.
|
||||
virtual void setFlippedX(bool flippedX) override;
|
||||
|
||||
//override "setFlippedY" method of widget.
|
||||
virtual void setFlippedY(bool flippedY) override;
|
||||
|
||||
//override "isFlippedX" method of widget.
|
||||
virtual bool isFlippedX() override;
|
||||
|
||||
//override "isFlippedY" method of widget.
|
||||
virtual bool isFlippedY() override;
|
||||
|
||||
/** @deprecated Use isFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); };
|
||||
/** @deprecated Use setFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flipX) { setFlippedX(flipX); };
|
||||
/** @deprecated Use isFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); };
|
||||
/** @deprecated Use setFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flipY) { setFlippedY(flipY); };
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(Touch *touch, Event *unusedEvent);
|
||||
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
|
@ -194,13 +203,13 @@ protected:
|
|||
|
||||
Ref* _checkBoxEventListener;
|
||||
SEL_SelectedStateEvent _checkBoxEventSelector;
|
||||
|
||||
|
||||
TextureResType _backGroundTexType;
|
||||
TextureResType _backGroundSelectedTexType;
|
||||
TextureResType _frontCrossTexType;
|
||||
TextureResType _backGroundDisabledTexType;
|
||||
TextureResType _frontCrossDisabledTexType;
|
||||
|
||||
|
||||
std::string _backGroundFileName;
|
||||
std::string _backGroundSelectedFileName;
|
||||
std::string _frontCrossFileName;
|
||||
|
|
|
@ -127,29 +127,29 @@ void ImageView::setTextureRect(const Rect &rect)
|
|||
}
|
||||
}
|
||||
|
||||
void ImageView::setFlipX(bool flipX)
|
||||
void ImageView::setFlippedX(bool flippedX)
|
||||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
STATIC_CAST_CCSPRITE->setFlippedX(flipX);
|
||||
STATIC_CAST_CCSPRITE->setFlippedX(flippedX);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageView::setFlipY(bool flipY)
|
||||
void ImageView::setFlippedY(bool flippedY)
|
||||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
STATIC_CAST_CCSPRITE->setFlippedY(flipY);
|
||||
STATIC_CAST_CCSPRITE->setFlippedY(flippedY);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageView::isFlipX()
|
||||
bool ImageView::isFlippedX()
|
||||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ bool ImageView::isFlipX()
|
|||
}
|
||||
}
|
||||
|
||||
bool ImageView::isFlipY()
|
||||
bool ImageView::isFlippedY()
|
||||
{
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
|
|
|
@ -42,17 +42,17 @@ public:
|
|||
* Default constructor
|
||||
*/
|
||||
ImageView();
|
||||
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
*/
|
||||
virtual ~ImageView();
|
||||
|
||||
|
||||
/**
|
||||
* Allocates and initializes.
|
||||
*/
|
||||
static ImageView* create();
|
||||
|
||||
|
||||
/**
|
||||
* Load texture for imageview.
|
||||
*
|
||||
|
@ -61,54 +61,63 @@ public:
|
|||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTexture(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
* Updates the texture rect of the ImageView in points.
|
||||
* It will call setTextureRect:rotated:untrimmedSize with rotated = NO, and utrimmedSize = rect.size.
|
||||
*/
|
||||
void setTextureRect(const Rect& rect);
|
||||
|
||||
|
||||
/**
|
||||
* Sets if imageview is using scale9 renderer.
|
||||
*
|
||||
* @param true that using scale9 renderer, false otherwise.
|
||||
*/
|
||||
void setScale9Enabled(bool able);
|
||||
|
||||
|
||||
bool isScale9Enabled();
|
||||
|
||||
|
||||
/**
|
||||
* Sets capinsets for imageview, if imageview is using scale9 renderer.
|
||||
*
|
||||
* @param capInsets capinsets for imageview
|
||||
*/
|
||||
void setCapInsets(const Rect &capInsets);
|
||||
|
||||
|
||||
const Rect& getCapInsets();
|
||||
|
||||
//override "setFlipX" method of widget.
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" method of widget.
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" method of widget.
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" method of widget.
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
|
||||
//override "setFlippedX" method of widget.
|
||||
virtual void setFlippedX(bool flippedX) override;
|
||||
|
||||
//override "setFlippedY" method of widget.
|
||||
virtual void setFlippedY(bool flippedY) override;
|
||||
|
||||
//override "isFlippedX" method of widget.
|
||||
virtual bool isFlippedX() override;
|
||||
|
||||
//override "isFlippedY" method of widget.
|
||||
virtual bool isFlippedY() override;
|
||||
|
||||
/** @deprecated Use isFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); };
|
||||
/** @deprecated Use setFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flipX) { setFlippedX(flipX); };
|
||||
/** @deprecated Use isFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); };
|
||||
/** @deprecated Use setFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flipY) { setFlippedY(flipY); };
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
|
||||
virtual const Size& getContentSize() const override;
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
protected:
|
||||
|
|
|
@ -197,22 +197,22 @@ void Text::onPressStateChangedToDisabled()
|
|||
|
||||
}
|
||||
|
||||
void Text::setFlipX(bool flipX)
|
||||
void Text::setFlippedX(bool flippedX)
|
||||
{
|
||||
_labelRenderer->setFlippedX(flipX);
|
||||
_labelRenderer->setFlippedX(flippedX);
|
||||
}
|
||||
|
||||
void Text::setFlipY(bool flipY)
|
||||
void Text::setFlippedY(bool flippedY)
|
||||
{
|
||||
_labelRenderer->setFlippedY(flipY);
|
||||
_labelRenderer->setFlippedY(flippedY);
|
||||
}
|
||||
|
||||
bool Text::isFlipX()
|
||||
bool Text::isFlippedX()
|
||||
{
|
||||
return _labelRenderer->isFlippedX();
|
||||
}
|
||||
|
||||
bool Text::isFlipY()
|
||||
bool Text::isFlippedY()
|
||||
{
|
||||
return _labelRenderer->isFlippedY();
|
||||
}
|
||||
|
|
|
@ -42,70 +42,70 @@ public:
|
|||
* Default constructor
|
||||
*/
|
||||
Text();
|
||||
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
*/
|
||||
virtual ~Text();
|
||||
|
||||
|
||||
/**
|
||||
* Allocates and initializes.
|
||||
*/
|
||||
static Text* create();
|
||||
|
||||
|
||||
/**
|
||||
* Changes the string value of label.
|
||||
*
|
||||
* @param text string value.
|
||||
*/
|
||||
void setText(const std::string& text);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the string value of label.
|
||||
*
|
||||
* @return text string value.
|
||||
*/
|
||||
const std::string& getStringValue();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the string length of label.
|
||||
*
|
||||
* @return string length.
|
||||
*/
|
||||
ssize_t getStringLength();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the font size of label.
|
||||
*
|
||||
* @param font size.
|
||||
*/
|
||||
void setFontSize(int size);
|
||||
|
||||
|
||||
int getFontSize();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the font name of label.
|
||||
*
|
||||
* @param font name.
|
||||
*/
|
||||
void setFontName(const std::string& name);
|
||||
|
||||
|
||||
const std::string& getFontName();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the touch scale enabled of label.
|
||||
*
|
||||
* @param touch scale enabled of label.
|
||||
*/
|
||||
void setTouchScaleChangeEnabled(bool enabled);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the touch scale enabled of label.
|
||||
*
|
||||
* @return touch scale enabled of label.
|
||||
*/
|
||||
bool isTouchScaleChangeEnabled();
|
||||
|
||||
|
||||
/**
|
||||
* Changes both X and Y scale factor of the widget.
|
||||
*
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
* @param scale The scale factor for both X and Y axis.
|
||||
*/
|
||||
virtual void setScale(float fScale) override;
|
||||
|
||||
|
||||
/**
|
||||
* Changes the scale factor on X axis of this widget
|
||||
*
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
* @param fScaleX The scale factor on X axis.
|
||||
*/
|
||||
virtual void setScaleX(float fScaleX) override;
|
||||
|
||||
|
||||
/**
|
||||
* Changes the scale factor on Y axis of this widget
|
||||
*
|
||||
|
@ -132,46 +132,55 @@ public:
|
|||
* @param fScaleY The scale factor on Y axis.
|
||||
*/
|
||||
virtual void setScaleY(float fScaleY) override;
|
||||
|
||||
|
||||
//override "setFlipX" method of widget.
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" method of widget.
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" method of widget.
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" method of widget.
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
|
||||
//override "setFlippedX" method of widget.
|
||||
virtual void setFlippedX(bool flippedX) override;
|
||||
|
||||
//override "setFlippedY" method of widget.
|
||||
virtual void setFlippedY(bool flippedY) override;
|
||||
|
||||
//override "isFlippedX" method of widget.
|
||||
virtual bool isFlippedX() override;
|
||||
|
||||
//override "isFlippedY" method of widget.
|
||||
virtual bool isFlippedY() override;
|
||||
|
||||
/** @deprecated Use isFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); };
|
||||
/** @deprecated Use setFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flipX) { setFlippedX(flipX); };
|
||||
/** @deprecated Use isFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); };
|
||||
/** @deprecated Use setFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flipY) { setFlippedY(flipY); };
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
|
||||
void setTextAreaSize(const Size &size);
|
||||
|
||||
|
||||
const Size& getTextAreaSize();
|
||||
|
||||
|
||||
void setTextHorizontalAlignment(TextHAlignment alignment);
|
||||
|
||||
|
||||
TextHAlignment getTextHorizontalAlignment();
|
||||
|
||||
|
||||
void setTextVerticalAlignment(TextVAlignment alignment);
|
||||
|
||||
|
||||
TextVAlignment getTextVerticalAlignment();
|
||||
|
||||
|
||||
protected:
|
||||
virtual bool init() override;
|
||||
virtual void initRenderer() override;
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
|
||||
Widget::Widget():
|
||||
_enabled(true),
|
||||
_bright(true),
|
||||
|
@ -57,7 +57,7 @@ _reorderWidgetChildDirty(true),
|
|||
_hitted(false),
|
||||
_touchListener(nullptr)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
|
@ -107,13 +107,13 @@ void Widget::onExit()
|
|||
unscheduleUpdate();
|
||||
Node::onExit();
|
||||
}
|
||||
|
||||
|
||||
void Widget::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (_enabled)
|
||||
{
|
||||
Node::visit(renderer, parentTransform, parentTransformUpdated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::addChild(Node *child)
|
||||
|
@ -125,14 +125,14 @@ void Widget::addChild(Node * child, int zOrder)
|
|||
{
|
||||
Node::addChild(child, zOrder);
|
||||
}
|
||||
|
||||
|
||||
void Widget::addChild(Node* child, int zOrder, int tag)
|
||||
{
|
||||
CCASSERT(dynamic_cast<Widget*>(child) != nullptr, "Widget only supports Widgets as children");
|
||||
Node::addChild(child, zOrder, tag);
|
||||
_widgetChildren.pushBack(child);
|
||||
}
|
||||
|
||||
|
||||
void Widget::sortAllChildren()
|
||||
{
|
||||
_reorderWidgetChildDirty = _reorderChildDirty;
|
||||
|
@ -143,11 +143,11 @@ void Widget::sortAllChildren()
|
|||
_reorderWidgetChildDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Node* Widget::getChildByTag(int aTag)
|
||||
{
|
||||
CCASSERT( aTag != Node::INVALID_TAG, "Invalid tag");
|
||||
|
||||
|
||||
for (auto& child : _widgetChildren)
|
||||
{
|
||||
if(child && child->getTag() == aTag)
|
||||
|
@ -160,12 +160,12 @@ Vector<Node*>& Widget::getChildren()
|
|||
{
|
||||
return _widgetChildren;
|
||||
}
|
||||
|
||||
|
||||
const Vector<Node*>& Widget::getChildren() const
|
||||
{
|
||||
return _widgetChildren;
|
||||
}
|
||||
|
||||
|
||||
ssize_t Widget::getChildrenCount() const
|
||||
{
|
||||
return _widgetChildren.size();
|
||||
|
@ -175,7 +175,7 @@ Widget* Widget::getWidgetParent()
|
|||
{
|
||||
return dynamic_cast<Widget*>(getParent());
|
||||
}
|
||||
|
||||
|
||||
void Widget::removeFromParent()
|
||||
{
|
||||
removeFromParentAndCleanup(true);
|
||||
|
@ -195,9 +195,9 @@ void Widget::removeChild(Node *child, bool cleanup)
|
|||
void Widget::removeChildByTag(int tag, bool cleanup)
|
||||
{
|
||||
CCASSERT( tag != Node::INVALID_TAG, "Invalid tag");
|
||||
|
||||
|
||||
Node *child = getChildByTag(tag);
|
||||
|
||||
|
||||
if (child == nullptr)
|
||||
{
|
||||
CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag);
|
||||
|
@ -212,7 +212,7 @@ void Widget::removeAllChildren()
|
|||
{
|
||||
removeAllChildrenWithCleanup(true);
|
||||
}
|
||||
|
||||
|
||||
void Widget::removeAllChildrenWithCleanup(bool cleanup)
|
||||
{
|
||||
for (auto& child : _widgetChildren)
|
||||
|
@ -252,7 +252,7 @@ Widget* Widget::getChildByName(const char *name)
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void Widget::addNode(Node* node)
|
||||
{
|
||||
addNode(node, node->getLocalZOrder(), node->getTag());
|
||||
|
@ -273,7 +273,7 @@ void Widget::addNode(Node* node, int zOrder, int tag)
|
|||
Node* Widget::getNodeByTag(int tag)
|
||||
{
|
||||
CCAssert( tag != Node::INVALID_TAG, "Invalid tag");
|
||||
|
||||
|
||||
for (auto& node : _nodes)
|
||||
{
|
||||
if(node && node->getTag() == tag)
|
||||
|
@ -296,9 +296,9 @@ void Widget::removeNode(Node* node)
|
|||
void Widget::removeNodeByTag(int tag)
|
||||
{
|
||||
CCAssert( tag != Node::INVALID_TAG, "Invalid tag");
|
||||
|
||||
|
||||
Node *node = this->getNodeByTag(tag);
|
||||
|
||||
|
||||
if (node == nullptr)
|
||||
{
|
||||
CCLOG("cocos2d: removeNodeByTag(tag = %d): child not found!", tag);
|
||||
|
@ -688,22 +688,22 @@ void Widget::setBrightStyle(BrightStyle style)
|
|||
|
||||
void Widget::onPressStateChangedToNormal()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Widget::onPressStateChangedToPressed()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Widget::onPressStateChangedToDisabled()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Widget::didNotSelectSelf()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent)
|
||||
|
@ -837,13 +837,13 @@ bool Widget::clippingParentAreaContainPoint(const Point &pt)
|
|||
}
|
||||
parent = parent->getWidgetParent();
|
||||
}
|
||||
|
||||
|
||||
if (!_affectByClipping)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (clippingParent)
|
||||
{
|
||||
bool bRet = false;
|
||||
|
@ -1020,7 +1020,7 @@ Widget* Widget::createCloneInstance()
|
|||
void Widget::copyClonedWidgetChildren(Widget* model)
|
||||
{
|
||||
auto& modelChildren = model->getChildren();
|
||||
|
||||
|
||||
for (auto& subWidget : modelChildren)
|
||||
{
|
||||
Widget* child = static_cast<Widget*>(subWidget);
|
||||
|
@ -1030,7 +1030,7 @@ void Widget::copyClonedWidgetChildren(Widget* model)
|
|||
|
||||
void Widget::copySpecialProperties(Widget* model)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Widget::copyProperties(Widget *widget)
|
||||
|
@ -1059,8 +1059,8 @@ void Widget::copyProperties(Widget *widget)
|
|||
setRotation(widget->getRotation());
|
||||
setRotationX(widget->getRotationX());
|
||||
setRotationY(widget->getRotationY());
|
||||
setFlipX(widget->isFlipX());
|
||||
setFlipY(widget->isFlipY());
|
||||
setFlippedX(widget->isFlippedX());
|
||||
setFlippedY(widget->isFlippedY());
|
||||
setColor(widget->getColor());
|
||||
setOpacity(widget->getOpacity());
|
||||
setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled());
|
||||
|
@ -1083,7 +1083,7 @@ int Widget::getActionTag()
|
|||
{
|
||||
return _actionTag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -80,22 +80,22 @@ typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType);
|
|||
*/
|
||||
class Widget : public Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
Widget(void);
|
||||
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
*/
|
||||
virtual ~Widget();
|
||||
|
||||
|
||||
/**
|
||||
* Allocates and initializes a widget.
|
||||
*/
|
||||
static Widget* create();
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether the widget is enabled
|
||||
*
|
||||
|
@ -105,14 +105,14 @@ public:
|
|||
* @param enabled true if the widget is enabled, widget may be touched and visible, false if the widget is disabled, widget cannot be touched and hidden.
|
||||
*/
|
||||
virtual void setEnabled(bool enabled);
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the widget is enabled
|
||||
*
|
||||
* @return true if the widget is enabled, false if the widget is disabled.
|
||||
*/
|
||||
bool isEnabled() const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether the widget is bright
|
||||
*
|
||||
|
@ -121,14 +121,14 @@ public:
|
|||
* @param visible true if the widget is bright, false if the widget is dark.
|
||||
*/
|
||||
void setBright(bool bright);
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the widget is bright
|
||||
*
|
||||
* @return true if the widget is bright, false if the widget is dark.
|
||||
*/
|
||||
bool isBright() const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether the widget is touch enabled
|
||||
*
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
* @param visible true if the widget is touch enabled, false if the widget is touch disabled.
|
||||
*/
|
||||
virtual void setTouchEnabled(bool enabled);
|
||||
|
||||
|
||||
/**
|
||||
* To set the bright style of widget.
|
||||
*
|
||||
|
@ -146,14 +146,14 @@ public:
|
|||
* @param style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state.
|
||||
*/
|
||||
void setBrightStyle(BrightStyle style);
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the widget is touch enabled
|
||||
*
|
||||
* @return true if the widget is touch enabled, false if the widget is touch disabled.
|
||||
*/
|
||||
bool isTouchEnabled() const;
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the widget is on focused
|
||||
*
|
||||
|
@ -169,28 +169,28 @@ public:
|
|||
* @param fucosed true if the widget is on focused, false if the widget is not on focused.
|
||||
*/
|
||||
void setFocused(bool fucosed);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the left boundary position of this widget.
|
||||
*
|
||||
* @return The left boundary position of this widget.
|
||||
*/
|
||||
float getLeftInParent();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the bottom boundary position of this widget.
|
||||
*
|
||||
* @return The bottom boundary position of this widget.
|
||||
*/
|
||||
float getBottomInParent();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the right boundary position of this widget.
|
||||
*
|
||||
* @return The right boundary position of this widget.
|
||||
*/
|
||||
float getRightInParent();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the top boundary position of this widget.
|
||||
*
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
* @return a Node object whose tag equals to the input parameter
|
||||
*/
|
||||
virtual Node * getChildByTag(int tag) override;
|
||||
|
||||
|
||||
virtual void sortAllChildren() override;
|
||||
/**
|
||||
* Return an array of children
|
||||
|
@ -253,14 +253,14 @@ public:
|
|||
*/
|
||||
virtual Vector<Node*>& getChildren() override;
|
||||
virtual const Vector<Node*>& getChildren() const override;
|
||||
|
||||
|
||||
/**
|
||||
* Get the amount of children.
|
||||
*
|
||||
* @return The amount of children.
|
||||
*/
|
||||
virtual ssize_t getChildrenCount() const override;
|
||||
|
||||
|
||||
/**
|
||||
* Removes this node itself from its parent node with a cleanup.
|
||||
* If the node orphan, then nothing happens.
|
||||
|
@ -275,7 +275,7 @@ public:
|
|||
* @lua removeFromParent
|
||||
*/
|
||||
virtual void removeFromParentAndCleanup(bool cleanup) override;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.
|
||||
*
|
||||
|
@ -283,7 +283,7 @@ public:
|
|||
* @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
|
||||
*/
|
||||
virtual void removeChild(Node* child, bool cleanup = true) override;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter
|
||||
*
|
||||
|
@ -305,7 +305,7 @@ public:
|
|||
* @lua removeAllChildren
|
||||
*/
|
||||
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||
|
||||
|
||||
/**
|
||||
* Gets a child from the container with its name
|
||||
*
|
||||
|
@ -314,33 +314,33 @@ public:
|
|||
* @return a Widget object whose name equals to the input parameter
|
||||
*/
|
||||
virtual Widget* getChildByName(const char* name);
|
||||
|
||||
|
||||
virtual void addNode(Node* node);
|
||||
|
||||
|
||||
virtual void addNode(Node * node, int zOrder);
|
||||
|
||||
|
||||
virtual void addNode(Node* node, int zOrder, int tag);
|
||||
|
||||
|
||||
virtual Node * getNodeByTag(int tag);
|
||||
|
||||
|
||||
virtual Vector<Node*>& getNodes();
|
||||
|
||||
|
||||
virtual void removeNode(Node* node);
|
||||
|
||||
|
||||
virtual void removeNodeByTag(int tag);
|
||||
|
||||
|
||||
virtual void removeAllNodes();
|
||||
|
||||
|
||||
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the touch event target/selector of the menu item
|
||||
*/
|
||||
void addTouchEventListener(Ref* target,SEL_TouchEvent selector);
|
||||
|
||||
|
||||
|
||||
|
||||
//cocos2d property
|
||||
|
||||
|
||||
/**
|
||||
* Changes the position (x,y) of the widget in OpenGL coordinates
|
||||
*
|
||||
|
@ -350,7 +350,7 @@ public:
|
|||
* @param position The position (x,y) of the widget in OpenGL coordinates
|
||||
*/
|
||||
virtual void setPosition(const Point &pos) override;
|
||||
|
||||
|
||||
/**
|
||||
* Changes the position (x,y) of the widget in OpenGL coordinates
|
||||
*
|
||||
|
@ -360,7 +360,7 @@ public:
|
|||
* @param percent The percent (x,y) of the widget in OpenGL coordinates
|
||||
*/
|
||||
void setPositionPercent(const Point &percent);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the percent (x,y) of the widget in OpenGL coordinates
|
||||
*
|
||||
|
@ -369,7 +369,7 @@ public:
|
|||
* @return The percent (x,y) of the widget in OpenGL coordinates
|
||||
*/
|
||||
const Point& getPositionPercent();
|
||||
|
||||
|
||||
/**
|
||||
* Changes the position type of the widget
|
||||
*
|
||||
|
@ -387,14 +387,14 @@ public:
|
|||
* @return type the position type of widget
|
||||
*/
|
||||
PositionType getPositionType() const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether the widget should be flipped horizontally or not.
|
||||
*
|
||||
* @param bFlipX true if the widget should be flipped horizaontally, false otherwise.
|
||||
* @param bFlippedX true if the widget should be flipped horizaontally, false otherwise.
|
||||
*/
|
||||
virtual void setFlipX(bool flipX){};
|
||||
|
||||
virtual void setFlippedX(bool flippedX){};
|
||||
|
||||
/**
|
||||
* Returns the flag which indicates whether the widget is flipped horizontally or not.
|
||||
*
|
||||
|
@ -405,15 +405,15 @@ public:
|
|||
*
|
||||
* @return true if the widget is flipped horizaontally, false otherwise.
|
||||
*/
|
||||
virtual bool isFlipX(){return false;};
|
||||
|
||||
virtual bool isFlippedX(){return false;};
|
||||
|
||||
/**
|
||||
* Sets whether the widget should be flipped vertically or not.
|
||||
*
|
||||
* @param bFlipY true if the widget should be flipped vertically, flase otherwise.
|
||||
* @param bFlippedY true if the widget should be flipped vertically, flase otherwise.
|
||||
*/
|
||||
virtual void setFlipY(bool flipY){};
|
||||
|
||||
virtual void setFlippedY(bool flippedY){};
|
||||
|
||||
/**
|
||||
* Return the flag which indicates whether the widget is flipped vertically or not.
|
||||
*
|
||||
|
@ -424,13 +424,22 @@ public:
|
|||
*
|
||||
* @return true if the widget is flipped vertically, flase otherwise.
|
||||
*/
|
||||
virtual bool isFlipY(){return false;};
|
||||
|
||||
virtual bool isFlippedY(){return false;};
|
||||
|
||||
/** @deprecated Use isFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); };
|
||||
/** @deprecated Use setFlippedX() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flipX) { setFlippedX(flipX); };
|
||||
/** @deprecated Use isFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); };
|
||||
/** @deprecated Use setFlippedY() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flipY) { setFlippedY(flipY); };
|
||||
|
||||
/**
|
||||
* A call back function when widget lost of focus.
|
||||
*/
|
||||
void didNotSelectSelf();
|
||||
|
||||
|
||||
/*
|
||||
* Checks a point if in parent's area.
|
||||
*
|
||||
|
@ -439,40 +448,40 @@ public:
|
|||
* @return true if the point is in parent's area, flase otherwise.
|
||||
*/
|
||||
bool clippingParentAreaContainPoint(const Point &pt);
|
||||
|
||||
|
||||
/*
|
||||
* Sends the touch event to widget's parent
|
||||
*/
|
||||
virtual void checkChildInfo(int handleState,Widget* sender,const Point &touchPoint);
|
||||
|
||||
|
||||
/*
|
||||
* Gets the touch began point of widget when widget is selected.
|
||||
*
|
||||
* @return the touch began point.
|
||||
*/
|
||||
const Point& getTouchStartPos();
|
||||
|
||||
|
||||
/*
|
||||
* Gets the touch move point of widget when widget is selected.
|
||||
*
|
||||
* @return the touch move point.
|
||||
*/
|
||||
const Point& getTouchMovePos();
|
||||
|
||||
|
||||
/*
|
||||
* Gets the touch end point of widget when widget is selected.
|
||||
*
|
||||
* @return the touch end point.
|
||||
*/
|
||||
const Point& getTouchEndPos();
|
||||
|
||||
|
||||
/**
|
||||
* Changes the name that is used to identify the widget easily.
|
||||
*
|
||||
* @param A const char* that indentifies the widget.
|
||||
*/
|
||||
void setName(const char* name);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a name that is used to identify the widget easily.
|
||||
*
|
||||
|
@ -481,7 +490,7 @@ public:
|
|||
* @return A const char* that identifies the widget.
|
||||
*/
|
||||
const char* getName() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a type that is widget's type
|
||||
*
|
||||
|
@ -490,21 +499,21 @@ public:
|
|||
* @return A WidgetType
|
||||
*/
|
||||
WidgetType getWidgetType() const;
|
||||
|
||||
|
||||
/**
|
||||
* Changes the size that is widget's size
|
||||
*
|
||||
* @param size that is widget's size
|
||||
*/
|
||||
virtual void setSize(const Size &size);
|
||||
|
||||
|
||||
/**
|
||||
* Changes the percent that is widget's percent size
|
||||
*
|
||||
* @param percent that is widget's percent size
|
||||
*/
|
||||
virtual void setSizePercent(const Point &percent);
|
||||
|
||||
|
||||
/**
|
||||
* Changes the size type of widget.
|
||||
*
|
||||
|
@ -522,21 +531,21 @@ public:
|
|||
* @param type that is widget's size type
|
||||
*/
|
||||
SizeType getSizeType() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns size of widget
|
||||
*
|
||||
* @return size
|
||||
*/
|
||||
const Size& getSize() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns size percent of widget
|
||||
*
|
||||
* @return size percent
|
||||
*/
|
||||
const Point& getSizePercent() const;
|
||||
|
||||
|
||||
/**
|
||||
* Checks a point if is in widget's space
|
||||
*
|
||||
|
@ -545,14 +554,14 @@ public:
|
|||
* @return true if the point is in widget's space, flase otherwise.
|
||||
*/
|
||||
virtual bool hitTest(const Point &pt);
|
||||
|
||||
|
||||
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent);
|
||||
virtual void onTouchMoved(Touch *touch, Event *unusedEvent);
|
||||
virtual void onTouchEnded(Touch *touch, Event *unusedEvent);
|
||||
virtual void onTouchCancelled(Touch *touch, Event *unusedEvent);
|
||||
|
||||
|
||||
/**
|
||||
* Sets a LayoutParameter to widget.
|
||||
* Sets a LayoutParameter to widget.
|
||||
*
|
||||
* @see LayoutParameter
|
||||
*
|
||||
|
@ -561,7 +570,7 @@ public:
|
|||
* @param type Relative or Linear
|
||||
*/
|
||||
void setLayoutParameter(LayoutParameter* parameter);
|
||||
|
||||
|
||||
/**
|
||||
* Gets LayoutParameter of widget.
|
||||
*
|
||||
|
@ -572,21 +581,21 @@ public:
|
|||
* @return LayoutParameter
|
||||
*/
|
||||
LayoutParameter* getLayoutParameter(LayoutParameterType type);
|
||||
|
||||
|
||||
/**
|
||||
* Ignore the widget size
|
||||
*
|
||||
* @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
|
||||
*/
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the widget if is ignore it's size.
|
||||
*
|
||||
* @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
|
||||
*/
|
||||
bool isIgnoreContentAdaptWithSize() const;
|
||||
|
||||
|
||||
/**
|
||||
* Gets world position of widget.
|
||||
*
|
||||
|
@ -602,45 +611,45 @@ public:
|
|||
* @return Node pointer.
|
||||
*/
|
||||
virtual Node* getVirtualRenderer();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the content size of widget.
|
||||
*
|
||||
* Content size is widget's texture size.
|
||||
*/
|
||||
virtual const Size& getContentSize() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
|
||||
Widget* clone();
|
||||
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
|
||||
void updateSizeAndPosition();
|
||||
|
||||
|
||||
/*temp action*/
|
||||
void setActionTag(int tag);
|
||||
int getActionTag();
|
||||
protected:
|
||||
//call back function called when size changed.
|
||||
virtual void onSizeChanged();
|
||||
|
||||
|
||||
//initializes state of widget.
|
||||
virtual bool init();
|
||||
|
||||
|
||||
//initializes renderer of widget.
|
||||
virtual void initRenderer();
|
||||
|
||||
|
||||
//call back function called widget's state changed to normal.
|
||||
virtual void onPressStateChangedToNormal();
|
||||
|
||||
|
||||
//call back function called widget's state changed to selected.
|
||||
virtual void onPressStateChangedToPressed();
|
||||
|
||||
|
||||
//call back function called widget's state changed to dark.
|
||||
virtual void onPressStateChangedToDisabled();
|
||||
void pushDownEvent();
|
||||
|
|
Loading…
Reference in New Issue