Merge pull request #7231 from andyque/fixUIMargin

fix ui Margin
This commit is contained in:
minggo 2014-06-27 16:37:24 +08:00
commit 26292b3e63
12 changed files with 77 additions and 10 deletions

View File

@ -995,6 +995,8 @@
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; 299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
29BDBA53195D597A003225C9 /* UIDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29BDBA52195D597A003225C9 /* UIDeprecated.cpp */; };
29BDBA54195D597A003225C9 /* UIDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29BDBA52195D597A003225C9 /* UIDeprecated.cpp */; };
29CB8F4C1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; }; 29CB8F4C1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
29CB8F4D1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; }; 29CB8F4D1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
29CB8F4E1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; }; 29CB8F4E1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; };
@ -2311,6 +2313,7 @@
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; }; 2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; }; 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; };
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; }; 299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
29BDBA52195D597A003225C9 /* UIDeprecated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIDeprecated.cpp; sourceTree = "<group>"; };
29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutManager.cpp; sourceTree = "<group>"; }; 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutManager.cpp; sourceTree = "<group>"; };
29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutManager.h; sourceTree = "<group>"; }; 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutManager.h; sourceTree = "<group>"; };
29E99D1C1957BA7000046604 /* CocoLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocoLoader.cpp; sourceTree = "<group>"; }; 29E99D1C1957BA7000046604 /* CocoLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocoLoader.cpp; sourceTree = "<group>"; };
@ -4030,6 +4033,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
29080DEB191B82CE0066F8DF /* UIDeprecated.h */, 29080DEB191B82CE0066F8DF /* UIDeprecated.h */,
29BDBA52195D597A003225C9 /* UIDeprecated.cpp */,
2905FA1318CF08D100240AA3 /* UIWidget.cpp */, 2905FA1318CF08D100240AA3 /* UIWidget.cpp */,
2905FA1418CF08D100240AA3 /* UIWidget.h */, 2905FA1418CF08D100240AA3 /* UIWidget.h */,
50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */, 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */,
@ -6360,6 +6364,7 @@
503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */, 503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */,
1AD71EB1180E26E600808F54 /* Bone.cpp in Sources */, 1AD71EB1180E26E600808F54 /* Bone.cpp in Sources */,
1AD71EB5180E26E600808F54 /* BoneData.cpp in Sources */, 1AD71EB5180E26E600808F54 /* BoneData.cpp in Sources */,
29BDBA53195D597A003225C9 /* UIDeprecated.cpp in Sources */,
1AD71EB9180E26E600808F54 /* CCSkeleton.cpp in Sources */, 1AD71EB9180E26E600808F54 /* CCSkeleton.cpp in Sources */,
50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */, 50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */,
1AD71EBD180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */, 1AD71EBD180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */,
@ -6855,6 +6860,7 @@
50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */, 50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */,
50ABC0121926664800A911A9 /* CCGLViewProtocol.cpp in Sources */, 50ABC0121926664800A911A9 /* CCGLViewProtocol.cpp in Sources */,
50ABC0021926664800A911A9 /* CCLock.cpp in Sources */, 50ABC0021926664800A911A9 /* CCLock.cpp in Sources */,
29BDBA54195D597A003225C9 /* UIDeprecated.cpp in Sources */,
50FCEBAC18C72017004AD434 /* PageViewReader.cpp in Sources */, 50FCEBAC18C72017004AD434 /* PageViewReader.cpp in Sources */,
1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */, 1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */,
1A8C5990180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */, 1A8C5990180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */,

View File

@ -29,7 +29,8 @@ CCProtectedNode.cpp \
UIHBox.cpp \ UIHBox.cpp \
UIVBox.cpp \ UIVBox.cpp \
UIRelativeBox.cpp \ UIRelativeBox.cpp \
UIVideoPlayerAndroid.cpp UIVideoPlayerAndroid.cpp \
UIDeprecated.cpp \
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \
$(LOCAL_PATH)/../editor-support $(LOCAL_PATH)/../editor-support

View File

@ -22,5 +22,6 @@ set(COCOS_UI_SRC
ui/UITextField.cpp ui/UITextField.cpp
ui/UIVBox.cpp ui/UIVBox.cpp
ui/UIWidget.cpp ui/UIWidget.cpp
ui/UIDeprecated.cpp
) )

33
cocos/ui/UIDeprecated.cpp Normal file
View File

@ -0,0 +1,33 @@
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "ui/UIDeprecated.h"
NS_CC_BEGIN
namespace ui {
const Margin MarginZero = Margin::ZERO ;
}}

View File

@ -26,6 +26,12 @@
#define cocos2d_libs_UIDeprecated_h #define cocos2d_libs_UIDeprecated_h
#include "base/CCPlatformMacros.h" #include "base/CCPlatformMacros.h"
#include "ui/UIWidget.h"
#include "ui/UILayout.h"
#include "ui/UIListView.h"
#include "ui/UILoadingBar.h"
#include "ui/UIPageView.h"
#include "ui/UIRichText.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -147,7 +153,7 @@ CC_DEPRECATED_ATTRIBUTE typedef LoadingBar::Direction LoadingBarType;
CC_DEPRECATED_ATTRIBUTE typedef PageView::TouchDirection PVTouchDir; CC_DEPRECATED_ATTRIBUTE typedef PageView::TouchDirection PVTouchDir;
CC_DEPRECATED_ATTRIBUTE typedef RichElement::Type RichElementType; CC_DEPRECATED_ATTRIBUTE typedef RichElement::Type RichElementType;
CC_DEPRECATED_ATTRIBUTE typedef ScrollView::Direction SCROLLVIEW_DIR; CC_DEPRECATED_ATTRIBUTE typedef ScrollView::Direction SCROLLVIEW_DIR;
CC_DEPRECATED_ATTRIBUTE extern const Margin MarginZero;
} }

View File

@ -29,6 +29,8 @@ NS_CC_BEGIN
namespace ui { namespace ui {
const Margin Margin::ZERO = Margin(0,0,0,0);
Margin::Margin(void) : left(0), top(0), right(0), bottom(0) Margin::Margin(void) : left(0), top(0), right(0), bottom(0)
{ {
} }

View File

@ -52,9 +52,11 @@ public:
Margin& operator= (const Margin& other); Margin& operator= (const Margin& other);
void setMargin(float l, float t, float r, float b); void setMargin(float l, float t, float r, float b);
bool equals(const Margin& target) const; bool equals(const Margin& target) const;
static const Margin ZERO;
}; };
const Margin MarginZero = Margin();
/** /**
* @js NA * @js NA

View File

@ -149,7 +149,7 @@ void ListView::remedyLayoutParameter(Widget *item)
} }
if (getIndex(item) == 0) if (getIndex(item) == 0)
{ {
defaultLp->setMargin(MarginZero); defaultLp->setMargin(Margin::ZERO);
} }
else else
{ {
@ -161,7 +161,7 @@ void ListView::remedyLayoutParameter(Widget *item)
{ {
if (getIndex(item) == 0) if (getIndex(item) == 0)
{ {
llp->setMargin(MarginZero); llp->setMargin(Margin::ZERO);
} }
else else
{ {
@ -204,7 +204,7 @@ void ListView::remedyLayoutParameter(Widget *item)
} }
if (getIndex(item) == 0) if (getIndex(item) == 0)
{ {
defaultLp->setMargin(MarginZero); defaultLp->setMargin(Margin::ZERO);
} }
else else
{ {
@ -216,7 +216,7 @@ void ListView::remedyLayoutParameter(Widget *item)
{ {
if (getIndex(item) == 0) if (getIndex(item) == 0)
{ {
llp->setMargin(MarginZero); llp->setMargin(Margin::ZERO);
} }
else else
{ {

View File

@ -15,6 +15,7 @@
<ClInclude Include="..\CocosGUI.h" /> <ClInclude Include="..\CocosGUI.h" />
<ClInclude Include="..\UIButton.h" /> <ClInclude Include="..\UIButton.h" />
<ClInclude Include="..\UICheckBox.h" /> <ClInclude Include="..\UICheckBox.h" />
<ClInclude Include="..\UIDeprecated.h" />
<ClInclude Include="..\UIHBox.h" /> <ClInclude Include="..\UIHBox.h" />
<ClInclude Include="..\UIHelper.h" /> <ClInclude Include="..\UIHelper.h" />
<ClInclude Include="..\UIImageView.h" /> <ClInclude Include="..\UIImageView.h" />
@ -40,6 +41,7 @@
<ClCompile Include="..\CocosGUI.cpp" /> <ClCompile Include="..\CocosGUI.cpp" />
<ClCompile Include="..\UIButton.cpp" /> <ClCompile Include="..\UIButton.cpp" />
<ClCompile Include="..\UICheckBox.cpp" /> <ClCompile Include="..\UICheckBox.cpp" />
<ClCompile Include="..\UIDeprecated.cpp" />
<ClCompile Include="..\UIHBox.cpp" /> <ClCompile Include="..\UIHBox.cpp" />
<ClCompile Include="..\UIHelper.cpp" /> <ClCompile Include="..\UIHelper.cpp" />
<ClCompile Include="..\UIImageView.cpp" /> <ClCompile Include="..\UIImageView.cpp" />

View File

@ -87,6 +87,9 @@
<ClInclude Include="..\UILayoutManager.h"> <ClInclude Include="..\UILayoutManager.h">
<Filter>Layouts</Filter> <Filter>Layouts</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\UIDeprecated.h">
<Filter>System</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\UIScrollView.cpp"> <ClCompile Include="..\UIScrollView.cpp">
@ -158,5 +161,8 @@
<ClCompile Include="..\UILayoutManager.cpp"> <ClCompile Include="..\UILayoutManager.cpp">
<Filter>Layouts</Filter> <Filter>Layouts</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\UIDeprecated.cpp">
<Filter>System</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -184,6 +184,7 @@
<ClInclude Include="..\..\ui\UITextField.h" /> <ClInclude Include="..\..\ui\UITextField.h" />
<ClInclude Include="..\..\ui\UIVBox.h" /> <ClInclude Include="..\..\ui\UIVBox.h" />
<ClInclude Include="..\..\ui\UIWidget.h" /> <ClInclude Include="..\..\ui\UIWidget.h" />
<ClInclude Include="..\UIDeprecated.h" />
<ClInclude Include="..\UIHBox.h" /> <ClInclude Include="..\UIHBox.h" />
<ClInclude Include="..\UILayoutManager.h" /> <ClInclude Include="..\UILayoutManager.h" />
<ClInclude Include="..\UIRelativeBox.h" /> <ClInclude Include="..\UIRelativeBox.h" />
@ -209,6 +210,7 @@
<ClCompile Include="..\..\ui\UITextField.cpp" /> <ClCompile Include="..\..\ui\UITextField.cpp" />
<ClCompile Include="..\..\ui\UIVBox.cpp" /> <ClCompile Include="..\..\ui\UIVBox.cpp" />
<ClCompile Include="..\..\ui\UIWidget.cpp" /> <ClCompile Include="..\..\ui\UIWidget.cpp" />
<ClCompile Include="..\UIDeprecated.cpp" />
<ClCompile Include="..\UIHBox.cpp" /> <ClCompile Include="..\UIHBox.cpp" />
<ClCompile Include="..\UILayoutManager.cpp" /> <ClCompile Include="..\UILayoutManager.cpp" />
<ClCompile Include="..\UIRelativeBox.cpp" /> <ClCompile Include="..\UIRelativeBox.cpp" />

View File

@ -84,6 +84,9 @@
<ClInclude Include="..\UILayoutManager.h"> <ClInclude Include="..\UILayoutManager.h">
<Filter>Layouts</Filter> <Filter>Layouts</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\UIDeprecated.h">
<Filter>System</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\ui\UILayout.cpp"> <ClCompile Include="..\..\ui\UILayout.cpp">
@ -155,5 +158,8 @@
<ClCompile Include="..\UILayoutManager.cpp"> <ClCompile Include="..\UILayoutManager.cpp">
<Filter>Layouts</Filter> <Filter>Layouts</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\UIDeprecated.cpp">
<Filter>System</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>