Modify for editor

This commit is contained in:
CaiWenzhi 2014-03-06 17:21:09 +08:00
parent b02ed6fb1e
commit 03f5be47da
5 changed files with 79 additions and 21 deletions

View File

@ -81,7 +81,9 @@ _currentStencilPassDepthPass(GL_KEEP),
_currentDepthWriteMask(GL_TRUE),
_currentAlphaTestEnabled(GL_FALSE),
_currentAlphaTestFunc(GL_ALWAYS),
_currentAlphaTestRef(1)
_currentAlphaTestRef(1),
_backGroundImageColor(Color3B::WHITE),
_backGroundImageOpacity(255)
{
_widgetType = WidgetTypeContainer;
}
@ -628,20 +630,9 @@ void Layout::setBackGroundImage(const char* fileName,TextureResType texType)
break;
}
}
if (_backGroundScale9Enabled)
{
extension::Scale9Sprite* bgiScale9 = static_cast<extension::Scale9Sprite*>(_backGroundImage);
bgiScale9->setColor(getColor());
bgiScale9->setOpacity(getOpacity());
}
else
{
Sprite* bgiScale9 = static_cast<Sprite*>(_backGroundImage);
bgiScale9->setColor(getColor());
bgiScale9->setOpacity(getOpacity());
}
_backGroundImageTextureSize = _backGroundImage->getContentSize();
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
updateBackGroundImageRGBA();
}
void Layout::setBackGroundImageCapInsets(const Rect &capInsets)
@ -828,7 +819,7 @@ const Color3B& Layout::getBackGroundEndColor()
return _gEndColor;
}
void Layout::setBackGroundColorOpacity(int opacity)
void Layout::setBackGroundColorOpacity(GLubyte opacity)
{
_cOpacity = opacity;
switch (_colorType)
@ -846,7 +837,7 @@ void Layout::setBackGroundColorOpacity(int opacity)
}
}
int Layout::getBackGroundColorOpacity()
GLubyte Layout::getBackGroundColorOpacity()
{
return _cOpacity;
}
@ -865,6 +856,53 @@ const Point& Layout::getBackGroundColorVector()
return _alongVector;
}
void Layout::setBackGroundImageColor(const Color3B &color)
{
_backGroundImageColor = color;
updateBackGroundImageColor();
}
void Layout::setBackGroundImageOpacity(GLubyte opacity)
{
_backGroundImageOpacity = opacity;
updateBackGroundImageOpacity();
}
const Color3B& Layout::getBackGroundImageColor()
{
return _backGroundImageColor;
}
GLubyte Layout::getBackGroundImageOpacity()
{
return _backGroundImageOpacity;
}
void Layout::updateBackGroundImageColor()
{
if (_backGroundImage)
{
_backGroundImage->setColor(_backGroundImageColor);
}
}
void Layout::updateBackGroundImageOpacity()
{
if (_backGroundImage)
{
_backGroundImage->setOpacity(_backGroundImageOpacity);
}
}
void Layout::updateBackGroundImageRGBA()
{
if (_backGroundImage)
{
_backGroundImage->setColor(_backGroundImageColor);
_backGroundImage->setOpacity(_backGroundImageOpacity);
}
}
const Size& Layout::getBackGroundImageTextureSize() const
{
return _backGroundImageTextureSize;

View File

@ -141,9 +141,9 @@ public:
*
* @param opacity
*/
void setBackGroundColorOpacity(int opacity);
void setBackGroundColorOpacity(GLubyte opacity);
int getBackGroundColorOpacity();
GLubyte getBackGroundColorOpacity();
/**
* Sets background color vector for layout, if color type is LAYOUT_COLOR_GRADIENT
@ -154,6 +154,14 @@ public:
const Point& getBackGroundColorVector();
void setBackGroundImageColor(const ccColor3B& color);
void setBackGroundImageOpacity(GLubyte opacity);
const ccColor3B& getBackGroundImageColor();
GLubyte getBackGroundImageOpacity();
/**
* Remove the background image of layout.
*/
@ -286,6 +294,9 @@ protected:
void onBeforeVisitScissor();
void onAfterVisitScissor();
void updateBackGroundImageColor();
void updateBackGroundImageOpacity();
void updateBackGroundImageRGBA();
protected:
bool _clippingEnabled;
@ -302,7 +313,7 @@ protected:
Color3B _gStartColor;
Color3B _gEndColor;
Point _alongVector;
int _cOpacity;
GLubyte _cOpacity;
Size _backGroundImageTextureSize;
LayoutType _layoutType;
LayoutClippingType _clippingType;
@ -329,8 +340,11 @@ protected:
GLenum _currentAlphaTestFunc;
GLclampf _currentAlphaTestRef;
GLint _mask_layer_le;
Color3B _backGroundImageColor;
GLubyte _backGroundImageOpacity;
GLint _mask_layer_le;
GroupCommand _groupCommand;
CustomCommand _beforeVisitCmdStencil;
CustomCommand _afterDrawStencilCmd;

View File

@ -172,7 +172,7 @@ public:
virtual std::string getDescription() const override;
void requestRefreshView();
void refreshView();
protected:
virtual void addChild(Node* child) override{ScrollView::addChild(child);};
virtual void addChild(Node * child, int zOrder) override{ScrollView::addChild(child, zOrder);};
@ -195,7 +195,6 @@ protected:
virtual void copyClonedWidgetChildren(Widget* model) override;
void selectedItemEvent();
virtual void interceptTouchEvent(int handleState,Widget* sender,const Point &touchPoint) override;
void refreshView();
protected:
Widget* _model;

View File

@ -568,6 +568,11 @@ const Size& Widget::getSize() const
{
return _size;
}
const Size& Widget::getCustomSize() const
{
return _customSize;
}
const Point& Widget::getSizePercent() const
{

View File

@ -547,6 +547,8 @@ public:
* @return size
*/
const Size& getSize() const;
const Size& getCustomSize() const;
/**
* Returns size percent of widget