Skip to content

Commit 2e71dd0

Browse files
committed
Add alternating background on TableList
1 parent 0711f8a commit 2e71dd0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Editor.Extras/Drawers/TableListDrawer.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ private class TableMultiColumnTreeView : TreeView
183183
private readonly TriElement _cellElementContainer;
184184
private readonly ReorderableList _listGui;
185185
private readonly TableListPropertyOverrideContext _propertyOverrideContext;
186+
private readonly bool _showAlternatingBackground;
186187

187188
private bool _wasRendered;
188189

@@ -191,9 +192,12 @@ private class TableMultiColumnTreeView : TreeView
191192
public TableMultiColumnTreeView(TriProperty property, TriElement container, ReorderableList listGui)
192193
: base(new TreeViewState(), new TableColumnHeader())
193194
{
195+
property.TryGetAttribute(out ListDrawerSettingsAttribute listSettings);
196+
194197
_property = property;
195198
_cellElementContainer = container;
196199
_listGui = listGui;
200+
_showAlternatingBackground = listSettings?.ShowAlternatingBackground ?? true;
197201
_propertyOverrideContext = new TableListPropertyOverrideContext(property);
198202

199203
showAlternatingRowBackgrounds = true;
@@ -302,7 +306,12 @@ protected override void RowGUI(RowGUIArgs args)
302306
base.RowGUI(args);
303307
return;
304308
}
305-
309+
310+
if (_showAlternatingBackground && args.row % 2 != 0)
311+
{
312+
EditorGUI.DrawRect(args.rowRect, new Color(0.1f, 0.1f, 0.1f, 0.15f));
313+
}
314+
306315
var rowElement = (TableRowElement) _cellElementContainer.GetChild(args.row);
307316

308317
for (var i = 0; i < multiColumnHeader.state.visibleColumns.Length; i++)

0 commit comments

Comments
 (0)