Refactor engine to support double-precision vectors
This commit is contained in:
@@ -34,7 +34,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
base.DrawSelf();
|
||||
|
||||
Render2D.DrawRectangle(new Rectangle(Vector2.Zero, Size), BorderColor, BorderWidth);
|
||||
Render2D.DrawRectangle(new Rectangle(Float2.Zero, Size), BorderColor, BorderWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace FlaxEngine.GUI
|
||||
/// </summary>
|
||||
/// <param name="location">Position</param>
|
||||
/// <param name="size">Size</param>
|
||||
public Button(Vector2 location, Vector2 size)
|
||||
public Button(Float2 location, Float2 size)
|
||||
: this(location.X, location.Y, size.X, size.Y)
|
||||
{
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace FlaxEngine.GUI
|
||||
public override void DrawSelf()
|
||||
{
|
||||
// Cache data
|
||||
Rectangle clientRect = new Rectangle(Vector2.Zero, Size);
|
||||
Rectangle clientRect = new Rectangle(Float2.Zero, Size);
|
||||
bool enabled = EnabledInHierarchy;
|
||||
Color backgroundColor = BackgroundColor;
|
||||
Color borderColor = BorderColor;
|
||||
@@ -244,7 +244,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
@@ -258,7 +258,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
@@ -273,7 +273,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchDown(Vector2 location, int pointerId)
|
||||
public override bool OnTouchDown(Float2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchDown(location, pointerId))
|
||||
return true;
|
||||
@@ -287,7 +287,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchUp(Vector2 location, int pointerId)
|
||||
public override bool OnTouchUp(Float2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchUp(location, pointerId))
|
||||
return true;
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
base.OnMouseMove(location);
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && !_isPressed)
|
||||
{
|
||||
@@ -262,7 +262,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _isPressed)
|
||||
{
|
||||
@@ -288,7 +288,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchDown(Vector2 location, int pointerId)
|
||||
public override bool OnTouchDown(Float2 location, int pointerId)
|
||||
{
|
||||
if (!_isPressed)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchUp(Vector2 location, int pointerId)
|
||||
public override bool OnTouchUp(Float2 location, int pointerId)
|
||||
{
|
||||
if (_isPressed)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Control OnNavigate(NavDirection direction, Vector2 location, Control caller, List<Control> visited)
|
||||
public override Control OnNavigate(NavDirection direction, Float2 location, Control caller, List<Control> visited)
|
||||
{
|
||||
if (IsFocused)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
public Action<Label> ItemClicked;
|
||||
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
@@ -99,7 +99,7 @@ namespace FlaxEngine.GUI
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnTouchDown(Vector2 location, int pointerId)
|
||||
public override bool OnTouchDown(Float2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchDown(location, pointerId))
|
||||
return true;
|
||||
@@ -410,7 +410,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
AutoFocus = true,
|
||||
X = itemsMargin,
|
||||
Size = new Vector2(itemsWidth - itemsMargin, itemsHeight),
|
||||
Size = new Float2(itemsWidth - itemsMargin, itemsHeight),
|
||||
Font = Font,
|
||||
TextColor = Color.White * 0.9f,
|
||||
TextColorHighlighted = Color.White,
|
||||
@@ -433,7 +433,7 @@ namespace FlaxEngine.GUI
|
||||
var icon = new Image
|
||||
{
|
||||
Brush = CheckedImage,
|
||||
Size = new Vector2(itemsMargin, itemsHeight),
|
||||
Size = new Float2(itemsMargin, itemsHeight),
|
||||
Margin = new Margin(4.0f, 6.0f, 4.0f, 4.0f),
|
||||
//AnchorPreset = AnchorPresets.VerticalStretchLeft,
|
||||
Parent = item,
|
||||
@@ -441,7 +441,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
popup.Size = new Vector2(itemsWidth, height);
|
||||
popup.Size = new Float2(itemsWidth, height);
|
||||
|
||||
return popup;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ namespace FlaxEngine.GUI
|
||||
_popup.LostFocus += DestroyPopup;
|
||||
|
||||
// Show dropdown popup
|
||||
Vector2 locationRootSpace = Location + new Vector2(0, Height);
|
||||
var locationRootSpace = Location + new Float2(0, Height);
|
||||
var parent = Parent;
|
||||
while (parent != null && parent != Root)
|
||||
{
|
||||
@@ -528,7 +528,7 @@ namespace FlaxEngine.GUI
|
||||
public override void DrawSelf()
|
||||
{
|
||||
// Cache data
|
||||
var clientRect = new Rectangle(Vector2.Zero, Size);
|
||||
var clientRect = new Rectangle(Float2.Zero, Size);
|
||||
float margin = clientRect.Height * 0.2f;
|
||||
float boxSize = clientRect.Height - margin * 2;
|
||||
bool isOpened = IsPopupOpened;
|
||||
@@ -590,7 +590,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
@@ -605,7 +605,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
@@ -620,7 +620,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchDown(Vector2 location, int pointerId)
|
||||
public override bool OnTouchDown(Float2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchDown(location, pointerId))
|
||||
return true;
|
||||
@@ -630,7 +630,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchUp(Vector2 location, int pointerId)
|
||||
public override bool OnTouchUp(Float2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchUp(location, pointerId))
|
||||
return true;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Image(Vector2 location, Vector2 size)
|
||||
public Image(Float2 location, Float2 size)
|
||||
: base(location, size)
|
||||
{
|
||||
AutoFocus = false;
|
||||
@@ -109,7 +109,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = new Rectangle(Vector2.Zero, Size);
|
||||
rect = new Rectangle(Float2.Zero, Size);
|
||||
}
|
||||
|
||||
Margin.ShrinkRectangle(ref rect);
|
||||
@@ -121,7 +121,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace FlaxEngine.GUI
|
||||
private bool _autoWidth;
|
||||
private bool _autoHeight;
|
||||
private bool _autoFitText;
|
||||
private Vector2 _textSize;
|
||||
private Vector2 _autoFitTextRange = new Vector2(0.1f, 100.0f);
|
||||
private Float2 _textSize;
|
||||
private Float2 _autoFitTextRange = new Float2(0.1f, 100.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The font.
|
||||
@@ -38,7 +38,7 @@ namespace FlaxEngine.GUI
|
||||
if (_text != value)
|
||||
{
|
||||
_text = value;
|
||||
_textSize = Vector2.Zero;
|
||||
_textSize = Float2.Zero;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace FlaxEngine.GUI
|
||||
|
||||
if (_autoWidth || _autoHeight || _autoFitText)
|
||||
{
|
||||
_textSize = Vector2.Zero;
|
||||
_textSize = Float2.Zero;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
@@ -169,8 +169,8 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the text scale range (min and max) for automatic fit text option. Can be used to constraint the text scale adjustment.
|
||||
/// </summary>
|
||||
[VisibleIf(nameof(AutoFitText))]
|
||||
[EditorOrder(110), DefaultValue(typeof(Vector2), "0.1, 100"), Tooltip("The text scale range (min and max) for automatic fit text option. Can be used to constraint the text scale adjustment.")]
|
||||
public Vector2 AutoFitTextRange
|
||||
[EditorOrder(110), DefaultValue(typeof(Float2), "0.1, 100"), Tooltip("The text scale range (min and max) for automatic fit text option. Can be used to constraint the text scale adjustment.")]
|
||||
public Float2 AutoFitTextRange
|
||||
{
|
||||
get => _autoFitTextRange;
|
||||
set => _autoFitTextRange = value;
|
||||
@@ -205,10 +205,10 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
base.Draw();
|
||||
|
||||
var rect = new Rectangle(new Vector2(Margin.Left, Margin.Top), Size - Margin.Size);
|
||||
var rect = new Rectangle(new Float2(Margin.Left, Margin.Top), Size - Margin.Size);
|
||||
|
||||
if (ClipText)
|
||||
Render2D.PushClip(new Rectangle(Vector2.Zero, Size));
|
||||
Render2D.PushClip(new Rectangle(Float2.Zero, Size));
|
||||
|
||||
var color = IsMouseOver || IsNavFocused ? TextColorHighlighted : TextColor;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace FlaxEngine.GUI
|
||||
private bool _invalid, _redrawRegistered, _isDuringTextureDraw;
|
||||
private bool _autoSize = true;
|
||||
private GPUTexture _texture;
|
||||
private Vector2 _textureSize;
|
||||
private Float2 _textureSize;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture with cached children controls.
|
||||
@@ -38,7 +38,7 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the size of the texture (in pixels).
|
||||
/// </summary>
|
||||
[EditorOrder(20), VisibleIf("CanEditTextureSize"), Limit(0, 4096), Tooltip("The size of the texture (in pixels).")]
|
||||
public Vector2 TextureSize
|
||||
public Float2 TextureSize
|
||||
{
|
||||
get => _textureSize;
|
||||
set
|
||||
@@ -113,7 +113,7 @@ namespace FlaxEngine.GUI
|
||||
// Draw cached texture
|
||||
if (_texture && !_invalid && !_isDuringTextureDraw)
|
||||
{
|
||||
var bounds = new Rectangle(Vector2.Zero, Size);
|
||||
var bounds = new Rectangle(Float2.Zero, Size);
|
||||
var backgroundColor = BackgroundColor;
|
||||
if (backgroundColor.A > 0.0f)
|
||||
Render2D.FillRectangle(bounds, backgroundColor);
|
||||
|
||||
@@ -91,21 +91,21 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Vector2 GetTextSize()
|
||||
public override Float2 GetTextSize()
|
||||
{
|
||||
var count = _textBlocks.Count;
|
||||
var textBlocks = Utils.ExtractArrayFromList(_textBlocks);
|
||||
var max = Vector2.Zero;
|
||||
var max = Float2.Zero;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
ref TextBlock textBlock = ref textBlocks[i];
|
||||
max = Vector2.Max(max, textBlock.Bounds.BottomRight);
|
||||
max = Float2.Max(max, textBlock.Bounds.BottomRight);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Vector2 GetCharPosition(int index, out float height)
|
||||
public override Float2 GetCharPosition(int index, out float height)
|
||||
{
|
||||
var count = _textBlocks.Count;
|
||||
var textBlocks = Utils.ExtractArrayFromList(_textBlocks);
|
||||
@@ -114,7 +114,7 @@ namespace FlaxEngine.GUI
|
||||
if (count == 0)
|
||||
{
|
||||
height = 0;
|
||||
return Vector2.Zero;
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
// Check if get first character position
|
||||
@@ -172,13 +172,13 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
height = 0;
|
||||
return Vector2.Zero;
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int HitTestText(Vector2 location)
|
||||
public override int HitTestText(Float2 location)
|
||||
{
|
||||
location = Vector2.Clamp(location, Vector2.Zero, _textSize);
|
||||
location = Float2.Clamp(location, Float2.Zero, _textSize);
|
||||
|
||||
var textBlocks = Utils.ExtractArrayFromList(_textBlocks);
|
||||
var count = _textBlocks.Count;
|
||||
@@ -202,7 +202,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
// Select the word under the mouse
|
||||
int textLength = TextLength;
|
||||
@@ -223,7 +223,7 @@ namespace FlaxEngine.GUI
|
||||
public override void DrawSelf()
|
||||
{
|
||||
// Cache data
|
||||
var rect = new Rectangle(Vector2.Zero, Size);
|
||||
var rect = new Rectangle(Float2.Zero, Size);
|
||||
bool enabled = EnabledInHierarchy;
|
||||
|
||||
// Background
|
||||
@@ -279,8 +279,8 @@ namespace FlaxEngine.GUI
|
||||
// Selection
|
||||
if (hasSelection && textBlock.Style.BackgroundSelectedBrush != null && textBlock.Range.Intersect(ref selection))
|
||||
{
|
||||
Vector2 leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : font.GetCharPosition(_text, selection.StartIndex);
|
||||
Vector2 rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : font.GetCharPosition(_text, selection.EndIndex);
|
||||
var leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : font.GetCharPosition(_text, selection.StartIndex);
|
||||
var rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : font.GetCharPosition(_text, selection.EndIndex);
|
||||
float height = font.Height / DpiScale;
|
||||
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
|
||||
alpha *= alpha;
|
||||
|
||||
@@ -95,25 +95,25 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Vector2 GetTextSize()
|
||||
public override Float2 GetTextSize()
|
||||
{
|
||||
var font = Font.GetFont();
|
||||
if (font == null)
|
||||
{
|
||||
return Vector2.Zero;
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
return font.MeasureText(_text, ref _layout);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Vector2 GetCharPosition(int index, out float height)
|
||||
public override Float2 GetCharPosition(int index, out float height)
|
||||
{
|
||||
var font = Font.GetFont();
|
||||
if (font == null)
|
||||
{
|
||||
height = Height;
|
||||
return Vector2.Zero;
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
height = font.Height / DpiScale;
|
||||
@@ -121,7 +121,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int HitTestText(Vector2 location)
|
||||
public override int HitTestText(Float2 location)
|
||||
{
|
||||
var font = Font.GetFont();
|
||||
if (font == null)
|
||||
@@ -144,7 +144,7 @@ namespace FlaxEngine.GUI
|
||||
public override void DrawSelf()
|
||||
{
|
||||
// Cache data
|
||||
var rect = new Rectangle(Vector2.Zero, Size);
|
||||
var rect = new Rectangle(Float2.Zero, Size);
|
||||
bool enabled = EnabledInHierarchy;
|
||||
var font = Font.GetFont();
|
||||
if (!font)
|
||||
@@ -166,8 +166,8 @@ namespace FlaxEngine.GUI
|
||||
// Check if sth is selected to draw selection
|
||||
if (HasSelection)
|
||||
{
|
||||
Vector2 leftEdge = font.GetCharPosition(_text, SelectionLeft, ref _layout);
|
||||
Vector2 rightEdge = font.GetCharPosition(_text, SelectionRight, ref _layout);
|
||||
var leftEdge = font.GetCharPosition(_text, SelectionLeft, ref _layout);
|
||||
var rightEdge = font.GetCharPosition(_text, SelectionRight, ref _layout);
|
||||
float fontHeight = font.Height / DpiScale;
|
||||
|
||||
// Draw selection background
|
||||
@@ -230,7 +230,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
SelectAll();
|
||||
return base.OnMouseDoubleClick(location, button);
|
||||
|
||||
@@ -62,17 +62,17 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// The view offset
|
||||
/// </summary>
|
||||
protected Vector2 _viewOffset;
|
||||
protected Float2 _viewOffset;
|
||||
|
||||
/// <summary>
|
||||
/// The target view offset.
|
||||
/// </summary>
|
||||
protected Vector2 _targetViewOffset;
|
||||
protected Float2 _targetViewOffset;
|
||||
|
||||
/// <summary>
|
||||
/// The text size calculated from font.
|
||||
/// </summary>
|
||||
protected Vector2 _textSize;
|
||||
protected Float2 _textSize;
|
||||
|
||||
/// <summary>
|
||||
/// Flag used to indicate whenever text can contain multiple lines.
|
||||
@@ -231,7 +231,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// Gets the size of the text (cached).
|
||||
/// </summary>
|
||||
public Vector2 TextSize => _textSize;
|
||||
public Float2 TextSize => _textSize;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when target view offset gets changed.
|
||||
@@ -241,21 +241,20 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// Gets the current view offset (text scrolling offset). Includes the smoothing.
|
||||
/// </summary>
|
||||
public Vector2 ViewOffset => _viewOffset;
|
||||
public Float2 ViewOffset => _viewOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the target view offset (text scrolling offset).
|
||||
/// </summary>
|
||||
[NoAnimate, NoSerialize, HideInEditor]
|
||||
public Vector2 TargetViewOffset
|
||||
public Float2 TargetViewOffset
|
||||
{
|
||||
get => _targetViewOffset;
|
||||
set
|
||||
{
|
||||
value = Vector2.Round(value);
|
||||
if (Vector2.NearEqual(ref value, ref _targetViewOffset))
|
||||
value = Float2.Round(value);
|
||||
if (Float2.NearEqual(ref value, ref _targetViewOffset))
|
||||
return;
|
||||
|
||||
_targetViewOffset = _viewOffset = value;
|
||||
OnTargetViewOffsetChanged();
|
||||
}
|
||||
@@ -391,7 +390,7 @@ namespace FlaxEngine.GUI
|
||||
get
|
||||
{
|
||||
const float caretWidth = 1.2f;
|
||||
Vector2 caretPos = GetCharPosition(CaretPosition, out var height);
|
||||
Float2 caretPos = GetCharPosition(CaretPosition, out var height);
|
||||
return new Rectangle(
|
||||
caretPos.X - (caretWidth * 0.5f),
|
||||
caretPos.Y,
|
||||
@@ -462,7 +461,7 @@ namespace FlaxEngine.GUI
|
||||
/// </summary>
|
||||
public virtual void ResetViewOffset()
|
||||
{
|
||||
TargetViewOffset = Vector2.Zero;
|
||||
TargetViewOffset = Float2.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -550,7 +549,7 @@ namespace FlaxEngine.GUI
|
||||
// If it's empty
|
||||
if (_text.Length == 0)
|
||||
{
|
||||
TargetViewOffset = Vector2.Zero;
|
||||
TargetViewOffset = Float2.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -564,8 +563,8 @@ namespace FlaxEngine.GUI
|
||||
Rectangle textArea = TextRectangle;
|
||||
|
||||
// Update view offset (caret needs to be in a view)
|
||||
Vector2 caretInView = caretBounds.Location - _targetViewOffset;
|
||||
Vector2 clampedCaretInView = Vector2.Clamp(caretInView, textArea.UpperLeft, textArea.BottomRight);
|
||||
var caretInView = caretBounds.Location - _targetViewOffset;
|
||||
var clampedCaretInView = Float2.Clamp(caretInView, textArea.UpperLeft, textArea.BottomRight);
|
||||
TargetViewOffset += caretInView - clampedCaretInView;
|
||||
}
|
||||
|
||||
@@ -593,7 +592,7 @@ namespace FlaxEngine.GUI
|
||||
/// </summary>
|
||||
/// <param name="location">The location (in control-space).</param>
|
||||
/// <returns>The character index under the location</returns>
|
||||
public virtual int CharIndexAtPoint(ref Vector2 location)
|
||||
public virtual int CharIndexAtPoint(ref Float2 location)
|
||||
{
|
||||
return HitTestText(location + _viewOffset);
|
||||
}
|
||||
@@ -849,7 +848,7 @@ namespace FlaxEngine.GUI
|
||||
if (!IsMultiline)
|
||||
return 0;
|
||||
|
||||
Vector2 location = GetCharPosition(index, out var height);
|
||||
var location = GetCharPosition(index, out var height);
|
||||
location.Y += height;
|
||||
|
||||
return HitTestText(location);
|
||||
@@ -860,7 +859,7 @@ namespace FlaxEngine.GUI
|
||||
if (!IsMultiline)
|
||||
return _text.Length;
|
||||
|
||||
Vector2 location = GetCharPosition(index, out var height);
|
||||
var location = GetCharPosition(index, out var height);
|
||||
location.Y -= height;
|
||||
|
||||
return HitTestText(location);
|
||||
@@ -870,7 +869,7 @@ namespace FlaxEngine.GUI
|
||||
/// Calculates total text size. Called by <see cref="OnTextChanged"/> to cache the text size.
|
||||
/// </summary>
|
||||
/// <returns>The total text size.</returns>
|
||||
public abstract Vector2 GetTextSize();
|
||||
public abstract Float2 GetTextSize();
|
||||
|
||||
/// <summary>
|
||||
/// Calculates character position for given character index.
|
||||
@@ -878,14 +877,14 @@ namespace FlaxEngine.GUI
|
||||
/// <param name="index">The text position to get it's coordinates.</param>
|
||||
/// <param name="height">The character height (at the given character position).</param>
|
||||
/// <returns>The character position (upper left corner which can be used for a caret position).</returns>
|
||||
public abstract Vector2 GetCharPosition(int index, out float height);
|
||||
public abstract Float2 GetCharPosition(int index, out float height);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates hit character index at given location.
|
||||
/// </summary>
|
||||
/// <param name="location">The location to test.</param>
|
||||
/// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
|
||||
public abstract int HitTestText(Vector2 location);
|
||||
public abstract int HitTestText(Float2 location);
|
||||
|
||||
/// <summary>
|
||||
/// Called when is multiline gets changed.
|
||||
@@ -984,7 +983,7 @@ namespace FlaxEngine.GUI
|
||||
_animateTime += deltaTime;
|
||||
|
||||
// Animate view offset
|
||||
_viewOffset = isDeltaSlow ? _targetViewOffset : Vector2.Lerp(_viewOffset, _targetViewOffset, deltaTime * 20.0f);
|
||||
_viewOffset = isDeltaSlow ? _targetViewOffset : Float2.Lerp(_viewOffset, _targetViewOffset, deltaTime * 20.0f);
|
||||
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
@@ -1039,7 +1038,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
base.OnMouseMove(location);
|
||||
|
||||
@@ -1054,7 +1053,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
@@ -1093,7 +1092,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
@@ -1108,7 +1107,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseWheel(Vector2 location, float delta)
|
||||
public override bool OnMouseWheel(Float2 location, float delta)
|
||||
{
|
||||
if (base.OnMouseWheel(location, delta))
|
||||
return true;
|
||||
@@ -1116,7 +1115,7 @@ namespace FlaxEngine.GUI
|
||||
// Multiline scroll
|
||||
if (IsMultiline && _text.Length != 0)
|
||||
{
|
||||
TargetViewOffset = Vector2.Clamp(_targetViewOffset - new Vector2(0, delta * 10.0f), Vector2.Zero, new Vector2(_targetViewOffset.X, _textSize.Y));
|
||||
TargetViewOffset = Float2.Clamp(_targetViewOffset - new Float2(0, delta * 10.0f), Float2.Zero, new Float2(_targetViewOffset.X, _textSize.Y));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user