Merge branch 'table-improve' of https://github.com/Tryibion/FlaxEngine into Tryibion-table-improve
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
|
using FlaxEngine.GUI;
|
||||||
|
|
||||||
namespace FlaxEditor.GUI
|
namespace FlaxEditor.GUI
|
||||||
{
|
{
|
||||||
@@ -43,10 +44,20 @@ namespace FlaxEditor.GUI
|
|||||||
public Color TitleColor = Color.White;
|
public Color TitleColor = Color.White;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The column title background background.
|
/// The column title background color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color TitleBackgroundColor = Color.Brown;
|
public Color TitleBackgroundColor = Color.Brown;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The column title horizontal text alignment
|
||||||
|
/// </summary>
|
||||||
|
public TextAlignment TitleAlignment = TextAlignment.Near;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The column title margin.
|
||||||
|
/// </summary>
|
||||||
|
public Margin TitleMargin = new Margin(4, 4, 0, 0);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimum size (in pixels) of the column.
|
/// The minimum size (in pixels) of the column.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -130,12 +130,14 @@ namespace FlaxEditor.GUI
|
|||||||
|
|
||||||
var style = Style.Current;
|
var style = Style.Current;
|
||||||
var font = column.TitleFont ?? style.FontMedium;
|
var font = column.TitleFont ?? style.FontMedium;
|
||||||
Render2D.DrawText(font, column.Title, rect, column.TitleColor, TextAlignment.Center, TextAlignment.Center);
|
var textRect = rect;
|
||||||
|
column.TitleMargin.ShrinkRectangle(ref textRect);
|
||||||
|
Render2D.DrawText(font, column.Title, textRect, column.TitleColor, column.TitleAlignment, TextAlignment.Center);
|
||||||
|
|
||||||
if (columnIndex < _columns.Length - 1)
|
if (columnIndex < _columns.Length - 1)
|
||||||
{
|
{
|
||||||
var splitRect = new Rectangle(rect.Right - 1, 2, 2, rect.Height - 4);
|
var splitRect = new Rectangle(rect.Right - 2, 2, 4, rect.Height - 4);
|
||||||
Render2D.FillRectangle(splitRect, _movingSplit == columnIndex || splitRect.Contains(_mousePos) ? style.BorderNormal : column.TitleBackgroundColor * 0.9f);
|
Render2D.FillRectangle(splitRect, _movingSplit == columnIndex || splitRect.Contains(_mousePos) ? style.BorderNormal : style.Background * 0.9f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ namespace FlaxEditor.GUI
|
|||||||
{
|
{
|
||||||
rect.Width = GetColumnWidth(i);
|
rect.Width = GetColumnWidth(i);
|
||||||
|
|
||||||
var splitRect = new Rectangle(rect.Right - 1, 2, 2, rect.Height - 4);
|
var splitRect = new Rectangle(rect.Right - 2, 2, 4, rect.Height - 4);
|
||||||
if (splitRect.Contains(location))
|
if (splitRect.Contains(location))
|
||||||
{
|
{
|
||||||
// Start moving splitter
|
// Start moving splitter
|
||||||
@@ -193,6 +195,31 @@ namespace FlaxEditor.GUI
|
|||||||
|
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_columns != null && _splits != null)
|
||||||
|
{
|
||||||
|
Rectangle rect = new Rectangle(0, 0, 0, _headerHeight);
|
||||||
|
for (int i = 0; i < _columns.Length - 1; i++)
|
||||||
|
{
|
||||||
|
rect.Width = GetColumnWidth(i);
|
||||||
|
|
||||||
|
var splitRect = new Rectangle(rect.Right - 2, 2, 4, rect.Height - 4);
|
||||||
|
if (splitRect.Contains(location))
|
||||||
|
{
|
||||||
|
// Start moving splitter
|
||||||
|
Cursor = CursorType.SizeWE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Cursor = CursorType.Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
rect.X += rect.Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
base.OnMouseMove(location);
|
base.OnMouseMove(location);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user