Selaa lähdekoodia

Merge pull request #120 from blackberry-gaming/next

Next
Sean Paul Taylor 13 vuotta sitten
vanhempi
sitoutus
a97d7f9bc5

+ 1 - 1
gameplay/android/jni/Android.mk

@@ -16,7 +16,7 @@ LOCAL_PATH := $(call my-dir)/../../src
 
 
 include $(CLEAR_VARS)
 include $(CLEAR_VARS)
 LOCAL_MODULE    := libgameplay
 LOCAL_MODULE    := libgameplay
-LOCAL_SRC_FILES := AbsoluteLayout.cpp Animation.cpp AnimationClip.cpp AnimationController.cpp AnimationTarget.cpp AnimationValue.cpp AudioBuffer.cpp AudioController.cpp AudioListener.cpp AudioSource.cpp BoundingBox.cpp BoundingSphere.cpp Bundle.cpp Button.cpp Camera.cpp CheckBox.cpp Container.cpp Control.cpp Curve.cpp DebugNew.cpp DepthStencilTarget.cpp Effect.cpp FileSystem.cpp FlowLayout.cpp Font.cpp Form.cpp FrameBuffer.cpp Frustum.cpp Game.cpp gameplay-main-android.cpp Image.cpp Joint.cpp Label.cpp Layout.cpp Light.cpp Material.cpp MaterialParameter.cpp Matrix.cpp Mesh.cpp MeshBatch.cpp MeshPart.cpp MeshSkin.cpp Model.cpp Node.cpp ParticleEmitter.cpp Pass.cpp PhysicsCharacter.cpp PhysicsCollisionObject.cpp PhysicsCollisionShape.cpp PhysicsConstraint.cpp PhysicsController.cpp PhysicsFixedConstraint.cpp PhysicsGenericConstraint.cpp PhysicsGhostObject.cpp PhysicsHingeConstraint.cpp PhysicsMotionState.cpp PhysicsRigidBody.cpp PhysicsSocketConstraint.cpp PhysicsSpringConstraint.cpp Plane.cpp PlatformAndroid.cpp Properties.cpp Quaternion.cpp RadioButton.cpp Ray.cpp Rectangle.cpp Ref.cpp RenderState.cpp RenderTarget.cpp Scene.cpp SceneLoader.cpp ScrollLayout.cpp Slider.cpp SpriteBatch.cpp Technique.cpp TextBox.cpp Texture.cpp Theme.cpp ThemeStyle.cpp Transform.cpp Vector2.cpp Vector3.cpp Vector4.cpp VertexAttributeBinding.cpp VertexFormat.cpp VerticalLayout.cpp
+LOCAL_SRC_FILES := AbsoluteLayout.cpp Animation.cpp AnimationClip.cpp AnimationController.cpp AnimationTarget.cpp AnimationValue.cpp AudioBuffer.cpp AudioController.cpp AudioListener.cpp AudioSource.cpp BoundingBox.cpp BoundingSphere.cpp Bundle.cpp Button.cpp Camera.cpp CheckBox.cpp Container.cpp Control.cpp Curve.cpp DebugNew.cpp DepthStencilTarget.cpp Effect.cpp FileSystem.cpp FlowLayout.cpp Font.cpp Form.cpp FrameBuffer.cpp Frustum.cpp Game.cpp gameplay-main-android.cpp Image.cpp Joint.cpp Label.cpp Layout.cpp Light.cpp Material.cpp MaterialParameter.cpp Matrix.cpp Mesh.cpp MeshBatch.cpp MeshPart.cpp MeshSkin.cpp Model.cpp Node.cpp ParticleEmitter.cpp Pass.cpp PhysicsCharacter.cpp PhysicsCollisionObject.cpp PhysicsCollisionShape.cpp PhysicsConstraint.cpp PhysicsController.cpp PhysicsFixedConstraint.cpp PhysicsGenericConstraint.cpp PhysicsGhostObject.cpp PhysicsHingeConstraint.cpp PhysicsMotionState.cpp PhysicsRigidBody.cpp PhysicsSocketConstraint.cpp PhysicsSpringConstraint.cpp Plane.cpp PlatformAndroid.cpp Properties.cpp Quaternion.cpp RadioButton.cpp Ray.cpp Rectangle.cpp Ref.cpp RenderState.cpp RenderTarget.cpp Scene.cpp SceneLoader.cpp Slider.cpp SpriteBatch.cpp Technique.cpp TextBox.cpp Texture.cpp Theme.cpp ThemeStyle.cpp Transform.cpp Vector2.cpp Vector3.cpp Vector4.cpp VertexAttributeBinding.cpp VertexFormat.cpp VerticalLayout.cpp
 LOCAL_CFLAGS := -D__ANDROID__ -I"../../external-deps/bullet/include" -I"../../external-deps/libpng/include" -I"../../external-deps/oggvorbis/include" -I"../../external-deps/openal/include"
 LOCAL_CFLAGS := -D__ANDROID__ -I"../../external-deps/bullet/include" -I"../../external-deps/libpng/include" -I"../../external-deps/oggvorbis/include" -I"../../external-deps/openal/include"
 LOCAL_STATIC_LIBRARIES := android_native_app_glue
 LOCAL_STATIC_LIBRARIES := android_native_app_glue
 
 

+ 19 - 19
gameplay/src/Container.cpp

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

+ 14 - 5
gameplay/src/Container.h

@@ -25,6 +25,7 @@ namespace gameplay
          size        = <width, height>   // Size of the container, measured in pixels.
          size        = <width, height>   // Size of the container, measured in pixels.
          width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
          width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
+         scroll      = <Container::Scroll constant>
   
   
          // All the nested controls within this container.
          // All the nested controls within this container.
          container 
          container 
@@ -45,7 +46,10 @@ class Container : public Control
 {
 {
 public:
 public:
 
 
-    enum ScrollBars
+    /**
+     * The definition for container scrolling.
+     */
+    enum Scroll
     {
     {
         SCROLL_NONE        = 0,
         SCROLL_NONE        = 0,
         SCROLL_HORIZONTAL  = 0x01,
         SCROLL_HORIZONTAL  = 0x01,
@@ -122,9 +126,14 @@ public:
      */
      */
     const std::vector<Control*>& getControls() const;
     const std::vector<Control*>& getControls() const;
 
 
-    void setScrollBars(ScrollBars scrollBars);
+    /**
+     * Sets the scrolling for the container.
+     *
+     * @param scroll The scroll for the 
+     */
+    void setScroll(Scroll scroll);
 
 
-    ScrollBars getScrollBars() const;
+    Scroll getScroll() const;
 
 
     /**
     /**
      * Gets the first animation in the control with the specified ID.
      * Gets the first animation in the control with the specified ID.
@@ -229,7 +238,7 @@ protected:
 
 
     bool touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
     bool touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
 
 
-    static ScrollBars getScrollBars(const char* scrollBars);
+    static Scroll getScroll(const char* scroll);
 
 
     /**
     /**
      * The container's layout.
      * The container's layout.
@@ -249,7 +258,7 @@ protected:
     Theme::ThemeImage* _scrollBarRightCap;
     Theme::ThemeImage* _scrollBarRightCap;
 
 
     // Flag representing whether scrolling is enabled, and in which directions.
     // Flag representing whether scrolling is enabled, and in which directions.
-    ScrollBars _scrollBars;
+    Scroll _scroll;
 
 
     // Data required when scrolling is enabled.
     // 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->_bounds.x = Game::getInstance()->getWidth() * 0.5f - form->_bounds.width * 0.5f;
     }
     }
 
 
-    form->_scrollBars = getScrollBars(formProperties->getString("scrollbars"));
+    form->_scroll = getScroll(formProperties->getString("scroll"));
 
 
     // Add all the controls to the form.
     // Add all the controls to the form.
     form->addControls(theme, formProperties);
     form->addControls(theme, formProperties);
@@ -384,7 +384,7 @@ void Form::update()
         _opacity = getOpacity(_state);
         _opacity = getOpacity(_state);
 
 
         // Get scrollbar images and diminish clipping bounds to make room for scrollbars.
         // Get scrollbar images and diminish clipping bounds to make room for scrollbars.
-        if ((_scrollBars & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL)
+        if ((_scroll & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL)
         {
         {
             _scrollBarLeftCap = getImage("scrollBarLeftCap", _state);
             _scrollBarLeftCap = getImage("scrollBarLeftCap", _state);
             _scrollBarHorizontal = getImage("horizontalScrollBar", _state);
             _scrollBarHorizontal = getImage("horizontalScrollBar", _state);
@@ -393,7 +393,7 @@ void Form::update()
             _viewportClipBounds.height -= _scrollBarHorizontal->getRegion().height;
             _viewportClipBounds.height -= _scrollBarHorizontal->getRegion().height;
         }
         }
 
 
-        if ((_scrollBars & SCROLL_VERTICAL) == SCROLL_VERTICAL)
+        if ((_scroll & SCROLL_VERTICAL) == SCROLL_VERTICAL)
         {
         {
             _scrollBarTopCap = getImage("scrollBarTopCap", _state);
             _scrollBarTopCap = getImage("scrollBarTopCap", _state);
             _scrollBarVertical = getImage("verticalScrollBar", _state);
             _scrollBarVertical = getImage("verticalScrollBar", _state);
@@ -405,7 +405,7 @@ void Form::update()
         GP_ASSERT(_layout);
         GP_ASSERT(_layout);
         _layout->update(this);
         _layout->update(this);
 
 
-        if (_scrollBars != SCROLL_NONE)
+        if (_scroll != SCROLL_NONE)
             this->updateScroll(this);
             this->updateScroll(this);
     }
     }
 }
 }