diff --git a/Source/Editor/GUI/Table.cs b/Source/Editor/GUI/Table.cs
index 71b01aa0f..bcb4dd163 100644
--- a/Source/Editor/GUI/Table.cs
+++ b/Source/Editor/GUI/Table.cs
@@ -82,6 +82,53 @@ namespace FlaxEditor.GUI
}
}
+ private bool _alternateRows = true;
+
+ ///
+ /// Gets or sets a value indicating whether alternate row background colors should be applied.
+ ///
+ public bool AlternateRows
+ {
+ get => _alternateRows;
+ set
+ {
+ if (_alternateRows != value)
+ {
+ _alternateRows = value;
+ PerformLayout();
+ }
+ }
+ }
+
+ private Color? _rowColorEven;
+ private Color? _rowColorOdd;
+
+ ///
+ /// Gets or sets the background color of even rows.
+ ///
+ public Color RowColorEven
+ {
+ get => _rowColorEven ?? Color.Transparent;
+ set
+ {
+ _rowColorEven = value;
+ PerformLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets the background color of odd rows.
+ ///
+ public Color RowColorOdd
+ {
+ get => _rowColorOdd ?? (Style.Current != null ? Style.Current.Background * 1.4f : Color.Transparent);
+ set
+ {
+ _rowColorOdd = value;
+ PerformLayout();
+ }
+ }
+
///
/// Initializes a new instance of the class.
///
@@ -250,6 +297,7 @@ namespace FlaxEditor.GUI
// Arrange rows
float y = _headerHeight;
+ int visibleRowIndex = 0;
for (int i = 0; i < Children.Count; i++)
{
var c = Children[i];
@@ -260,6 +308,12 @@ namespace FlaxEditor.GUI
bounds.Y = y;
c.Bounds = bounds;
y += bounds.Height + 1;
+
+ if (_alternateRows && c is Row row)
+ {
+ row.BackgroundColor = visibleRowIndex % 2 == 1 ? RowColorOdd : RowColorEven;
+ visibleRowIndex++;
+ }
}
}
diff --git a/Source/Editor/Windows/Profiler/Assets.cs b/Source/Editor/Windows/Profiler/Assets.cs
index e4e41c668..8ee6f5f6d 100644
--- a/Source/Editor/Windows/Profiler/Assets.cs
+++ b/Source/Editor/Windows/Profiler/Assets.cs
@@ -80,6 +80,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -242,8 +244,6 @@ namespace FlaxEditor.Windows.Profiler
var resourcesOrdered = resources.OrderByDescending(x => x.MemoryUsage);
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
- int rowIndex = 0;
foreach (var e in resourcesOrdered)
{
ClickableRow row;
@@ -271,9 +271,7 @@ namespace FlaxEditor.Windows.Profiler
// Add row to the table
row.Width = _table.Width;
- row.BackgroundColor = rowIndex % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
- rowIndex++;
}
}
diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs
index d034a058b..fad7c4de8 100644
--- a/Source/Editor/Windows/Profiler/CPU.cs
+++ b/Source/Editor/Windows/Profiler/CPU.cs
@@ -106,6 +106,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -464,7 +466,6 @@ namespace FlaxEditor.Windows.Profiler
float totalTimeMs = _mainChart.SelectedSample;
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
for (int j = 0; j < data.Length; j++)
{
var events = data[j].Events;
@@ -540,7 +541,6 @@ namespace FlaxEditor.Windows.Profiler
row.Depth = e.Depth;
row.Width = _table.Width;
row.Visible = e.Depth < 2;
- row.BackgroundColor = i % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
}
}
diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs
index 5cc9cd681..6abfef5e1 100644
--- a/Source/Editor/Windows/Profiler/GPU.cs
+++ b/Source/Editor/Windows/Profiler/GPU.cs
@@ -83,6 +83,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -339,7 +341,6 @@ namespace FlaxEditor.Windows.Profiler
float totalTimeMs = _drawTimeGPU.SelectedSample;
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
for (int i = 0; i < data.Length; i++)
{
var e = data[i];
@@ -386,7 +387,6 @@ namespace FlaxEditor.Windows.Profiler
row.Depth = e.Depth;
row.Width = _table.Width;
row.Visible = e.Depth < 3;
- row.BackgroundColor = i % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
}
}
diff --git a/Source/Editor/Windows/Profiler/Memory.cs b/Source/Editor/Windows/Profiler/Memory.cs
index a74472a8c..56178acf2 100644
--- a/Source/Editor/Windows/Profiler/Memory.cs
+++ b/Source/Editor/Windows/Profiler/Memory.cs
@@ -84,6 +84,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -236,7 +238,6 @@ namespace FlaxEditor.Windows.Profiler
});
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
for (int i = 0; i < (int)ProfilerMemory.Groups.MAX; i++)
{
var group = _groupOrder[i];
@@ -278,7 +279,6 @@ namespace FlaxEditor.Windows.Profiler
row.BackgroundColors[3] = Color.Red.AlphaMultiplied(Mathf.Min(1, (float)groupCount / totalCount) * 0.5f);
}
row.Width = _table.Width;
- row.BackgroundColor = i % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
var useBackground = group != (int)ProfilerMemory.Groups.Total &&
diff --git a/Source/Editor/Windows/Profiler/MemoryGPU.cs b/Source/Editor/Windows/Profiler/MemoryGPU.cs
index 11b8a1980..76c02888b 100644
--- a/Source/Editor/Windows/Profiler/MemoryGPU.cs
+++ b/Source/Editor/Windows/Profiler/MemoryGPU.cs
@@ -81,6 +81,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -299,8 +301,6 @@ namespace FlaxEditor.Windows.Profiler
var resourcesOrdered = resources.OrderByDescending(x => x?.MemoryUsage ?? 0);
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
- int rowIndex = 0;
foreach (var e in resourcesOrdered)
{
if (e == null)
@@ -335,9 +335,7 @@ namespace FlaxEditor.Windows.Profiler
// Add row to the table
row.Width = _table.Width;
- row.BackgroundColor = rowIndex % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
- rowIndex++;
}
}
diff --git a/Source/Editor/Windows/Profiler/Network.cs b/Source/Editor/Windows/Profiler/Network.cs
index 988398b0c..2a2d542f5 100644
--- a/Source/Editor/Windows/Profiler/Network.cs
+++ b/Source/Editor/Windows/Profiler/Network.cs
@@ -190,7 +190,6 @@ namespace FlaxEditor.Windows.Profiler
var rowCount = Int2.Zero;
if (events != null && events.Length != 0)
{
- var rowColor2 = Style.Current.Background * 1.4f;
for (int i = 0; i < events.Length; i++)
{
var e = events[i];
@@ -230,7 +229,6 @@ namespace FlaxEditor.Windows.Profiler
var table = isRpc ? _tableRpc : _tableRep;
row.Width = table.Width;
- row.BackgroundColor = rowCount[isRpc ? 0 : 1] % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = table;
if (isRpc)
rowCount.X++;
@@ -266,6 +264,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
var table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition