コード例 #1
0
ファイル: Canvas.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>Draw the picture, stretched to fit into the dst rectangle.</summary>
		/// <remarks>Draw the picture, stretched to fit into the dst rectangle.</remarks>
		public virtual void drawPicture(android.graphics.Picture picture, android.graphics.Rect
			 dst)
		{
			save();
			translate(dst.left, dst.top);
			if (picture.getWidth() > 0 && picture.getHeight() > 0)
			{
				scale((float)dst.width() / picture.getWidth(), (float)dst.height() / picture.getHeight
					());
			}
			drawPicture(picture);
			restore();
		}
コード例 #2
0
ファイル: Gravity.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>
		/// Apply additional gravity behavior based on the overall "display" that an
		/// object exists in.
		/// </summary>
		/// <remarks>
		/// Apply additional gravity behavior based on the overall "display" that an
		/// object exists in.  This can be used after
		/// <see cref="apply(int, int, int, android.graphics.Rect, int, int, android.graphics.Rect)
		/// 	">apply(int, int, int, android.graphics.Rect, int, int, android.graphics.Rect)</see>
		/// to place the object
		/// within a visible display.  By default this moves or clips the object
		/// to be visible in the display; the gravity flags
		/// <see cref="DISPLAY_CLIP_HORIZONTAL">DISPLAY_CLIP_HORIZONTAL</see>
		/// and
		/// <see cref="DISPLAY_CLIP_VERTICAL">DISPLAY_CLIP_VERTICAL</see>
		/// can be used to change this behavior.
		/// </remarks>
		/// <param name="gravity">
		/// Gravity constants to modify the placement within the
		/// display.
		/// </param>
		/// <param name="display">
		/// The rectangle of the display in which the object is
		/// being placed.
		/// </param>
		/// <param name="inoutObj">
		/// Supplies the current object position; returns with it
		/// modified if needed to fit in the display.
		/// </param>
		public static void applyDisplay(int gravity, android.graphics.Rect display, android.graphics.Rect
			 inoutObj)
		{
			if ((gravity & DISPLAY_CLIP_VERTICAL) != 0)
			{
				if (inoutObj.top < display.top)
				{
					inoutObj.top = display.top;
				}
				if (inoutObj.bottom > display.bottom)
				{
					inoutObj.bottom = display.bottom;
				}
			}
			else
			{
				int off = 0;
				if (inoutObj.top < display.top)
				{
					off = display.top - inoutObj.top;
				}
				else
				{
					if (inoutObj.bottom > display.bottom)
					{
						off = display.bottom - inoutObj.bottom;
					}
				}
				if (off != 0)
				{
					if (inoutObj.height() > (display.bottom - display.top))
					{
						inoutObj.top = display.top;
						inoutObj.bottom = display.bottom;
					}
					else
					{
						inoutObj.top += off;
						inoutObj.bottom += off;
					}
				}
			}
			if ((gravity & DISPLAY_CLIP_HORIZONTAL) != 0)
			{
				if (inoutObj.left < display.left)
				{
					inoutObj.left = display.left;
				}
				if (inoutObj.right > display.right)
				{
					inoutObj.right = display.right;
				}
			}
			else
			{
				int off = 0;
				if (inoutObj.left < display.left)
				{
					off = display.left - inoutObj.left;
				}
				else
				{
					if (inoutObj.right > display.right)
					{
						off = display.right - inoutObj.right;
					}
				}
				if (off != 0)
				{
					if (inoutObj.width() > (display.right - display.left))
					{
						inoutObj.left = display.left;
						inoutObj.right = display.right;
					}
					else
					{
						inoutObj.left += off;
						inoutObj.right += off;
					}
				}
			}
		}
コード例 #3
0
ファイル: ScaleDrawable.cs プロジェクト: hakeemsm/XobotOS
		protected internal override void onBoundsChange(android.graphics.Rect bounds)
		{
			android.graphics.Rect r = mTmpRect;
			bool min = mScaleState.mUseIntrinsicSizeAsMin;
			int level = getLevel();
			int w = bounds.width();
			if (mScaleState.mScaleWidth > 0)
			{
				int iw = min ? mScaleState.mDrawable.getIntrinsicWidth() : 0;
				w -= (int)((w - iw) * (10000 - level) * mScaleState.mScaleWidth / 10000);
			}
			int h = bounds.height();
			if (mScaleState.mScaleHeight > 0)
			{
				int ih = min ? mScaleState.mDrawable.getIntrinsicHeight() : 0;
				h -= (int)((h - ih) * (10000 - level) * mScaleState.mScaleHeight / 10000);
			}
			int layoutDirection = getResolvedLayoutDirectionSelf();
			android.view.Gravity.apply(mScaleState.mGravity, w, h, bounds, r, layoutDirection
				);
			if (w > 0 && h > 0)
			{
				mScaleState.mDrawable.setBounds(r.left, r.top, r.right, r.bottom);
			}
		}
コード例 #4
0
ファイル: MipmapDrawable.cs プロジェクト: hakeemsm/XobotOS
			/// <summary>Returns the index of the child mipmap drawable that will best fit the provided bounds.
			/// 	</summary>
			/// <remarks>
			/// Returns the index of the child mipmap drawable that will best fit the provided bounds.
			/// This index is determined by comparing bounds' height and children intrinsic heights.
			/// The returned mipmap index is the smallest mipmap which height is greater or equal than
			/// the bounds' height. If the bounds' height is larger than the largest mipmap, the largest
			/// mipmap index is returned.
			/// </remarks>
			/// <param name="bounds">The bounds of the MipMapDrawable.</param>
			/// <returns>
			/// The index of the child Drawable that will best fit these bounds, or -1 if there
			/// are no children mipmaps.
			/// </returns>
			public int indexForBounds(android.graphics.Rect bounds)
			{
				int boundsHeight = bounds.height();
				int N = getChildCount();
				{
					for (int i = 0; i < N; i++)
					{
						if (boundsHeight <= mMipmapHeights[i])
						{
							return i;
						}
					}
				}
				// No mipmap larger than bounds found. Use largest one which will be scaled up.
				if (N > 0)
				{
					return N - 1;
				}
				// No Drawable mipmap at all
				return -1;
			}
コード例 #5
0
ファイル: ScrollView.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>
		/// Compute the amount to scroll in the Y direction in order to get
		/// a rectangle completely on the screen (or, if taller than the screen,
		/// at least the first screen size chunk of it).
		/// </summary>
		/// <remarks>
		/// Compute the amount to scroll in the Y direction in order to get
		/// a rectangle completely on the screen (or, if taller than the screen,
		/// at least the first screen size chunk of it).
		/// </remarks>
		/// <param name="rect">The rect.</param>
		/// <returns>The scroll delta.</returns>
		protected internal virtual int computeScrollDeltaToGetChildRectOnScreen(android.graphics.Rect
			 rect)
		{
			if (getChildCount() == 0)
			{
				return 0;
			}
			int height = getHeight();
			int screenTop = getScrollY();
			int screenBottom = screenTop + height;
			int fadingEdge = getVerticalFadingEdgeLength();
			// leave room for top fading edge as long as rect isn't at very top
			if (rect.top > 0)
			{
				screenTop += fadingEdge;
			}
			// leave room for bottom fading edge as long as rect isn't at very bottom
			if (rect.bottom < getChildAt(0).getHeight())
			{
				screenBottom -= fadingEdge;
			}
			int scrollYDelta = 0;
			if (rect.bottom > screenBottom && rect.top > screenTop)
			{
				// need to move down to get it in view: move down just enough so
				// that the entire rectangle is in view (or at least the first
				// screen size chunk).
				if (rect.height() > height)
				{
					// just enough to get screen size chunk on
					scrollYDelta += (rect.top - screenTop);
				}
				else
				{
					// get entire rect at bottom of screen
					scrollYDelta += (rect.bottom - screenBottom);
				}
				// make sure we aren't scrolling beyond the end of our content
				int bottom = getChildAt(0).getBottom();
				int distanceToBottom = bottom - screenBottom;
				scrollYDelta = System.Math.Min(scrollYDelta, distanceToBottom);
			}
			else
			{
				if (rect.top < screenTop && rect.bottom < screenBottom)
				{
					// need to move up to get it in view: move up just enough so that
					// entire rectangle is in view (or at least the first screen
					// size chunk of it).
					if (rect.height() > height)
					{
						// screen size chunk
						scrollYDelta -= (screenBottom - rect.bottom);
					}
					else
					{
						// entire rect at top
						scrollYDelta -= (screenTop - rect.top);
					}
					// make sure we aren't scrolling any further than the top our content
					scrollYDelta = System.Math.Max(scrollYDelta, -getScrollY());
				}
			}
			return scrollYDelta;
		}
コード例 #6
0
ファイル: YuvImage.cs プロジェクト: hakeemsm/XobotOS
		private void adjustRectangle(android.graphics.Rect rect)
		{
			int width = rect.width();
			int height = rect.height();
			if (mFormat == android.graphics.ImageFormat.NV21)
			{
				// Make sure left, top, width and height are all even.
				width &= ~1;
				height &= ~1;
				rect.left &= ~1;
				rect.top &= ~1;
				rect.right = rect.left + width;
				rect.bottom = rect.top + height;
			}
			if (mFormat == android.graphics.ImageFormat.YUY2)
			{
				// Make sure left and width are both even.
				width &= ~1;
				rect.left &= ~1;
				rect.right = rect.left + width;
			}
		}