Example #1
0
        private float CalcWidth()
        {
            if (FlexibleMenu.s_Styles == null)
            {
                FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
            }
            float b = 0.0f;

            for (int index = 0; index < this.m_ItemProvider.Count(); ++index)
            {
                b = Mathf.Max(FlexibleMenu.s_Styles.menuItem.CalcSize(GUIContent.Temp(this.m_ItemProvider.GetName(index))).x, b);
            }
            return(b + 6f);
        }
Example #2
0
        private float CalcWidth()
        {
            if (FlexibleMenu.s_Styles == null)
            {
                FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
            }
            float num = 0f;

            for (int i = 0; i < this.m_ItemProvider.Count(); i++)
            {
                float x = FlexibleMenu.s_Styles.menuItem.CalcSize(GUIContent.Temp(this.m_ItemProvider.GetName(i))).x;
                num = Mathf.Max(x, num);
            }
            return(num + 6f);
        }
Example #3
0
        public override void OnGUI(Rect rect)
        {
            if (FlexibleMenu.s_Styles == null)
            {
                FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
            }
            Event current  = Event.current;
            Rect  viewRect = new Rect(0f, 0f, 1f, this.CalcSize().y);

            this.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_ScrollPosition, viewRect);
            float num = 0f;

            for (int i = 0; i <= this.maxIndex; i++)
            {
                int  num2  = i + 1000000;
                Rect rect2 = new Rect(0f, num, rect.width, 18f);
                bool flag  = Array.IndexOf <int>(this.m_SeperatorIndices, i) >= 0;
                if (this.m_ShowAddNewPresetItem && i == this.m_ItemProvider.Count())
                {
                    this.CreateNewItemButton(rect2);
                }
                else
                {
                    if (this.m_ShowEditWindowForIndex == i)
                    {
                        this.m_ShowEditWindowForIndex = -1;
                        this.EditExistingItem(rect2, i);
                    }
                    EventType type = current.type;
                    switch (type)
                    {
                    case EventType.MouseDown:
                        if (current.button == 0 && rect2.Contains(current.mousePosition))
                        {
                            GUIUtility.hotControl = num2;
                            if (!this.IsDeleteModiferPressed() && current.clickCount == 1)
                            {
                                GUIUtility.hotControl = 0;
                                this.SelectItem(i);
                                base.editorWindow.Close();
                                current.Use();
                            }
                        }
                        goto IL_389;

                    case EventType.MouseUp:
                        if (GUIUtility.hotControl == num2)
                        {
                            GUIUtility.hotControl = 0;
                            if (current.button == 0 && rect2.Contains(current.mousePosition) && this.AllowDeleteClick(i))
                            {
                                this.DeleteItem(i);
                                current.Use();
                            }
                        }
                        goto IL_389;

                    case EventType.MouseMove:
                        if (rect2.Contains(current.mousePosition))
                        {
                            if (this.m_HoverIndex != i)
                            {
                                this.m_HoverIndex = i;
                                this.Repaint();
                            }
                        }
                        else
                        {
                            if (this.m_HoverIndex == i)
                            {
                                this.m_HoverIndex = -1;
                                this.Repaint();
                            }
                        }
                        goto IL_389;

                    case EventType.MouseDrag:
                    case EventType.KeyDown:
                    case EventType.KeyUp:
                    case EventType.ScrollWheel:
IL_109:
                        if (type != EventType.ContextClick)
                        {
                            goto IL_389;
                        }
                        if (rect2.Contains(current.mousePosition))
                        {
                            current.Use();
                            if (this.m_ModifyItemUI != null && this.m_ItemProvider.IsModificationAllowed(i))
                            {
                                FlexibleMenu.ItemContextMenu.Show(i, this);
                            }
                        }
                        goto IL_389;

                    case EventType.Repaint:
                    {
                        bool isHover = false;
                        if (this.m_HoverIndex == i)
                        {
                            if (rect2.Contains(current.mousePosition))
                            {
                                isHover = true;
                            }
                            else
                            {
                                this.m_HoverIndex = -1;
                            }
                        }
                        if (this.m_ModifyItemUI != null && this.m_ModifyItemUI.IsShowing())
                        {
                            isHover = (this.m_ItemProvider.GetItem(i) == this.m_ModifyItemUI.m_Object);
                        }
                        FlexibleMenu.s_Styles.menuItem.Draw(rect2, GUIContent.Temp(this.m_ItemProvider.GetName(i)), isHover, false, i == this.selectedIndex, false);
                        if (flag)
                        {
                            Rect rect3 = new Rect(rect2.x + 4f, rect2.y + rect2.height + 4f, rect2.width - 8f, 1f);
                            FlexibleMenu.DrawRect(rect3, (!EditorGUIUtility.isProSkin) ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                        }
                        if (this.AllowDeleteClick(i))
                        {
                            EditorGUIUtility.AddCursorRect(rect2, MouseCursor.ArrowMinus);
                        }
                        goto IL_389;
                    }
                    }
                    goto IL_109;
IL_389:
                    num += 18f;
                    if (flag)
                    {
                        num += 8f;
                    }
                }
            }
            GUI.EndScrollView();
        }
Example #4
0
        public override void OnGUI(Rect rect)
        {
            if (FlexibleMenu.s_Styles == null)
            {
                FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
            }
            Event current  = Event.current;
            Rect  viewRect = new Rect(0.0f, 0.0f, 1f, this.CalcSize().y);

            this.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_ScrollPosition, viewRect);
            float y = 0.0f;

            for (int index = 0; index <= this.maxIndex; ++index)
            {
                int  num   = index + 1000000;
                Rect rect1 = new Rect(0.0f, y, rect.width, 18f);
                bool flag  = Array.IndexOf <int>(this.m_SeperatorIndices, index) >= 0;
                if (this.m_ShowAddNewPresetItem && index == this.m_ItemProvider.Count())
                {
                    this.CreateNewItemButton(rect1);
                }
                else
                {
                    if (this.m_ShowEditWindowForIndex == index)
                    {
                        this.m_ShowEditWindowForIndex = -1;
                        this.EditExistingItem(rect1, index);
                    }
                    EventType type = current.type;
                    switch (type)
                    {
                    case EventType.MouseDown:
                        if (current.button == 0 && rect1.Contains(current.mousePosition))
                        {
                            GUIUtility.hotControl = num;
                            if (!this.IsDeleteModiferPressed() && current.clickCount == 1)
                            {
                                GUIUtility.hotControl = 0;
                                this.SelectItem(index);
                                this.editorWindow.Close();
                                current.Use();
                                break;
                            }
                            break;
                        }
                        break;

                    case EventType.MouseUp:
                        if (GUIUtility.hotControl == num)
                        {
                            GUIUtility.hotControl = 0;
                            if (current.button == 0 && rect1.Contains(current.mousePosition) && this.AllowDeleteClick(index))
                            {
                                this.DeleteItem(index);
                                current.Use();
                                break;
                            }
                            break;
                        }
                        break;

                    case EventType.MouseMove:
                        if (rect1.Contains(current.mousePosition))
                        {
                            if (this.m_HoverIndex != index)
                            {
                                this.m_HoverIndex = index;
                                this.Repaint();
                                break;
                            }
                            break;
                        }
                        if (this.m_HoverIndex == index)
                        {
                            this.m_HoverIndex = -1;
                            this.Repaint();
                            break;
                        }
                        break;

                    case EventType.Repaint:
                        bool isHover = false;
                        if (this.m_HoverIndex == index)
                        {
                            if (rect1.Contains(current.mousePosition))
                            {
                                isHover = true;
                            }
                            else
                            {
                                this.m_HoverIndex = -1;
                            }
                        }
                        if (this.m_ModifyItemUI != null && this.m_ModifyItemUI.IsShowing())
                        {
                            isHover = this.m_ItemProvider.GetItem(index) == this.m_ModifyItemUI.m_Object;
                        }
                        FlexibleMenu.s_Styles.menuItem.Draw(rect1, GUIContent.Temp(this.m_ItemProvider.GetName(index)), isHover, false, index == this.selectedIndex, false);
                        if (flag)
                        {
                            FlexibleMenu.DrawRect(new Rect(rect1.x + 4f, (float)((double)rect1.y + (double)rect1.height + 4.0), rect1.width - 8f, 1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                        }
                        if (this.AllowDeleteClick(index))
                        {
                            EditorGUIUtility.AddCursorRect(rect1, MouseCursor.ArrowMinus);
                            break;
                        }
                        break;

                    default:
                        if (type == EventType.ContextClick && rect1.Contains(current.mousePosition))
                        {
                            current.Use();
                            if (this.m_ModifyItemUI != null && this.m_ItemProvider.IsModificationAllowed(index))
                            {
                                FlexibleMenu.ItemContextMenu.Show(index, this);
                                break;
                            }
                            break;
                        }
                        break;
                    }
                    y += 18f;
                    if (flag)
                    {
                        y += 8f;
                    }
                }
            }
            GUI.EndScrollView();
        }
		public override void OnGUI(Rect rect)
		{
			if (FlexibleMenu.s_Styles == null)
			{
				FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
			}
			Event current = Event.current;
			Rect viewRect = new Rect(0f, 0f, 1f, this.CalcSize().y);
			this.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_ScrollPosition, viewRect);
			float num = 0f;
			for (int i = 0; i <= this.maxIndex; i++)
			{
				int num2 = i + 1000000;
				Rect rect2 = new Rect(0f, num, rect.width, 18f);
				bool flag = Array.IndexOf<int>(this.m_SeperatorIndices, i) >= 0;
				if (this.m_ShowAddNewPresetItem && i == this.m_ItemProvider.Count())
				{
					this.CreateNewItemButton(rect2);
				}
				else
				{
					if (this.m_ShowEditWindowForIndex == i)
					{
						this.m_ShowEditWindowForIndex = -1;
						this.EditExistingItem(rect2, i);
					}
					EventType type = current.type;
					switch (type)
					{
					case EventType.MouseDown:
						if (current.button == 0 && rect2.Contains(current.mousePosition))
						{
							GUIUtility.hotControl = num2;
							if (!this.IsDeleteModiferPressed() && current.clickCount == 1)
							{
								GUIUtility.hotControl = 0;
								this.SelectItem(i);
								base.editorWindow.Close();
								current.Use();
							}
						}
						goto IL_389;
					case EventType.MouseUp:
						if (GUIUtility.hotControl == num2)
						{
							GUIUtility.hotControl = 0;
							if (current.button == 0 && rect2.Contains(current.mousePosition) && this.AllowDeleteClick(i))
							{
								this.DeleteItem(i);
								current.Use();
							}
						}
						goto IL_389;
					case EventType.MouseMove:
						if (rect2.Contains(current.mousePosition))
						{
							if (this.m_HoverIndex != i)
							{
								this.m_HoverIndex = i;
								this.Repaint();
							}
						}
						else
						{
							if (this.m_HoverIndex == i)
							{
								this.m_HoverIndex = -1;
								this.Repaint();
							}
						}
						goto IL_389;
					case EventType.MouseDrag:
					case EventType.KeyDown:
					case EventType.KeyUp:
					case EventType.ScrollWheel:
						IL_109:
						if (type != EventType.ContextClick)
						{
							goto IL_389;
						}
						if (rect2.Contains(current.mousePosition))
						{
							current.Use();
							if (this.m_ModifyItemUI != null && this.m_ItemProvider.IsModificationAllowed(i))
							{
								FlexibleMenu.ItemContextMenu.Show(i, this);
							}
						}
						goto IL_389;
					case EventType.Repaint:
					{
						bool isHover = false;
						if (this.m_HoverIndex == i)
						{
							if (rect2.Contains(current.mousePosition))
							{
								isHover = true;
							}
							else
							{
								this.m_HoverIndex = -1;
							}
						}
						if (this.m_ModifyItemUI != null && this.m_ModifyItemUI.IsShowing())
						{
							isHover = (this.m_ItemProvider.GetItem(i) == this.m_ModifyItemUI.m_Object);
						}
						FlexibleMenu.s_Styles.menuItem.Draw(rect2, GUIContent.Temp(this.m_ItemProvider.GetName(i)), isHover, false, i == this.selectedIndex, false);
						if (flag)
						{
							Rect rect3 = new Rect(rect2.x + 4f, rect2.y + rect2.height + 4f, rect2.width - 8f, 1f);
							FlexibleMenu.DrawRect(rect3, (!EditorGUIUtility.isProSkin) ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
						}
						if (this.AllowDeleteClick(i))
						{
							EditorGUIUtility.AddCursorRect(rect2, MouseCursor.ArrowMinus);
						}
						goto IL_389;
					}
					}
					goto IL_109;
					IL_389:
					num += 18f;
					if (flag)
					{
						num += 8f;
					}
				}
			}
			GUI.EndScrollView();
		}
		private float CalcWidth()
		{
			if (FlexibleMenu.s_Styles == null)
			{
				FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
			}
			float num = 0f;
			for (int i = 0; i < this.m_ItemProvider.Count(); i++)
			{
				float x = FlexibleMenu.s_Styles.menuItem.CalcSize(GUIContent.Temp(this.m_ItemProvider.GetName(i))).x;
				num = Mathf.Max(x, num);
			}
			return num + 6f;
		}
 public override void OnGUI(Rect rect)
 {
   if (FlexibleMenu.s_Styles == null)
     FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
   Event current = Event.current;
   Rect viewRect = new Rect(0.0f, 0.0f, 1f, this.CalcSize().y);
   this.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_ScrollPosition, viewRect);
   float y = 0.0f;
   for (int index = 0; index <= this.maxIndex; ++index)
   {
     int num = index + 1000000;
     Rect rect1 = new Rect(0.0f, y, rect.width, 18f);
     bool flag = Array.IndexOf<int>(this.m_SeperatorIndices, index) >= 0;
     if (this.m_ShowAddNewPresetItem && index == this.m_ItemProvider.Count())
     {
       this.CreateNewItemButton(rect1);
     }
     else
     {
       if (this.m_ShowEditWindowForIndex == index)
       {
         this.m_ShowEditWindowForIndex = -1;
         this.EditExistingItem(rect1, index);
       }
       EventType type = current.type;
       switch (type)
       {
         case EventType.MouseDown:
           if (current.button == 0 && rect1.Contains(current.mousePosition))
           {
             GUIUtility.hotControl = num;
             if (!this.IsDeleteModiferPressed() && current.clickCount == 1)
             {
               GUIUtility.hotControl = 0;
               this.SelectItem(index);
               this.editorWindow.Close();
               current.Use();
               break;
             }
             break;
           }
           break;
         case EventType.MouseUp:
           if (GUIUtility.hotControl == num)
           {
             GUIUtility.hotControl = 0;
             if (current.button == 0 && rect1.Contains(current.mousePosition) && this.AllowDeleteClick(index))
             {
               this.DeleteItem(index);
               current.Use();
               break;
             }
             break;
           }
           break;
         case EventType.MouseMove:
           if (rect1.Contains(current.mousePosition))
           {
             if (this.m_HoverIndex != index)
             {
               this.m_HoverIndex = index;
               this.Repaint();
               break;
             }
             break;
           }
           if (this.m_HoverIndex == index)
           {
             this.m_HoverIndex = -1;
             this.Repaint();
             break;
           }
           break;
         case EventType.Repaint:
           bool isHover = false;
           if (this.m_HoverIndex == index)
           {
             if (rect1.Contains(current.mousePosition))
               isHover = true;
             else
               this.m_HoverIndex = -1;
           }
           if (this.m_ModifyItemUI != null && this.m_ModifyItemUI.IsShowing())
             isHover = this.m_ItemProvider.GetItem(index) == this.m_ModifyItemUI.m_Object;
           FlexibleMenu.s_Styles.menuItem.Draw(rect1, GUIContent.Temp(this.m_ItemProvider.GetName(index)), isHover, false, index == this.selectedIndex, false);
           if (flag)
             FlexibleMenu.DrawRect(new Rect(rect1.x + 4f, (float) ((double) rect1.y + (double) rect1.height + 4.0), rect1.width - 8f, 1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
           if (this.AllowDeleteClick(index))
           {
             EditorGUIUtility.AddCursorRect(rect1, MouseCursor.ArrowMinus);
             break;
           }
           break;
         default:
           if (type == EventType.ContextClick && rect1.Contains(current.mousePosition))
           {
             current.Use();
             if (this.m_ModifyItemUI != null && this.m_ItemProvider.IsModificationAllowed(index))
             {
               FlexibleMenu.ItemContextMenu.Show(index, this);
               break;
             }
             break;
           }
           break;
       }
       y += 18f;
       if (flag)
         y += 8f;
     }
   }
   GUI.EndScrollView();
 }
 private float CalcWidth()
 {
   if (FlexibleMenu.s_Styles == null)
     FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
   float b = 0.0f;
   for (int index = 0; index < this.m_ItemProvider.Count(); ++index)
     b = Mathf.Max(FlexibleMenu.s_Styles.menuItem.CalcSize(GUIContent.Temp(this.m_ItemProvider.GetName(index))).x, b);
   return b + 6f;
 }