Ejemplo n.º 1
0
		public virtual bool getChildVisibleRect(android.view.View child, android.graphics.Rect
			 r, android.graphics.Point offset)
		{
			int dx = child.mLeft - mScrollX;
			int dy = child.mTop - mScrollY;
			if (offset != null)
			{
				offset.x += dx;
				offset.y += dy;
			}
			r.offset(dx, dy);
			return r.intersect(0, 0, mRight - mLeft, mBottom - mTop) && (mParent == null || mParent
				.getChildVisibleRect(this, r, offset));
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Helper method that offsets a rect either from parent to descendant or
		/// descendant to parent.
		/// </summary>
		/// <remarks>
		/// Helper method that offsets a rect either from parent to descendant or
		/// descendant to parent.
		/// </remarks>
		internal virtual void offsetRectBetweenParentAndChild(android.view.View descendant
			, android.graphics.Rect rect, bool offsetFromChildToParent, bool clipToBounds)
		{
			// already in the same coord system :)
			if (descendant == this)
			{
				return;
			}
			android.view.ViewParent theParent = descendant.mParent;
			// search and offset up to the parent
			while ((theParent != null) && (theParent is android.view.View) && (theParent != this
				))
			{
				if (offsetFromChildToParent)
				{
					rect.offset(descendant.mLeft - descendant.mScrollX, descendant.mTop - descendant.
						mScrollY);
					if (clipToBounds)
					{
						android.view.View p = (android.view.View)theParent;
						rect.intersect(0, 0, p.mRight - p.mLeft, p.mBottom - p.mTop);
					}
				}
				else
				{
					if (clipToBounds)
					{
						android.view.View p = (android.view.View)theParent;
						rect.intersect(0, 0, p.mRight - p.mLeft, p.mBottom - p.mTop);
					}
					rect.offset(descendant.mScrollX - descendant.mLeft, descendant.mScrollY - descendant
						.mTop);
				}
				descendant = (android.view.View)theParent;
				theParent = descendant.mParent;
			}
			// now that we are up to this view, need to offset one more time
			// to get into our coordinate space
			if (theParent == this)
			{
				if (offsetFromChildToParent)
				{
					rect.offset(descendant.mLeft - descendant.mScrollX, descendant.mTop - descendant.
						mScrollY);
				}
				else
				{
					rect.offset(descendant.mScrollX - descendant.mLeft, descendant.mScrollY - descendant
						.mTop);
				}
			}
			else
			{
				throw new System.ArgumentException("parameter must be a descendant of this view");
			}
		}
Ejemplo n.º 3
0
		public override bool requestChildRectangleOnScreen(android.view.View child, android.graphics.Rect
			 rectangle, bool immediate)
		{
			// offset into coordinate space of this scroll view
			rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY
				());
			return scrollToChildRect(rectangle, immediate);
		}
Ejemplo n.º 4
0
		public virtual android.view.ViewParent invalidateChildInParent(int[] location, android.graphics.Rect
			 dirty)
		{
			if ((mPrivateFlags & DRAWN) == DRAWN || (mPrivateFlags & DRAWING_CACHE_VALID) == 
				DRAWING_CACHE_VALID)
			{
				if ((mGroupFlags & (FLAG_OPTIMIZE_INVALIDATE | FLAG_ANIMATION_DONE)) != FLAG_OPTIMIZE_INVALIDATE)
				{
					dirty.offset(location[CHILD_LEFT_INDEX] - mScrollX, location[CHILD_TOP_INDEX] - mScrollY
						);
					int left = mLeft;
					int top = mTop;
					if ((mGroupFlags & FLAG_CLIP_CHILDREN) != FLAG_CLIP_CHILDREN || dirty.intersect(0
						, 0, mRight - left, mBottom - top) || (mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION)
					{
						mPrivateFlags &= ~DRAWING_CACHE_VALID;
						location[CHILD_LEFT_INDEX] = left;
						location[CHILD_TOP_INDEX] = top;
						if (mLayerType != LAYER_TYPE_NONE)
						{
							mLocalDirtyRect.union(dirty);
						}
						return mParent;
					}
				}
				else
				{
					mPrivateFlags &= ~DRAWN & ~DRAWING_CACHE_VALID;
					location[CHILD_LEFT_INDEX] = mLeft;
					location[CHILD_TOP_INDEX] = mTop;
					if ((mGroupFlags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN)
					{
						dirty.set(0, 0, mRight - mLeft, mBottom - mTop);
					}
					else
					{
						// in case the dirty rect extends outside the bounds of this container
						dirty.union(0, 0, mRight - mLeft, mBottom - mTop);
					}
					if (mLayerType != LAYER_TYPE_NONE)
					{
						mLocalDirtyRect.union(dirty);
					}
					return mParent;
				}
			}
			return null;
		}
Ejemplo n.º 5
0
		protected internal override void onFocusChanged(bool gainFocus, int direction, android.graphics.Rect
			 previouslyFocusedRect)
		{
			base.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
			int closestChildIndex = -1;
			if (gainFocus && previouslyFocusedRect != null)
			{
				previouslyFocusedRect.offset(mScrollX, mScrollY);
				// figure out which item should be selected based on previously
				// focused rect
				android.graphics.Rect otherRect = mTempRect;
				int minDistance = int.MaxValue;
				int childCount = getChildCount();
				{
					for (int i = 0; i < childCount; i++)
					{
						// only consider view's on appropriate edge of grid
						if (!isCandidateSelection(i, direction))
						{
							continue;
						}
						android.view.View other = getChildAt(i);
						other.getDrawingRect(otherRect);
						offsetDescendantRectToMyCoords(other, otherRect);
						int distance = getDistance(previouslyFocusedRect, otherRect, direction);
						if (distance < minDistance)
						{
							minDistance = distance;
							closestChildIndex = i;
						}
					}
				}
			}
			if (closestChildIndex >= 0)
			{
				setSelection(closestChildIndex + mFirstPosition);
			}
			else
			{
				requestLayout();
			}
		}