Esempio n. 1
0
 public override void draw(android.graphics.Canvas canvas)
 {
     base.draw(canvas);
     if (mForeground != null)
     {
         android.graphics.drawable.Drawable foreground = mForeground;
         if (mForegroundBoundsChanged)
         {
             mForegroundBoundsChanged = false;
             android.graphics.Rect selfBounds    = mSelfBounds;
             android.graphics.Rect overlayBounds = mOverlayBounds;
             int w = mRight - mLeft;
             int h = mBottom - mTop;
             if (mForegroundInPadding)
             {
                 selfBounds.set(0, 0, w, h);
             }
             else
             {
                 selfBounds.set(mPaddingLeft, mPaddingTop, w - mPaddingRight, h - mPaddingBottom);
             }
             int layoutDirection = getResolvedLayoutDirection();
             android.view.Gravity.apply(mForegroundGravity, foreground.getIntrinsicWidth(), foreground
                                        .getIntrinsicHeight(), selfBounds, overlayBounds, layoutDirection);
             foreground.setBounds(overlayBounds);
         }
         foreground.draw(canvas);
     }
 }
Esempio n. 2
0
 internal void set(android.view.ViewTreeObserver.InternalInsetsInfo other)
 {
     contentInsets.set(other.contentInsets);
     visibleInsets.set(other.visibleInsets);
     touchableRegion.set(other.touchableRegion);
     mTouchableInsets = other.mTouchableInsets;
 }
Esempio n. 3
0
 /// <summary>Gets the size of the display as a rectangle, in pixels.</summary>
 /// <remarks>Gets the size of the display as a rectangle, in pixels.</remarks>
 /// <param name="outSize">
 /// A
 /// <see cref="android.graphics.Rect">android.graphics.Rect</see>
 /// object to receive the size information.
 /// </param>
 /// <seealso cref="getSize(android.graphics.Point)">getSize(android.graphics.Point)</seealso>
 public virtual void getRectSize(android.graphics.Rect outSize)
 {
     lock (mTmpPoint)
     {
         getSizeInternal(mTmpPoint, true);
         outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y);
     }
 }
Esempio n. 4
0
 public override bool getPadding(android.graphics.Rect padding)
 {
     if (mShapeState.mPadding != null)
     {
         padding.set(mShapeState.mPadding);
         return(true);
     }
     else
     {
         return(base.getPadding(padding));
     }
 }
Esempio n. 5
0
        protected internal virtual void drawThumb(android.graphics.Canvas canvas, android.graphics.Rect
                                                  bounds, int offset, int length, bool vertical)
        {
            android.graphics.Rect thumbRect = mTempBounds;
            bool changed = mRangeChanged || mChanged;

            if (changed)
            {
                if (vertical)
                {
                    thumbRect.set(bounds.left, bounds.top + offset, bounds.right, bounds.top + offset
                                  + length);
                }
                else
                {
                    thumbRect.set(bounds.left + offset, bounds.top, bounds.left + offset + length, bounds
                                  .bottom);
                }
            }
            if (vertical)
            {
                android.graphics.drawable.Drawable thumb = mVerticalThumb;
                if (changed)
                {
                    thumb.setBounds(thumbRect);
                }
                thumb.draw(canvas);
            }
            else
            {
                android.graphics.drawable.Drawable thumb = mHorizontalThumb;
                if (changed)
                {
                    thumb.setBounds(thumbRect);
                }
                thumb.draw(canvas);
            }
        }
Esempio n. 6
0
 public override bool dispatchTouchEvent(android.view.MotionEvent ev)
 {
     if (mDefaultTouchRecepient == null)
     {
         return(base.dispatchTouchEvent(ev));
     }
     if (base.dispatchTouchEvent(ev))
     {
         return(true);
     }
     mTempRect.set(0, 0, 0, 0);
     offsetRectIntoDescendantCoords(mDefaultTouchRecepient, mTempRect);
     ev.setLocation(ev.getX() + mTempRect.left, ev.getY() + mTempRect.top);
     return(mDefaultTouchRecepient.dispatchTouchEvent(ev));
 }
Esempio n. 7
0
        /// <summary>
        /// Positions the icon vertically (horizontal centering is taken care of by
        /// the TextView's gravity).
        /// </summary>
        /// <remarks>
        /// Positions the icon vertically (horizontal centering is taken care of by
        /// the TextView's gravity).
        /// </remarks>
        private void positionIcon()
        {
            if (mIcon == null)
            {
                return;
            }
            // We reuse the output rectangle as a temp rect
            android.graphics.Rect tmpRect = mPositionIconOutput;
            getLineBounds(0, tmpRect);
            mPositionIconAvailable.set(0, 0, getWidth(), tmpRect.top);
            int layoutDirection = getResolvedLayoutDirection();

            android.view.Gravity.apply(android.view.Gravity.CENTER_VERTICAL | android.view.Gravity
                                       .LEFT, mIcon.getIntrinsicWidth(), mIcon.getIntrinsicHeight(), mPositionIconAvailable
                                       , mPositionIconOutput, layoutDirection);
            mIcon.setBounds(mPositionIconOutput);
        }
Esempio n. 8
0
 public override bool getPadding(android.graphics.Rect padding)
 {
     android.graphics.Rect r = mDrawableContainerState.getConstantPadding();
     if (r != null)
     {
         padding.set(r);
         return(true);
     }
     if (mCurrDrawable != null)
     {
         return(mCurrDrawable.getPadding(padding));
     }
     else
     {
         return(base.getPadding(padding));
     }
 }
Esempio n. 9
0
        /// <summary>Find the nearest touchable view to the specified view.</summary>
        /// <remarks>Find the nearest touchable view to the specified view.</remarks>
        /// <param name="root">The root of the tree in which to search</param>
        /// <param name="x">X coordinate from which to start the search</param>
        /// <param name="y">Y coordinate from which to start the search</param>
        /// <param name="direction">Direction to look</param>
        /// <param name="deltas">
        /// Offset from the <x, y> to the edge of the nearest view. Note that this array
        /// may already be populated with values.
        /// </param>
        /// <returns>The nearest touchable view, or null if none exists.</returns>
        public virtual android.view.View findNearestTouchable(android.view.ViewGroup root
                                                              , int x, int y, int direction, int[] deltas)
        {
            java.util.ArrayList <android.view.View> touchables = root.getTouchables();
            int minDistance = int.MaxValue;

            android.view.View closest = null;
            int numTouchables         = touchables.size();
            int edgeSlop = android.view.ViewConfiguration.get(root.mContext).getScaledEdgeSlop
                               ();

            android.graphics.Rect closestBounds   = new android.graphics.Rect();
            android.graphics.Rect touchableBounds = mOtherRect;
            {
                for (int i = 0; i < numTouchables; i++)
                {
                    android.view.View touchable = touchables.get(i);
                    // get visible bounds of other view in same coordinate system
                    touchable.getDrawingRect(touchableBounds);
                    root.offsetRectBetweenParentAndChild(touchable, touchableBounds, true, true);
                    if (!isTouchCandidate(x, y, touchableBounds, direction))
                    {
                        continue;
                    }
                    int distance = int.MaxValue;
                    switch (direction)
                    {
                    case android.view.View.FOCUS_LEFT:
                    {
                        distance = x - touchableBounds.right + 1;
                        break;
                    }

                    case android.view.View.FOCUS_RIGHT:
                    {
                        distance = touchableBounds.left;
                        break;
                    }

                    case android.view.View.FOCUS_UP:
                    {
                        distance = y - touchableBounds.bottom + 1;
                        break;
                    }

                    case android.view.View.FOCUS_DOWN:
                    {
                        distance = touchableBounds.top;
                        break;
                    }
                    }
                    if (distance < edgeSlop)
                    {
                        // Give preference to innermost views
                        if (closest == null || closestBounds.contains(touchableBounds) || (!touchableBounds
                                                                                           .contains(closestBounds) && distance < minDistance))
                        {
                            minDistance = distance;
                            closest     = touchable;
                            closestBounds.set(touchableBounds);
                            switch (direction)
                            {
                            case android.view.View.FOCUS_LEFT:
                            {
                                deltas[0] = -distance;
                                break;
                            }

                            case android.view.View.FOCUS_RIGHT:
                            {
                                deltas[0] = distance;
                                break;
                            }

                            case android.view.View.FOCUS_UP:
                            {
                                deltas[1] = -distance;
                                break;
                            }

                            case android.view.View.FOCUS_DOWN:
                            {
                                deltas[1] = distance;
                                break;
                            }
                            }
                        }
                    }
                }
            }
            return(closest);
        }
Esempio n. 10
0
 /// <summary>
 /// Set the dst integer Rect by rounding "out" this rectangle, choosing the
 /// floor of top and left, and the ceiling of right and bottom.
 /// </summary>
 /// <remarks>
 /// Set the dst integer Rect by rounding "out" this rectangle, choosing the
 /// floor of top and left, and the ceiling of right and bottom.
 /// </remarks>
 public virtual void roundOut(android.graphics.Rect dst)
 {
     dst.set((int)android.util.FloatMath.floor(left), (int)android.util.FloatMath.floor
                 (top), (int)android.util.FloatMath.ceil(right), (int)android.util.FloatMath.ceil
                 (bottom));
 }
Esempio n. 11
0
 /// <summary>
 /// Set the dst integer Rect by rounding this rectangle's coordinates
 /// to their nearest integer values.
 /// </summary>
 /// <remarks>
 /// Set the dst integer Rect by rounding this rectangle's coordinates
 /// to their nearest integer values.
 /// </remarks>
 public virtual void round(android.graphics.Rect dst)
 {
     dst.set([email protected](left), [email protected]
             .round(top), [email protected](right), [email protected]
             .round(bottom));
 }
Esempio n. 12
0
 public virtual void setRectSize(int width, int height)
 {
     mRect.set(mRect.left, mRect.top, mRect.left + width, mRect.top + height);
 }
Esempio n. 13
0
 public override bool getPadding(android.graphics.Rect padding)
 {
     padding.set(mPadding);
     return(true);
 }