2
0
Эх сурвалжийг харах

Merge pull request #505 from ablake/master

Patching sticky buttons and Container::isScrolling().
Sean Paul Taylor 13 жил өмнө
parent
commit
75375cd36a

+ 15 - 13
gameplay/src/Container.cpp

@@ -37,7 +37,7 @@ Container::Container()
       _scrollBarLeftCap(NULL), _scrollBarHorizontal(NULL), _scrollBarRightCap(NULL),
       _scroll(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
       _scrollBarsAutoHide(false), _scrollBarOpacity(1.0f), _scrolling(false),
-       _scrollingFirstX(0), _scrollingFirstY(0), _scrollingLastX(0), _scrollingLastY(0),
+      _scrollingVeryFirstX(0), _scrollingVeryFirstY(0), _scrollingFirstX(0), _scrollingFirstY(0), _scrollingLastX(0), _scrollingLastY(0),
       _scrollingStartTimeX(0), _scrollingStartTimeY(0), _scrollingLastTime(0),
       _scrollingVelocity(Vector2::zero()), _scrollingFriction(1.0f),
       _scrollingRight(false), _scrollingDown(false),
@@ -369,8 +369,8 @@ bool Container::isScrolling() const
         return true;
 
     return (_scrolling &&
-            (abs(_scrollingLastX - _scrollingFirstX) > SCROLL_THRESHOLD ||
-             abs(_scrollingLastY - _scrollingFirstY) > SCROLL_THRESHOLD));
+            (abs(_scrollingLastX - _scrollingVeryFirstX) > SCROLL_THRESHOLD ||
+             abs(_scrollingLastY - _scrollingVeryFirstY) > SCROLL_THRESHOLD));
 }
 
 Animation* Container::getAnimation(const char* id) const
@@ -804,8 +804,8 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
         {
             _contactIndex = (int) contactIndex;
             _contactIndices++;
-            _scrollingLastX = _scrollingFirstX = x;
-            _scrollingLastY = _scrollingFirstY = y;
+            _scrollingLastX = _scrollingFirstX = _scrollingVeryFirstX = x;
+            _scrollingLastY = _scrollingFirstY = _scrollingVeryFirstY = y;
             _scrollingVelocity.set(0, 0);
             _scrolling = true;
             _scrollingStartTimeX = _scrollingStartTimeY = 0;
@@ -1108,13 +1108,11 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         }
         break;
     case Touch::TOUCH_RELEASE:
-        {
-            if (eventConsumed)
-            {
-                if (_contactIndices > 0)
-                    _contactIndices--;
-            }
-        }
+		if (eventConsumed)
+		{
+			if (_contactIndices > 0)
+				_contactIndices--;
+		}
         break;
     }
 
@@ -1128,7 +1126,11 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
     }
 
     release();
-    return (_consumeInputEvents | eventConsumed);
+    if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+		y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+    	return (_consumeInputEvents | eventConsumed);
+    else
+    	return eventConsumed;
 }
 
 Container::Scroll Container::getScroll(const char* scroll)

+ 10 - 2
gameplay/src/Container.h

@@ -444,11 +444,19 @@ protected:
      */
     bool _scrolling;
     /** 
-     * First scrolling touch x position
+	 * First scrolling touch x position
+	 */
+	int _scrollingVeryFirstX;
+	/**
+	 * First scrolling touch y position
+	 */
+	int _scrollingVeryFirstY;
+    /**
+     * First scrolling touch x position since last change in direction.
      */ 
     int _scrollingFirstX;
     /** 
-     * First scrolling touch y position
+     * First scrolling touch y position since last change in direction.
      */ 
     int _scrollingFirstY;
     /**