本文整理汇总了C#中IReorderableListAdaptor类的典型用法代码示例。如果您正苦于以下问题:C# IReorderableListAdaptor类的具体用法?C# IReorderableListAdaptor怎么用?C# IReorderableListAdaptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IReorderableListAdaptor类属于命名空间,在下文中一共展示了IReorderableListAdaptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ItemRemovingEventArgs
/// <summary>
/// Initializes a new instance of <see cref="ItemRemovingEventArgs"/>.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="itemIndex">Zero-based index of item.</param>
public ItemRemovingEventArgs(IReorderableListAdaptor adaptor, int itemIndex) {
this.Adaptor = adaptor;
this.ItemIndex = itemIndex;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:9,代码来源:ReorderableListControl.cs
示例2: DrawFloatingListItem
private void DrawFloatingListItem(EventType eventType, IReorderableListAdaptor adaptor, float targetSlotPosition) {
if (eventType == EventType.Repaint) {
Color restoreColor = GUI.color;
// Fill background of target area.
Rect targetPosition = s_DragItemPosition;
targetPosition.y = targetSlotPosition - 1;
targetPosition.height = 1;
GUIHelper.DrawTexture(targetPosition, ReorderableListResources.texItemSplitter);
--targetPosition.x;
++targetPosition.y;
targetPosition.width += 2;
targetPosition.height = s_DragItemPosition.height - 1;
GUI.color = TargetBackgroundColor;
GUIHelper.DrawTexture(targetPosition, EditorGUIUtility.whiteTexture);
// Fill background of item which is being dragged.
--s_DragItemPosition.x;
s_DragItemPosition.width += 2;
--s_DragItemPosition.height;
GUI.color = AnchorBackgroundColor;
GUIHelper.DrawTexture(s_DragItemPosition, EditorGUIUtility.whiteTexture);
++s_DragItemPosition.x;
s_DragItemPosition.width -= 2;
++s_DragItemPosition.height;
// Draw horizontal splitter above and below.
GUI.color = new Color(0f, 0f, 0f, 0.6f);
targetPosition.y = s_DragItemPosition.y - 1;
targetPosition.height = 1;
GUIHelper.DrawTexture(targetPosition, EditorGUIUtility.whiteTexture);
targetPosition.y += s_DragItemPosition.height;
GUIHelper.DrawTexture(targetPosition, EditorGUIUtility.whiteTexture);
GUI.color = restoreColor;
}
DrawListItem(eventType, s_DragItemPosition, adaptor, s_AnchorIndex);
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:45,代码来源:ReorderableListControl.cs
示例3: AcceptReorderDrag
/// <summary>
/// Accept reordering.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
private void AcceptReorderDrag(IReorderableListAdaptor adaptor) {
try {
// Reorder list as needed!
s_TargetIndex = Mathf.Clamp(s_TargetIndex, 0, adaptor.Count + 1);
if (s_TargetIndex != s_AnchorIndex && s_TargetIndex != s_AnchorIndex + 1)
MoveItem(adaptor, s_AnchorIndex, s_TargetIndex);
}
finally {
StopTrackingReorderDrag();
}
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:15,代码来源:ReorderableListControl.cs
示例4: PrepareState
/// <summary>
/// Prepare initial state for list control.
/// </summary>
/// <param name="controlID">Unique ID of list control.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
private void PrepareState(int controlID, IReorderableListAdaptor adaptor) {
_controlID = controlID;
_visibleRect = GUIHelper.VisibleRect();
if ((Flags & ReorderableListFlags.ShowIndices) != 0) {
int digitCount = Mathf.Max(2, Mathf.CeilToInt(Mathf.Log10((float)adaptor.Count)));
_indexLabelWidth = digitCount * 8 + 8;
}
else {
_indexLabelWidth = 0;
}
_tracking = IsTrackingControl(controlID);
_allowReordering = (Flags & ReorderableListFlags.DisableReordering) == 0;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:21,代码来源:ReorderableListControl.cs
示例5: AddMenuClickedEventArgs
/// <summary>
/// Initializes a new instance of <see cref="ItemMovedEventArgs"/>.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="buttonPosition">Position of the add menu button.</param>
public AddMenuClickedEventArgs(IReorderableListAdaptor adaptor, Rect buttonPosition) {
this.Adaptor = adaptor;
this.ButtonPosition = buttonPosition;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:9,代码来源:ReorderableListControl.cs
示例6: ClearAll
/// <summary>
/// Remove all items from list.
/// </summary>
/// <remarks>
/// <para>The event <see cref="ItemRemoving"/> is raised for each item prior to
/// clearing array and allows entire operation to be cancelled.</para>
/// </remarks>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <returns>
/// Returns a value of <c>false</c> if operation was cancelled.
/// </returns>
protected bool ClearAll(IReorderableListAdaptor adaptor) {
if (adaptor.Count == 0)
return true;
var args = new ItemRemovingEventArgs(adaptor, 0);
int count = adaptor.Count;
for (int i = 0; i < count; ++i) {
args.ItemIndex = i;
OnItemRemoving(args);
if (args.Cancel)
return false;
}
adaptor.Clear();
GUI.changed = true;
ReorderableListGUI.IndexOfChangedItem = -1;
return true;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:31,代码来源:ReorderableListControl.cs
示例7: DuplicateItem
/// <summary>
/// Duplicate specified item and raises the event <see cref="ItemInserted"/>.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="itemIndex">Zero-based index of item.</param>
protected void DuplicateItem(IReorderableListAdaptor adaptor, int itemIndex) {
adaptor.Duplicate(itemIndex);
AutoFocusItem(s_ContextControlID, itemIndex + 1);
GUI.changed = true;
ReorderableListGUI.IndexOfChangedItem = -1;
var args = new ItemInsertedEventArgs(adaptor, itemIndex + 1, true);
OnItemInserted(args);
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:15,代码来源:ReorderableListControl.cs
示例8: Draw
/// <inheritdoc cref="Draw(Rect, IReorderableListAdaptor, DrawEmptyAbsolute)"/>
public void Draw(Rect position, IReorderableListAdaptor adaptor) {
int controlID = GUIUtility.GetControlID(FocusType.Passive);
Draw(position, controlID, adaptor, null);
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:5,代码来源:ReorderableListControl.cs
示例9: DrawLayoutListField
/// <summary>
/// Do layout version of list field.
/// </summary>
/// <param name="controlID">Unique ID of list control.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <returns>
/// Position of list container area in GUI (excludes footer area).
/// </returns>
private Rect DrawLayoutListField(int controlID, IReorderableListAdaptor adaptor) {
float totalHeight;
// Calculate position of list field using layout engine.
if (Event.current.type == EventType.Layout) {
totalHeight = CalculateListHeight(adaptor);
s_ContainerHeightCache[controlID] = totalHeight;
}
else {
totalHeight = s_ContainerHeightCache.ContainsKey(controlID)
? s_ContainerHeightCache[controlID]
: 0;
}
Rect position = GUILayoutUtility.GetRect(GUIContent.none, ContainerStyle, GUILayout.Height(totalHeight));
// Make room for footer buttons?
if (HasFooterButtons)
position.height -= FooterButtonStyle.fixedHeight;
// Draw list as normal.
DrawListContainerAndItems(position, controlID, adaptor);
CheckForAutoFocusControl(controlID);
return position;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:35,代码来源:ReorderableListControl.cs
示例10: DrawFooterControls
/// <summary>
/// Draw additional controls below list control and highlight drop target.
/// </summary>
/// <param name="position">Position of list control in GUI.</param>
/// <param name="controlID">Unique ID of list control.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
private void DrawFooterControls(Rect position, int controlID, IReorderableListAdaptor adaptor) {
if (HasFooterButtons) {
Rect buttonPosition = new Rect(position.xMax - 30, position.yMax - 1, 30, FooterButtonStyle.fixedHeight);
Rect menuButtonPosition = buttonPosition;
var menuIconNormal = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_AddMenu_Normal);
var menuIconActive = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_AddMenu_Active);
if (HasAddButton) {
// Draw add menu drop-down button.
if (HasAddMenuButton) {
menuButtonPosition.x = buttonPosition.xMax - 14;
menuButtonPosition.xMax = buttonPosition.xMax;
menuIconNormal = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_Menu_Normal);
menuIconActive = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_Menu_Active);
buttonPosition.width -= 5;
buttonPosition.x = menuButtonPosition.x - buttonPosition.width + 1;
}
// Draw add item button.
var iconNormal = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_Add_Normal);
var iconActive = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_Add_Active);
if (GUIHelper.IconButton(buttonPosition, true, iconNormal, iconActive, FooterButtonStyle)) {
// Append item to list.
GUIUtility.keyboardControl = 0;
AddItem(adaptor);
}
}
if (HasAddMenuButton) {
// Draw add menu drop-down button.
if (GUIHelper.IconButton(menuButtonPosition, true, menuIconNormal, menuIconActive, FooterButtonStyle)) {
GUIUtility.keyboardControl = 0;
Rect totalAddButtonPosition = buttonPosition;
totalAddButtonPosition.xMax = position.xMax;
OnAddMenuClicked(new AddMenuClickedEventArgs(adaptor, totalAddButtonPosition));
// This will be helpful in many circumstances; including by default!
GUIUtility.ExitGUI();
}
}
}
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:50,代码来源:ReorderableListControl.cs
示例11: MoveItem
/// <summary>
/// Move item from source index to destination index.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="sourceIndex">Zero-based index of source item.</param>
/// <param name="destIndex">Zero-based index of destination index.</param>
protected void MoveItem(IReorderableListAdaptor adaptor, int sourceIndex, int destIndex) {
// Raise event before moving item so that the operation can be cancelled.
var movingEventArgs = new ItemMovingEventArgs(adaptor, sourceIndex, destIndex);
OnItemMoving(movingEventArgs);
if (!movingEventArgs.Cancel) {
adaptor.Move(sourceIndex, destIndex);
// Item was actually moved!
int newIndex = destIndex;
if (newIndex > sourceIndex)
--newIndex;
OnItemMoved(new ItemMovedEventArgs(adaptor, sourceIndex, newIndex));
GUI.changed = true;
}
ReorderableListGUI.IndexOfChangedItem = -1;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:23,代码来源:ReorderableListControl.cs
示例12: AddItem
/// <summary>
/// Add item at end of list and raises the event <see cref="ItemInserted"/>.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
protected void AddItem(IReorderableListAdaptor adaptor) {
adaptor.Add();
AutoFocusItem(s_ContextControlID, adaptor.Count - 1);
GUI.changed = true;
ReorderableListGUI.IndexOfChangedItem = -1;
var args = new ItemInsertedEventArgs(adaptor, adaptor.Count - 1, false);
OnItemInserted(args);
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:14,代码来源:ReorderableListControl.cs
示例13: ShowContextMenu
private void ShowContextMenu(int controlID, int itemIndex, IReorderableListAdaptor adaptor) {
GenericMenu menu = new GenericMenu();
s_ContextControlID = controlID;
s_ContextItemIndex = itemIndex;
AddItemsToMenu(menu, itemIndex, adaptor);
if (menu.GetItemCount() > 0)
menu.ShowAsContext();
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:11,代码来源:ReorderableListControl.cs
示例14: RemoveItem
/// <summary>
/// Remove specified item.
/// </summary>
/// <remarks>
/// <para>The event <see cref="ItemRemoving"/> is raised prior to removing item
/// and allows removal to be cancelled.</para>
/// </remarks>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="itemIndex">Zero-based index of item.</param>
/// <returns>
/// Returns a value of <c>false</c> if operation was cancelled.
/// </returns>
protected bool RemoveItem(IReorderableListAdaptor adaptor, int itemIndex) {
var args = new ItemRemovingEventArgs(adaptor, itemIndex);
OnItemRemoving(args);
if (args.Cancel)
return false;
adaptor.Remove(itemIndex);
GUI.changed = true;
ReorderableListGUI.IndexOfChangedItem = -1;
return true;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:25,代码来源:ReorderableListControl.cs
示例15: AddItemsToMenu
/// <summary>
/// Invoked to generate context menu for list item.
/// </summary>
/// <param name="menu">Menu which can be populated.</param>
/// <param name="itemIndex">Zero-based index of item which was right-clicked.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
protected virtual void AddItemsToMenu(GenericMenu menu, int itemIndex, IReorderableListAdaptor adaptor) {
if ((Flags & ReorderableListFlags.DisableReordering) == 0) {
if (itemIndex > 0)
menu.AddItem(CommandMoveToTop, false, DefaultContextHandler, CommandMoveToTop);
else
menu.AddDisabledItem(CommandMoveToTop);
if (itemIndex + 1 < adaptor.Count)
menu.AddItem(CommandMoveToBottom, false, DefaultContextHandler, CommandMoveToBottom);
else
menu.AddDisabledItem(CommandMoveToBottom);
if (HasAddButton) {
menu.AddSeparator("");
menu.AddItem(CommandInsertAbove, false, DefaultContextHandler, CommandInsertAbove);
menu.AddItem(CommandInsertBelow, false, DefaultContextHandler, CommandInsertBelow);
if ((Flags & ReorderableListFlags.DisableDuplicateCommand) == 0)
menu.AddItem(CommandDuplicate, false, DefaultContextHandler, CommandDuplicate);
}
}
if (HasRemoveButtons) {
if (menu.GetItemCount() > 0)
menu.AddSeparator("");
menu.AddItem(CommandRemove, false, DefaultContextHandler, CommandRemove);
menu.AddSeparator("");
menu.AddItem(CommandClearAll, false, DefaultContextHandler, CommandClearAll);
}
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:38,代码来源:ReorderableListControl.cs
示例16: ItemMovedEventArgs
/// <summary>
/// Initializes a new instance of <see cref="ItemMovedEventArgs"/>.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="oldItemIndex">Old zero-based index of item.</param>
/// <param name="newItemIndex">New zero-based index of item.</param>
public ItemMovedEventArgs(IReorderableListAdaptor adaptor, int oldItemIndex, int newItemIndex) {
this.Adaptor = adaptor;
this.OldItemIndex = oldItemIndex;
this.NewItemIndex = newItemIndex;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:11,代码来源:ReorderableListControl.cs
示例17: HandleCommand
/// <summary>
/// Invoked to handle context command.
/// </summary>
/// <remarks>
/// <para>It is important to set the value of <c>GUI.changed</c> to <c>true</c> if any
/// changes are made by command handler.</para>
/// <para>Default command handling functionality can be inherited:</para>
/// <code language="csharp"><![CDATA[
/// protected override bool HandleCommand(string commandName, int itemIndex, IReorderableListAdaptor adaptor) {
/// if (base.HandleCommand(itemIndex, adaptor))
/// return true;
///
/// // Place custom command handling code here...
/// switch (commandName) {
/// case "Your Command":
/// return true;
/// }
///
/// return false;
/// }
/// ]]></code>
/// <code language="unityscript"><![CDATA[
/// function HandleCommand(commandName:String, itemIndex:int, adaptor:IReorderableListAdaptor):boolean {
/// if (base.HandleCommand(itemIndex, adaptor))
/// return true;
///
/// // Place custom command handling code here...
/// switch (commandName) {
/// case 'Your Command':
/// return true;
/// }
///
/// return false;
/// }
/// ]]></code>
/// </remarks>
/// <param name="commandName">Name of command. This is the text shown in the context menu.</param>
/// <param name="itemIndex">Zero-based index of item which was right-clicked.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <returns>
/// A value of <c>true</c> if command was known; otherwise <c>false</c>.
/// </returns>
protected virtual bool HandleCommand(string commandName, int itemIndex, IReorderableListAdaptor adaptor) {
switch (commandName) {
case "Move to Top":
MoveItem(adaptor, itemIndex, 0);
return true;
case "Move to Bottom":
MoveItem(adaptor, itemIndex, adaptor.Count);
return true;
case "Insert Above":
InsertItem(adaptor, itemIndex);
return true;
case "Insert Below":
InsertItem(adaptor, itemIndex + 1);
return true;
case "Duplicate":
DuplicateItem(adaptor, itemIndex);
return true;
case "Remove":
RemoveItem(adaptor, itemIndex);
return true;
case "Clear All":
ClearAll(adaptor);
return true;
default:
return false;
}
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:72,代码来源:ReorderableListControl.cs
示例18: DrawControlFromState
/// <summary>
/// Generate and draw control from state object.
/// </summary>
/// <param name="position">Position of control.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="drawEmpty">Delegate for drawing empty list.</param>
/// <param name="flags">Optional flags to pass into list field.</param>
public static void DrawControlFromState(Rect position, IReorderableListAdaptor adaptor, DrawEmptyAbsolute drawEmpty, ReorderableListFlags flags) {
int controlID = GUIUtility.GetControlID(FocusType.Passive);
var control = GUIUtility.GetStateObject(typeof(ReorderableListControl), controlID) as ReorderableListControl;
control.Flags = flags;
control.Draw(position, controlID, adaptor, drawEmpty);
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:14,代码来源:ReorderableListControl.cs
示例19: DoCommand
/// <summary>
/// Call to manually perform command.
/// </summary>
/// <remarks>
/// <para>Warning message is logged to console if attempted to execute unknown command.</para>
/// </remarks>
/// <param name="commandName">Name of command. This is the text shown in the context menu.</param>
/// <param name="itemIndex">Zero-based index of item which was right-clicked.</param>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <returns>
/// A value of <c>true</c> if command was known; otherwise <c>false</c>.
/// </returns>
public bool DoCommand(string commandName, int itemIndex, IReorderableListAdaptor adaptor) {
if (!HandleCommand(s_ContextCommandName, itemIndex, adaptor)) {
Debug.LogWarning("Unknown context command.");
return false;
}
return true;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:19,代码来源:ReorderableListControl.cs
示例20: ItemInsertedEventArgs
/// <summary>
/// Initializes a new instance of <see cref="ItemInsertedEventArgs"/>.
/// </summary>
/// <param name="adaptor">Reorderable list adaptor.</param>
/// <param name="itemIndex">Zero-based index of item.</param>
/// <param name="wasDuplicated">Indicates if inserted item was duplicated from another item.</param>
public ItemInsertedEventArgs(IReorderableListAdaptor adaptor, int itemIndex, bool wasDuplicated) {
this.Adaptor = adaptor;
this.ItemIndex = itemIndex;
this.WasDuplicated = wasDuplicated;
}
开发者ID:mhfirdausi,项目名称:VGDSix,代码行数:11,代码来源:ReorderableListControl.cs
注:本文中的IReorderableListAdaptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论