Merge branch 'fix-table-row-colors' of https://github.com/Tryibion/FlaxEngine into Tryibion-fix-table-row-colors
This commit is contained in:
@@ -82,6 +82,53 @@ namespace FlaxEditor.GUI
|
||||
}
|
||||
}
|
||||
|
||||
private bool _alternateRows = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether alternate row background colors should be applied.
|
||||
/// </summary>
|
||||
public bool AlternateRows
|
||||
{
|
||||
get => _alternateRows;
|
||||
set
|
||||
{
|
||||
if (_alternateRows != value)
|
||||
{
|
||||
_alternateRows = value;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color? _rowColorEven;
|
||||
private Color? _rowColorOdd;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background color of even rows.
|
||||
/// </summary>
|
||||
public Color RowColorEven
|
||||
{
|
||||
get => _rowColorEven ?? Color.Transparent;
|
||||
set
|
||||
{
|
||||
_rowColorEven = value;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background color of odd rows.
|
||||
/// </summary>
|
||||
public Color RowColorOdd
|
||||
{
|
||||
get => _rowColorOdd ?? (Style.Current != null ? Style.Current.Background * 1.4f : Color.Transparent);
|
||||
set
|
||||
{
|
||||
_rowColorOdd = value;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Table"/> class.
|
||||
/// </summary>
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user