示例#1
0
        protected internal override bool onLevelChange(int level)
        {
            android.graphics.drawable.LayerDrawable.ChildDrawable[] array = mLayerState.mChildren;
            int  N = mLayerState.mNum;
            bool paddingChanged = false;
            bool changed        = false;

            {
                for (int i = 0; i < N; i++)
                {
                    android.graphics.drawable.LayerDrawable.ChildDrawable r = array[i];
                    if (r.mDrawable.setLevel(level))
                    {
                        changed = true;
                    }
                    if (reapplyPadding(i, r))
                    {
                        paddingChanged = true;
                    }
                }
            }
            if (paddingChanged)
            {
                onBoundsChange(getBounds());
            }
            return(changed);
        }
示例#2
0
        /// <summary>Add a new layer to this drawable.</summary>
        /// <remarks>Add a new layer to this drawable. The new layer is identified by an id.</remarks>
        /// <param name="layer">The drawable to add as a layer.</param>
        /// <param name="id">The id of the new layer.</param>
        /// <param name="left">The left padding of the new layer.</param>
        /// <param name="top">The top padding of the new layer.</param>
        /// <param name="right">The right padding of the new layer.</param>
        /// <param name="bottom">The bottom padding of the new layer.</param>
        private void addLayer(android.graphics.drawable.Drawable layer, int id, int left,
                              int top, int right, int bottom)
        {
            android.graphics.drawable.LayerDrawable.LayerState st = mLayerState;
            int N = st.mChildren != null ? st.mChildren.Length : 0;
            int i = st.mNum;

            if (i >= N)
            {
                android.graphics.drawable.LayerDrawable.ChildDrawable[] nu = new android.graphics.drawable.LayerDrawable
                                                                             .ChildDrawable[N + 10];
                if (i > 0)
                {
                    System.Array.Copy(st.mChildren, 0, nu, 0, i);
                }
                st.mChildren = nu;
            }
            mLayerState.mChildrenChangingConfigurations |= layer.getChangingConfigurations();
            android.graphics.drawable.LayerDrawable.ChildDrawable childDrawable = new android.graphics.drawable.LayerDrawable
                                                                                  .ChildDrawable();
            st.mChildren[i]         = childDrawable;
            childDrawable.mId       = id;
            childDrawable.mDrawable = layer;
            childDrawable.mInsetL   = left;
            childDrawable.mInsetT   = top;
            childDrawable.mInsetR   = right;
            childDrawable.mInsetB   = bottom;
            st.mNum++;
            layer.setCallback(this);
        }
示例#3
0
 /// <summary>Specify modifiers to the bounds for the drawable[index].</summary>
 /// <remarks>
 /// Specify modifiers to the bounds for the drawable[index].
 /// left += l
 /// top += t;
 /// right -= r;
 /// bottom -= b;
 /// </remarks>
 public virtual void setLayerInset(int index, int l, int t, int r, int b)
 {
     android.graphics.drawable.LayerDrawable.ChildDrawable childDrawable = mLayerState
                                                                           .mChildren[index];
     childDrawable.mInsetL = l;
     childDrawable.mInsetT = t;
     childDrawable.mInsetR = r;
     childDrawable.mInsetB = b;
 }
示例#4
0
 internal bool reapplyPadding(int i, android.graphics.drawable.LayerDrawable.ChildDrawable
                              r)
 {
     android.graphics.Rect rect = mTmpRect;
     r.mDrawable.getPadding(rect);
     if (rect.left != mPaddingL[i] || rect.top != mPaddingT[i] || rect.right != mPaddingR
         [i] || rect.bottom != mPaddingB[i])
     {
         mPaddingL[i] = rect.left;
         mPaddingT[i] = rect.top;
         mPaddingR[i] = rect.right;
         mPaddingB[i] = rect.bottom;
         return(true);
     }
     return(false);
 }
示例#5
0
 internal LayerState(android.graphics.drawable.LayerDrawable.LayerState orig, android.graphics.drawable.LayerDrawable
                     owner, android.content.res.Resources res)
 {
     if (orig != null)
     {
         android.graphics.drawable.LayerDrawable.ChildDrawable[] origChildDrawable = orig.
                                                                                     mChildren;
         int N = orig.mNum;
         mNum      = N;
         mChildren = new android.graphics.drawable.LayerDrawable.ChildDrawable[N];
         mChangingConfigurations         = orig.mChangingConfigurations;
         mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations;
         {
             for (int i = 0; i < N; i++)
             {
                 android.graphics.drawable.LayerDrawable.ChildDrawable r = mChildren[i] = new android.graphics.drawable.LayerDrawable
                                                                                          .ChildDrawable();
                 android.graphics.drawable.LayerDrawable.ChildDrawable or = origChildDrawable[i];
                 if (res != null)
                 {
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable(res);
                 }
                 else
                 {
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable();
                 }
                 r.mDrawable.setCallback(owner);
                 r.mInsetL = or.mInsetL;
                 r.mInsetT = or.mInsetT;
                 r.mInsetR = or.mInsetR;
                 r.mInsetB = or.mInsetB;
                 r.mId     = or.mId;
             }
         }
         mHaveOpacity          = orig.mHaveOpacity;
         mOpacity              = orig.mOpacity;
         mHaveStateful         = orig.mHaveStateful;
         mStateful             = orig.mStateful;
         mCheckedConstantState = mCanConstantState = true;
     }
     else
     {
         mNum      = 0;
         mChildren = null;
     }
 }
示例#6
0
		/// <summary>
		/// Create a new layer drawable with the specified list of layers and the specified
		/// constant state.
		/// </summary>
		/// <remarks>
		/// Create a new layer drawable with the specified list of layers and the specified
		/// constant state.
		/// </remarks>
		/// <param name="layers">The list of layers to add to this drawable.</param>
		/// <param name="state">The constant drawable state.</param>
		internal LayerDrawable(android.graphics.drawable.Drawable[] layers, android.graphics.drawable.LayerDrawable
			.LayerState state) : this(state, null)
		{
			int length = layers.Length;
			android.graphics.drawable.LayerDrawable.ChildDrawable[] r = new android.graphics.drawable.LayerDrawable
				.ChildDrawable[length];
			{
				for (int i = 0; i < length; i++)
				{
					r[i] = new android.graphics.drawable.LayerDrawable.ChildDrawable();
					r[i].mDrawable = layers[i];
					layers[i].setCallback(this);
					mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations
						();
				}
			}
			mLayerState.mNum = length;
			mLayerState.mChildren = r;
			ensurePadding();
		}
示例#7
0
        /// <summary>
        /// Create a new layer drawable with the specified list of layers and the specified
        /// constant state.
        /// </summary>
        /// <remarks>
        /// Create a new layer drawable with the specified list of layers and the specified
        /// constant state.
        /// </remarks>
        /// <param name="layers">The list of layers to add to this drawable.</param>
        /// <param name="state">The constant drawable state.</param>
        internal LayerDrawable(android.graphics.drawable.Drawable[] layers, android.graphics.drawable.LayerDrawable
                               .LayerState state) : this(state, null)
        {
            int length = layers.Length;

            android.graphics.drawable.LayerDrawable.ChildDrawable[] r = new android.graphics.drawable.LayerDrawable
                                                                        .ChildDrawable[length];
            {
                for (int i = 0; i < length; i++)
                {
                    r[i]           = new android.graphics.drawable.LayerDrawable.ChildDrawable();
                    r[i].mDrawable = layers[i];
                    layers[i].setCallback(this);
                    mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations
                                                                       ();
                }
            }
            mLayerState.mNum      = length;
            mLayerState.mChildren = r;
            ensurePadding();
        }
示例#8
0
 protected internal override void onBoundsChange(android.graphics.Rect bounds)
 {
     android.graphics.drawable.LayerDrawable.ChildDrawable[] array = mLayerState.mChildren;
     int N    = mLayerState.mNum;
     int padL = 0;
     int padT = 0;
     int padR = 0;
     int padB = 0;
     {
         for (int i = 0; i < N; i++)
         {
             android.graphics.drawable.LayerDrawable.ChildDrawable r = array[i];
             r.mDrawable.setBounds(bounds.left + r.mInsetL + padL, bounds.top + r.mInsetT + padT
                                   , bounds.right - r.mInsetR - padR, bounds.bottom - r.mInsetB - padB);
             padL += mPaddingL[i];
             padR += mPaddingR[i];
             padT += mPaddingT[i];
             padB += mPaddingB[i];
         }
     }
 }
示例#9
0
        public override int getIntrinsicHeight()
        {
            int height = -1;

            android.graphics.drawable.LayerDrawable.ChildDrawable[] array = mLayerState.mChildren;
            int N    = mLayerState.mNum;
            int padT = 0;
            int padB = 0;

            {
                for (int i = 0; i < N; i++)
                {
                    android.graphics.drawable.LayerDrawable.ChildDrawable r = array[i];
                    int h = r.mDrawable.getIntrinsicHeight() + r.mInsetT + r.mInsetB + +padT + padB;
                    if (h > height)
                    {
                        height = h;
                    }
                    padT += mPaddingT[i];
                    padB += mPaddingB[i];
                }
            }
            return(height);
        }
示例#10
0
        public override int getIntrinsicWidth()
        {
            int width = -1;

            android.graphics.drawable.LayerDrawable.ChildDrawable[] array = mLayerState.mChildren;
            int N    = mLayerState.mNum;
            int padL = 0;
            int padR = 0;

            {
                for (int i = 0; i < N; i++)
                {
                    android.graphics.drawable.LayerDrawable.ChildDrawable r = array[i];
                    int w = r.mDrawable.getIntrinsicWidth() + r.mInsetL + r.mInsetR + padL + padR;
                    if (w > width)
                    {
                        width = w;
                    }
                    padL += mPaddingL[i];
                    padR += mPaddingR[i];
                }
            }
            return(width);
        }
示例#11
0
			internal LayerState(android.graphics.drawable.LayerDrawable.LayerState orig, android.graphics.drawable.LayerDrawable
				 owner, android.content.res.Resources res)
			{
				if (orig != null)
				{
					android.graphics.drawable.LayerDrawable.ChildDrawable[] origChildDrawable = orig.
						mChildren;
					int N = orig.mNum;
					mNum = N;
					mChildren = new android.graphics.drawable.LayerDrawable.ChildDrawable[N];
					mChangingConfigurations = orig.mChangingConfigurations;
					mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations;
					{
						for (int i = 0; i < N; i++)
						{
							android.graphics.drawable.LayerDrawable.ChildDrawable r = mChildren[i] = new android.graphics.drawable.LayerDrawable
								.ChildDrawable();
							android.graphics.drawable.LayerDrawable.ChildDrawable or = origChildDrawable[i];
							if (res != null)
							{
								r.mDrawable = or.mDrawable.getConstantState().newDrawable(res);
							}
							else
							{
								r.mDrawable = or.mDrawable.getConstantState().newDrawable();
							}
							r.mDrawable.setCallback(owner);
							r.mInsetL = or.mInsetL;
							r.mInsetT = or.mInsetT;
							r.mInsetR = or.mInsetR;
							r.mInsetB = or.mInsetB;
							r.mId = or.mId;
						}
					}
					mHaveOpacity = orig.mHaveOpacity;
					mOpacity = orig.mOpacity;
					mHaveStateful = orig.mHaveStateful;
					mStateful = orig.mStateful;
					mCheckedConstantState = mCanConstantState = true;
				}
				else
				{
					mNum = 0;
					mChildren = null;
				}
			}
示例#12
0
		/// <summary>Add a new layer to this drawable.</summary>
		/// <remarks>Add a new layer to this drawable. The new layer is identified by an id.</remarks>
		/// <param name="layer">The drawable to add as a layer.</param>
		/// <param name="id">The id of the new layer.</param>
		/// <param name="left">The left padding of the new layer.</param>
		/// <param name="top">The top padding of the new layer.</param>
		/// <param name="right">The right padding of the new layer.</param>
		/// <param name="bottom">The bottom padding of the new layer.</param>
		private void addLayer(android.graphics.drawable.Drawable layer, int id, int left, 
			int top, int right, int bottom)
		{
			android.graphics.drawable.LayerDrawable.LayerState st = mLayerState;
			int N = st.mChildren != null ? st.mChildren.Length : 0;
			int i = st.mNum;
			if (i >= N)
			{
				android.graphics.drawable.LayerDrawable.ChildDrawable[] nu = new android.graphics.drawable.LayerDrawable
					.ChildDrawable[N + 10];
				if (i > 0)
				{
					System.Array.Copy(st.mChildren, 0, nu, 0, i);
				}
				st.mChildren = nu;
			}
			mLayerState.mChildrenChangingConfigurations |= layer.getChangingConfigurations();
			android.graphics.drawable.LayerDrawable.ChildDrawable childDrawable = new android.graphics.drawable.LayerDrawable
				.ChildDrawable();
			st.mChildren[i] = childDrawable;
			childDrawable.mId = id;
			childDrawable.mDrawable = layer;
			childDrawable.mInsetL = left;
			childDrawable.mInsetT = top;
			childDrawable.mInsetR = right;
			childDrawable.mInsetB = bottom;
			st.mNum++;
			layer.setCallback(this);
		}