AdjustWidget() static public method

Adjust the widget's rectangle based on the specified modifier values.
static public AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top ) : void
w UIWidget,
left float
bottom float
right float
top float
return void
Example #1
0
    // Token: 0x060003F7 RID: 1015 RVA: 0x00024208 File Offset: 0x00022408
    public static void ResizeWidget(UIWidget w, UIWidget.Pivot pivot, float x, float y, int minWidth, int minHeight, int maxWidth, int maxHeight)
    {
        if (pivot == UIWidget.Pivot.Center)
        {
            int num  = Mathf.RoundToInt(x - (float)w.width);
            int num2 = Mathf.RoundToInt(y - (float)w.height);
            num  -= (num & 1);
            num2 -= (num2 & 1);
            if ((num | num2) != 0)
            {
                num  >>= 1;
                num2 >>= 1;
                NGUIMath.AdjustWidget(w, (float)(-(float)num), (float)(-(float)num2), (float)num, (float)num2, minWidth, minHeight);
            }
            return;
        }
        Vector3 vector = new Vector3(x, y);

        vector = Quaternion.Inverse(w.cachedTransform.localRotation) * vector;
        switch (pivot)
        {
        case UIWidget.Pivot.TopLeft:
            NGUIMath.AdjustWidget(w, vector.x, 0f, 0f, vector.y, minWidth, minHeight, maxWidth, maxHeight);
            return;

        case UIWidget.Pivot.Top:
            NGUIMath.AdjustWidget(w, 0f, 0f, 0f, vector.y, minWidth, minHeight, maxWidth, maxHeight);
            return;

        case UIWidget.Pivot.TopRight:
            NGUIMath.AdjustWidget(w, 0f, 0f, vector.x, vector.y, minWidth, minHeight, maxWidth, maxHeight);
            return;

        case UIWidget.Pivot.Left:
            NGUIMath.AdjustWidget(w, vector.x, 0f, 0f, 0f, minWidth, minHeight, maxWidth, maxHeight);
            return;

        case UIWidget.Pivot.Center:
            break;

        case UIWidget.Pivot.Right:
            NGUIMath.AdjustWidget(w, 0f, 0f, vector.x, 0f, minWidth, minHeight, maxWidth, maxHeight);
            return;

        case UIWidget.Pivot.BottomLeft:
            NGUIMath.AdjustWidget(w, vector.x, vector.y, 0f, 0f, minWidth, minHeight, maxWidth, maxHeight);
            return;

        case UIWidget.Pivot.Bottom:
            NGUIMath.AdjustWidget(w, 0f, vector.y, 0f, 0f, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.BottomRight:
            NGUIMath.AdjustWidget(w, 0f, vector.y, vector.x, 0f, minWidth, minHeight, maxWidth, maxHeight);
            return;

        default:
            return;
        }
    }
Example #2
0
        public static void AdjustSize(this UIWidget widget, float width, float height, EPPZ.NGUI.SizeConstraintType constraint)
        {
            // Get size difference.
            float widthDifference  = width - widget.width;
            float heightDifference = height - widget.height;

            float leftDifference   = 0.0f;
            float bottomDifference = 0.0f;
            float rightDifference  = 0.0f;
            float topDifference    = 0.0f;

            // Calculate horizontal differences.
            if (constraint == EPPZ.NGUI.SizeConstraintType.Width || constraint == EPPZ.NGUI.SizeConstraintType.Both)
            {
                leftDifference  = -(widget.pivotOffset.x * widthDifference);
                rightDifference = (1.0f - widget.pivotOffset.x) * widthDifference;
            }

            // Calculate vertical differences.
            if (constraint == EPPZ.NGUI.SizeConstraintType.Height || constraint == EPPZ.NGUI.SizeConstraintType.Both)
            {
                bottomDifference = -(widget.pivotOffset.y * heightDifference);
                topDifference    = (1.0f - widget.pivotOffset.y) * heightDifference;
            }

            // Adjust every internal NGUI goodie under the hood (Anchors, Serialization, Colliders, Aspect, etc.).
            NGUIMath.AdjustWidget(widget, leftDifference, bottomDifference, rightDifference, topDifference);
        }
Example #3
0
    public static void ResizeWidget(UIWidget w, UIWidget.Pivot pivot, Single x, Single y, Int32 minWidth, Int32 minHeight, Int32 maxWidth, Int32 maxHeight)
    {
        if (pivot == UIWidget.Pivot.Center)
        {
            Int32 num  = Mathf.RoundToInt(x - (Single)w.width);
            Int32 num2 = Mathf.RoundToInt(y - (Single)w.height);
            num  -= (num & 1);
            num2 -= (num2 & 1);
            if ((num | num2) != 0)
            {
                num  >>= 1;
                num2 >>= 1;
                NGUIMath.AdjustWidget(w, (Single)(-(Single)num), (Single)(-(Single)num2), (Single)num, (Single)num2, minWidth, minHeight);
            }
            return;
        }
        Vector3 point = new Vector3(x, y);

        point = Quaternion.Inverse(w.cachedTransform.localRotation) * point;
        switch (pivot)
        {
        case UIWidget.Pivot.TopLeft:
            NGUIMath.AdjustWidget(w, point.x, 0f, 0f, point.y, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.Top:
            NGUIMath.AdjustWidget(w, 0f, 0f, 0f, point.y, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.TopRight:
            NGUIMath.AdjustWidget(w, 0f, 0f, point.x, point.y, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.Left:
            NGUIMath.AdjustWidget(w, point.x, 0f, 0f, 0f, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.Right:
            NGUIMath.AdjustWidget(w, 0f, 0f, point.x, 0f, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.BottomLeft:
            NGUIMath.AdjustWidget(w, point.x, point.y, 0f, 0f, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.Bottom:
            NGUIMath.AdjustWidget(w, 0f, point.y, 0f, 0f, minWidth, minHeight, maxWidth, maxHeight);
            break;

        case UIWidget.Pivot.BottomRight:
            NGUIMath.AdjustWidget(w, 0f, point.y, point.x, 0f, minWidth, minHeight, maxWidth, maxHeight);
            break;
        }
    }
Example #4
0
 public void forceWidth(int value)
 {
     if (isAnchoredHorizontally)
     {
         if (leftAnchor.target != null && rightAnchor.target != null)
         {
             if (mPivot == Pivot.BottomLeft || mPivot == Pivot.Left || mPivot == Pivot.TopLeft)
             {
                 NGUIMath.AdjustWidget(this, 0f, 0f, value - mWidth, 0f);
             }
             else if (mPivot == Pivot.BottomRight || mPivot == Pivot.Right || mPivot == Pivot.TopRight)
             {
                 NGUIMath.AdjustWidget(this, mWidth - value, 0f, 0f, 0f);
             }
             else
             {
                 int diff = value - mWidth;
                 diff = diff - (diff & 1);
                 if (diff != 0)
                 {
                     NGUIMath.AdjustWidget(this, -diff * 0.5f, 0f, diff * 0.5f, 0f);
                 }
             }
         }
         else if (leftAnchor.target != null)
         {
             NGUIMath.AdjustWidget(this, 0f, 0f, value - mWidth, 0f);
         }
         else
         {
             NGUIMath.AdjustWidget(this, mWidth - value, 0f, 0f, 0f);
         }
     }
     else
     {
         SetDimensions(value, mHeight);
     }
 }
Example #5
0
 public static void AdjustWidget(UIWidget w, float left, float bottom, float right, float top, int minWidth, int minHeight)
 {
     NGUIMath.AdjustWidget(w, left, bottom, right, top, minWidth, minHeight, 100000, 100000);
 }
Example #6
0
 public static void AdjustWidget(UIWidget w, float left, float bottom, float right, float top)
 {
     NGUIMath.AdjustWidget(w, left, bottom, right, top, 2, 2, 100000, 100000);
 }
Example #7
0
 public static void AdjustWidget(UIWidget w, Single left, Single bottom, Single right, Single top, Int32 minWidth, Int32 minHeight)
 {
     NGUIMath.AdjustWidget(w, left, bottom, right, top, minWidth, minHeight, 100000, 100000);
 }
Example #8
0
 public static void AdjustWidget(UIWidget w, Single left, Single bottom, Single right, Single top)
 {
     NGUIMath.AdjustWidget(w, left, bottom, right, top, 2, 2, 100000, 100000);
 }
Example #9
0
 public unsafe static long $Invoke3(long instance, long *args)
 {
     NGUIMath.AdjustWidget((UIWidget)GCHandledObjects.GCHandleToObject(*args), *(float *)(args + 1), *(float *)(args + 2), *(float *)(args + 3), *(float *)(args + 4), *(int *)(args + 5), *(int *)(args + 6), *(int *)(args + 7), *(int *)(args + 8));
     return(-1L);
 }
Example #10
0
 static public int AdjustWidget_s(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 5)
         {
             UIWidget a1;
             checkType(l, 1, out a1);
             System.Single a2;
             checkType(l, 2, out a2);
             System.Single a3;
             checkType(l, 3, out a3);
             System.Single a4;
             checkType(l, 4, out a4);
             System.Single a5;
             checkType(l, 5, out a5);
             NGUIMath.AdjustWidget(a1, a2, a3, a4, a5);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 7)
         {
             UIWidget a1;
             checkType(l, 1, out a1);
             System.Single a2;
             checkType(l, 2, out a2);
             System.Single a3;
             checkType(l, 3, out a3);
             System.Single a4;
             checkType(l, 4, out a4);
             System.Single a5;
             checkType(l, 5, out a5);
             System.Int32 a6;
             checkType(l, 6, out a6);
             System.Int32 a7;
             checkType(l, 7, out a7);
             NGUIMath.AdjustWidget(a1, a2, a3, a4, a5, a6, a7);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 9)
         {
             UIWidget a1;
             checkType(l, 1, out a1);
             System.Single a2;
             checkType(l, 2, out a2);
             System.Single a3;
             checkType(l, 3, out a3);
             System.Single a4;
             checkType(l, 4, out a4);
             System.Single a5;
             checkType(l, 5, out a5);
             System.Int32 a6;
             checkType(l, 6, out a6);
             System.Int32 a7;
             checkType(l, 7, out a7);
             System.Int32 a8;
             checkType(l, 8, out a8);
             System.Int32 a9;
             checkType(l, 9, out a9);
             NGUIMath.AdjustWidget(a1, a2, a3, a4, a5, a6, a7, a8, a9);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }