Merge remote-tracking branch 'upstream/master'

This commit is contained in:
ExMatics HydrogenC
2023-12-19 12:33:13 +08:00
183 changed files with 6019 additions and 3547 deletions

View File

@@ -98,8 +98,8 @@ namespace FlaxEngine.GUI
private float _scale = 1.0f;
private float _scaleFactor = 1.0f;
private float _physicalUnitSize = 1.0f;
private Float2 _resolutionMin = new Float2(1, 1);
private Float2 _resolutionMax = new Float2(10000, 10000);
private Float2 _resolutionMin = new Float2(640, 480);
private Float2 _resolutionMax = new Float2(7680, 4320);
/// <summary>
/// Gets the current UI scale. Computed based on the setup when performing layout.

View File

@@ -469,7 +469,13 @@ namespace FlaxEngine.GUI
var itemsHeight = 20.0f;
var itemsMargin = 20.0f;
// Scale height and margive with text height if needed
var textHeight = Font.GetFont().Height;
if (textHeight > itemsHeight)
{
itemsHeight = textHeight;
itemsMargin = textHeight;
}
/*
var itemsWidth = 40.0f;
var font = Font.GetFont();

View File

@@ -448,6 +448,8 @@ namespace FlaxEngine.GUI
internal virtual void AddChildInternal(Control child)
{
Assert.IsNotNull(child, "Invalid control.");
if (Parent == child)
throw new InvalidOperationException();
// Add child
_children.Add(child);
@@ -820,13 +822,14 @@ namespace FlaxEngine.GUI
protected virtual void DrawChildren()
{
// Draw all visible child controls
var children = _children;
if (_cullChildren)
{
Render2D.PeekClip(out var globalClipping);
Render2D.PeekTransform(out var globalTransform);
for (int i = 0; i < _children.Count; i++)
for (int i = 0; i < children.Count; i++)
{
var child = _children[i];
var child = children[i];
if (child.Visible)
{
Matrix3x3.Multiply(ref child._cachedTransform, ref globalTransform, out var globalChildTransform);
@@ -842,9 +845,9 @@ namespace FlaxEngine.GUI
}
else
{
for (int i = 0; i < _children.Count; i++)
for (int i = 0; i < children.Count; i++)
{
var child = _children[i];
var child = children[i];
if (child.Visible)
{
Render2D.PushTransform(ref child._cachedTransform);

View File

@@ -207,19 +207,20 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override void Update(float deltaTime)
{
// Move window with mouse location
var mousePos = Input.MouseScreenPosition;
WrapPosition(ref mousePos, 10);
if (_window)
_window.Position = mousePos + new Float2(15, 10);
// Auto hide if mouse leaves control area
var location = _showTarget.PointFromScreen(mousePos);
if (!_showTarget.OnTestTooltipOverControl(ref location))
{
// Mouse left or sth
// Auto hide if mouse leaves control area
Hide();
}
else
{
// Position tooltip when mouse moves
WrapPosition(ref mousePos, 10);
if (_window)
_window.Position = mousePos + new Float2(15, 10);
}
base.Update(deltaTime);
}