Skip to content

Commit be4f104

Browse files
committed
Include global indentation while drawing ReorderableLists
1 parent 3f88c46 commit be4f104

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ namespace Toolbox.Editor.Internal
1212
/// </summary>
1313
public class ToolboxEditorList : ReorderableListBase
1414
{
15+
/// <summary>
16+
/// Style used for the vertical layout built around all list controls.
17+
/// </summary>
18+
private static readonly GUIStyle listGroupStyle = new GUIStyle()
19+
{
20+
margin = new RectOffset()
21+
};
22+
1523
private int lastCoveredIndex = -1;
1624

1725
private Rect[] elementsRects;
@@ -207,6 +215,13 @@ private void DrawTargetGap(int targetIndex, int draggingIndex)
207215
EditorGUI.DrawRect(rect, Style.selectionColor);
208216
}
209217

218+
private GUIStyle RequestBodyStyle()
219+
{
220+
var indent = EditorGuiUtility.IndentSize;
221+
listGroupStyle.margin.left = (int)indent;
222+
return listGroupStyle;
223+
}
224+
210225
protected override void DoListMiddle()
211226
{
212227
using (var middleGroup = new EditorGUILayout.VerticalScope())
@@ -357,9 +372,10 @@ protected override void HandleHeaderEvents(Rect rect)
357372
/// <inheritdoc/>
358373
public override void DoList(GUIContent label)
359374
{
375+
var style = RequestBodyStyle();
360376
//pack eveything in one, vertical scope
361377
//it will keep sections always in order
362-
using (new EditorGUILayout.VerticalScope())
378+
using (new EditorGUILayout.VerticalScope(style))
363379
{
364380
base.DoList(label);
365381
}

Assets/Editor Toolbox/Editor/Utilities/EditorGuiUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Toolbox.Editor
1212
/// </summary>
1313
internal static class EditorGuiUtility
1414
{
15-
private const float indentPerLevel = 15.0f;
15+
internal const float indentPerLevel = 15.0f;
1616

1717
private static readonly Dictionary<string, Texture2D> loadedTextures = new Dictionary<string, Texture2D>();
1818

0 commit comments

Comments
 (0)