Bladeren bron

Merge pull request #431 from blackberry/next

Next
Sean Paul Taylor 13 jaren geleden
bovenliggende
commit
e78ef5b694
4 gewijzigde bestanden met toevoegingen van 28 en 52 verwijderingen
  1. 0 12
      gameplay/gameplay.xcodeproj/project.pbxproj
  2. 19 19
      gameplay/src/Container.cpp
  3. 5 17
      gameplay/src/Container.h
  4. 4 4
      gameplay/src/Form.cpp

+ 0 - 12
gameplay/gameplay.xcodeproj/project.pbxproj

@@ -28,10 +28,6 @@
 		42554EA2152BC35C000ED910 /* PhysicsCollisionShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42554E9F152BC35C000ED910 /* PhysicsCollisionShape.cpp */; };
 		42554EA3152BC35C000ED910 /* PhysicsCollisionShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 42554EA0152BC35C000ED910 /* PhysicsCollisionShape.h */; };
 		42554EA4152BC35C000ED910 /* PhysicsCollisionShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 42554EA0152BC35C000ED910 /* PhysicsCollisionShape.h */; };
-		4265D9241559A3C300581EB0 /* ScrollLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4265D9221559A3C300581EB0 /* ScrollLayout.cpp */; };
-		4265D9251559A3C300581EB0 /* ScrollLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4265D9221559A3C300581EB0 /* ScrollLayout.cpp */; };
-		4265D9261559A3C300581EB0 /* ScrollLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 4265D9231559A3C300581EB0 /* ScrollLayout.h */; };
-		4265D9271559A3C300581EB0 /* ScrollLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 4265D9231559A3C300581EB0 /* ScrollLayout.h */; };
 		426878AC153F4BB300844500 /* FlowLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 426878AA153F4BB300844500 /* FlowLayout.cpp */; };
 		426878AD153F4BB300844500 /* FlowLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 426878AA153F4BB300844500 /* FlowLayout.cpp */; };
 		426878AE153F4BB300844500 /* FlowLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 426878AB153F4BB300844500 /* FlowLayout.h */; };
@@ -408,8 +404,6 @@
 		4251B130152D049B002F6199 /* ThemeStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThemeStyle.h; path = src/ThemeStyle.h; sourceTree = SOURCE_ROOT; };
 		42554E9F152BC35C000ED910 /* PhysicsCollisionShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PhysicsCollisionShape.cpp; path = src/PhysicsCollisionShape.cpp; sourceTree = SOURCE_ROOT; };
 		42554EA0152BC35C000ED910 /* PhysicsCollisionShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhysicsCollisionShape.h; path = src/PhysicsCollisionShape.h; sourceTree = SOURCE_ROOT; };
-		4265D9221559A3C300581EB0 /* ScrollLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScrollLayout.cpp; path = src/ScrollLayout.cpp; sourceTree = SOURCE_ROOT; };
-		4265D9231559A3C300581EB0 /* ScrollLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScrollLayout.h; path = src/ScrollLayout.h; sourceTree = SOURCE_ROOT; };
 		426878AA153F4BB300844500 /* FlowLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FlowLayout.cpp; path = src/FlowLayout.cpp; sourceTree = SOURCE_ROOT; };
 		426878AB153F4BB300844500 /* FlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FlowLayout.h; path = src/FlowLayout.h; sourceTree = SOURCE_ROOT; };
 		4271C08D15337C8200B89DA7 /* Layout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Layout.cpp; path = src/Layout.cpp; sourceTree = SOURCE_ROOT; };
@@ -862,8 +856,6 @@
 				428390971489D6E800E2B2F5 /* SceneLoader.cpp */,
 				428390981489D6E800E2B2F5 /* SceneLoader.h */,
 				4251B12E152D049B002F6199 /* ScreenDisplayer.h */,
-				4265D9221559A3C300581EB0 /* ScrollLayout.cpp */,
-				4265D9231559A3C300581EB0 /* ScrollLayout.h */,
 				5BD52646150F822A004C9099 /* Slider.cpp */,
 				5BD52647150F822A004C9099 /* Slider.h */,
 				42CD0E2F147D8FF50000361E /* SpriteBatch.cpp */,
@@ -1072,7 +1064,6 @@
 				4251B135152D049B002F6199 /* ThemeStyle.h in Headers */,
 				422260D81537790F0011E3AB /* Bundle.h in Headers */,
 				426878AE153F4BB300844500 /* FlowLayout.h in Headers */,
-				4265D9261559A3C300581EB0 /* ScrollLayout.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1170,7 +1161,6 @@
 				4251B136152D049B002F6199 /* ThemeStyle.h in Headers */,
 				422260D91537790F0011E3AB /* Bundle.h in Headers */,
 				426878AF153F4BB300844500 /* FlowLayout.h in Headers */,
-				4265D9271559A3C300581EB0 /* ScrollLayout.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1327,7 +1317,6 @@
 				4271C08E15337C8200B89DA7 /* Layout.cpp in Sources */,
 				422260D61537790F0011E3AB /* Bundle.cpp in Sources */,
 				426878AC153F4BB300844500 /* FlowLayout.cpp in Sources */,
-				4265D9241559A3C300581EB0 /* ScrollLayout.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1420,7 +1409,6 @@
 				4271C08F15337C8200B89DA7 /* Layout.cpp in Sources */,
 				422260D71537790F0011E3AB /* Bundle.cpp in Sources */,
 				426878AD153F4BB300844500 /* FlowLayout.cpp in Sources */,
-				4265D9251559A3C300581EB0 /* ScrollLayout.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 19 - 19
gameplay/src/Container.cpp

@@ -29,7 +29,7 @@ namespace gameplay
 Container::Container()
     : _layout(NULL), _scrollBarTopCap(NULL), _scrollBarVertical(NULL), _scrollBarBottomCap(NULL),
       _scrollBarLeftCap(NULL), _scrollBarHorizontal(NULL), _scrollBarRightCap(NULL),
-      _scrollState(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
+      _scrollBars(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
       _scrolling(false), _firstX(0), _firstY(0),
       _lastX(0), _lastY(0),
       _startTimeX(0), _startTimeY(0), _lastTime(0),
@@ -82,7 +82,7 @@ Container* Container::create(Theme::Style* style, Properties* properties, Theme*
     const char* layoutString = properties->getString("layout");
     Container* container = Container::create(getLayoutType(layoutString));
     container->initialize(style, properties);
-    container->_scrollState = getScrollState(properties->getString("scroll"));
+    container->_scrollBars = getScrollBars(properties->getString("scroll"));
     container->addControls(theme, properties);
 
     return container;
@@ -241,18 +241,18 @@ const std::vector<Control*>& Container::getControls() const
     return _controls;
 }
 
-void Container::setScrollState(ScrollState scrollState)
+void Container::setScrollBars(ScrollBars scrollBars)
 {
-    if (scrollState != _scrollState)
+    if (scrollBars != _scrollBars)
     {
-        _scrollState = scrollState;
+        _scrollBars = scrollBars;
         _dirty = true;
     }
 }
 
-Container::ScrollState Container::getScrollState() const
+Container::ScrollBars Container::getScrollBars() const
 {
-    return _scrollState;
+    return _scrollBars;
 }
 
 Animation* Container::getAnimation(const char* id) const
@@ -286,7 +286,7 @@ void Container::update(const Rectangle& clip, const Vector2& offset)
     Control::update(clip, offset);
 
     // Get scrollbar images and diminish clipping bounds to make room for scrollbars.
-    if ((_scrollState & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL)
+    if ((_scrollBars & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL)
     {
         _scrollBarLeftCap = getImage("scrollBarLeftCap", _state);
         _scrollBarHorizontal = getImage("horizontalScrollBar", _state);
@@ -295,7 +295,7 @@ void Container::update(const Rectangle& clip, const Vector2& offset)
         _viewportClipBounds.height -= _scrollBarHorizontal->getRegion().height;
     }
 
-    if ((_scrollState & SCROLL_VERTICAL) == SCROLL_VERTICAL)
+    if ((_scrollBars & SCROLL_VERTICAL) == SCROLL_VERTICAL)
     {
         _scrollBarTopCap = getImage("scrollBarTopCap", _state);
         _scrollBarVertical = getImage("verticalScrollBar", _state);
@@ -307,7 +307,7 @@ void Container::update(const Rectangle& clip, const Vector2& offset)
     GP_ASSERT(_layout);
     _layout->update(this);
 
-    if (_scrollState != SCROLL_NONE)
+    if (_scrollBars != SCROLL_NONE)
         this->updateScroll(this);
 }
 
@@ -341,7 +341,7 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
         }
     }
 
-    if (_scrollState != SCROLL_NONE)
+    if (_scrollBars != SCROLL_NONE)
     {
         // Draw scroll bars.
         Rectangle clipRegion(_viewportClipBounds);
@@ -453,7 +453,7 @@ bool Container::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int con
     float yPos = border.top + padding.top;
 
     Vector2* offset = NULL;
-    if (_scrollState != SCROLL_NONE)
+    if (_scrollBars != SCROLL_NONE)
     {
         offset = &_scrollPosition;
     }
@@ -766,30 +766,30 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
     return false;
 }
 
-Container::ScrollState Container::getScrollState(const char* scrollState)
+Container::ScrollBars Container::getScrollBars(const char* scrollBars)
 {
-    if (!scrollState)
+    if (!scrollBars)
         return Container::SCROLL_NONE;
 
-    if (strcmp(scrollState, "SCROLL_NONE") == 0)
+    if (strcmp(scrollBars, "SCROLL_NONE") == 0)
     {
         return Container::SCROLL_NONE;
     }
-    else if (strcmp(scrollState, "SCROLL_HORIZONTAL") == 0)
+    else if (strcmp(scrollBars, "SCROLL_HORIZONTAL") == 0)
     {
         return Container::SCROLL_HORIZONTAL;
     }
-    else if (strcmp(scrollState, "SCROLL_VERTICAL") == 0)
+    else if (strcmp(scrollBars, "SCROLL_VERTICAL") == 0)
     {
         return Container::SCROLL_VERTICAL;
     }
-    else if (strcmp(scrollState, "SCROLL_BOTH") == 0)
+    else if (strcmp(scrollBars, "SCROLL_BOTH") == 0)
     {
         return Container::SCROLL_BOTH;
     }
     else
     {
-        GP_ERROR("Failed to get corresponding scroll state for unsupported value '%s'.", scrollState);
+        GP_ERROR("Failed to get corresponding scroll state for unsupported value '%s'.", scrollBars);
     }
 
     return Container::SCROLL_NONE;

+ 5 - 17
gameplay/src/Container.h

@@ -45,7 +45,7 @@ class Container : public Control
 {
 public:
 
-    enum ScrollState
+    enum ScrollBars
     {
         SCROLL_NONE        = 0,
         SCROLL_HORIZONTAL  = 0x01,
@@ -122,9 +122,9 @@ public:
      */
     const std::vector<Control*>& getControls() const;
 
-    void setScrollState(ScrollState scrollState);
+    void setScrollBars(ScrollBars scrollBars);
 
-    ScrollState getScrollState() const;
+    ScrollBars getScrollBars() const;
 
     /**
      * Gets the first animation in the control with the specified ID.
@@ -229,7 +229,7 @@ protected:
 
     bool touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
 
-    static ScrollState getScrollState(const char* scrollState);
+    static ScrollBars getScrollBars(const char* scrollBars);
 
     /**
      * The container's layout.
@@ -241,27 +241,15 @@ protected:
      */
     std::vector<Control*> _controls;
 
-    /**
-     * Scrollbar top cap image.
-     */
     Theme::ThemeImage* _scrollBarTopCap;
-
-    /**
-     * Vertical scrollbar image.
-     */
     Theme::ThemeImage* _scrollBarVertical;
-
-    /**
-     * Scrollbar bottom cap image.
-     */
     Theme::ThemeImage* _scrollBarBottomCap;
-
     Theme::ThemeImage* _scrollBarLeftCap;
     Theme::ThemeImage* _scrollBarHorizontal;
     Theme::ThemeImage* _scrollBarRightCap;
 
     // Flag representing whether scrolling is enabled, and in which directions.
-    ScrollState _scrollState;
+    ScrollBars _scrollBars;
 
     // Data required when scrolling is enabled.
 

+ 4 - 4
gameplay/src/Form.cpp

@@ -108,7 +108,7 @@ Form* Form::create(const char* url)
         form->_bounds.x = Game::getInstance()->getWidth() * 0.5f - form->_bounds.width * 0.5f;
     }
 
-    form->_scrollState = getScrollState(formProperties->getString("scroll"));
+    form->_scrollBars = getScrollBars(formProperties->getString("scrollbars"));
 
     // Add all the controls to the form.
     form->addControls(theme, formProperties);
@@ -384,7 +384,7 @@ void Form::update()
         _opacity = getOpacity(_state);
 
         // Get scrollbar images and diminish clipping bounds to make room for scrollbars.
-        if ((_scrollState & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL)
+        if ((_scrollBars & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL)
         {
             _scrollBarLeftCap = getImage("scrollBarLeftCap", _state);
             _scrollBarHorizontal = getImage("horizontalScrollBar", _state);
@@ -393,7 +393,7 @@ void Form::update()
             _viewportClipBounds.height -= _scrollBarHorizontal->getRegion().height;
         }
 
-        if ((_scrollState & SCROLL_VERTICAL) == SCROLL_VERTICAL)
+        if ((_scrollBars & SCROLL_VERTICAL) == SCROLL_VERTICAL)
         {
             _scrollBarTopCap = getImage("scrollBarTopCap", _state);
             _scrollBarVertical = getImage("verticalScrollBar", _state);
@@ -405,7 +405,7 @@ void Form::update()
         GP_ASSERT(_layout);
         _layout->update(this);
 
-        if (_scrollState != SCROLL_NONE)
+        if (_scrollBars != SCROLL_NONE)
             this->updateScroll(this);
     }
 }