Skip to content

Commit

Permalink
Merge pull request #12 from christo-auer/master
Browse files Browse the repository at this point in the history
Made sortability optional
  • Loading branch information
cfoulston authored Aug 21, 2018
2 parents f1622c6 + b29dcf3 commit b79de15
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ReorderableAttribute : PropertyAttribute {
public bool draggable;
public bool singleLine;
public bool paginate;
public bool sortable;
public int pageSize;
public string elementNameProperty;
public string elementNameOverride;
Expand Down Expand Up @@ -39,9 +40,10 @@ public ReorderableAttribute(bool add, bool remove, bool draggable, string elemen
this.add = add;
this.remove = remove;
this.draggable = draggable;
this.sortable = true;
this.elementNameProperty = elementNameProperty;
this.elementNameOverride = elementNameOverride;
this.elementIconPath = elementIconPath;
}
}
}
}
3 changes: 2 additions & 1 deletion Assets/ReorderableList/List/Editor/ReorderableDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static ReorderableList GetList(SerializedProperty property, ReorderableAt
list = new ReorderableList(array, attrib.add, attrib.remove, attrib.draggable, displayType, attrib.elementNameProperty, attrib.elementNameOverride, icon);
list.paginate = attrib.paginate;
list.pageSize = attrib.pageSize;
list.sortable = attrib.sortable;
}
else {

Expand All @@ -98,4 +99,4 @@ public static ReorderableList GetList(SerializedProperty property, ReorderableAt
return list;
}
}
}
}
28 changes: 15 additions & 13 deletions Assets/ReorderableList/List/Editor/ReorderableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public enum ElementDisplayType {
public bool canAdd;
public bool canRemove;
public bool draggable;
public bool sortable;
public bool expandable;
public bool multipleSelection;
public GUIContent label;
Expand Down Expand Up @@ -632,23 +633,24 @@ private void DrawHeader(Rect rect, GUIContent label) {
}

//draw sorting options
if (sortable) {
Rect sortRect1 = rect;
sortRect1.xMin = rect.xMax - 25;
sortRect1.xMax = rect.xMax;

Rect sortRect1 = rect;
sortRect1.xMin = rect.xMax - 25;
sortRect1.xMax = rect.xMax;
Rect sortRect2 = rect;
sortRect2.xMin = sortRect1.xMin - 20;
sortRect2.xMax = sortRect1.xMin;

Rect sortRect2 = rect;
sortRect2.xMin = sortRect1.xMin - 20;
sortRect2.xMax = sortRect1.xMin;
if (EditorGUI.DropdownButton(sortRect1, Style.sortAscending, FocusType.Passive, Style.preButton)) {

if (EditorGUI.DropdownButton(sortRect1, Style.sortAscending, FocusType.Passive, Style.preButton)) {

SortElements(sortRect1, false);
}
SortElements(sortRect1, false);
}

if (EditorGUI.DropdownButton(sortRect2, Style.sortDescending, FocusType.Passive, Style.preButton)) {
if (EditorGUI.DropdownButton(sortRect2, Style.sortDescending, FocusType.Passive, Style.preButton)) {

SortElements(sortRect2, true);
SortElements(sortRect2, true);
}
}
}

Expand Down Expand Up @@ -2627,4 +2629,4 @@ private static object[] GetParams(ref object[] parameters, int count) {
}
}
}


0 comments on commit b79de15

Please sign in to comment.