当前位置: 首页>>代码示例>>C#>>正文


C# IReorderableListAdaptor.DrawItem方法代码示例

本文整理汇总了C#中IReorderableListAdaptor.DrawItem方法的典型用法代码示例。如果您正苦于以下问题:C# IReorderableListAdaptor.DrawItem方法的具体用法?C# IReorderableListAdaptor.DrawItem怎么用?C# IReorderableListAdaptor.DrawItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReorderableListAdaptor的用法示例。


在下文中一共展示了IReorderableListAdaptor.DrawItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawListItem

		private void DrawListItem(EventType eventType, Rect position, IReorderableListAdaptor adaptor, int itemIndex) {
			bool visible = (position.y < _visibleRect.yMax && position.yMax > _visibleRect.y);
			bool draggable = _allowReordering && adaptor.CanDrag(itemIndex);

			Rect itemContentPosition = position;
			itemContentPosition.x = position.x + 2;
			itemContentPosition.y += 1;
			itemContentPosition.width = position.width - 4;
			itemContentPosition.height = position.height - 4;

			// Make space for grab handle?
			if (draggable) {
				itemContentPosition.x += 20;
				itemContentPosition.width -= 20;
			}

			// Make space for element index.
			if (_indexLabelWidth != 0) {
				itemContentPosition.width -= _indexLabelWidth;

				if (eventType == EventType.Repaint && visible)
					s_RightAlignedLabelStyle.Draw(new Rect(itemContentPosition.x, position.y, _indexLabelWidth, position.height - 4), itemIndex + ":", false, false, false, false);

				itemContentPosition.x += _indexLabelWidth;
			}

			// Make space for remove button?
			if (HasRemoveButtons)
				itemContentPosition.width -= 27;

			try {
				s_CurrentItemIndex.Push(itemIndex);
				EditorGUI.BeginChangeCheck();

				if (eventType == EventType.Repaint && visible) {
					// Draw background of list item.
					var backgroundPosition = new Rect(position.x, position.y, position.width, position.height - 1);
					adaptor.DrawItemBackground(backgroundPosition, itemIndex);

					// Draw grab handle?
					if (draggable) {
						var texturePosition = new Rect(position.x + 6, position.y + position.height / 2f - 3, 9, 5);
						GUIHelper.DrawTexture(texturePosition, ReorderableListResources.GetTexture(ReorderableListTexture.GrabHandle));
					}

					// Draw splitter between list items.
					if (itemIndex != 0 && (!_tracking || itemIndex != s_AnchorIndex)) {
						var texturePosition = new Rect(position.x, position.y - 1, position.width, 1);
						GUIHelper.DrawTexture(texturePosition, ReorderableListResources.texItemSplitter);
					}
				}

				// Allow control to be automatically focused.
				if (s_AutoFocusIndex == itemIndex)
					GUI.SetNextControlName("AutoFocus_" + _controlID + "_" + itemIndex);

				// Present actual control.
				adaptor.DrawItem(itemContentPosition, itemIndex);

				if (EditorGUI.EndChangeCheck())
					ReorderableListGUI.IndexOfChangedItem = itemIndex;

				// Draw remove button?
				if (HasRemoveButtons && adaptor.CanRemove(itemIndex)) {
					s_RemoveButtonPosition = position;
					s_RemoveButtonPosition.width = 27;
					s_RemoveButtonPosition.x = itemContentPosition.xMax + 2;
					s_RemoveButtonPosition.height -= 2;

					if (DoRemoveButton(s_RemoveButtonPosition, visible))
						RemoveItem(adaptor, itemIndex);
				}

				// Check for context click?
				if (eventType == EventType.ContextClick && position.Contains(Event.current.mousePosition) && (Flags & ReorderableListFlags.DisableContextMenu) == 0) {
					ShowContextMenu(_controlID, itemIndex, adaptor);
					Event.current.Use();
				}
			}
			finally {
				s_CurrentItemIndex.Pop();
			}
		}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:83,代码来源:ReorderableListControl.cs

示例2: DrawListItem

 private void DrawListItem(EventType eventType, Rect position, IReorderableListAdaptor adaptor, int itemIndex)
 {
     bool flag = position.y < this._visibleRect.yMax && position.yMax > this._visibleRect.y;
     bool flag2 = this._allowReordering && adaptor.CanDrag(itemIndex);
     Rect position2 = position;
     position2.x = position.x + 2f;
     position2.y = position2.y + 1f;
     position2.width = position.width - 4f;
     position2.height = position.height - 4f;
     if (flag2)
     {
         position2.x = position2.x + 20f;
         position2.width = position2.width - 20f;
     }
     if (this._indexLabelWidth != 0f)
     {
         position2.width = position2.width - this._indexLabelWidth;
         if (eventType == EventType.Repaint && flag)
         {
             ReorderableListControl.s_RightAlignedLabelStyle.Draw(new Rect(position2.x, position.y, this._indexLabelWidth, position.height - 4f), itemIndex + ":", false, false, false, false);
         }
         position2.x = position2.x + this._indexLabelWidth;
     }
     if (this.hasRemoveButtons)
     {
         position2.width = position2.width - this.removeButtonStyle.fixedWidth;
     }
     if (eventType == EventType.Repaint && flag)
     {
         if (flag2)
         {
             GUI.DrawTexture(new Rect(position.x + 6f, position.y + position.height / 2f - 3f, 9f, 5f), ReorderableListResources.texGrabHandle);
         }
         if (!this._tracking || itemIndex != ReorderableListControl.s_AnchorIndex)
         {
             GUI.DrawTexture(new Rect(position.x, position.y - 1f, position.width, 1f), ReorderableListResources.texItemSplitter);
         }
     }
     if (ReorderableListControl.s_AutoFocusIndex == itemIndex)
     {
         GUI.SetNextControlName(string.Concat(new object[]
         {
             "AutoFocus_",
             this._controlID,
             "_",
             itemIndex
         }));
     }
     try
     {
         ReorderableListControl.s_CurrentItemIndex.Push(itemIndex);
         EditorGUI.BeginChangeCheck();
         adaptor.DrawItem(position2, itemIndex);
         if (EditorGUI.EndChangeCheck())
         {
             ReorderableListGUI.indexOfChangedItem = itemIndex;
         }
         if (this.hasRemoveButtons && adaptor.CanRemove(itemIndex))
         {
             ReorderableListControl.s_RemoveButtonPosition = position;
             ReorderableListControl.s_RemoveButtonPosition.width = this.removeButtonStyle.fixedWidth;
             ReorderableListControl.s_RemoveButtonPosition.x = position2.xMax + 2f;
             ReorderableListControl.s_RemoveButtonPosition.height = ReorderableListControl.s_RemoveButtonPosition.height - 2f;
             if (this.DoRemoveButton(ReorderableListControl.s_RemoveButtonPosition, flag))
             {
                 this.RemoveItem(adaptor, itemIndex);
             }
         }
         if (eventType == EventType.ContextClick && position.Contains(Event.current.mousePosition) && (this.flags & ReorderableListFlags.DisableContextMenu) == (ReorderableListFlags)0)
         {
             this.ShowContextMenu(this._controlID, itemIndex, adaptor);
             Event.current.Use();
         }
     }
     finally
     {
         ReorderableListControl.s_CurrentItemIndex.Pop();
     }
 }
开发者ID:fuboss,项目名称:aiProject,代码行数:79,代码来源:ReorderableListControl.cs


注:本文中的IReorderableListAdaptor.DrawItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。