mirror of https://github.com/axmolengine/axmol.git
Merge remote-tracking branch 'upstream/develop' into develop
* upstream/develop: modify autotest.py in tools/jenkins-scripts Adjust layout [EventDispatcher] Adds 'pauseEventListenersForTarget', 'resumeEventListenersForTarget' and 'removeEventListenersForTarget'. Add method for editor fixed incorrect effect of Gaussian Blur. Add "override" optimize scissor clipping Fixed bug of label Add clone method to LayoutParameter Fixed bug of reader. Fixed bugs. Fixed bug of reader Fixed bugs
This commit is contained in:
commit
95208d7543
|
@ -267,9 +267,9 @@ void EventDispatcher::visitTarget(Node* node, bool isRootNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::pauseTarget(Node* node)
|
void EventDispatcher::pauseEventListenersForTarget(Node* target, bool recursive/* = false */)
|
||||||
{
|
{
|
||||||
auto listenerIter = _nodeListenersMap.find(node);
|
auto listenerIter = _nodeListenersMap.find(target);
|
||||||
if (listenerIter != _nodeListenersMap.end())
|
if (listenerIter != _nodeListenersMap.end())
|
||||||
{
|
{
|
||||||
auto listeners = listenerIter->second;
|
auto listeners = listenerIter->second;
|
||||||
|
@ -278,11 +278,20 @@ void EventDispatcher::pauseTarget(Node* node)
|
||||||
l->setPaused(true);
|
l->setPaused(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
const auto& children = target->getChildren();
|
||||||
|
for (const auto& child : children)
|
||||||
|
{
|
||||||
|
pauseEventListenersForTarget(child, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::resumeTarget(Node* node)
|
void EventDispatcher::resumeEventListenersForTarget(Node* target, bool recursive/* = false */)
|
||||||
{
|
{
|
||||||
auto listenerIter = _nodeListenersMap.find(node);
|
auto listenerIter = _nodeListenersMap.find(target);
|
||||||
if (listenerIter != _nodeListenersMap.end())
|
if (listenerIter != _nodeListenersMap.end())
|
||||||
{
|
{
|
||||||
auto listeners = listenerIter->second;
|
auto listeners = listenerIter->second;
|
||||||
|
@ -291,12 +300,21 @@ void EventDispatcher::resumeTarget(Node* node)
|
||||||
l->setPaused(false);
|
l->setPaused(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setDirtyForNode(node);
|
setDirtyForNode(target);
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
const auto& children = target->getChildren();
|
||||||
|
for (const auto& child : children)
|
||||||
|
{
|
||||||
|
resumeEventListenersForTarget(child, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::cleanTarget(Node* node)
|
void EventDispatcher::removeEventListenersForTarget(Node* target, bool recursive/* = false */)
|
||||||
{
|
{
|
||||||
auto listenerIter = _nodeListenersMap.find(node);
|
auto listenerIter = _nodeListenersMap.find(target);
|
||||||
if (listenerIter != _nodeListenersMap.end())
|
if (listenerIter != _nodeListenersMap.end())
|
||||||
{
|
{
|
||||||
auto listeners = listenerIter->second;
|
auto listeners = listenerIter->second;
|
||||||
|
@ -306,6 +324,15 @@ void EventDispatcher::cleanTarget(Node* node)
|
||||||
removeEventListener(l);
|
removeEventListener(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
const auto& children = target->getChildren();
|
||||||
|
for (const auto& child : children)
|
||||||
|
{
|
||||||
|
removeEventListenersForTarget(child, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* listener)
|
void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* listener)
|
||||||
|
@ -389,7 +416,7 @@ void EventDispatcher::forceAddEventListener(EventListener* listener)
|
||||||
|
|
||||||
if (node->isRunning())
|
if (node->isRunning())
|
||||||
{
|
{
|
||||||
resumeTarget(node);
|
resumeEventListenersForTarget(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -430,7 +457,7 @@ void EventDispatcher::addEventListenerWithFixedPriority(EventListener* listener,
|
||||||
addEventListener(listener);
|
addEventListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventListenerCustom* EventDispatcher::addCustomEventListener(const std::string &eventName, std::function<void(EventCustom*)> callback)
|
EventListenerCustom* EventDispatcher::addCustomEventListener(const std::string &eventName, const std::function<void(EventCustom*)>& callback)
|
||||||
{
|
{
|
||||||
EventListenerCustom *listener = EventListenerCustom::create(eventName, callback);
|
EventListenerCustom *listener = EventListenerCustom::create(eventName, callback);
|
||||||
addEventListenerWithFixedPriority(listener, 1);
|
addEventListenerWithFixedPriority(listener, 1);
|
||||||
|
@ -553,7 +580,7 @@ void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, std::function<bool(EventListener*)> onEvent)
|
void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, const std::function<bool(EventListener*)>& onEvent)
|
||||||
{
|
{
|
||||||
bool shouldStopPropagation = false;
|
bool shouldStopPropagation = false;
|
||||||
auto fixedPriorityListeners = listeners->getFixedPriorityListeners();
|
auto fixedPriorityListeners = listeners->getFixedPriorityListeners();
|
||||||
|
@ -1121,7 +1148,7 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::removeEventListeners(EventListener::Type listenerType)
|
void EventDispatcher::removeEventListenersForType(EventListener::Type listenerType)
|
||||||
{
|
{
|
||||||
if (listenerType == EventListener::Type::TOUCH_ONE_BY_ONE)
|
if (listenerType == EventListener::Type::TOUCH_ONE_BY_ONE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,8 @@ dispatched.
|
||||||
class EventDispatcher : public Ref
|
class EventDispatcher : public Ref
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// Adds event listener
|
||||||
|
|
||||||
/** Adds a event listener for a specified event with the priority of scene graph.
|
/** Adds a event listener for a specified event with the priority of scene graph.
|
||||||
* @param listener The listener of a specified event.
|
* @param listener The listener of a specified event.
|
||||||
* @param node The priority of the listener is based on the draw order of this node.
|
* @param node The priority of the listener is based on the draw order of this node.
|
||||||
|
@ -76,7 +78,11 @@ public:
|
||||||
It will use a fixed priority of 1.
|
It will use a fixed priority of 1.
|
||||||
@return the generated event. Needed in order to remove the event from the dispather
|
@return the generated event. Needed in order to remove the event from the dispather
|
||||||
*/
|
*/
|
||||||
EventListenerCustom* addCustomEventListener(const std::string &eventName, std::function<void(EventCustom*)> callback);
|
EventListenerCustom* addCustomEventListener(const std::string &eventName, const std::function<void(EventCustom*)>& callback);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Removes event listener
|
||||||
|
|
||||||
/** Remove a listener
|
/** Remove a listener
|
||||||
* @param listener The specified event listener which needs to be removed.
|
* @param listener The specified event listener which needs to be removed.
|
||||||
|
@ -84,7 +90,10 @@ public:
|
||||||
void removeEventListener(EventListener* listener);
|
void removeEventListener(EventListener* listener);
|
||||||
|
|
||||||
/** Removes all listeners with the same event listener type */
|
/** Removes all listeners with the same event listener type */
|
||||||
void removeEventListeners(EventListener::Type listenerType);
|
void removeEventListenersForType(EventListener::Type listenerType);
|
||||||
|
|
||||||
|
/** Removes all listeners which are associated with the specified target. */
|
||||||
|
void removeEventListenersForTarget(Node* target, bool recursive = false);
|
||||||
|
|
||||||
/** Removes all custom listeners with the same event name */
|
/** Removes all custom listeners with the same event name */
|
||||||
void removeCustomEventListeners(const std::string& customEventName);
|
void removeCustomEventListeners(const std::string& customEventName);
|
||||||
|
@ -92,6 +101,18 @@ public:
|
||||||
/** Removes all listeners */
|
/** Removes all listeners */
|
||||||
void removeAllEventListeners();
|
void removeAllEventListeners();
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Pauses / Resumes event listener
|
||||||
|
|
||||||
|
/** Pauses all listeners which are associated the specified target. */
|
||||||
|
void pauseEventListenersForTarget(Node* target, bool recursive = false);
|
||||||
|
|
||||||
|
/** Resumes all listeners which are associated the specified target. */
|
||||||
|
void resumeEventListenersForTarget(Node* target, bool recursive = false);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
/** Sets listener's priority with fixed value. */
|
/** Sets listener's priority with fixed value. */
|
||||||
void setPriority(EventListener* listener, int fixedPriority);
|
void setPriority(EventListener* listener, int fixedPriority);
|
||||||
|
|
||||||
|
@ -101,6 +122,8 @@ public:
|
||||||
/** Checks whether dispatching events is enabled */
|
/** Checks whether dispatching events is enabled */
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
/** Dispatches the event
|
/** Dispatches the event
|
||||||
* Also removes all EventListeners marked for deletion from the
|
* Also removes all EventListeners marked for deletion from the
|
||||||
* event dispatcher list.
|
* event dispatcher list.
|
||||||
|
@ -110,6 +133,8 @@ public:
|
||||||
/** Dispatches a Custom Event with a event name an optional user data */
|
/** Dispatches a Custom Event with a event name an optional user data */
|
||||||
void dispatchCustomEvent(const std::string &eventName, void *optionalUserData = nullptr);
|
void dispatchCustomEvent(const std::string &eventName, void *optionalUserData = nullptr);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
/** Constructor of EventDispatcher */
|
/** Constructor of EventDispatcher */
|
||||||
EventDispatcher();
|
EventDispatcher();
|
||||||
/** Destructor of EventDispatcher */
|
/** Destructor of EventDispatcher */
|
||||||
|
@ -121,15 +146,6 @@ protected:
|
||||||
/** Sets the dirty flag for a node. */
|
/** Sets the dirty flag for a node. */
|
||||||
void setDirtyForNode(Node* node);
|
void setDirtyForNode(Node* node);
|
||||||
|
|
||||||
/** Notifys event dispatcher that the node has been paused. */
|
|
||||||
void pauseTarget(Node* node);
|
|
||||||
|
|
||||||
/** Notifys event dispatcher that the node has been resumed. */
|
|
||||||
void resumeTarget(Node* node);
|
|
||||||
|
|
||||||
/** Notifys event dispatcher that the node has been deleted. */
|
|
||||||
void cleanTarget(Node* node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The vector to store event listeners with scene graph based priority and fixed priority.
|
* The vector to store event listeners with scene graph based priority and fixed priority.
|
||||||
*/
|
*/
|
||||||
|
@ -202,7 +218,7 @@ protected:
|
||||||
void dissociateNodeAndEventListener(Node* node, EventListener* listener);
|
void dissociateNodeAndEventListener(Node* node, EventListener* listener);
|
||||||
|
|
||||||
/** Dispatches event to listeners with a specified listener type */
|
/** Dispatches event to listeners with a specified listener type */
|
||||||
void dispatchEventToListeners(EventListenerVector* listeners, std::function<bool(EventListener*)> onEvent);
|
void dispatchEventToListeners(EventListenerVector* listeners, const std::function<bool(EventListener*)>& onEvent);
|
||||||
|
|
||||||
/// Priority dirty flag
|
/// Priority dirty flag
|
||||||
enum class DirtyFlag
|
enum class DirtyFlag
|
||||||
|
|
|
@ -156,7 +156,7 @@ Node::~Node()
|
||||||
CC_SAFE_RELEASE(_actionManager);
|
CC_SAFE_RELEASE(_actionManager);
|
||||||
CC_SAFE_RELEASE(_scheduler);
|
CC_SAFE_RELEASE(_scheduler);
|
||||||
|
|
||||||
_eventDispatcher->cleanTarget(this);
|
_eventDispatcher->removeEventListenersForTarget(this);
|
||||||
CC_SAFE_RELEASE(_eventDispatcher);
|
CC_SAFE_RELEASE(_eventDispatcher);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
@ -1065,7 +1065,7 @@ void Node::setEventDispatcher(EventDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
if (dispatcher != _eventDispatcher)
|
if (dispatcher != _eventDispatcher)
|
||||||
{
|
{
|
||||||
_eventDispatcher->cleanTarget(this);
|
_eventDispatcher->removeEventListenersForTarget(this);
|
||||||
CC_SAFE_RETAIN(dispatcher);
|
CC_SAFE_RETAIN(dispatcher);
|
||||||
CC_SAFE_RELEASE(_eventDispatcher);
|
CC_SAFE_RELEASE(_eventDispatcher);
|
||||||
_eventDispatcher = dispatcher;
|
_eventDispatcher = dispatcher;
|
||||||
|
@ -1208,14 +1208,14 @@ void Node::resume()
|
||||||
{
|
{
|
||||||
_scheduler->resumeTarget(this);
|
_scheduler->resumeTarget(this);
|
||||||
_actionManager->resumeTarget(this);
|
_actionManager->resumeTarget(this);
|
||||||
_eventDispatcher->resumeTarget(this);
|
_eventDispatcher->resumeEventListenersForTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::pause()
|
void Node::pause()
|
||||||
{
|
{
|
||||||
_scheduler->pauseTarget(this);
|
_scheduler->pauseTarget(this);
|
||||||
_actionManager->pauseTarget(this);
|
_actionManager->pauseTarget(this);
|
||||||
_eventDispatcher->pauseTarget(this);
|
_eventDispatcher->pauseEventListenersForTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::resumeSchedulerAndActions()
|
void Node::resumeSchedulerAndActions()
|
||||||
|
|
|
@ -474,7 +474,7 @@ void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(Widget*wi
|
||||||
{
|
{
|
||||||
checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp);
|
checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp);
|
||||||
}
|
}
|
||||||
|
checkBox->setSelectedState(DICTOOL->getBooleanValue_json(options, "selectedState"));
|
||||||
setColorPropsForWidgetFromJsonDictionary(widget,options);
|
setColorPropsForWidgetFromJsonDictionary(widget,options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1364,7 +1364,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*wi
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
checkBox->setSelectedState(DICTOOL->getBooleanValue_json(options, "selectedState"));
|
||||||
setColorPropsForWidgetFromJsonDictionary(widget,options);
|
setColorPropsForWidgetFromJsonDictionary(widget,options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,11 @@ void Button::setScale9Enabled(bool able)
|
||||||
setBright(_bright);
|
setBright(_bright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Button::isScale9Enabled()
|
||||||
|
{
|
||||||
|
return _scale9Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void Button::ignoreContentAdaptWithSize(bool ignore)
|
void Button::ignoreContentAdaptWithSize(bool ignore)
|
||||||
{
|
{
|
||||||
if (!_scale9Enabled || (_scale9Enabled && !ignore))
|
if (!_scale9Enabled || (_scale9Enabled && !ignore))
|
||||||
|
@ -327,6 +332,11 @@ void Button::setCapInsetsNormalRenderer(const Rect &capInsets)
|
||||||
static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setCapInsets(capInsets);
|
static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& Button::getCapInsetsNormalRenderer()
|
||||||
|
{
|
||||||
|
return _capInsetsNormal;
|
||||||
|
}
|
||||||
|
|
||||||
void Button::setCapInsetsPressedRenderer(const Rect &capInsets)
|
void Button::setCapInsetsPressedRenderer(const Rect &capInsets)
|
||||||
{
|
{
|
||||||
_capInsetsPressed = capInsets;
|
_capInsetsPressed = capInsets;
|
||||||
|
@ -337,6 +347,11 @@ void Button::setCapInsetsPressedRenderer(const Rect &capInsets)
|
||||||
static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setCapInsets(capInsets);
|
static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& Button::getCapInsetsPressedRenderer()
|
||||||
|
{
|
||||||
|
return _capInsetsPressed;
|
||||||
|
}
|
||||||
|
|
||||||
void Button::setCapInsetsDisabledRenderer(const Rect &capInsets)
|
void Button::setCapInsetsDisabledRenderer(const Rect &capInsets)
|
||||||
{
|
{
|
||||||
_capInsetsDisabled = capInsets;
|
_capInsetsDisabled = capInsets;
|
||||||
|
@ -347,6 +362,11 @@ void Button::setCapInsetsDisabledRenderer(const Rect &capInsets)
|
||||||
static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setCapInsets(capInsets);
|
static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& Button::getCapInsetsDisabledRenderer()
|
||||||
|
{
|
||||||
|
return _capInsetsDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
void Button::onPressStateChangedToNormal()
|
void Button::onPressStateChangedToNormal()
|
||||||
{
|
{
|
||||||
_buttonNormalRenderer->setVisible(true);
|
_buttonNormalRenderer->setVisible(true);
|
||||||
|
@ -366,8 +386,7 @@ void Button::onPressStateChangedToNormal()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_buttonNormalRenderer->stopAllActions();
|
_buttonNormalRenderer->stopAllActions();
|
||||||
Action *zoomAction = ScaleTo::create(0.05f, _normalTextureScaleXInSize, _normalTextureScaleYInSize);
|
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
|
||||||
_buttonNormalRenderer->runAction(zoomAction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,8 +412,7 @@ void Button::onPressStateChangedToPressed()
|
||||||
_buttonClickedRenderer->setVisible(true);
|
_buttonClickedRenderer->setVisible(true);
|
||||||
_buttonDisableRenderer->setVisible(false);
|
_buttonDisableRenderer->setVisible(false);
|
||||||
_buttonNormalRenderer->stopAllActions();
|
_buttonNormalRenderer->stopAllActions();
|
||||||
Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f);
|
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize + 0.1f, _normalTextureScaleYInSize + 0.1f);
|
||||||
_buttonNormalRenderer->runAction(zoomAction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsetsNormalRenderer(const Rect &capInsets);
|
void setCapInsetsNormalRenderer(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsetsNormalRenderer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for button, if button is using scale9 renderer.
|
* Sets capinsets for button, if button is using scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -114,6 +116,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsetsPressedRenderer(const Rect &capInsets);
|
void setCapInsetsPressedRenderer(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsetsPressedRenderer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for button, if button is using scale9 renderer.
|
* Sets capinsets for button, if button is using scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -121,6 +125,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsetsDisabledRenderer(const Rect &capInsets);
|
void setCapInsetsDisabledRenderer(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsetsDisabledRenderer();
|
||||||
|
|
||||||
//override "setAnchorPoint" of widget.
|
//override "setAnchorPoint" of widget.
|
||||||
virtual void setAnchorPoint(const Point &pt) override;
|
virtual void setAnchorPoint(const Point &pt) override;
|
||||||
|
|
||||||
|
@ -131,6 +137,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void setScale9Enabled(bool able);
|
virtual void setScale9Enabled(bool able);
|
||||||
|
|
||||||
|
bool isScale9Enabled();
|
||||||
|
|
||||||
//override "setFlipX" of widget.
|
//override "setFlipX" of widget.
|
||||||
virtual void setFlipX(bool flipX) override;
|
virtual void setFlipX(bool flipX) override;
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,11 @@ void ImageView::setScale9Enabled(bool able)
|
||||||
setCapInsets(_capInsets);
|
setCapInsets(_capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImageView::isScale9Enabled()
|
||||||
|
{
|
||||||
|
return _scale9Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageView::ignoreContentAdaptWithSize(bool ignore)
|
void ImageView::ignoreContentAdaptWithSize(bool ignore)
|
||||||
{
|
{
|
||||||
if (!_scale9Enabled || (_scale9Enabled && !ignore))
|
if (!_scale9Enabled || (_scale9Enabled && !ignore))
|
||||||
|
@ -226,6 +231,11 @@ void ImageView::setCapInsets(const Rect &capInsets)
|
||||||
STATIC_CAST_SCALE9SPRITE->setCapInsets(capInsets);
|
STATIC_CAST_SCALE9SPRITE->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& ImageView::getCapInsets()
|
||||||
|
{
|
||||||
|
return _capInsets;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageView::setAnchorPoint(const Point &pt)
|
void ImageView::setAnchorPoint(const Point &pt)
|
||||||
{
|
{
|
||||||
Widget::setAnchorPoint(pt);
|
Widget::setAnchorPoint(pt);
|
||||||
|
|
|
@ -75,6 +75,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setScale9Enabled(bool able);
|
void setScale9Enabled(bool able);
|
||||||
|
|
||||||
|
bool isScale9Enabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for imageview, if imageview is using scale9 renderer.
|
* Sets capinsets for imageview, if imageview is using scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -82,6 +84,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsets(const Rect &capInsets);
|
void setCapInsets(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsets();
|
||||||
|
|
||||||
//override "setFlipX" method of widget.
|
//override "setFlipX" method of widget.
|
||||||
virtual void setFlipX(bool flipX) override;
|
virtual void setFlipX(bool flipX) override;
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ _scissorRectDirty(false),
|
||||||
_clippingRect(Rect::ZERO),
|
_clippingRect(Rect::ZERO),
|
||||||
_clippingParent(nullptr),
|
_clippingParent(nullptr),
|
||||||
_doLayoutDirty(true),
|
_doLayoutDirty(true),
|
||||||
|
_clippingRectDirty(true),
|
||||||
_currentStencilEnabled(GL_FALSE),
|
_currentStencilEnabled(GL_FALSE),
|
||||||
_currentStencilWriteMask(~0),
|
_currentStencilWriteMask(~0),
|
||||||
_currentStencilFunc(GL_ALWAYS),
|
_currentStencilFunc(GL_ALWAYS),
|
||||||
|
@ -95,6 +96,8 @@ void Layout::onEnter()
|
||||||
{
|
{
|
||||||
_clippingStencil->onEnter();
|
_clippingStencil->onEnter();
|
||||||
}
|
}
|
||||||
|
_doLayoutDirty = true;
|
||||||
|
_clippingRectDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::onExit()
|
void Layout::onExit()
|
||||||
|
@ -151,6 +154,23 @@ void Layout::addChild(Node *child, int zOrder, int tag)
|
||||||
_doLayoutDirty = true;
|
_doLayoutDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layout::removeChild(Node *child, bool cleanup)
|
||||||
|
{
|
||||||
|
Widget::removeChild(child, cleanup);
|
||||||
|
_doLayoutDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layout::removeAllChildren()
|
||||||
|
{
|
||||||
|
Widget::removeAllChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layout::removeAllChildrenWithCleanup(bool cleanup)
|
||||||
|
{
|
||||||
|
Widget::removeAllChildrenWithCleanup(cleanup);
|
||||||
|
_doLayoutDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Layout::isClippingEnabled()
|
bool Layout::isClippingEnabled()
|
||||||
{
|
{
|
||||||
return _clippingEnabled;
|
return _clippingEnabled;
|
||||||
|
@ -405,6 +425,11 @@ void Layout::setClippingType(LayoutClippingType type)
|
||||||
setClippingEnabled(clippingEnabled);
|
setClippingEnabled(clippingEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayoutClippingType Layout::getClippingType()
|
||||||
|
{
|
||||||
|
return _clippingType;
|
||||||
|
}
|
||||||
|
|
||||||
void Layout::setStencilClippingSize(const Size &size)
|
void Layout::setStencilClippingSize(const Size &size)
|
||||||
{
|
{
|
||||||
if (_clippingEnabled && _clippingType == LAYOUT_CLIPPING_STENCIL)
|
if (_clippingEnabled && _clippingType == LAYOUT_CLIPPING_STENCIL)
|
||||||
|
@ -422,79 +447,83 @@ void Layout::setStencilClippingSize(const Size &size)
|
||||||
|
|
||||||
const Rect& Layout::getClippingRect()
|
const Rect& Layout::getClippingRect()
|
||||||
{
|
{
|
||||||
Point worldPos = convertToWorldSpace(Point::ZERO);
|
if (_clippingRectDirty)
|
||||||
AffineTransform t = getNodeToWorldAffineTransform();
|
|
||||||
float scissorWidth = _size.width*t.a;
|
|
||||||
float scissorHeight = _size.height*t.d;
|
|
||||||
Rect parentClippingRect;
|
|
||||||
Layout* parent = this;
|
|
||||||
bool firstClippingParentFounded = false;
|
|
||||||
while (parent)
|
|
||||||
{
|
{
|
||||||
parent = dynamic_cast<Layout*>(parent->getParent());
|
Point worldPos = convertToWorldSpace(Point::ZERO);
|
||||||
if(parent)
|
AffineTransform t = getNodeToWorldAffineTransform();
|
||||||
|
float scissorWidth = _size.width*t.a;
|
||||||
|
float scissorHeight = _size.height*t.d;
|
||||||
|
Rect parentClippingRect;
|
||||||
|
Layout* parent = this;
|
||||||
|
bool firstClippingParentFounded = false;
|
||||||
|
while (parent)
|
||||||
{
|
{
|
||||||
if (parent->isClippingEnabled())
|
parent = dynamic_cast<Layout*>(parent->getParent());
|
||||||
|
if(parent)
|
||||||
{
|
{
|
||||||
if (!firstClippingParentFounded)
|
if (parent->isClippingEnabled())
|
||||||
{
|
{
|
||||||
_clippingParent = parent;
|
if (!firstClippingParentFounded)
|
||||||
firstClippingParentFounded = true;
|
{
|
||||||
break;
|
_clippingParent = parent;
|
||||||
|
firstClippingParentFounded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_clippingParent)
|
if (_clippingParent)
|
||||||
{
|
{
|
||||||
parentClippingRect = _clippingParent->getClippingRect();
|
parentClippingRect = _clippingParent->getClippingRect();
|
||||||
float finalX = worldPos.x - (scissorWidth * _anchorPoint.x);
|
float finalX = worldPos.x - (scissorWidth * _anchorPoint.x);
|
||||||
float finalY = worldPos.y - (scissorHeight * _anchorPoint.y);
|
float finalY = worldPos.y - (scissorHeight * _anchorPoint.y);
|
||||||
float finalWidth = scissorWidth;
|
float finalWidth = scissorWidth;
|
||||||
float finalHeight = scissorHeight;
|
float finalHeight = scissorHeight;
|
||||||
|
|
||||||
float leftOffset = worldPos.x - parentClippingRect.origin.x;
|
float leftOffset = worldPos.x - parentClippingRect.origin.x;
|
||||||
if (leftOffset < 0.0f)
|
if (leftOffset < 0.0f)
|
||||||
{
|
{
|
||||||
finalX = parentClippingRect.origin.x;
|
finalX = parentClippingRect.origin.x;
|
||||||
finalWidth += leftOffset;
|
finalWidth += leftOffset;
|
||||||
|
}
|
||||||
|
float rightOffset = (worldPos.x + scissorWidth) - (parentClippingRect.origin.x + parentClippingRect.size.width);
|
||||||
|
if (rightOffset > 0.0f)
|
||||||
|
{
|
||||||
|
finalWidth -= rightOffset;
|
||||||
|
}
|
||||||
|
float topOffset = (worldPos.y + scissorHeight) - (parentClippingRect.origin.y + parentClippingRect.size.height);
|
||||||
|
if (topOffset > 0.0f)
|
||||||
|
{
|
||||||
|
finalHeight -= topOffset;
|
||||||
|
}
|
||||||
|
float bottomOffset = worldPos.y - parentClippingRect.origin.y;
|
||||||
|
if (bottomOffset < 0.0f)
|
||||||
|
{
|
||||||
|
finalY = parentClippingRect.origin.x;
|
||||||
|
finalHeight += bottomOffset;
|
||||||
|
}
|
||||||
|
if (finalWidth < 0.0f)
|
||||||
|
{
|
||||||
|
finalWidth = 0.0f;
|
||||||
|
}
|
||||||
|
if (finalHeight < 0.0f)
|
||||||
|
{
|
||||||
|
finalHeight = 0.0f;
|
||||||
|
}
|
||||||
|
_clippingRect.origin.x = finalX;
|
||||||
|
_clippingRect.origin.y = finalY;
|
||||||
|
_clippingRect.size.width = finalWidth;
|
||||||
|
_clippingRect.size.height = finalHeight;
|
||||||
}
|
}
|
||||||
float rightOffset = (worldPos.x + scissorWidth) - (parentClippingRect.origin.x + parentClippingRect.size.width);
|
else
|
||||||
if (rightOffset > 0.0f)
|
|
||||||
{
|
{
|
||||||
finalWidth -= rightOffset;
|
_clippingRect.origin.x = worldPos.x - (scissorWidth * _anchorPoint.x);
|
||||||
|
_clippingRect.origin.y = worldPos.y - (scissorHeight * _anchorPoint.y);
|
||||||
|
_clippingRect.size.width = scissorWidth;
|
||||||
|
_clippingRect.size.height = scissorHeight;
|
||||||
}
|
}
|
||||||
float topOffset = (worldPos.y + scissorHeight) - (parentClippingRect.origin.y + parentClippingRect.size.height);
|
_clippingRectDirty = false;
|
||||||
if (topOffset > 0.0f)
|
|
||||||
{
|
|
||||||
finalHeight -= topOffset;
|
|
||||||
}
|
|
||||||
float bottomOffset = worldPos.y - parentClippingRect.origin.y;
|
|
||||||
if (bottomOffset < 0.0f)
|
|
||||||
{
|
|
||||||
finalY = parentClippingRect.origin.x;
|
|
||||||
finalHeight += bottomOffset;
|
|
||||||
}
|
|
||||||
if (finalWidth < 0.0f)
|
|
||||||
{
|
|
||||||
finalWidth = 0.0f;
|
|
||||||
}
|
|
||||||
if (finalHeight < 0.0f)
|
|
||||||
{
|
|
||||||
finalHeight = 0.0f;
|
|
||||||
}
|
|
||||||
_clippingRect.origin.x = finalX;
|
|
||||||
_clippingRect.origin.y = finalY;
|
|
||||||
_clippingRect.size.width = finalWidth;
|
|
||||||
_clippingRect.size.height = finalHeight;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_clippingRect.origin.x = worldPos.x - (scissorWidth * _anchorPoint.x);
|
|
||||||
_clippingRect.origin.y = worldPos.y - (scissorHeight * _anchorPoint.y);
|
|
||||||
_clippingRect.size.width = scissorWidth;
|
|
||||||
_clippingRect.size.height = scissorHeight;
|
|
||||||
}
|
}
|
||||||
return _clippingRect;
|
return _clippingRect;
|
||||||
}
|
}
|
||||||
|
@ -505,6 +534,7 @@ void Layout::onSizeChanged()
|
||||||
setContentSize(_size);
|
setContentSize(_size);
|
||||||
setStencilClippingSize(_size);
|
setStencilClippingSize(_size);
|
||||||
_doLayoutDirty = true;
|
_doLayoutDirty = true;
|
||||||
|
_clippingRectDirty = true;
|
||||||
if (_backGroundImage)
|
if (_backGroundImage)
|
||||||
{
|
{
|
||||||
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
||||||
|
@ -613,6 +643,11 @@ void Layout::setBackGroundImageCapInsets(const Rect &capInsets)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& Layout::getBackGroundImageCapInsets()
|
||||||
|
{
|
||||||
|
return _backGroundImageCapInsets;
|
||||||
|
}
|
||||||
|
|
||||||
void Layout::supplyTheLayoutParameterLackToChild(Widget *child)
|
void Layout::supplyTheLayoutParameterLackToChild(Widget *child)
|
||||||
{
|
{
|
||||||
if (!child)
|
if (!child)
|
||||||
|
@ -740,6 +775,11 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayoutBackGroundColorType Layout::getBackGroundColorType()
|
||||||
|
{
|
||||||
|
return _colorType;
|
||||||
|
}
|
||||||
|
|
||||||
void Layout::setBackGroundColor(const Color3B &color)
|
void Layout::setBackGroundColor(const Color3B &color)
|
||||||
{
|
{
|
||||||
_cColor = color;
|
_cColor = color;
|
||||||
|
@ -749,6 +789,11 @@ void Layout::setBackGroundColor(const Color3B &color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Color3B& Layout::getBackGroundColor()
|
||||||
|
{
|
||||||
|
return _cColor;
|
||||||
|
}
|
||||||
|
|
||||||
void Layout::setBackGroundColor(const Color3B &startColor, const Color3B &endColor)
|
void Layout::setBackGroundColor(const Color3B &startColor, const Color3B &endColor)
|
||||||
{
|
{
|
||||||
_gStartColor = startColor;
|
_gStartColor = startColor;
|
||||||
|
@ -763,6 +808,16 @@ void Layout::setBackGroundColor(const Color3B &startColor, const Color3B &endCol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Color3B& Layout::getBackGroundStartColor()
|
||||||
|
{
|
||||||
|
return _gStartColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Color3B& Layout::getBackGroundEndColor()
|
||||||
|
{
|
||||||
|
return _gEndColor;
|
||||||
|
}
|
||||||
|
|
||||||
void Layout::setBackGroundColorOpacity(int opacity)
|
void Layout::setBackGroundColorOpacity(int opacity)
|
||||||
{
|
{
|
||||||
_cOpacity = opacity;
|
_cOpacity = opacity;
|
||||||
|
@ -781,6 +836,11 @@ void Layout::setBackGroundColorOpacity(int opacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Layout::getBackGroundColorOpacity()
|
||||||
|
{
|
||||||
|
return _cOpacity;
|
||||||
|
}
|
||||||
|
|
||||||
void Layout::setBackGroundColorVector(const Point &vector)
|
void Layout::setBackGroundColorVector(const Point &vector)
|
||||||
{
|
{
|
||||||
_alongVector = vector;
|
_alongVector = vector;
|
||||||
|
@ -790,6 +850,11 @@ void Layout::setBackGroundColorVector(const Point &vector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Point& Layout::getBackGroundColorVector()
|
||||||
|
{
|
||||||
|
return _alongVector;
|
||||||
|
}
|
||||||
|
|
||||||
const Size& Layout::getBackGroundImageTextureSize() const
|
const Size& Layout::getBackGroundImageTextureSize() const
|
||||||
{
|
{
|
||||||
return _backGroundImageTextureSize;
|
return _backGroundImageTextureSize;
|
||||||
|
@ -1192,128 +1257,50 @@ void Layout::doLayout()
|
||||||
|
|
||||||
case RELATIVE_LOCATION_ABOVE_LEFTALIGN:
|
case RELATIVE_LOCATION_ABOVE_LEFTALIGN:
|
||||||
finalPosY += mg.bottom;
|
finalPosY += mg.bottom;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT)
|
|
||||||
{
|
|
||||||
finalPosY += relativeWidgetMargin.top;
|
|
||||||
}
|
|
||||||
finalPosX += mg.left;
|
finalPosX += mg.left;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_ABOVE_RIGHTALIGN:
|
case RELATIVE_LOCATION_ABOVE_RIGHTALIGN:
|
||||||
finalPosY += mg.bottom;
|
finalPosY += mg.bottom;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT)
|
|
||||||
{
|
|
||||||
finalPosY += relativeWidgetMargin.top;
|
|
||||||
}
|
|
||||||
finalPosX -= mg.right;
|
finalPosX -= mg.right;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_ABOVE_CENTER:
|
case RELATIVE_LOCATION_ABOVE_CENTER:
|
||||||
finalPosY += mg.bottom;
|
finalPosY += mg.bottom;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT)
|
|
||||||
{
|
|
||||||
finalPosY += relativeWidgetMargin.top;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RELATIVE_LOCATION_LEFT_OF_TOPALIGN:
|
case RELATIVE_LOCATION_LEFT_OF_TOPALIGN:
|
||||||
finalPosX -= mg.right;
|
finalPosX -= mg.right;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL)
|
|
||||||
{
|
|
||||||
finalPosX -= relativeWidgetMargin.left;
|
|
||||||
}
|
|
||||||
finalPosY -= mg.top;
|
finalPosY -= mg.top;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN:
|
case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN:
|
||||||
finalPosX -= mg.right;
|
finalPosX -= mg.right;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL)
|
|
||||||
{
|
|
||||||
finalPosX -= relativeWidgetMargin.left;
|
|
||||||
}
|
|
||||||
finalPosY += mg.bottom;
|
finalPosY += mg.bottom;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_LEFT_OF_CENTER:
|
case RELATIVE_LOCATION_LEFT_OF_CENTER:
|
||||||
finalPosX -= mg.right;
|
finalPosX -= mg.right;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL)
|
|
||||||
{
|
|
||||||
finalPosX -= relativeWidgetMargin.left;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN:
|
case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN:
|
||||||
finalPosX += mg.left;
|
finalPosX += mg.left;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL)
|
|
||||||
{
|
|
||||||
finalPosX += relativeWidgetMargin.right;
|
|
||||||
}
|
|
||||||
finalPosY -= mg.top;
|
finalPosY -= mg.top;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN:
|
case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN:
|
||||||
finalPosX += mg.left;
|
finalPosX += mg.left;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL)
|
|
||||||
{
|
|
||||||
finalPosX += relativeWidgetMargin.right;
|
|
||||||
}
|
|
||||||
finalPosY += mg.bottom;
|
finalPosY += mg.bottom;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_RIGHT_OF_CENTER:
|
case RELATIVE_LOCATION_RIGHT_OF_CENTER:
|
||||||
finalPosX += mg.left;
|
finalPosX += mg.left;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL)
|
|
||||||
{
|
|
||||||
finalPosX += relativeWidgetMargin.right;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RELATIVE_LOCATION_BELOW_LEFTALIGN:
|
case RELATIVE_LOCATION_BELOW_LEFTALIGN:
|
||||||
finalPosY -= mg.top;
|
finalPosY -= mg.top;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL)
|
|
||||||
{
|
|
||||||
finalPosY -= relativeWidgetMargin.bottom;
|
|
||||||
}
|
|
||||||
finalPosX += mg.left;
|
finalPosX += mg.left;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_BELOW_RIGHTALIGN:
|
case RELATIVE_LOCATION_BELOW_RIGHTALIGN:
|
||||||
finalPosY -= mg.top;
|
finalPosY -= mg.top;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL)
|
|
||||||
{
|
|
||||||
finalPosY -= relativeWidgetMargin.bottom;
|
|
||||||
}
|
|
||||||
finalPosX -= mg.right;
|
finalPosX -= mg.right;
|
||||||
break;
|
break;
|
||||||
case RELATIVE_LOCATION_BELOW_CENTER:
|
case RELATIVE_LOCATION_BELOW_CENTER:
|
||||||
finalPosY -= mg.top;
|
finalPosY -= mg.top;
|
||||||
if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
|
|
||||||
&& relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL)
|
|
||||||
{
|
|
||||||
finalPosY -= relativeWidgetMargin.bottom;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -91,6 +91,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundImageCapInsets(const Rect& capInsets);
|
void setBackGroundImageCapInsets(const Rect& capInsets);
|
||||||
|
|
||||||
|
const Rect& getBackGroundImageCapInsets();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets Color Type for layout.
|
* Sets Color Type for layout.
|
||||||
*
|
*
|
||||||
|
@ -98,6 +100,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundColorType(LayoutBackGroundColorType type);
|
void setBackGroundColorType(LayoutBackGroundColorType type);
|
||||||
|
|
||||||
|
LayoutBackGroundColorType getBackGroundColorType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets background iamge use scale9 renderer.
|
* Sets background iamge use scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -105,6 +109,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundImageScale9Enabled(bool enabled);
|
void setBackGroundImageScale9Enabled(bool enabled);
|
||||||
|
|
||||||
|
bool isBackGroundImageScale9Enabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets background color for layout, if color type is LAYOUT_COLOR_SOLID
|
* Sets background color for layout, if color type is LAYOUT_COLOR_SOLID
|
||||||
*
|
*
|
||||||
|
@ -112,6 +118,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundColor(const Color3B &color);
|
void setBackGroundColor(const Color3B &color);
|
||||||
|
|
||||||
|
const Color3B& getBackGroundColor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets background color for layout, if color type is LAYOUT_COLOR_GRADIENT
|
* Sets background color for layout, if color type is LAYOUT_COLOR_GRADIENT
|
||||||
*
|
*
|
||||||
|
@ -121,6 +129,10 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundColor(const Color3B &startColor, const Color3B &endColor);
|
void setBackGroundColor(const Color3B &startColor, const Color3B &endColor);
|
||||||
|
|
||||||
|
const Color3B& getBackGroundStartColor();
|
||||||
|
|
||||||
|
const Color3B& getBackGroundEndColor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets background opacity layout.
|
* Sets background opacity layout.
|
||||||
*
|
*
|
||||||
|
@ -128,6 +140,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundColorOpacity(int opacity);
|
void setBackGroundColorOpacity(int opacity);
|
||||||
|
|
||||||
|
int getBackGroundColorOpacity();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets background color vector for layout, if color type is LAYOUT_COLOR_GRADIENT
|
* Sets background color vector for layout, if color type is LAYOUT_COLOR_GRADIENT
|
||||||
*
|
*
|
||||||
|
@ -135,6 +149,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setBackGroundColorVector(const Point &vector);
|
void setBackGroundColorVector(const Point &vector);
|
||||||
|
|
||||||
|
const Point& getBackGroundColorVector();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the background image of layout.
|
* Remove the background image of layout.
|
||||||
*/
|
*/
|
||||||
|
@ -158,6 +174,8 @@ public:
|
||||||
|
|
||||||
void setClippingType(LayoutClippingType type);
|
void setClippingType(LayoutClippingType type);
|
||||||
|
|
||||||
|
LayoutClippingType getClippingType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if layout is clipping enabled.
|
* Gets if layout is clipping enabled.
|
||||||
*
|
*
|
||||||
|
@ -209,6 +227,24 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||||
|
|
||||||
|
virtual void removeChild(Node* child, bool cleanup = true) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all children from the container with a cleanup.
|
||||||
|
*
|
||||||
|
* @see `removeAllChildrenWithCleanup(bool)`
|
||||||
|
*/
|
||||||
|
virtual void removeAllChildren() override;
|
||||||
|
/**
|
||||||
|
* Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter.
|
||||||
|
*
|
||||||
|
* @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise.
|
||||||
|
* @js removeAllChildren
|
||||||
|
* @lua removeAllChildren
|
||||||
|
*/
|
||||||
|
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||||
|
|
||||||
|
|
||||||
virtual void visit();
|
virtual void visit();
|
||||||
|
|
||||||
virtual void sortAllChildren() override;
|
virtual void sortAllChildren() override;
|
||||||
|
@ -273,6 +309,7 @@ protected:
|
||||||
Rect _clippingRect;
|
Rect _clippingRect;
|
||||||
Layout* _clippingParent;
|
Layout* _clippingParent;
|
||||||
bool _doLayoutDirty;
|
bool _doLayoutDirty;
|
||||||
|
bool _clippingRectDirty;
|
||||||
|
|
||||||
//clipping
|
//clipping
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "gui/UILayoutParameter.h"
|
#include "gui/UILayoutParameter.h"
|
||||||
#include "gui/UILayout.h"
|
#include "gui/UILayout.h"
|
||||||
|
@ -57,6 +57,23 @@ LayoutParameterType LayoutParameter::getLayoutType() const
|
||||||
return _layoutParameterType;
|
return _layoutParameterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayoutParameter* LayoutParameter::clone()
|
||||||
|
{
|
||||||
|
LayoutParameter* clonedParameter = createCloneInstance();
|
||||||
|
clonedParameter->copyProperties(this);
|
||||||
|
return clonedParameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutParameter* LayoutParameter::createCloneInstance()
|
||||||
|
{
|
||||||
|
return LayoutParameter::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutParameter::copyProperties(LayoutParameter *model)
|
||||||
|
{
|
||||||
|
_margin = model->_margin;
|
||||||
|
}
|
||||||
|
|
||||||
LinearLayoutParameter* LinearLayoutParameter::create()
|
LinearLayoutParameter* LinearLayoutParameter::create()
|
||||||
{
|
{
|
||||||
LinearLayoutParameter* parameter = new LinearLayoutParameter();
|
LinearLayoutParameter* parameter = new LinearLayoutParameter();
|
||||||
|
@ -79,6 +96,21 @@ LinearGravity LinearLayoutParameter::getGravity() const
|
||||||
return _linearGravity;
|
return _linearGravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayoutParameter* LinearLayoutParameter::createCloneInstance()
|
||||||
|
{
|
||||||
|
return LinearLayoutParameter::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinearLayoutParameter::copyProperties(LayoutParameter *model)
|
||||||
|
{
|
||||||
|
LayoutParameter::copyProperties(model);
|
||||||
|
LinearLayoutParameter* parameter = dynamic_cast<LinearLayoutParameter*>(model);
|
||||||
|
if (parameter)
|
||||||
|
{
|
||||||
|
setGravity(parameter->_linearGravity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RelativeLayoutParameter* RelativeLayoutParameter::create()
|
RelativeLayoutParameter* RelativeLayoutParameter::create()
|
||||||
{
|
{
|
||||||
RelativeLayoutParameter* parameter = new RelativeLayoutParameter();
|
RelativeLayoutParameter* parameter = new RelativeLayoutParameter();
|
||||||
|
@ -121,6 +153,23 @@ const char* RelativeLayoutParameter::getRelativeName() const
|
||||||
return _relativeLayoutName.c_str();
|
return _relativeLayoutName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayoutParameter* RelativeLayoutParameter::createCloneInstance()
|
||||||
|
{
|
||||||
|
return RelativeLayoutParameter::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RelativeLayoutParameter::copyProperties(LayoutParameter *model)
|
||||||
|
{
|
||||||
|
LayoutParameter::copyProperties(model);
|
||||||
|
RelativeLayoutParameter* parameter = dynamic_cast<RelativeLayoutParameter*>(model);
|
||||||
|
if (parameter)
|
||||||
|
{
|
||||||
|
setAlign(parameter->_relativeAlign);
|
||||||
|
setRelativeName(parameter->_relativeLayoutName.c_str());
|
||||||
|
setRelativeToWidgetName(parameter->_relativeWidgetName.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __LAYOUTPARMETER_H__
|
#ifndef __LAYOUTPARMETER_H__
|
||||||
#define __LAYOUTPARMETER_H__
|
#define __LAYOUTPARMETER_H__
|
||||||
|
@ -86,6 +86,10 @@ public:
|
||||||
* @return LayoutParameterType
|
* @return LayoutParameterType
|
||||||
*/
|
*/
|
||||||
LayoutParameterType getLayoutType() const;
|
LayoutParameterType getLayoutType() const;
|
||||||
|
|
||||||
|
LayoutParameter* clone();
|
||||||
|
virtual LayoutParameter* createCloneInstance();
|
||||||
|
virtual void copyProperties(LayoutParameter* model);
|
||||||
protected:
|
protected:
|
||||||
Margin _margin;
|
Margin _margin;
|
||||||
LayoutParameterType _layoutParameterType;
|
LayoutParameterType _layoutParameterType;
|
||||||
|
@ -130,6 +134,8 @@ public:
|
||||||
* @return LinearGravity
|
* @return LinearGravity
|
||||||
*/
|
*/
|
||||||
LinearGravity getGravity() const;
|
LinearGravity getGravity() const;
|
||||||
|
virtual LayoutParameter* createCloneInstance() override;
|
||||||
|
virtual void copyProperties(LayoutParameter* model) override;
|
||||||
protected:
|
protected:
|
||||||
LinearGravity _linearGravity;
|
LinearGravity _linearGravity;
|
||||||
};
|
};
|
||||||
|
@ -202,6 +208,9 @@ public:
|
||||||
* @return name
|
* @return name
|
||||||
*/
|
*/
|
||||||
const char* getRelativeName() const;
|
const char* getRelativeName() const;
|
||||||
|
|
||||||
|
virtual LayoutParameter* createCloneInstance() override;
|
||||||
|
virtual void copyProperties(LayoutParameter* model) override;
|
||||||
protected:
|
protected:
|
||||||
RelativeAlign _relativeAlign;
|
RelativeAlign _relativeAlign;
|
||||||
std::string _relativeWidgetName;
|
std::string _relativeWidgetName;
|
||||||
|
|
|
@ -348,6 +348,11 @@ void ListView::setItemsMargin(float margin)
|
||||||
_refreshViewDirty = true;
|
_refreshViewDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ListView::getItemsMargin()
|
||||||
|
{
|
||||||
|
return _itemsMargin;
|
||||||
|
}
|
||||||
|
|
||||||
void ListView::setDirection(SCROLLVIEW_DIR dir)
|
void ListView::setDirection(SCROLLVIEW_DIR dir)
|
||||||
{
|
{
|
||||||
switch (dir)
|
switch (dir)
|
||||||
|
|
|
@ -150,6 +150,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setItemsMargin(float margin);
|
void setItemsMargin(float margin);
|
||||||
|
|
||||||
|
float getItemsMargin();
|
||||||
|
|
||||||
virtual void sortAllChildren() override;
|
virtual void sortAllChildren() override;
|
||||||
|
|
||||||
ssize_t getCurSelectedIndex() const;
|
ssize_t getCurSelectedIndex() const;
|
||||||
|
|
|
@ -196,6 +196,11 @@ void LoadingBar::setScale9Enabled(bool enabled)
|
||||||
setCapInsets(_capInsets);
|
setCapInsets(_capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoadingBar::isScale9Enabled()
|
||||||
|
{
|
||||||
|
return _scale9Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void LoadingBar::setCapInsets(const Rect &capInsets)
|
void LoadingBar::setCapInsets(const Rect &capInsets)
|
||||||
{
|
{
|
||||||
_capInsets = capInsets;
|
_capInsets = capInsets;
|
||||||
|
@ -206,6 +211,11 @@ void LoadingBar::setCapInsets(const Rect &capInsets)
|
||||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->setCapInsets(capInsets);
|
static_cast<extension::Scale9Sprite*>(_barRenderer)->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& LoadingBar::getCapInsets()
|
||||||
|
{
|
||||||
|
return _capInsets;
|
||||||
|
}
|
||||||
|
|
||||||
void LoadingBar::setPercent(int percent)
|
void LoadingBar::setPercent(int percent)
|
||||||
{
|
{
|
||||||
if ( percent < 0 || percent > 100)
|
if ( percent < 0 || percent > 100)
|
||||||
|
@ -334,6 +344,7 @@ void LoadingBar::copySpecialProperties(Widget *widget)
|
||||||
loadTexture(loadingBar->_textureFile.c_str(), loadingBar->_renderBarTexType);
|
loadTexture(loadingBar->_textureFile.c_str(), loadingBar->_renderBarTexType);
|
||||||
setCapInsets(loadingBar->_capInsets);
|
setCapInsets(loadingBar->_capInsets);
|
||||||
setPercent(loadingBar->_percent);
|
setPercent(loadingBar->_percent);
|
||||||
|
setDirection(loadingBar->_barType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setScale9Enabled(bool enabled);
|
void setScale9Enabled(bool enabled);
|
||||||
|
|
||||||
|
bool isScale9Enabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for loadingbar, if loadingbar is using scale9 renderer.
|
* Sets capinsets for loadingbar, if loadingbar is using scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -113,6 +115,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsets(const Rect &capInsets);
|
void setCapInsets(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsets();
|
||||||
|
|
||||||
//override "ignoreContentAdaptWithSize" method of widget.
|
//override "ignoreContentAdaptWithSize" method of widget.
|
||||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,46 @@ Widget* ScrollView::getChildByName(const char *name)
|
||||||
return _innerContainer->getChildByName(name);
|
return _innerContainer->getChildByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScrollView::addNode(Node* node)
|
||||||
|
{
|
||||||
|
Layout::addNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScrollView::addNode(Node * node, int zOrder)
|
||||||
|
{
|
||||||
|
Layout::addNode(node, zOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScrollView::addNode(Node* node, int zOrder, int tag)
|
||||||
|
{
|
||||||
|
_innerContainer->addNode(node, zOrder, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
Node* ScrollView::getNodeByTag(int tag)
|
||||||
|
{
|
||||||
|
return _innerContainer->getNodeByTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Node*>& ScrollView::getNodes()
|
||||||
|
{
|
||||||
|
return _innerContainer->getNodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScrollView::removeNode(Node* node)
|
||||||
|
{
|
||||||
|
_innerContainer->removeNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScrollView::removeNodeByTag(int tag)
|
||||||
|
{
|
||||||
|
_innerContainer->removeNodeByTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScrollView::removeAllNodes()
|
||||||
|
{
|
||||||
|
_innerContainer->removeAllNodes();
|
||||||
|
}
|
||||||
|
|
||||||
void ScrollView::moveChildren(float offsetX, float offsetY)
|
void ScrollView::moveChildren(float offsetX, float offsetY)
|
||||||
{
|
{
|
||||||
_moveChildPoint = _innerContainer->getPosition() + Point(offsetX, offsetY);
|
_moveChildPoint = _innerContainer->getPosition() + Point(offsetX, offsetY);
|
||||||
|
|
|
@ -274,6 +274,22 @@ public:
|
||||||
|
|
||||||
virtual Widget* getChildByName(const char* name) override;
|
virtual Widget* getChildByName(const char* name) override;
|
||||||
|
|
||||||
|
virtual void addNode(Node* node) override;
|
||||||
|
|
||||||
|
virtual void addNode(Node * node, int zOrder) override;
|
||||||
|
|
||||||
|
virtual void addNode(Node* node, int zOrder, int tag) override;
|
||||||
|
|
||||||
|
virtual Node * getNodeByTag(int tag) override;
|
||||||
|
|
||||||
|
virtual Vector<Node*>& getNodes() override;
|
||||||
|
|
||||||
|
virtual void removeNode(Node* node) override;
|
||||||
|
|
||||||
|
virtual void removeNodeByTag(int tag) override;
|
||||||
|
|
||||||
|
virtual void removeAllNodes() override;
|
||||||
|
|
||||||
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
|
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
|
||||||
virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override;
|
virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override;
|
||||||
virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;
|
virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;
|
||||||
|
|
|
@ -217,6 +217,11 @@ void Slider::setScale9Enabled(bool able)
|
||||||
setCapInsetProgressBarRebderer(_capInsetsProgressBarRenderer);
|
setCapInsetProgressBarRebderer(_capInsetsProgressBarRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Slider::isScale9Enabled()
|
||||||
|
{
|
||||||
|
return _scale9Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void Slider::ignoreContentAdaptWithSize(bool ignore)
|
void Slider::ignoreContentAdaptWithSize(bool ignore)
|
||||||
{
|
{
|
||||||
if (!_scale9Enabled || (_scale9Enabled && !ignore))
|
if (!_scale9Enabled || (_scale9Enabled && !ignore))
|
||||||
|
@ -242,6 +247,11 @@ void Slider::setCapInsetsBarRenderer(const Rect &capInsets)
|
||||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->setCapInsets(capInsets);
|
static_cast<extension::Scale9Sprite*>(_barRenderer)->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& Slider::getCapInsetsBarRenderer()
|
||||||
|
{
|
||||||
|
return _capInsetsBarRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets)
|
void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets)
|
||||||
{
|
{
|
||||||
_capInsetsProgressBarRenderer = capInsets;
|
_capInsetsProgressBarRenderer = capInsets;
|
||||||
|
@ -252,6 +262,11 @@ void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets)
|
||||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setCapInsets(capInsets);
|
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setCapInsets(capInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Rect& Slider::getCapInsetsProgressBarRebderer()
|
||||||
|
{
|
||||||
|
return _capInsetsProgressBarRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
void Slider::loadSlidBallTextures(const char* normal,const char* pressed,const char* disabled,TextureResType texType)
|
void Slider::loadSlidBallTextures(const char* normal,const char* pressed,const char* disabled,TextureResType texType)
|
||||||
{
|
{
|
||||||
loadSlidBallTextureNormal(normal, texType);
|
loadSlidBallTextureNormal(normal, texType);
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setScale9Enabled(bool able);
|
void setScale9Enabled(bool able);
|
||||||
|
|
||||||
|
bool isScale9Enabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for slider, if slider is using scale9 renderer.
|
* Sets capinsets for slider, if slider is using scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -91,6 +93,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsetsBarRenderer(const Rect &capInsets);
|
void setCapInsetsBarRenderer(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsetsBarRenderer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for slider, if slider is using scale9 renderer.
|
* Sets capinsets for slider, if slider is using scale9 renderer.
|
||||||
*
|
*
|
||||||
|
@ -98,6 +102,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCapInsetProgressBarRebderer(const Rect &capInsets);
|
void setCapInsetProgressBarRebderer(const Rect &capInsets);
|
||||||
|
|
||||||
|
const Rect& getCapInsetsProgressBarRebderer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load textures for slider ball.
|
* Load textures for slider ball.
|
||||||
*
|
*
|
||||||
|
|
|
@ -99,6 +99,11 @@ void Text::setFontSize(int size)
|
||||||
labelScaleChangedWithSize();
|
labelScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Text::getFontSize()
|
||||||
|
{
|
||||||
|
return _fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
void Text::setFontName(const std::string& name)
|
void Text::setFontName(const std::string& name)
|
||||||
{
|
{
|
||||||
_fontName = name;
|
_fontName = name;
|
||||||
|
@ -106,35 +111,52 @@ void Text::setFontName(const std::string& name)
|
||||||
labelScaleChangedWithSize();
|
labelScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& Text::getFontName()
|
||||||
|
{
|
||||||
|
return _fontName;
|
||||||
|
}
|
||||||
|
|
||||||
void Text::setTextAreaSize(const Size &size)
|
void Text::setTextAreaSize(const Size &size)
|
||||||
{
|
{
|
||||||
_labelRenderer->setDimensions(size);
|
_labelRenderer->setDimensions(size);
|
||||||
labelScaleChangedWithSize();
|
labelScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Size& Text::getTextAreaSize()
|
||||||
|
{
|
||||||
|
return _labelRenderer->getDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
void Text::setTextHorizontalAlignment(TextHAlignment alignment)
|
void Text::setTextHorizontalAlignment(TextHAlignment alignment)
|
||||||
{
|
{
|
||||||
_labelRenderer->setHorizontalAlignment(alignment);
|
_labelRenderer->setHorizontalAlignment(alignment);
|
||||||
labelScaleChangedWithSize();
|
labelScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextHAlignment Text::getTextHorizontalAlignment()
|
||||||
|
{
|
||||||
|
return _labelRenderer->getHorizontalAlignment();
|
||||||
|
}
|
||||||
|
|
||||||
void Text::setTextVerticalAlignment(TextVAlignment alignment)
|
void Text::setTextVerticalAlignment(TextVAlignment alignment)
|
||||||
{
|
{
|
||||||
_labelRenderer->setVerticalAlignment(alignment);
|
_labelRenderer->setVerticalAlignment(alignment);
|
||||||
labelScaleChangedWithSize();
|
labelScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextVAlignment Text::getTextVerticalAlignment()
|
||||||
|
{
|
||||||
|
return _labelRenderer->getVerticalAlignment();
|
||||||
|
}
|
||||||
|
|
||||||
void Text::setTouchScaleChangeEnabled(bool enable)
|
void Text::setTouchScaleChangeEnabled(bool enable)
|
||||||
{
|
{
|
||||||
_touchScaleChangeEnabled = enable;
|
_touchScaleChangeEnabled = enable;
|
||||||
_normalScaleValueX = getScaleX();
|
|
||||||
_normalScaleValueY = getScaleY();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::setScale(float fScale)
|
void Text::setScale(float fScale)
|
||||||
{
|
{
|
||||||
Widget::setScale(fScale);
|
Widget::setScale(fScale);
|
||||||
_normalScaleValueX = _normalScaleValueY = fScale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::setScaleX(float fScaleX)
|
void Text::setScaleX(float fScaleX)
|
||||||
|
@ -158,7 +180,7 @@ void Text::onPressStateChangedToNormal()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clickScale(_normalScaleValueX, _normalScaleValueY);
|
_labelRenderer->setScale(_normalScaleValueX, _normalScaleValueY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::onPressStateChangedToPressed()
|
void Text::onPressStateChangedToPressed()
|
||||||
|
@ -167,9 +189,7 @@ void Text::onPressStateChangedToPressed()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_normalScaleValueX = getScaleX();
|
_labelRenderer->setScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset);
|
||||||
_normalScaleValueY = getScaleY();
|
|
||||||
clickScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::onPressStateChangedToDisabled()
|
void Text::onPressStateChangedToDisabled()
|
||||||
|
@ -177,12 +197,6 @@ void Text::onPressStateChangedToDisabled()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::clickScale(float scaleX, float scaleY)
|
|
||||||
{
|
|
||||||
setScaleX(scaleX);
|
|
||||||
setScaleY(scaleY);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Text::setFlipX(bool flipX)
|
void Text::setFlipX(bool flipX)
|
||||||
{
|
{
|
||||||
_labelRenderer->setFlippedX(flipX);
|
_labelRenderer->setFlippedX(flipX);
|
||||||
|
@ -231,6 +245,7 @@ void Text::labelScaleChangedWithSize()
|
||||||
{
|
{
|
||||||
_labelRenderer->setScale(1.0f);
|
_labelRenderer->setScale(1.0f);
|
||||||
_size = _labelRenderer->getContentSize();
|
_size = _labelRenderer->getContentSize();
|
||||||
|
_normalScaleValueX = _normalScaleValueY = 1.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -244,6 +259,8 @@ void Text::labelScaleChangedWithSize()
|
||||||
float scaleY = _size.height / textureSize.height;
|
float scaleY = _size.height / textureSize.height;
|
||||||
_labelRenderer->setScaleX(scaleX);
|
_labelRenderer->setScaleX(scaleX);
|
||||||
_labelRenderer->setScaleY(scaleY);
|
_labelRenderer->setScaleY(scaleY);
|
||||||
|
_normalScaleValueX = scaleX;
|
||||||
|
_normalScaleValueY = scaleY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setFontSize(int size);
|
void setFontSize(int size);
|
||||||
|
|
||||||
|
int getFontSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the font name of label.
|
* Sets the font name of label.
|
||||||
*
|
*
|
||||||
|
@ -88,6 +90,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setFontName(const std::string& name);
|
void setFontName(const std::string& name);
|
||||||
|
|
||||||
|
const std::string& getFontName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the touch scale enabled of label.
|
* Sets the touch scale enabled of label.
|
||||||
*
|
*
|
||||||
|
@ -157,8 +161,17 @@ public:
|
||||||
virtual std::string getDescription() const override;
|
virtual std::string getDescription() const override;
|
||||||
|
|
||||||
void setTextAreaSize(const Size &size);
|
void setTextAreaSize(const Size &size);
|
||||||
|
|
||||||
|
const Size& getTextAreaSize();
|
||||||
|
|
||||||
void setTextHorizontalAlignment(TextHAlignment alignment);
|
void setTextHorizontalAlignment(TextHAlignment alignment);
|
||||||
|
|
||||||
|
TextHAlignment getTextHorizontalAlignment();
|
||||||
|
|
||||||
void setTextVerticalAlignment(TextVAlignment alignment);
|
void setTextVerticalAlignment(TextVAlignment alignment);
|
||||||
|
|
||||||
|
TextVAlignment getTextVerticalAlignment();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
|
@ -166,7 +179,6 @@ protected:
|
||||||
virtual void onPressStateChangedToPressed() override;
|
virtual void onPressStateChangedToPressed() override;
|
||||||
virtual void onPressStateChangedToDisabled() override;
|
virtual void onPressStateChangedToDisabled() override;
|
||||||
virtual void onSizeChanged() override;
|
virtual void onSizeChanged() override;
|
||||||
void clickScale(float scaleX, float scaleY);
|
|
||||||
void labelScaleChangedWithSize();
|
void labelScaleChangedWithSize();
|
||||||
virtual Widget* createCloneInstance() override;
|
virtual Widget* createCloneInstance() override;
|
||||||
virtual void copySpecialProperties(Widget* model) override;
|
virtual void copySpecialProperties(Widget* model) override;
|
||||||
|
|
|
@ -320,6 +320,11 @@ void TextField::setTouchSize(const Size &size)
|
||||||
_touchHeight = size.height;
|
_touchHeight = size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Size TextField::getTouchSize()
|
||||||
|
{
|
||||||
|
return Size(_touchWidth, _touchHeight);
|
||||||
|
}
|
||||||
|
|
||||||
void TextField::setText(const std::string& text)
|
void TextField::setText(const std::string& text)
|
||||||
{
|
{
|
||||||
std::string strText(text);
|
std::string strText(text);
|
||||||
|
@ -346,18 +351,33 @@ void TextField::setPlaceHolder(const std::string& value)
|
||||||
textfieldRendererScaleChangedWithSize();
|
textfieldRendererScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& TextField::getPlaceHolder()
|
||||||
|
{
|
||||||
|
return _textFieldRenderer->getPlaceHolder();
|
||||||
|
}
|
||||||
|
|
||||||
void TextField::setFontSize(int size)
|
void TextField::setFontSize(int size)
|
||||||
{
|
{
|
||||||
_textFieldRenderer->setFontSize(size);
|
_textFieldRenderer->setFontSize(size);
|
||||||
textfieldRendererScaleChangedWithSize();
|
textfieldRendererScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TextField::getFontSize()
|
||||||
|
{
|
||||||
|
return _textFieldRenderer->getFontSize();
|
||||||
|
}
|
||||||
|
|
||||||
void TextField::setFontName(const std::string& name)
|
void TextField::setFontName(const std::string& name)
|
||||||
{
|
{
|
||||||
_textFieldRenderer->setFontName(name);
|
_textFieldRenderer->setFontName(name);
|
||||||
textfieldRendererScaleChangedWithSize();
|
textfieldRendererScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& TextField::getFontName()
|
||||||
|
{
|
||||||
|
return _textFieldRenderer->getFontName();
|
||||||
|
}
|
||||||
|
|
||||||
void TextField::didNotSelectSelf()
|
void TextField::didNotSelectSelf()
|
||||||
{
|
{
|
||||||
_textFieldRenderer->detachWithIME();
|
_textFieldRenderer->detachWithIME();
|
||||||
|
@ -415,6 +435,11 @@ void TextField::setPasswordStyleText(const char *styleText)
|
||||||
_passwordStyleText = styleText;
|
_passwordStyleText = styleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* TextField::getPasswordStyleText()
|
||||||
|
{
|
||||||
|
return _passwordStyleText.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
void TextField::update(float dt)
|
void TextField::update(float dt)
|
||||||
{
|
{
|
||||||
if (getAttachWithIME())
|
if (getAttachWithIME())
|
||||||
|
|
|
@ -108,10 +108,14 @@ public:
|
||||||
virtual ~TextField();
|
virtual ~TextField();
|
||||||
static TextField* create();
|
static TextField* create();
|
||||||
void setTouchSize(const Size &size);
|
void setTouchSize(const Size &size);
|
||||||
|
Size getTouchSize();
|
||||||
void setText(const std::string& text);
|
void setText(const std::string& text);
|
||||||
void setPlaceHolder(const std::string& value);
|
void setPlaceHolder(const std::string& value);
|
||||||
|
const std::string& getPlaceHolder();
|
||||||
void setFontSize(int size);
|
void setFontSize(int size);
|
||||||
|
int getFontSize();
|
||||||
void setFontName(const std::string& name);
|
void setFontName(const std::string& name);
|
||||||
|
const std::string& getFontName();
|
||||||
virtual void didNotSelectSelf();
|
virtual void didNotSelectSelf();
|
||||||
const std::string& getStringValue();
|
const std::string& getStringValue();
|
||||||
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
|
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
|
||||||
|
@ -122,6 +126,7 @@ public:
|
||||||
void setPasswordEnabled(bool enable);
|
void setPasswordEnabled(bool enable);
|
||||||
bool isPasswordEnabled();
|
bool isPasswordEnabled();
|
||||||
void setPasswordStyleText(const char* styleText);
|
void setPasswordStyleText(const char* styleText);
|
||||||
|
const char* getPasswordStyleText();
|
||||||
virtual void update(float dt) override;
|
virtual void update(float dt) override;
|
||||||
bool getAttachWithIME();
|
bool getAttachWithIME();
|
||||||
void setAttachWithIME(bool attach);
|
void setAttachWithIME(bool attach);
|
||||||
|
|
|
@ -1065,6 +1065,11 @@ void Widget::copyProperties(Widget *widget)
|
||||||
setOpacity(widget->getOpacity());
|
setOpacity(widget->getOpacity());
|
||||||
setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled());
|
setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled());
|
||||||
setCascadeColorEnabled(widget->isCascadeColorEnabled());
|
setCascadeColorEnabled(widget->isCascadeColorEnabled());
|
||||||
|
Map<int, LayoutParameter*>& layoutParameterDic = widget->_layoutParameterDictionary;
|
||||||
|
for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter)
|
||||||
|
{
|
||||||
|
setLayoutParameter(iter->second->clone());
|
||||||
|
}
|
||||||
onSizeChanged();
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ std::function<Layer*()> createFunctions[] =
|
||||||
CL(DirectorEventTest),
|
CL(DirectorEventTest),
|
||||||
CL(GlobalZTouchTest),
|
CL(GlobalZTouchTest),
|
||||||
CL(StopPropagationTest),
|
CL(StopPropagationTest),
|
||||||
|
CL(PauseResumeTargetTest),
|
||||||
CL(Issue4129),
|
CL(Issue4129),
|
||||||
CL(Issue4160)
|
CL(Issue4160)
|
||||||
};
|
};
|
||||||
|
@ -187,7 +188,7 @@ void TouchableSpriteTest::onEnter()
|
||||||
auto senderItem = static_cast<MenuItemFont*>(sender);
|
auto senderItem = static_cast<MenuItemFont*>(sender);
|
||||||
senderItem->setString("Only Next item could be clicked");
|
senderItem->setString("Only Next item could be clicked");
|
||||||
|
|
||||||
_eventDispatcher->removeEventListeners(EventListener::Type::TOUCH_ONE_BY_ONE);
|
_eventDispatcher->removeEventListenersForType(EventListener::Type::TOUCH_ONE_BY_ONE);
|
||||||
|
|
||||||
auto nextItem = MenuItemFont::create("Next", [=](Ref* sender){
|
auto nextItem = MenuItemFont::create("Next", [=](Ref* sender){
|
||||||
nextCallback(nullptr);
|
nextCallback(nullptr);
|
||||||
|
@ -223,21 +224,32 @@ std::string TouchableSpriteTest::subtitle() const
|
||||||
|
|
||||||
// FixedPriorityChangedTest
|
// FixedPriorityChangedTest
|
||||||
|
|
||||||
class TouchableSpriteWithFixedPriority : public Sprite
|
class TouchableSprite : public Sprite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static TouchableSprite* create(int priority = 0)
|
||||||
|
{
|
||||||
|
auto ret = new TouchableSprite(priority);
|
||||||
|
if (ret && ret->init())
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
CREATE_FUNC(TouchableSpriteWithFixedPriority);
|
protected:
|
||||||
|
TouchableSprite(int priority)
|
||||||
TouchableSpriteWithFixedPriority()
|
|
||||||
: _listener(nullptr)
|
: _listener(nullptr)
|
||||||
, _fixedPriority(0)
|
, _fixedPriority(priority)
|
||||||
, _removeListenerOnTouchEnded(false)
|
, _removeListenerOnTouchEnded(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPriority(int fixedPriority) { _fixedPriority = fixedPriority; };
|
public:
|
||||||
|
|
||||||
void onEnter() override
|
void onEnter() override
|
||||||
{
|
{
|
||||||
Sprite::onEnter();
|
Sprite::onEnter();
|
||||||
|
@ -268,7 +280,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_eventDispatcher->addEventListenerWithFixedPriority(listener, _fixedPriority);
|
if (_fixedPriority != 0)
|
||||||
|
{
|
||||||
|
_eventDispatcher->addEventListenerWithFixedPriority(listener, _fixedPriority);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||||
|
}
|
||||||
|
|
||||||
_listener = listener;
|
_listener = listener;
|
||||||
}
|
}
|
||||||
|
@ -295,21 +314,18 @@ void FixedPriorityTest::onEnter()
|
||||||
Point origin = Director::getInstance()->getVisibleOrigin();
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
Size size = Director::getInstance()->getVisibleSize();
|
Size size = Director::getInstance()->getVisibleSize();
|
||||||
|
|
||||||
auto sprite1 = TouchableSpriteWithFixedPriority::create();
|
auto sprite1 = TouchableSprite::create(30);
|
||||||
sprite1->setTexture("Images/CyanSquare.png");
|
sprite1->setTexture("Images/CyanSquare.png");
|
||||||
sprite1->setPriority(30);
|
|
||||||
sprite1->setPosition(origin+Point(size.width/2, size.height/2) + Point(-80, 40));
|
sprite1->setPosition(origin+Point(size.width/2, size.height/2) + Point(-80, 40));
|
||||||
addChild(sprite1, 10);
|
addChild(sprite1, 10);
|
||||||
|
|
||||||
auto sprite2 = TouchableSpriteWithFixedPriority::create();
|
auto sprite2 = TouchableSprite::create(20);
|
||||||
sprite2->setTexture("Images/MagentaSquare.png");
|
sprite2->setTexture("Images/MagentaSquare.png");
|
||||||
sprite2->setPriority(20);
|
|
||||||
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
|
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
|
||||||
addChild(sprite2, 20);
|
addChild(sprite2, 20);
|
||||||
|
|
||||||
auto sprite3 = TouchableSpriteWithFixedPriority::create();
|
auto sprite3 = TouchableSprite::create(10);
|
||||||
sprite3->setTexture("Images/YellowSquare.png");
|
sprite3->setTexture("Images/YellowSquare.png");
|
||||||
sprite3->setPriority(10);
|
|
||||||
sprite3->setPosition(Point(0, 0));
|
sprite3->setPosition(Point(0, 0));
|
||||||
sprite2->addChild(sprite3, 1);
|
sprite2->addChild(sprite3, 1);
|
||||||
|
|
||||||
|
@ -701,7 +717,7 @@ void RemoveListenerAfterAddingTest::onEnter()
|
||||||
};
|
};
|
||||||
|
|
||||||
_eventDispatcher->addEventListenerWithFixedPriority(listener, -1);
|
_eventDispatcher->addEventListenerWithFixedPriority(listener, -1);
|
||||||
_eventDispatcher->removeEventListeners(EventListener::Type::TOUCH_ONE_BY_ONE);
|
_eventDispatcher->removeEventListenersForType(EventListener::Type::TOUCH_ONE_BY_ONE);
|
||||||
|
|
||||||
addNextButton();
|
addNextButton();
|
||||||
});
|
});
|
||||||
|
@ -1087,6 +1103,72 @@ std::string StopPropagationTest::subtitle() const
|
||||||
return "Shouldn't crash and only blue block could be clicked";
|
return "Shouldn't crash and only blue block could be clicked";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PauseResumeTargetTest
|
||||||
|
PauseResumeTargetTest::PauseResumeTargetTest()
|
||||||
|
{
|
||||||
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
|
Size size = Director::getInstance()->getVisibleSize();
|
||||||
|
|
||||||
|
auto sprite1 = TouchableSprite::create();
|
||||||
|
sprite1->setTexture("Images/CyanSquare.png");
|
||||||
|
sprite1->setPosition(origin+Point(size.width/2, size.height/2) + Point(-80, 40));
|
||||||
|
addChild(sprite1, -10);
|
||||||
|
|
||||||
|
auto sprite2 = TouchableSprite::create();
|
||||||
|
sprite2->setTexture("Images/MagentaSquare.png");
|
||||||
|
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
|
||||||
|
addChild(sprite2, -20);
|
||||||
|
|
||||||
|
auto sprite3 = TouchableSprite::create();
|
||||||
|
sprite3->setTexture("Images/YellowSquare.png");
|
||||||
|
sprite3->setPosition(Point(0, 0));
|
||||||
|
sprite2->addChild(sprite3, -1);
|
||||||
|
|
||||||
|
auto popup = MenuItemFont::create("Popup", [this](Ref* sender){
|
||||||
|
|
||||||
|
_eventDispatcher->pauseEventListenersForTarget(this, true);
|
||||||
|
|
||||||
|
auto colorLayer = LayerColor::create(Color4B(0, 0, 255, 100));
|
||||||
|
this->addChild(colorLayer, 99999);
|
||||||
|
|
||||||
|
auto closeItem = MenuItemFont::create("close", [this, colorLayer](Ref* sender){
|
||||||
|
colorLayer->removeFromParent();
|
||||||
|
_eventDispatcher->resumeEventListenersForTarget(this, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
closeItem->setPosition(VisibleRect::center());
|
||||||
|
|
||||||
|
auto closeMenu = Menu::create(closeItem, NULL);
|
||||||
|
closeMenu->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||||
|
closeMenu->setPosition(Point::ZERO);
|
||||||
|
|
||||||
|
colorLayer->addChild(closeMenu);
|
||||||
|
});
|
||||||
|
|
||||||
|
popup->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
|
||||||
|
popup->setPosition(VisibleRect::right());
|
||||||
|
|
||||||
|
auto menu = Menu::create(popup, nullptr);
|
||||||
|
menu->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||||
|
menu->setPosition(Point::ZERO);
|
||||||
|
|
||||||
|
addChild(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
PauseResumeTargetTest::~PauseResumeTargetTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PauseResumeTargetTest::title() const
|
||||||
|
{
|
||||||
|
return "PauseResumeTargetTest";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PauseResumeTargetTest::subtitle() const
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// Issue4129
|
// Issue4129
|
||||||
Issue4129::Issue4129()
|
Issue4129::Issue4129()
|
||||||
: _bugFixed(false)
|
: _bugFixed(false)
|
||||||
|
@ -1157,22 +1239,19 @@ Issue4160::Issue4160()
|
||||||
Point origin = Director::getInstance()->getVisibleOrigin();
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
Size size = Director::getInstance()->getVisibleSize();
|
Size size = Director::getInstance()->getVisibleSize();
|
||||||
|
|
||||||
auto sprite1 = TouchableSpriteWithFixedPriority::create();
|
auto sprite1 = TouchableSprite::create(-30);
|
||||||
sprite1->setTexture("Images/CyanSquare.png");
|
sprite1->setTexture("Images/CyanSquare.png");
|
||||||
sprite1->setPriority(-30);
|
|
||||||
sprite1->setPosition(origin+Point(size.width/2, size.height/2) + Point(-80, 40));
|
sprite1->setPosition(origin+Point(size.width/2, size.height/2) + Point(-80, 40));
|
||||||
addChild(sprite1, -10);
|
addChild(sprite1, -10);
|
||||||
|
|
||||||
auto sprite2 = TouchableSpriteWithFixedPriority::create();
|
auto sprite2 = TouchableSprite::create(-20);
|
||||||
sprite2->setTexture("Images/MagentaSquare.png");
|
sprite2->setTexture("Images/MagentaSquare.png");
|
||||||
sprite2->setPriority(-20);
|
|
||||||
sprite2->removeListenerOnTouchEnded(true);
|
sprite2->removeListenerOnTouchEnded(true);
|
||||||
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
|
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
|
||||||
addChild(sprite2, -20);
|
addChild(sprite2, -20);
|
||||||
|
|
||||||
auto sprite3 = TouchableSpriteWithFixedPriority::create();
|
auto sprite3 = TouchableSprite::create(-10);
|
||||||
sprite3->setTexture("Images/YellowSquare.png");
|
sprite3->setTexture("Images/YellowSquare.png");
|
||||||
sprite3->setPriority(-10);
|
|
||||||
sprite3->setPosition(Point(0, 0));
|
sprite3->setPosition(Point(0, 0));
|
||||||
sprite2->addChild(sprite3, -1);
|
sprite2->addChild(sprite3, -1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,19 @@ protected:
|
||||||
bool isPointInTopHalfAreaOfScreen(Point pt);
|
bool isPointInTopHalfAreaOfScreen(Point pt);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PauseResumeTargetTest : public EventDispatcherTestDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(PauseResumeTargetTest);
|
||||||
|
PauseResumeTargetTest();
|
||||||
|
virtual ~PauseResumeTargetTest();
|
||||||
|
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
class Issue4129 : public EventDispatcherTestDemo
|
class Issue4129 : public EventDispatcherTestDemo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -438,14 +438,21 @@ public:
|
||||||
|
|
||||||
static SpriteBlur* create(const char *pszFileName);
|
static SpriteBlur* create(const char *pszFileName);
|
||||||
|
|
||||||
Point blur_;
|
|
||||||
GLfloat sub_[4];
|
|
||||||
|
|
||||||
GLuint blurLocation;
|
|
||||||
GLuint subLocation;
|
|
||||||
protected:
|
protected:
|
||||||
void onDraw();
|
void onDraw();
|
||||||
private:
|
private:
|
||||||
|
int _blurRadius;
|
||||||
|
Point _pixelSize;
|
||||||
|
|
||||||
|
int _samplingRadius;
|
||||||
|
//gaussian = cons * exp( (dx*dx + dy*dy) * scale);
|
||||||
|
float _scale;
|
||||||
|
float _cons;
|
||||||
|
float _weightSum;
|
||||||
|
|
||||||
|
GLuint pixelSizeLocation;
|
||||||
|
GLuint coefficientLocation;
|
||||||
|
|
||||||
CustomCommand _customCommand;
|
CustomCommand _customCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -470,6 +477,7 @@ SpriteBlur* SpriteBlur::create(const char *pszFileName)
|
||||||
|
|
||||||
bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect)
|
bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||||
{
|
{
|
||||||
|
_blurRadius = 0;
|
||||||
if( Sprite::initWithTexture(texture, rect) )
|
if( Sprite::initWithTexture(texture, rect) )
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
|
@ -483,9 +491,8 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||||
|
|
||||||
auto s = getTexture()->getContentSizeInPixels();
|
auto s = getTexture()->getContentSizeInPixels();
|
||||||
|
|
||||||
blur_ = Point(1/s.width, 1/s.height);
|
_pixelSize = Point(1/s.width, 1/s.height);
|
||||||
sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0;
|
_samplingRadius = 0;
|
||||||
|
|
||||||
this->initProgram();
|
this->initProgram();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -519,8 +526,8 @@ void SpriteBlur::initProgram()
|
||||||
|
|
||||||
CHECK_GL_ERROR_DEBUG();
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
|
||||||
subLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "substract");
|
pixelSizeLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "onePixelSize");
|
||||||
blurLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "blurSize");
|
coefficientLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "gaussianCoefficient");
|
||||||
|
|
||||||
CHECK_GL_ERROR_DEBUG();
|
CHECK_GL_ERROR_DEBUG();
|
||||||
}
|
}
|
||||||
|
@ -540,8 +547,8 @@ void SpriteBlur::onDraw()
|
||||||
|
|
||||||
getShaderProgram()->use();
|
getShaderProgram()->use();
|
||||||
getShaderProgram()->setUniformsForBuiltins();
|
getShaderProgram()->setUniformsForBuiltins();
|
||||||
getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y);
|
getShaderProgram()->setUniformLocationWith2f(pixelSizeLocation, _pixelSize.x, _pixelSize.y);
|
||||||
getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1);
|
getShaderProgram()->setUniformLocationWith4f(coefficientLocation, _samplingRadius, _scale,_cons,_weightSum);
|
||||||
|
|
||||||
GL::bindTexture2D( getTexture()->getName());
|
GL::bindTexture2D( getTexture()->getName());
|
||||||
|
|
||||||
|
@ -571,10 +578,37 @@ void SpriteBlur::onDraw()
|
||||||
|
|
||||||
void SpriteBlur::setBlurSize(float f)
|
void SpriteBlur::setBlurSize(float f)
|
||||||
{
|
{
|
||||||
auto s = getTexture()->getContentSizeInPixels();
|
if(_blurRadius == (int)f)
|
||||||
|
return;
|
||||||
|
_blurRadius = (int)f;
|
||||||
|
|
||||||
blur_ = Point(1/s.width, 1/s.height);
|
_samplingRadius = _blurRadius;
|
||||||
blur_ = blur_ * f;
|
if (_samplingRadius > 10)
|
||||||
|
{
|
||||||
|
_samplingRadius = 10;
|
||||||
|
}
|
||||||
|
if (_blurRadius > 0)
|
||||||
|
{
|
||||||
|
float sigma = _blurRadius / 2.0f;
|
||||||
|
_scale = -0.5f / (sigma * sigma);
|
||||||
|
_cons = -1.0f * _scale / 3.141592f;
|
||||||
|
_weightSum = -_cons;
|
||||||
|
|
||||||
|
float weight;
|
||||||
|
int squareX;
|
||||||
|
for(int dx = 0; dx <= _samplingRadius; ++dx)
|
||||||
|
{
|
||||||
|
squareX = dx * dx;
|
||||||
|
weight = _cons * exp(squareX * _scale);
|
||||||
|
_weightSum += 2.0 * weight;
|
||||||
|
for (int dy = 1; dy <= _samplingRadius; ++dy)
|
||||||
|
{
|
||||||
|
weight = _cons * exp((squareX + dy * dy) * _scale);
|
||||||
|
_weightSum += 4.0 * weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("_blurRadius:%d",_blurRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShaderBlur
|
// ShaderBlur
|
||||||
|
@ -601,12 +635,13 @@ ControlSlider* ShaderBlur::createSliderCtl()
|
||||||
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
|
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
|
||||||
slider->setAnchorPoint(Point(0.5f, 1.0f));
|
slider->setAnchorPoint(Point(0.5f, 1.0f));
|
||||||
slider->setMinimumValue(0.0f); // Sets the min value of range
|
slider->setMinimumValue(0.0f); // Sets the min value of range
|
||||||
slider->setMaximumValue(3.0f); // Sets the max value of range
|
slider->setMaximumValue(25.0f); // Sets the max value of range
|
||||||
slider->setValue(1.0f);
|
|
||||||
slider->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 3.0f));
|
slider->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 3.0f));
|
||||||
|
|
||||||
// When the value of the slider will change, the given selector will be call
|
// When the value of the slider will change, the given selector will be call
|
||||||
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), Control::EventType::VALUE_CHANGED);
|
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), Control::EventType::VALUE_CHANGED);
|
||||||
|
slider->setValue(2.0f);
|
||||||
|
|
||||||
return slider;
|
return slider;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import socket
|
||||||
|
import time
|
||||||
|
|
||||||
|
HOST = 'localhost'
|
||||||
|
PORT = 5678
|
||||||
|
|
||||||
|
def autotest():
|
||||||
|
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
|
soc.connect((HOST, PORT))
|
||||||
|
time.sleep(3)
|
||||||
|
print 'autotest run:'
|
||||||
|
soc.send('autotest run\r\n')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
buf = soc.recv(64)
|
||||||
|
print buf
|
||||||
|
|
||||||
|
print 'test end and close socket.'
|
||||||
|
soc.close()
|
||||||
|
|
||||||
|
#----------------autotest build and run----------------#
|
||||||
|
sleep_time = 1.5
|
||||||
|
def cleanProj():
|
||||||
|
infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target Test\ cpp\ Mac clean')
|
||||||
|
print 'infoClean: ', infoClean
|
||||||
|
if infoClean != 0:
|
||||||
|
print 'clean **CLEAN FAILED**'
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
def buildProj():
|
||||||
|
infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target Test\ cpp\ Mac')
|
||||||
|
print 'infoBuild: ', infoBuild
|
||||||
|
if infoBuild != 0:
|
||||||
|
print 'build **BUILD FAILED**'
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
return infoBuild
|
||||||
|
def openProj():
|
||||||
|
cmd = 'open ./build/build/Debug/Test\ cpp\ Mac.app'
|
||||||
|
print 'cmd: ', cmd
|
||||||
|
infoOpen = os.system(cmd)
|
||||||
|
print 'infoOpen: ', infoOpen
|
||||||
|
if infoOpen != 0:
|
||||||
|
print 'open **OPEN FAILED**'
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
def buildAndRun():
|
||||||
|
# cleanProj()
|
||||||
|
if buildProj() != 0:
|
||||||
|
cleanProj()
|
||||||
|
buildProj()
|
||||||
|
openProj()
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
#----------------autotest build and run end----------------#
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
buildAndRun()
|
||||||
|
except Exception, e:
|
||||||
|
print 'BUILD FAILED!'
|
||||||
|
else:
|
||||||
|
autotest()
|
||||||
|
|
||||||
|
|
||||||
|
# -------------- main --------------
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys_ret = 0
|
||||||
|
try:
|
||||||
|
sys_ret = main()
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
sys_ret = 1
|
||||||
|
finally:
|
||||||
|
sys.exit(sys_ret)
|
||||||
|
|
Loading…
Reference in New Issue