Refactor engine to support double-precision vectors

This commit is contained in:
Wojtek Figat
2022-06-13 00:40:32 +02:00
parent f82e370392
commit a881c90b2e
744 changed files with 19062 additions and 12467 deletions

View File

@@ -73,7 +73,7 @@ void EditorAnalytics::StartSession()
}
if (ScreenResolution.IsEmpty())
{
const Vector2 desktopSize = Platform::GetDesktopSize();
const auto desktopSize = Platform::GetDesktopSize();
ScreenResolution = StringAnsi(StringUtils::ToString((int32)desktopSize.X)) + "x" + StringAnsi(StringUtils::ToString((int32)desktopSize.Y));
}
if (UserLanguage.IsEmpty())

View File

@@ -84,7 +84,7 @@ namespace FlaxEditor.Content.Create
_settingsEditor = new CustomEditorPresenter(null);
_settingsEditor.Panel.Parent = panel;
_dialogSize = new Vector2(TotalWidth, panel.Bottom);
_dialogSize = new Float2(TotalWidth, panel.Bottom);
_settingsEditor.Select(_entry.Settings);
}
@@ -102,7 +102,7 @@ namespace FlaxEditor.Content.Create
{
base.SetupWindowSettings(ref settings);
settings.MinimumSize = new Vector2(300, 400);
settings.MinimumSize = new Float2(300, 400);
settings.HasSizingFrame = true;
}
}

View File

@@ -66,7 +66,7 @@ namespace FlaxEditor.Content.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
base.OnDragEnter(ref location, data);
@@ -80,7 +80,7 @@ namespace FlaxEditor.Content.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
base.OnDragMove(ref location, data);
@@ -97,7 +97,7 @@ namespace FlaxEditor.Content.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = DragDropEffect.None;
base.OnDragDrop(ref location, data);

View File

@@ -13,7 +13,7 @@ namespace FlaxEditor.Content.GUI
private DragActors _dragActors;
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
var result = base.OnDragEnter(ref location, data);
if (result != DragDropEffect.None)
@@ -50,7 +50,7 @@ namespace FlaxEditor.Content.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
_validDragOver = false;
var result = base.OnDragMove(ref location, data);
@@ -72,7 +72,7 @@ namespace FlaxEditor.Content.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = base.OnDragDrop(ref location, data);
if (result != DragDropEffect.None)

View File

@@ -594,18 +594,18 @@ namespace FlaxEditor.Content.GUI
// Check if drag is over
if (IsDragOver && _validDragOver)
{
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), style.BackgroundSelected * 0.4f);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundSelected * 0.4f);
}
// Check if it's an empty thing
if (_items.Count == 0)
{
Render2D.DrawText(style.FontSmall, IsSearching ? "No results" : "Empty", new Rectangle(Vector2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
Render2D.DrawText(style.FontSmall, IsSearching ? "No results" : "Empty", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (base.OnMouseDown(location, button))
return true;
@@ -613,7 +613,7 @@ namespace FlaxEditor.Content.GUI
}
/// <inheritdoc />
public override bool OnMouseWheel(Vector2 location, float delta)
public override bool OnMouseWheel(Float2 location, float delta)
{
// Check if pressing control key
if (Root.GetKey(KeyboardKeys.Control))
@@ -655,26 +655,26 @@ namespace FlaxEditor.Content.GUI
// Movement with arrows
{
var root = _selection[0];
Vector2 size = root.Size;
Vector2 offset = Vector2.Minimum;
var size = root.Size;
var offset = Float2.Minimum;
ContentItem item = null;
if (key == KeyboardKeys.ArrowUp)
{
offset = new Vector2(0, -size.Y);
offset = new Float2(0, -size.Y);
}
else if (key == KeyboardKeys.ArrowDown)
{
offset = new Vector2(0, size.Y);
offset = new Float2(0, size.Y);
}
else if (key == KeyboardKeys.ArrowRight)
{
offset = new Vector2(size.X, 0);
offset = new Float2(size.X, 0);
}
else if (key == KeyboardKeys.ArrowLeft)
{
offset = new Vector2(-size.X, 0);
offset = new Float2(-size.X, 0);
}
if (offset != Vector2.Minimum)
if (offset != Float2.Minimum)
{
item = GetChildAt(root.Location + size / 2 + offset) as ContentItem;
}

View File

@@ -131,10 +131,10 @@ namespace FlaxEditor.Content.Import
// Select the first item
tree.Select(_rootNode.Children[0] as TreeNode);
_dialogSize = new Vector2(TotalWidth, EditorHeight + splitPanel.Offsets.Height);
_dialogSize = new Float2(TotalWidth, EditorHeight + splitPanel.Offsets.Height);
}
private void OnTreeRightClick(TreeNode node, Vector2 location)
private void OnTreeRightClick(TreeNode node, Float2 location)
{
var menu = new ContextMenu();
menu.AddButton("Rename", OnRenameClicked);
@@ -183,7 +183,7 @@ namespace FlaxEditor.Content.Import
}
/// <inheritdoc />
protected override bool OnMouseDoubleClickHeader(ref Vector2 location, MouseButton button)
protected override bool OnMouseDoubleClickHeader(ref Float2 location, MouseButton button)
{
StartRenaming();
return true;
@@ -254,7 +254,7 @@ namespace FlaxEditor.Content.Import
{
base.SetupWindowSettings(ref settings);
settings.MinimumSize = new Vector2(300, 400);
settings.MinimumSize = new Float2(300, 400);
settings.HasSizingFrame = true;
}
}

View File

@@ -199,9 +199,9 @@ namespace FlaxEditor.Content.Import
/// <summary>
/// Custom import geometry offset.
/// </summary>
[DefaultValue(typeof(Vector3), "0,0,0")]
[DefaultValue(typeof(Float3), "0,0,0")]
[EditorOrder(520), EditorDisplay("Transform")]
public Vector3 Translation { get; set; } = Vector3.Zero;
public Float3 Translation { get; set; } = Float3.Zero;
/// <summary>
/// If checked, the imported geometry will be shifted to the center of mass.
@@ -376,7 +376,7 @@ namespace FlaxEditor.Content.Import
// Transform
public float Scale;
public Quaternion Rotation;
public Vector3 Translation;
public Float3 Translation;
public byte CenterGeometry;
// Animation

View File

@@ -56,7 +56,7 @@ namespace FlaxEditor.Content
Offsets = Margin.Zero;
}
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
return Item.OnMouseDoubleClick(Item.PointFromScreen(PointToScreen(location)), button);
}

View File

@@ -228,7 +228,7 @@ namespace FlaxEditor.Content
// Check if drag is over
if (IsDragOver && _validDragOver)
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), Style.Current.BackgroundSelected * 0.6f);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), Style.Current.BackgroundSelected * 0.6f);
}
private bool ValidateDragItem(ContentItem item)
@@ -238,7 +238,7 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
base.OnDragEnter(ref location, data);
@@ -258,7 +258,7 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
base.OnDragMove(ref location, data);
@@ -268,7 +268,7 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = base.OnDragDrop(ref location, data);

View File

@@ -183,7 +183,7 @@ namespace FlaxEditor.Content
private ContentFolder _parentFolder;
private bool _isMouseDown;
private Vector2 _mouseDownStartPos;
private Float2 _mouseDownStartPos;
private readonly List<IContentItemOwner> _references = new List<IContentItemOwner>(4);
private SpriteHandle _thumbnail;
@@ -593,11 +593,11 @@ namespace FlaxEditor.Content
protected override bool ShowTooltip => true;
/// <inheritdoc />
public override bool OnShowTooltip(out string text, out Vector2 location, out Rectangle area)
public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area)
{
UpdateTooltipText();
var result = base.OnShowTooltip(out text, out _, out area);
location = Size * new Vector2(0.9f, 0.5f);
location = Size * new Float2(0.9f, 0.5f);
return result;
}
@@ -618,7 +618,7 @@ namespace FlaxEditor.Content
var style = Style.Current;
var view = Parent as ContentView;
var isSelected = view.IsSelected(this);
var clientRect = new Rectangle(Vector2.Zero, size);
var clientRect = new Rectangle(Float2.Zero, size);
var textRect = TextRectangle;
Rectangle thumbnailRect;
TextAlignment nameAlignment;
@@ -657,7 +657,7 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
Focus();
@@ -672,7 +672,7 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isMouseDown)
{
@@ -687,7 +687,7 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
Focus();
@@ -707,10 +707,10 @@ namespace FlaxEditor.Content
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
// Check if start drag and drop
if (_isMouseDown && Vector2.Distance(_mouseDownStartPos, location) > 10.0f)
if (_isMouseDown && Float2.Distance(_mouseDownStartPos, location) > 10.0f)
{
// Clear flag
_isMouseDown = false;

View File

@@ -121,7 +121,7 @@ Asset::LoadResult PreviewsCache::load()
const float positionOffset = static_cast<float>(ASSETS_ICONS_ATLAS_MARGIN) / ASSETS_ICONS_ATLAS_SIZE;
for (int32 i = 0; i < ASSETS_ICONS_PER_ATLAS; i++)
{
sprite.Area.Location = Vector2(static_cast<float>(i % ASSETS_ICONS_PER_ROW), static_cast<float>(i / ASSETS_ICONS_PER_ROW)) * positionScale + positionOffset;
sprite.Area.Location = Float2(static_cast<float>(i % ASSETS_ICONS_PER_ROW), static_cast<float>(i / ASSETS_ICONS_PER_ROW)) * positionScale + positionOffset;
sprite.Name = StringUtils::ToString(i);
Sprites.Add(sprite);
}

View File

@@ -130,7 +130,7 @@ namespace FlaxEditor.Content
{
_preview.Prefab = (Prefab)request.Asset;
_preview.Parent = guiRoot;
_preview.Scale = Vector2.One;
_preview.Scale = Float2.One;
_preview.ShowDefaultSceneActors = true;
_preview.SyncBackbufferSize();
@@ -138,7 +138,7 @@ namespace FlaxEditor.Content
if (_preview.Instance is UIControl uiControl && uiControl.HasControl)
{
// Ensure to place UI in a proper way
uiControl.Control.Location = Vector2.Zero;
uiControl.Control.Location = Float2.Zero;
uiControl.Control.Scale *= PreviewsCache.AssetIconSize / uiControl.Control.Size.MaxValue;
uiControl.Control.AnchorPreset = AnchorPresets.TopLeft;
uiControl.Control.AnchorPreset = AnchorPresets.MiddleCenter;
@@ -154,8 +154,8 @@ namespace FlaxEditor.Content
// Auto fit actor to camera
float targetSize = 30.0f;
var bounds = _preview.Instance.EditorBoxChildren;
float maxSize = Mathf.Max(0.001f, bounds.Size.MaxValue);
_preview.Instance.Scale = new Vector3(targetSize / maxSize);
var maxSize = Math.Max(0.001f, (float)bounds.Size.MaxValue);
_preview.Instance.Scale = new Float3(targetSize / maxSize);
_preview.Instance.Position = Vector3.Zero;
}

View File

@@ -75,7 +75,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Viewing changes applied to this actor
var viewChanges = panel.Button("View Changes");
viewChanges.Button.Clicked += () => ViewChanges(viewChanges.Button, new Vector2(0.0f, 20.0f));
viewChanges.Button.Clicked += () => ViewChanges(viewChanges.Button, new Float2(0.0f, 20.0f));
// Link event to update editor on prefab apply
_linkedPrefabId = prefab.ID;
@@ -319,7 +319,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
return result;
}
private void ViewChanges(Control target, Vector2 targetLocation)
private void ViewChanges(Control target, Float2 targetLocation)
{
// Build a tree out of modified properties
var rootNode = ProcessDiff(this, false);
@@ -343,7 +343,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
cm.Show(target, targetLocation);
}
private void OnDiffNodeRightClick(TreeNode node, Vector2 location)
private void OnDiffNodeRightClick(TreeNode node, Float2 location)
{
var diffMenu = (PrefabDiffContextMenu)node.ParentTree.Tag;
@@ -353,7 +353,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
menu.AddButton("Revert All", OnDiffRevertAll);
menu.AddButton("Apply All", OnDiffApplyAll);
diffMenu.ShowChild(menu, node.PointToParent(diffMenu, new Vector2(location.X, node.HeaderHeight)));
diffMenu.ShowChild(menu, node.PointToParent(diffMenu, new Float2(location.X, node.HeaderHeight)));
}
private void OnDiffRevertAll()

View File

@@ -80,6 +80,21 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
}
[CustomEditor(typeof(BezierCurve<Float2>)), DefaultEditor]
sealed class Float2BezierCurveObjectEditor : BezierCurveObjectEditor<Float2>
{
}
[CustomEditor(typeof(BezierCurve<Float3>)), DefaultEditor]
sealed class Float3BezierCurveObjectEditor : BezierCurveObjectEditor<Float3>
{
}
[CustomEditor(typeof(BezierCurve<Float4>)), DefaultEditor]
sealed class Float4BezierCurveObjectEditor : BezierCurveObjectEditor<Float4>
{
}
[CustomEditor(typeof(BezierCurve<Quaternion>)), DefaultEditor]
sealed class QuaternionBezierCurveObjectEditor : BezierCurveObjectEditor<Quaternion>
{
@@ -165,6 +180,21 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
}
[CustomEditor(typeof(LinearCurve<Float2>)), DefaultEditor]
sealed class Float2LinearCurveObjectEditor : LinearCurveObjectEditor<Float2>
{
}
[CustomEditor(typeof(LinearCurve<Float3>)), DefaultEditor]
sealed class Float3LinearCurveObjectEditor : LinearCurveObjectEditor<Float3>
{
}
[CustomEditor(typeof(LinearCurve<Float4>)), DefaultEditor]
sealed class Float4LinearCurveObjectEditor : LinearCurveObjectEditor<Float4>
{
}
[CustomEditor(typeof(LinearCurve<Quaternion>)), DefaultEditor]
sealed class QuaternionLinearCurveObjectEditor : LinearCurveObjectEditor<Quaternion>
{

View File

@@ -45,8 +45,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
var upperRightCell = new VerticalPanel
{
ClipChildren = false,
Pivot = new Vector2(0.0f, 0.0f),
Offset = new Vector2(-labelsWidth, 0),
Pivot = new Float2(0.0f, 0.0f),
Offset = new Float2(-labelsWidth, 0),
Rotation = -90,
Spacing = 0,
TopMargin = 0,
@@ -116,7 +116,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
var box = new CheckBox(0, 0, true)
{
Tag = new Vector2(_layersCount - column - 1, row),
Tag = new Float2(_layersCount - column - 1, row),
Parent = grid,
Checked = GetBit(column, row),
};
@@ -132,8 +132,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
private void OnCheckBoxChanged(CheckBox box)
{
int column = (int)((Vector2)box.Tag).X;
int row = (int)((Vector2)box.Tag).Y;
int column = (int)((Float2)box.Tag).X;
int row = (int)((Float2)box.Tag).Y;
SetBit(column, row, box.Checked);
}
@@ -144,8 +144,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
for (int i = 0; i < _checkBoxes.Count; i++)
{
var box = _checkBoxes[i];
int column = (int)((Vector2)box.Tag).X;
int row = (int)((Vector2)box.Tag).Y;
int column = (int)((Float2)box.Tag).X;
int row = (int)((Float2)box.Tag).Y;
box.Checked = GetBit(column, row);
}
}

View File

@@ -158,7 +158,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
RebuildLayout();
Profiler.EndEvent();
});
menu.Show(button, new Vector2(0, button.Height));
menu.Show(button, new Float2(0, button.Height));
};
// Export button

View File

@@ -28,14 +28,14 @@ namespace FlaxEditor.CustomEditors.Dedicated
private object ParameterGet(object instance, GraphParameter parameter, object tag)
{
if (instance is ParticleEffect particleEffect && particleEffect && parameter && tag is ParticleEffectParameter effectParameter)
if (instance is ParticleEffect particleEffect && particleEffect && parameter && tag is ParticleEffectParameter effectParameter && effectParameter)
return particleEffect.GetParameterValue(effectParameter.TrackName, parameter.Name);
return null;
}
private void ParameterSet(object instance, object value, GraphParameter parameter, object tag)
{
if (instance is ParticleEffect particleEffect && particleEffect && parameter && tag is ParticleEffectParameter effectParameter)
if (instance is ParticleEffect particleEffect && particleEffect && parameter && tag is ParticleEffectParameter effectParameter && effectParameter)
particleEffect.SetParameterValue(effectParameter.TrackName, parameter.Name, value);
}

View File

@@ -76,7 +76,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
const float width = 280.0f;
const float height = 220.0f;
Size = new Vector2(width, height);
Size = new Float2(width, height);
// Title
var title = new Label(2, 2, width - 4, 23.0f)

View File

@@ -87,7 +87,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Check if drag is over
if (IsDragOver && _dragHandlers != null && _dragHandlers.HasValidDrag)
{
var area = new Rectangle(Vector2.Zero, size);
var area = new Rectangle(Float2.Zero, size);
Render2D.FillRectangle(area, Color.Orange * 0.5f);
Render2D.DrawRectangle(area, Color.Black);
}
@@ -110,7 +110,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
var result = base.OnDragEnter(ref location, data);
if (result != DragDropEffect.None)
@@ -130,7 +130,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
var result = base.OnDragMove(ref location, data);
if (result != DragDropEffect.None)
@@ -148,7 +148,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = base.OnDragDrop(ref location, data);
if (result != DragDropEffect.None)
@@ -253,7 +253,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
private ScriptsEditor _editor;
private bool _isMouseDown;
private Vector2 _mouseDownPos;
private Float2 _mouseDownPos;
/// <summary>
/// Gets the target script.
@@ -272,9 +272,9 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
_mouseDownPos = Vector2.Minimum;
_mouseDownPos = Float2.Minimum;
base.OnMouseEnter(location);
}
@@ -293,10 +293,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
// Check if start drag drop
if (_isMouseDown && Vector2.Distance(location, _mouseDownPos) > 10.0f)
if (_isMouseDown && Float2.Distance(location, _mouseDownPos) > 10.0f)
{
DoDrag();
_isMouseDown = false;
@@ -306,7 +306,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -318,7 +318,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -373,11 +373,11 @@ namespace FlaxEditor.CustomEditors.Dedicated
base.Draw();
var color = FlaxEngine.GUI.Style.Current.BackgroundSelected * (IsDragOver ? 0.9f : 0.1f);
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), color);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), color);
}
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
_dragEffect = DragDropEffect.None;
@@ -392,7 +392,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
return _dragEffect;
}
@@ -406,7 +406,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = base.OnDragDrop(ref location, data);
if (result != DragDropEffect.None)
@@ -636,7 +636,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
IsScrollable = false,
Checked = script.Enabled,
Parent = group.Panel,
Size = new Vector2(14, 14),
Size = new Float2(14, 14),
Bounds = new Rectangle(2, 0, 14, 14),
BoxSize = 12.0f,
Tag = script,

View File

@@ -44,7 +44,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
public override void Draw()
{
// Cache data
var rect = new Rectangle(Vector2.Zero, Size);
var rect = new Rectangle(Float2.Zero, Size);
if (rect.Width >= rect.Height)
{
rect.X = (rect.Width - rect.Height) * 0.5f;
@@ -159,49 +159,49 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Draw pivot point
if (SupportsShiftModulation && Input.GetKey(KeyboardKeys.Control))
{
Vector2 pivotPoint;
Float2 pivotPoint;
switch (_presets)
{
case AnchorPresets.Custom:
pivotPoint = Vector2.Minimum;
pivotPoint = Float2.Minimum;
break;
case AnchorPresets.TopLeft:
pivotPoint = new Vector2(0, 0);
pivotPoint = new Float2(0, 0);
break;
case AnchorPresets.TopCenter:
case AnchorPresets.HorizontalStretchTop:
pivotPoint = new Vector2(rect.Width / 2, 0);
pivotPoint = new Float2(rect.Width / 2, 0);
break;
case AnchorPresets.TopRight:
pivotPoint = new Vector2(rect.Width, 0);
pivotPoint = new Float2(rect.Width, 0);
break;
case AnchorPresets.MiddleLeft:
case AnchorPresets.VerticalStretchLeft:
pivotPoint = new Vector2(0, rect.Height / 2);
pivotPoint = new Float2(0, rect.Height / 2);
break;
case AnchorPresets.MiddleCenter:
case AnchorPresets.VerticalStretchCenter:
case AnchorPresets.HorizontalStretchMiddle:
case AnchorPresets.StretchAll:
pivotPoint = new Vector2(rect.Width / 2, rect.Height / 2);
pivotPoint = new Float2(rect.Width / 2, rect.Height / 2);
break;
case AnchorPresets.MiddleRight:
case AnchorPresets.VerticalStretchRight:
pivotPoint = new Vector2(rect.Width, rect.Height / 2);
pivotPoint = new Float2(rect.Width, rect.Height / 2);
break;
case AnchorPresets.BottomLeft:
pivotPoint = new Vector2(0, rect.Height);
pivotPoint = new Float2(0, rect.Height);
break;
case AnchorPresets.BottomCenter:
case AnchorPresets.HorizontalStretchBottom:
pivotPoint = new Vector2(rect.Width / 2, rect.Height);
pivotPoint = new Float2(rect.Width / 2, rect.Height);
break;
case AnchorPresets.BottomRight:
pivotPoint = new Vector2(rect.Width, rect.Height);
pivotPoint = new Float2(rect.Width, rect.Height);
break;
default: throw new ArgumentOutOfRangeException();
}
var pivotPointSize = new Vector2(3.0f);
var pivotPointSize = new Float2(3.0f);
Render2D.DrawRectangle(new Rectangle(pivotPoint - pivotPointSize * 0.5f, pivotPointSize), style.ProgressNormal, 1.1f);
}
}
@@ -234,7 +234,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
var style = FlaxEngine.GUI.Style.Current;
Tag = presets;
Size = new Vector2(DialogWidth, DialogHeight);
Size = new Float2(DialogWidth, DialogHeight);
// Title
var title = new Label(2, 2, DialogWidth - 4, TitleHeight)
@@ -346,7 +346,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
private void OnButtonClicked()
{
var location = _button.Center + new Vector2(3.0f);
var location = _button.Center + new Float2(3.0f);
var editor = new AnchorPresetsEditorPopup(_button.Presets, true);
editor.VisibleChanged += OnEditorVisibleChanged;
editor.Show(_button.Parent, location);
@@ -563,17 +563,17 @@ namespace FlaxEditor.CustomEditors.Dedicated
yEl = UniformPanelCapsuleForObjectWithText(horUp, "Top: ", topItem.GetValues(Values));
hEl = UniformPanelCapsuleForObjectWithText(horDown, "Bottom: ", bottomItem.GetValues(Values));
}
xEl.Control.AnchorMin = new Vector2(0, xEl.Control.AnchorMin.Y);
xEl.Control.AnchorMax = new Vector2(0.5f, xEl.Control.AnchorMax.Y);
xEl.Control.AnchorMin = new Float2(0, xEl.Control.AnchorMin.Y);
xEl.Control.AnchorMax = new Float2(0.5f, xEl.Control.AnchorMax.Y);
vEl.Control.AnchorMin = new Vector2(0, xEl.Control.AnchorMin.Y);
vEl.Control.AnchorMax = new Vector2(0.5f, xEl.Control.AnchorMax.Y);
vEl.Control.AnchorMin = new Float2(0, xEl.Control.AnchorMin.Y);
vEl.Control.AnchorMax = new Float2(0.5f, xEl.Control.AnchorMax.Y);
yEl.Control.AnchorMin = new Vector2(0.5f, xEl.Control.AnchorMin.Y);
yEl.Control.AnchorMax = new Vector2(1, xEl.Control.AnchorMax.Y);
yEl.Control.AnchorMin = new Float2(0.5f, xEl.Control.AnchorMin.Y);
yEl.Control.AnchorMax = new Float2(1, xEl.Control.AnchorMax.Y);
hEl.Control.AnchorMin = new Vector2(0.5f, xEl.Control.AnchorMin.Y);
hEl.Control.AnchorMax = new Vector2(1, xEl.Control.AnchorMax.Y);
hEl.Control.AnchorMin = new Float2(0.5f, xEl.Control.AnchorMin.Y);
hEl.Control.AnchorMax = new Float2(1, xEl.Control.AnchorMax.Y);
}
private VerticalPanelElement VerticalPanelWithoutMargin(LayoutElementsContainer cont)

View File

@@ -26,10 +26,10 @@ namespace FlaxEditor.CustomEditors.Editors
public static Color AxisColorZ = new Color(0.0f, 0.0235294f, 1.0f, 1.0f);
/// <summary>
/// Custom editor for actor position/scale property.
/// Custom editor for actor position property.
/// </summary>
/// <seealso cref="FlaxEditor.CustomEditors.Editors.Vector3Editor" />
public class PositionScaleEditor : Vector3Editor
public class PositionEditor : Vector3Editor
{
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
@@ -39,12 +39,12 @@ namespace FlaxEditor.CustomEditors.Editors
// Override colors
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
var grayOutFactor = 0.6f;
XElement.FloatValue.BorderColor = Color.Lerp(AxisColorX, back, grayOutFactor);
XElement.FloatValue.BorderSelectedColor = AxisColorX;
YElement.FloatValue.BorderColor = Color.Lerp(AxisColorY, back, grayOutFactor);
YElement.FloatValue.BorderSelectedColor = AxisColorY;
ZElement.FloatValue.BorderColor = Color.Lerp(AxisColorZ, back, grayOutFactor);
ZElement.FloatValue.BorderSelectedColor = AxisColorZ;
XElement.ValueBox.BorderColor = Color.Lerp(AxisColorX, back, grayOutFactor);
XElement.ValueBox.BorderSelectedColor = AxisColorX;
YElement.ValueBox.BorderColor = Color.Lerp(AxisColorY, back, grayOutFactor);
YElement.ValueBox.BorderSelectedColor = AxisColorY;
ZElement.ValueBox.BorderColor = Color.Lerp(AxisColorZ, back, grayOutFactor);
ZElement.ValueBox.BorderSelectedColor = AxisColorZ;
}
}
@@ -62,12 +62,35 @@ namespace FlaxEditor.CustomEditors.Editors
// Override colors
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
var grayOutFactor = 0.6f;
XElement.FloatValue.BorderColor = Color.Lerp(AxisColorX, back, grayOutFactor);
XElement.FloatValue.BorderSelectedColor = AxisColorX;
YElement.FloatValue.BorderColor = Color.Lerp(AxisColorY, back, grayOutFactor);
YElement.FloatValue.BorderSelectedColor = AxisColorY;
ZElement.FloatValue.BorderColor = Color.Lerp(AxisColorZ, back, grayOutFactor);
ZElement.FloatValue.BorderSelectedColor = AxisColorZ;
XElement.ValueBox.BorderColor = Color.Lerp(AxisColorX, back, grayOutFactor);
XElement.ValueBox.BorderSelectedColor = AxisColorX;
YElement.ValueBox.BorderColor = Color.Lerp(AxisColorY, back, grayOutFactor);
YElement.ValueBox.BorderSelectedColor = AxisColorY;
ZElement.ValueBox.BorderColor = Color.Lerp(AxisColorZ, back, grayOutFactor);
ZElement.ValueBox.BorderSelectedColor = AxisColorZ;
}
}
/// <summary>
/// Custom editor for actor scale property.
/// </summary>
/// <seealso cref="FlaxEditor.CustomEditors.Editors.Float3Editor" />
public class ScaleEditor : Float3Editor
{
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
base.Initialize(layout);
// Override colors
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
var grayOutFactor = 0.6f;
XElement.ValueBox.BorderColor = Color.Lerp(AxisColorX, back, grayOutFactor);
XElement.ValueBox.BorderSelectedColor = AxisColorX;
YElement.ValueBox.BorderColor = Color.Lerp(AxisColorY, back, grayOutFactor);
YElement.ValueBox.BorderSelectedColor = AxisColorY;
ZElement.ValueBox.BorderColor = Color.Lerp(AxisColorZ, back, grayOutFactor);
ZElement.ValueBox.BorderSelectedColor = AxisColorZ;
}
}
}

View File

@@ -9,7 +9,7 @@ using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Custom implementation of the inspector used to edit Vector4 color value type properties with color grading trackball.
/// Custom implementation of the inspector used to edit Float4 color value type properties with color grading trackball.
/// </summary>
public sealed class ColorTrackball : CustomEditor
{
@@ -73,12 +73,12 @@ namespace FlaxEditor.CustomEditors.Editors
{
var element = layout.FloatValue();
element.SetLimits(limit);
element.FloatValue.ValueChanged += OnValueChanged;
element.FloatValue.SlidingEnd += ClearToken;
element.ValueBox.ValueChanged += OnValueChanged;
element.ValueBox.SlidingEnd += ClearToken;
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
var grayOutFactor = 0.6f;
element.FloatValue.BorderColor = Color.Lerp(borderColor, back, grayOutFactor);
element.FloatValue.BorderSelectedColor = borderColor;
element.ValueBox.BorderColor = Color.Lerp(borderColor, back, grayOutFactor);
element.ValueBox.BorderSelectedColor = borderColor;
return element;
}
@@ -89,7 +89,7 @@ namespace FlaxEditor.CustomEditors.Editors
var isSliding = _trackball.CustomControl.IsSliding;
var token = isSliding ? this : null;
var value = new Vector4(color.R, color.G, color.B, _wElement.FloatValue.Value);
var value = new Float4(color.R, color.G, color.B, _wElement.ValueBox.Value);
SetValue(value, token);
}
@@ -100,7 +100,7 @@ namespace FlaxEditor.CustomEditors.Editors
var isSliding = _xElement.IsSliding || _yElement.IsSliding || _zElement.IsSliding || _wElement.IsSliding;
var token = isSliding ? this : null;
var value = new Vector4(_xElement.FloatValue.Value, _yElement.FloatValue.Value, _zElement.FloatValue.Value, _wElement.FloatValue.Value);
var value = new Float4(_xElement.ValueBox.Value, _yElement.ValueBox.Value, _zElement.ValueBox.Value, _wElement.ValueBox.Value);
SetValue(value, token);
}
@@ -111,8 +111,8 @@ namespace FlaxEditor.CustomEditors.Editors
if (!HasDifferentValues)
{
var value = (Vector4)Values[0];
var color = new Vector3(value);
var value = (Float4)Values[0];
var color = new Float3(value);
var scale = value.W;
float min = color.MinValue;
float max = color.MaxValue;
@@ -130,7 +130,7 @@ namespace FlaxEditor.CustomEditors.Editors
_yElement.Value = color.Y;
_zElement.Value = color.Z;
_wElement.Value = scale;
_trackball.CustomControl.Color = Vector3.Abs(color);
_trackball.CustomControl.Color = Float3.Abs(color);
}
}
}

View File

@@ -108,7 +108,7 @@ namespace FlaxEditor.CustomEditors.Editors
private void ShowPicker()
{
var menu = CreatePicker(Culture, value => { Culture = value; });
menu.Show(_label, new Vector2(0, _label.Height));
menu.Show(_label, new Float2(0, _label.Height));
}
internal static ContextMenuBase CreatePicker(CultureInfo value, Action<CultureInfo> changed)

View File

@@ -113,7 +113,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{

View File

@@ -1,85 +0,0 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit Double2 value type properties.
/// </summary>
[CustomEditor(typeof(Double2)), DefaultEditor]
public class Double2Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected DoubleValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected DoubleValueElement YElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 2;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.DoubleValue();
XElement.SetLimits(limit);
XElement.DoubleValue.ValueChanged += OnValueChanged;
XElement.DoubleValue.SlidingEnd += ClearToken;
YElement = grid.DoubleValue();
YElement.SetLimits(limit);
YElement.DoubleValue.ValueChanged += OnValueChanged;
YElement.DoubleValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding;
var token = isSliding ? this : null;
var value = new Double2(XElement.DoubleValue.Value, YElement.DoubleValue.Value);
SetValue(value, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = (Double2)Values[0];
XElement.DoubleValue.Value = value.X;
YElement.DoubleValue.Value = value.Y;
}
}
}
}

View File

@@ -1,96 +0,0 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit Double3 value type properties.
/// </summary>
[CustomEditor(typeof(Double3)), DefaultEditor]
public class Double3Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected DoubleValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected DoubleValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected DoubleValueElement ZElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 3;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.DoubleValue();
XElement.SetLimits(limit);
XElement.DoubleValue.ValueChanged += OnValueChanged;
XElement.DoubleValue.SlidingEnd += ClearToken;
YElement = grid.DoubleValue();
YElement.SetLimits(limit);
YElement.DoubleValue.ValueChanged += OnValueChanged;
YElement.DoubleValue.SlidingEnd += ClearToken;
ZElement = grid.DoubleValue();
ZElement.SetLimits(limit);
ZElement.DoubleValue.ValueChanged += OnValueChanged;
ZElement.DoubleValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
var value = new Double3(XElement.DoubleValue.Value, YElement.DoubleValue.Value, ZElement.DoubleValue.Value);
SetValue(value, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = (Double3)Values[0];
XElement.DoubleValue.Value = value.X;
YElement.DoubleValue.Value = value.Y;
ZElement.DoubleValue.Value = value.Z;
}
}
}
}

View File

@@ -1,107 +0,0 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit Double4 value type properties.
/// </summary>
[CustomEditor(typeof(Double4)), DefaultEditor]
public class Double4Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected DoubleValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected DoubleValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected DoubleValueElement ZElement;
/// <summary>
/// The W component editor.
/// </summary>
protected DoubleValueElement WElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 4;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.DoubleValue();
XElement.SetLimits(limit);
XElement.DoubleValue.ValueChanged += OnValueChanged;
XElement.DoubleValue.SlidingEnd += ClearToken;
YElement = grid.DoubleValue();
YElement.SetLimits(limit);
YElement.DoubleValue.ValueChanged += OnValueChanged;
YElement.DoubleValue.SlidingEnd += ClearToken;
ZElement = grid.DoubleValue();
ZElement.SetLimits(limit);
ZElement.DoubleValue.ValueChanged += OnValueChanged;
ZElement.DoubleValue.SlidingEnd += ClearToken;
WElement = grid.DoubleValue();
WElement.SetLimits(limit);
WElement.DoubleValue.ValueChanged += OnValueChanged;
WElement.DoubleValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding || WElement.IsSliding;
var token = isSliding ? this : null;
var value = new Double4(XElement.DoubleValue.Value, YElement.DoubleValue.Value, ZElement.DoubleValue.Value, WElement.DoubleValue.Value);
SetValue(value, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = (Double4)Values[0];
XElement.DoubleValue.Value = value.X;
YElement.DoubleValue.Value = value.Y;
ZElement.DoubleValue.Value = value.Z;
WElement.DoubleValue.Value = value.W;
}
}
}
}

View File

@@ -33,8 +33,8 @@ namespace FlaxEditor.CustomEditors.Editors
// Use double value editor with limit
var doubleValue = layout.DoubleValue();
doubleValue.SetLimits((LimitAttribute)limit);
doubleValue.DoubleValue.ValueChanged += OnValueChanged;
doubleValue.DoubleValue.SlidingEnd += ClearToken;
doubleValue.ValueBox.ValueChanged += OnValueChanged;
doubleValue.ValueBox.SlidingEnd += ClearToken;
_element = doubleValue;
return;
}
@@ -43,8 +43,8 @@ namespace FlaxEditor.CustomEditors.Editors
{
// Use double value editor
var doubleValue = layout.DoubleValue();
doubleValue.DoubleValue.ValueChanged += OnValueChanged;
doubleValue.DoubleValue.SlidingEnd += ClearToken;
doubleValue.ValueBox.ValueChanged += OnValueChanged;
doubleValue.ValueBox.SlidingEnd += ClearToken;
_element = doubleValue;
}
}

View File

@@ -27,8 +27,8 @@ namespace FlaxEditor.CustomEditors.Editors
private bool _supportsPickDropDown;
private bool _isMouseDown;
private Vector2 _mouseDownPos;
private Vector2 _mousePos;
private Float2 _mouseDownPos;
private Float2 _mousePos;
private bool _hasValidDragOver;
private DragActors _dragActors;
@@ -146,7 +146,7 @@ namespace FlaxEditor.CustomEditors.Editors
Focus();
if (new ScriptType(typeof(Actor)).IsAssignableFrom(_type))
{
ActorSearchPopup.Show(this, new Vector2(0, Height), IsValid, actor =>
ActorSearchPopup.Show(this, new Float2(0, Height), IsValid, actor =>
{
Value = actor;
RootWindow.Focus();
@@ -155,7 +155,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
else
{
ScriptSearchPopup.Show(this, new Vector2(0, Height), IsValid, script =>
ScriptSearchPopup.Show(this, new Float2(0, Height), IsValid, script =>
{
Value = script;
RootWindow.Focus();
@@ -219,14 +219,14 @@ namespace FlaxEditor.CustomEditors.Editors
// Check if drag is over
if (IsDragOver && _hasValidDragOver)
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), style.BackgroundSelected * 0.4f);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundSelected * 0.4f);
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
_mousePos = location;
_mouseDownPos = Vector2.Minimum;
_mouseDownPos = Float2.Minimum;
base.OnMouseEnter(location);
}
@@ -234,7 +234,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc />
public override void OnMouseLeave()
{
_mousePos = Vector2.Minimum;
_mousePos = Float2.Minimum;
// Check if start drag drop
if (_isMouseDown)
@@ -250,12 +250,12 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
// Check if start drag drop
if (_isMouseDown && Vector2.Distance(location, _mouseDownPos) > 10.0f)
if (_isMouseDown && Float2.Distance(location, _mouseDownPos) > 10.0f)
{
// Do the drag
DoDrag();
@@ -268,7 +268,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -299,7 +299,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -312,7 +312,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
Focus();
@@ -358,7 +358,7 @@ namespace FlaxEditor.CustomEditors.Editors
private DragDropEffect DragEffect => _hasValidDragOver ? DragDropEffect.Move : DragDropEffect.None;
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
base.OnDragEnter(ref location, data);
@@ -417,7 +417,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
base.OnDragMove(ref location, data);
@@ -434,7 +434,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = DragEffect;

View File

@@ -49,8 +49,8 @@ namespace FlaxEditor.CustomEditors.Editors
// Use float value editor with limit
var floatValue = layout.FloatValue();
floatValue.SetLimits((LimitAttribute)limit);
floatValue.FloatValue.ValueChanged += OnValueChanged;
floatValue.FloatValue.SlidingEnd += ClearToken;
floatValue.ValueBox.ValueChanged += OnValueChanged;
floatValue.ValueBox.SlidingEnd += ClearToken;
_element = floatValue;
return;
}
@@ -59,8 +59,8 @@ namespace FlaxEditor.CustomEditors.Editors
{
// Use float value editor
var floatValue = layout.FloatValue();
floatValue.FloatValue.ValueChanged += OnValueChanged;
floatValue.FloatValue.SlidingEnd += ClearToken;
floatValue.ValueBox.ValueChanged += OnValueChanged;
floatValue.ValueBox.SlidingEnd += ClearToken;
_element = floatValue;
}
}

View File

@@ -498,7 +498,7 @@ namespace FlaxEditor.CustomEditors.Editors
return false;
}
private void OnGroupPanelMouseButtonRightClicked(DropPanel groupPanel, Vector2 location)
private void OnGroupPanelMouseButtonRightClicked(DropPanel groupPanel, Float2 location)
{
var group = (GroupElement)groupPanel.Tag;
bool canRevertReference = false, canRevertDefault = false;
@@ -637,10 +637,10 @@ namespace FlaxEditor.CustomEditors.Editors
{
Text = "+",
TooltipText = "Create a new instance of the object",
Size = new Vector2(ButtonSize, ButtonSize),
Size = new Float2(ButtonSize, ButtonSize),
AnchorPreset = AnchorPresets.MiddleRight,
Parent = layout.ContainerControl,
Location = new Vector2(layout.ContainerControl.Width - ButtonSize - 4, (layout.ContainerControl.Height - ButtonSize) * 0.5f),
Location = new Float2(layout.ContainerControl.Width - ButtonSize - 4, (layout.ContainerControl.Height - ButtonSize) * 0.5f),
};
button.Clicked += () => SetValue(Values.Type.CreateInstance());
}

View File

@@ -1,87 +0,0 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit Int2 value type properties.
/// </summary>
[CustomEditor(typeof(Int2)), DefaultEditor]
public class Int2Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected IntegerValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected IntegerValueElement YElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 2;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.IntegerValue();
XElement.SetLimits(limit);
XElement.IntValue.ValueChanged += OnValueChanged;
XElement.IntValue.SlidingEnd += ClearToken;
YElement = grid.IntegerValue();
YElement.SetLimits(limit);
YElement.IntValue.ValueChanged += OnValueChanged;
YElement.IntValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding;
var token = isSliding ? this : null;
var value = new Int2(
XElement.IntValue.Value,
YElement.IntValue.Value);
SetValue(value, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = (Int2)Values[0];
XElement.IntValue.Value = value.X;
YElement.IntValue.Value = value.Y;
}
}
}
}

View File

@@ -1,99 +0,0 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit Int3 value type properties.
/// </summary>
[CustomEditor(typeof(Int3)), DefaultEditor]
public class Int3Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected IntegerValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected IntegerValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected IntegerValueElement ZElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 3;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.IntegerValue();
XElement.SetLimits(limit);
XElement.IntValue.ValueChanged += OnValueChanged;
XElement.IntValue.SlidingEnd += ClearToken;
YElement = grid.IntegerValue();
YElement.SetLimits(limit);
YElement.IntValue.ValueChanged += OnValueChanged;
YElement.IntValue.SlidingEnd += ClearToken;
ZElement = grid.IntegerValue();
ZElement.SetLimits(limit);
ZElement.IntValue.ValueChanged += OnValueChanged;
ZElement.IntValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
var value = new Int3(
XElement.IntValue.Value,
YElement.IntValue.Value,
ZElement.IntValue.Value);
SetValue(value, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = (Int3)Values[0];
XElement.IntValue.Value = value.X;
YElement.IntValue.Value = value.Y;
ZElement.IntValue.Value = value.Z;
}
}
}
}

View File

@@ -1,111 +0,0 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit Int4 value type properties.
/// </summary>
[CustomEditor(typeof(Int4)), DefaultEditor]
public class Int4Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected IntegerValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected IntegerValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected IntegerValueElement ZElement;
/// <summary>
/// The W component editor.
/// </summary>
protected IntegerValueElement WElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 4;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.IntegerValue();
XElement.SetLimits(limit);
XElement.IntValue.ValueChanged += OnValueChanged;
XElement.IntValue.SlidingEnd += ClearToken;
YElement = grid.IntegerValue();
YElement.SetLimits(limit);
YElement.IntValue.ValueChanged += OnValueChanged;
YElement.IntValue.SlidingEnd += ClearToken;
ZElement = grid.IntegerValue();
ZElement.SetLimits(limit);
ZElement.IntValue.ValueChanged += OnValueChanged;
ZElement.IntValue.SlidingEnd += ClearToken;
WElement = grid.IntegerValue();
WElement.SetLimits(limit);
WElement.IntValue.ValueChanged += OnValueChanged;
WElement.IntValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding || WElement.IsSliding;
var token = isSliding ? this : null;
var value = new Int4(
XElement.IntValue.Value,
YElement.IntValue.Value,
ZElement.IntValue.Value,
WElement.IntValue.Value);
SetValue(value, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = (Int4)Values[0];
XElement.IntValue.Value = value.X;
YElement.IntValue.Value = value.Y;
ZElement.IntValue.Value = value.Z;
WElement.IntValue.Value = value.W;
}
}
}
}

View File

@@ -152,7 +152,7 @@ namespace FlaxEditor.CustomEditors.Editors
tree.UnlockChildrenRecursive();
menu.PerformLayout();
};
menu.Show(button, new Vector2(0, button.Height));
menu.Show(button, new Float2(0, button.Height));
Profiler.EndEvent();
}

View File

@@ -42,8 +42,8 @@ namespace FlaxEditor.CustomEditors.Editors
{
var elemnt = grid.FloatValue();
elemnt.SetLimits(limit);
elemnt.FloatValue.ValueChanged += OnValueChanged;
elemnt.FloatValue.SlidingEnd += ClearToken;
elemnt.ValueBox.ValueChanged += OnValueChanged;
elemnt.ValueBox.SlidingEnd += ClearToken;
Elements[i] = elemnt;
}
}
@@ -62,7 +62,7 @@ namespace FlaxEditor.CustomEditors.Editors
var value = new Matrix();
for (int i = 0; i < 16; i++)
{
value[i] = Elements[i].FloatValue.Value;
value[i] = Elements[i].ValueBox.Value;
}
SetValue(value, token);
}
@@ -81,7 +81,7 @@ namespace FlaxEditor.CustomEditors.Editors
var value = (Matrix)Values[0];
for (int i = 0; i < 16; i++)
{
Elements[i].FloatValue.Value = value[i];
Elements[i].ValueBox.Value = value[i];
}
}
}

View File

@@ -12,7 +12,7 @@ namespace FlaxEditor.CustomEditors.Editors
[CustomEditor(typeof(Quaternion)), DefaultEditor]
public class QuaternionEditor : CustomEditor
{
private Vector3 _cachedAngles = Vector3.Zero;
private Float3 _cachedAngles = Float3.Zero;
private object _cachedToken;
/// <summary>
@@ -44,16 +44,16 @@ namespace FlaxEditor.CustomEditors.Editors
gridControl.SlotsVertically = 1;
XElement = grid.FloatValue();
XElement.FloatValue.ValueChanged += OnValueChanged;
XElement.FloatValue.SlidingEnd += ClearToken;
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.FloatValue();
YElement.FloatValue.ValueChanged += OnValueChanged;
YElement.FloatValue.SlidingEnd += ClearToken;
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
ZElement = grid.FloatValue();
ZElement.FloatValue.ValueChanged += OnValueChanged;
ZElement.FloatValue.SlidingEnd += ClearToken;
ZElement.ValueBox.ValueChanged += OnValueChanged;
ZElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
@@ -65,9 +65,9 @@ namespace FlaxEditor.CustomEditors.Editors
var token = isSliding ? this : null;
var useCachedAngles = isSliding && token == _cachedToken;
float x = (useCachedAngles && !XElement.IsSliding) ? _cachedAngles.X : XElement.FloatValue.Value;
float y = (useCachedAngles && !YElement.IsSliding) ? _cachedAngles.Y : YElement.FloatValue.Value;
float z = (useCachedAngles && !ZElement.IsSliding) ? _cachedAngles.Z : ZElement.FloatValue.Value;
float x = (useCachedAngles && !XElement.IsSliding) ? _cachedAngles.X : XElement.ValueBox.Value;
float y = (useCachedAngles && !YElement.IsSliding) ? _cachedAngles.Y : YElement.ValueBox.Value;
float z = (useCachedAngles && !ZElement.IsSliding) ? _cachedAngles.Z : ZElement.ValueBox.Value;
x = Mathf.UnwindDegrees(x);
y = Mathf.UnwindDegrees(y);
@@ -75,7 +75,7 @@ namespace FlaxEditor.CustomEditors.Editors
if (!useCachedAngles)
{
_cachedAngles = new Vector3(x, y, z);
_cachedAngles = new Float3(x, y, z);
}
_cachedToken = token;
@@ -104,9 +104,9 @@ namespace FlaxEditor.CustomEditors.Editors
{
var value = (Quaternion)Values[0];
var euler = value.EulerAngles;
XElement.FloatValue.Value = euler.X;
YElement.FloatValue.Value = euler.Y;
ZElement.FloatValue.Value = euler.Z;
XElement.ValueBox.Value = euler.X;
YElement.ValueBox.Value = euler.Y;
ZElement.ValueBox.Value = euler.Z;
}
}
}

View File

@@ -23,7 +23,7 @@ namespace FlaxEditor.CustomEditors.Editors
private ScriptType _value;
private string _valueName;
private Vector2 _mousePos;
private Float2 _mousePos;
private bool _hasValidDragOver;
private DragActors _dragActors;
@@ -124,7 +124,7 @@ namespace FlaxEditor.CustomEditors.Editors
private void ShowDropDownMenu()
{
Focus();
TypeSearchPopup.Show(this, new Vector2(0, Height), IsValid, scriptType =>
TypeSearchPopup.Show(this, new Float2(0, Height), IsValid, scriptType =>
{
Value = scriptType;
RootWindow.Focus();
@@ -174,11 +174,11 @@ namespace FlaxEditor.CustomEditors.Editors
// Check if drag is over
if (IsDragOver && _hasValidDragOver)
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), style.BackgroundSelected * 0.4f);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundSelected * 0.4f);
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
_mousePos = location;
@@ -186,7 +186,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
@@ -196,13 +196,13 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc />
public override void OnMouseLeave()
{
_mousePos = Vector2.Minimum;
_mousePos = Float2.Minimum;
base.OnMouseLeave();
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
// Cache data
bool isSelected = _value != ScriptType.Null;
@@ -225,7 +225,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
// Navigate to types from game project
if (button == MouseButton.Left && _value != ScriptType.Null)
@@ -241,7 +241,7 @@ namespace FlaxEditor.CustomEditors.Editors
private DragDropEffect DragEffect => _hasValidDragOver ? DragDropEffect.Move : DragDropEffect.None;
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
base.OnDragEnter(ref location, data);
@@ -267,7 +267,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
base.OnDragMove(ref location, data);
@@ -284,7 +284,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
var result = DragEffect;

View File

@@ -11,7 +11,20 @@ namespace FlaxEditor.CustomEditors.Editors
/// Default implementation of the inspector used to edit Vector2 value type properties.
/// </summary>
[CustomEditor(typeof(Vector2)), DefaultEditor]
public class Vector2Editor : CustomEditor
public class Vector2Editor :
#if USE_LARGE_WORLDS
Double2Editor
#else
Float2Editor
#endif
{
}
/// <summary>
/// Default implementation of the inspector used to edit Float2 value type properties.
/// </summary>
[CustomEditor(typeof(Float2)), DefaultEditor]
public class Float2Editor : CustomEditor
{
/// <summary>
/// The X component editor.
@@ -45,13 +58,13 @@ namespace FlaxEditor.CustomEditors.Editors
XElement = grid.FloatValue();
XElement.SetLimits(limit);
XElement.FloatValue.ValueChanged += OnValueChanged;
XElement.FloatValue.SlidingEnd += ClearToken;
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.FloatValue();
YElement.SetLimits(limit);
YElement.FloatValue.ValueChanged += OnValueChanged;
YElement.FloatValue.SlidingEnd += ClearToken;
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
@@ -61,9 +74,185 @@ namespace FlaxEditor.CustomEditors.Editors
var isSliding = XElement.IsSliding || YElement.IsSliding;
var token = isSliding ? this : null;
var value = new Vector2(
XElement.FloatValue.Value,
YElement.FloatValue.Value);
var value = new Float2(XElement.ValueBox.Value, YElement.ValueBox.Value);
object v = Values[0];
if (v is Vector2)
v = (Vector2)value;
else if (v is Float2)
v = (Float2)value;
else if (v is Double2)
v = (Double2)value;
SetValue(v, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = Float2.Zero;
if (Values[0] is Vector2 asVector2)
value = asVector2;
else if (Values[0] is Float2 asFloat2)
value = asFloat2;
else if (Values[0] is Double2 asDouble2)
value = asDouble2;
XElement.ValueBox.Value = value.X;
YElement.ValueBox.Value = value.Y;
}
}
}
/// <summary>
/// Default implementation of the inspector used to edit Double2 value type properties.
/// </summary>
[CustomEditor(typeof(Double2)), DefaultEditor]
public class Double2Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected DoubleValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected DoubleValueElement YElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 2;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.DoubleValue();
XElement.SetLimits(limit);
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.DoubleValue();
YElement.SetLimits(limit);
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding;
var token = isSliding ? this : null;
var value = new Double2(XElement.ValueBox.Value, YElement.ValueBox.Value);
object v = Values[0];
if (v is Vector2)
v = (Vector2)value;
else if (v is Float2)
v = (Float2)value;
else if (v is Double2)
v = (Double2)value;
SetValue(v, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = Double2.Zero;
if (Values[0] is Vector2 asVector2)
value = asVector2;
else if (Values[0] is Float2 asFloat2)
value = asFloat2;
else if (Values[0] is Double2 asDouble2)
value = asDouble2;
XElement.ValueBox.Value = value.X;
YElement.ValueBox.Value = value.Y;
}
}
}
/// <summary>
/// Default implementation of the inspector used to edit Int2 value type properties.
/// </summary>
[CustomEditor(typeof(Int2)), DefaultEditor]
public class Int2Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected IntegerValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected IntegerValueElement YElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 2;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.IntegerValue();
XElement.SetLimits(limit);
XElement.IntValue.ValueChanged += OnValueChanged;
XElement.IntValue.SlidingEnd += ClearToken;
YElement = grid.IntegerValue();
YElement.SetLimits(limit);
YElement.IntValue.ValueChanged += OnValueChanged;
YElement.IntValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding;
var token = isSliding ? this : null;
var value = new Int2(XElement.IntValue.Value, YElement.IntValue.Value);
SetValue(value, token);
}
@@ -78,9 +267,9 @@ namespace FlaxEditor.CustomEditors.Editors
}
else
{
var value = (Vector2)Values[0];
XElement.FloatValue.Value = value.X;
YElement.FloatValue.Value = value.Y;
var value = (Int2)Values[0];
XElement.IntValue.Value = value.X;
YElement.IntValue.Value = value.Y;
}
}
}

View File

@@ -11,7 +11,20 @@ namespace FlaxEditor.CustomEditors.Editors
/// Default implementation of the inspector used to edit Vector3 value type properties.
/// </summary>
[CustomEditor(typeof(Vector3)), DefaultEditor]
public class Vector3Editor : CustomEditor
public class Vector3Editor :
#if USE_LARGE_WORLDS
Double3Editor
#else
Float3Editor
#endif
{
}
/// <summary>
/// Default implementation of the inspector used to edit Float3 value type properties.
/// </summary>
[CustomEditor(typeof(Float3)), DefaultEditor]
public class Float3Editor : CustomEditor
{
/// <summary>
/// The X component editor.
@@ -50,18 +63,18 @@ namespace FlaxEditor.CustomEditors.Editors
XElement = grid.FloatValue();
XElement.SetLimits(limit);
XElement.FloatValue.ValueChanged += OnValueChanged;
XElement.FloatValue.SlidingEnd += ClearToken;
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.FloatValue();
YElement.SetLimits(limit);
YElement.FloatValue.ValueChanged += OnValueChanged;
YElement.FloatValue.SlidingEnd += ClearToken;
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
ZElement = grid.FloatValue();
ZElement.SetLimits(limit);
ZElement.FloatValue.ValueChanged += OnValueChanged;
ZElement.FloatValue.SlidingEnd += ClearToken;
ZElement.ValueBox.ValueChanged += OnValueChanged;
ZElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
@@ -71,10 +84,207 @@ namespace FlaxEditor.CustomEditors.Editors
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
var value = new Vector3(
XElement.FloatValue.Value,
YElement.FloatValue.Value,
ZElement.FloatValue.Value);
var value = new Float3(XElement.ValueBox.Value, YElement.ValueBox.Value, ZElement.ValueBox.Value);
object v = Values[0];
if (v is Vector3)
v = (Vector3)value;
else if (v is Float3)
v = (Float3)value;
else if (v is Double3)
v = (Double3)value;
SetValue(v, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = Float3.Zero;
if (Values[0] is Vector3 asVector3)
value = asVector3;
else if (Values[0] is Float3 asFloat3)
value = asFloat3;
else if (Values[0] is Double3 asDouble3)
value = asDouble3;
XElement.ValueBox.Value = value.X;
YElement.ValueBox.Value = value.Y;
ZElement.ValueBox.Value = value.Z;
}
}
}
/// <summary>
/// Default implementation of the inspector used to edit Double3 value type properties.
/// </summary>
[CustomEditor(typeof(Double3)), DefaultEditor]
public class Double3Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected DoubleValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected DoubleValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected DoubleValueElement ZElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 3;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.DoubleValue();
XElement.SetLimits(limit);
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.DoubleValue();
YElement.SetLimits(limit);
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
ZElement = grid.DoubleValue();
ZElement.SetLimits(limit);
ZElement.ValueBox.ValueChanged += OnValueChanged;
ZElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
var value = new Double3(XElement.ValueBox.Value, YElement.ValueBox.Value, ZElement.ValueBox.Value);
object v = Values[0];
if (v is Vector3)
v = (Vector3)value;
else if (v is Float3)
v = (Float3)value;
else if (v is Double3)
v = (Double3)value;
SetValue(v, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = Double3.Zero;
if (Values[0] is Vector3 asVector3)
value = asVector3;
else if (Values[0] is Float3 asFloat3)
value = asFloat3;
else if (Values[0] is Double3 asDouble3)
value = asDouble3;
XElement.ValueBox.Value = value.X;
YElement.ValueBox.Value = value.Y;
ZElement.ValueBox.Value = value.Z;
}
}
}
/// <summary>
/// Default implementation of the inspector used to edit Int3 value type properties.
/// </summary>
[CustomEditor(typeof(Int3)), DefaultEditor]
public class Int3Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected IntegerValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected IntegerValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected IntegerValueElement ZElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 3;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.IntegerValue();
XElement.SetLimits(limit);
XElement.IntValue.ValueChanged += OnValueChanged;
XElement.IntValue.SlidingEnd += ClearToken;
YElement = grid.IntegerValue();
YElement.SetLimits(limit);
YElement.IntValue.ValueChanged += OnValueChanged;
YElement.IntValue.SlidingEnd += ClearToken;
ZElement = grid.IntegerValue();
ZElement.SetLimits(limit);
ZElement.IntValue.ValueChanged += OnValueChanged;
ZElement.IntValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
var value = new Int3(XElement.IntValue.Value, YElement.IntValue.Value, ZElement.IntValue.Value);
SetValue(value, token);
}
@@ -89,10 +299,10 @@ namespace FlaxEditor.CustomEditors.Editors
}
else
{
var value = (Vector3)Values[0];
XElement.FloatValue.Value = value.X;
YElement.FloatValue.Value = value.Y;
ZElement.FloatValue.Value = value.Z;
var value = (Int3)Values[0];
XElement.IntValue.Value = value.X;
YElement.IntValue.Value = value.Y;
ZElement.IntValue.Value = value.Z;
}
}
}

View File

@@ -11,7 +11,20 @@ namespace FlaxEditor.CustomEditors.Editors
/// Default implementation of the inspector used to edit Vector4 value type properties.
/// </summary>
[CustomEditor(typeof(Vector4)), DefaultEditor]
public class Vector4Editor : CustomEditor
public class Vector4Editor :
#if USE_LARGE_WORLDS
Double4Editor
#else
Float4Editor
#endif
{
}
/// <summary>
/// Default implementation of the inspector used to edit Vector4 value type properties.
/// </summary>
[CustomEditor(typeof(Float4)), DefaultEditor]
public class Float4Editor : CustomEditor
{
/// <summary>
/// The X component editor.
@@ -55,23 +68,23 @@ namespace FlaxEditor.CustomEditors.Editors
XElement = grid.FloatValue();
XElement.SetLimits(limit);
XElement.FloatValue.ValueChanged += OnValueChanged;
XElement.FloatValue.SlidingEnd += ClearToken;
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.FloatValue();
YElement.SetLimits(limit);
YElement.FloatValue.ValueChanged += OnValueChanged;
YElement.FloatValue.SlidingEnd += ClearToken;
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
ZElement = grid.FloatValue();
ZElement.SetLimits(limit);
ZElement.FloatValue.ValueChanged += OnValueChanged;
ZElement.FloatValue.SlidingEnd += ClearToken;
ZElement.ValueBox.ValueChanged += OnValueChanged;
ZElement.ValueBox.SlidingEnd += ClearToken;
WElement = grid.FloatValue();
WElement.SetLimits(limit);
WElement.FloatValue.ValueChanged += OnValueChanged;
WElement.FloatValue.SlidingEnd += ClearToken;
WElement.ValueBox.ValueChanged += OnValueChanged;
WElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
@@ -81,11 +94,229 @@ namespace FlaxEditor.CustomEditors.Editors
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding || WElement.IsSliding;
var token = isSliding ? this : null;
var value = new Vector4(
XElement.FloatValue.Value,
YElement.FloatValue.Value,
ZElement.FloatValue.Value,
WElement.FloatValue.Value);
var value = new Float4(XElement.ValueBox.Value, YElement.ValueBox.Value, ZElement.ValueBox.Value, WElement.ValueBox.Value);
object v = Values[0];
if (v is Vector4)
v = (Vector4)value;
else if (v is Float4)
v = (Float4)value;
else if (v is Double4)
v = (Double4)value;
SetValue(v, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = Float4.Zero;
if (Values[0] is Vector4 asVector4)
value = asVector4;
else if (Values[0] is Float4 asFloat4)
value = asFloat4;
else if (Values[0] is Double4 asDouble4)
value = asDouble4;
XElement.ValueBox.Value = value.X;
YElement.ValueBox.Value = value.Y;
ZElement.ValueBox.Value = value.Z;
WElement.ValueBox.Value = value.W;
}
}
}
/// <summary>
/// Default implementation of the inspector used to edit Double4 value type properties.
/// </summary>
[CustomEditor(typeof(Double4)), DefaultEditor]
public class Double4Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected DoubleValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected DoubleValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected DoubleValueElement ZElement;
/// <summary>
/// The W component editor.
/// </summary>
protected DoubleValueElement WElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 4;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.DoubleValue();
XElement.SetLimits(limit);
XElement.ValueBox.ValueChanged += OnValueChanged;
XElement.ValueBox.SlidingEnd += ClearToken;
YElement = grid.DoubleValue();
YElement.SetLimits(limit);
YElement.ValueBox.ValueChanged += OnValueChanged;
YElement.ValueBox.SlidingEnd += ClearToken;
ZElement = grid.DoubleValue();
ZElement.SetLimits(limit);
ZElement.ValueBox.ValueChanged += OnValueChanged;
ZElement.ValueBox.SlidingEnd += ClearToken;
WElement = grid.DoubleValue();
WElement.SetLimits(limit);
WElement.ValueBox.ValueChanged += OnValueChanged;
WElement.ValueBox.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding || WElement.IsSliding;
var token = isSliding ? this : null;
var value = new Double4(XElement.ValueBox.Value, YElement.ValueBox.Value, ZElement.ValueBox.Value, WElement.ValueBox.Value);
object v = Values[0];
if (v is Vector4)
v = (Vector4)value;
else if (v is Float4)
v = (Float4)value;
else if (v is Double4)
v = (Double4)value;
SetValue(v, token);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
// TODO: support different values for ValueBox<T>
}
else
{
var value = Double4.Zero;
if (Values[0] is Vector4 asVector4)
value = asVector4;
else if (Values[0] is Float4 asFloat4)
value = asFloat4;
else if (Values[0] is Double4 asDouble4)
value = asDouble4;
XElement.ValueBox.Value = value.X;
YElement.ValueBox.Value = value.Y;
ZElement.ValueBox.Value = value.Z;
WElement.ValueBox.Value = value.W;
}
}
}
/// <summary>
/// Default implementation of the inspector used to edit Int4 value type properties.
/// </summary>
[CustomEditor(typeof(Int4)), DefaultEditor]
public class Int4Editor : CustomEditor
{
/// <summary>
/// The X component editor.
/// </summary>
protected IntegerValueElement XElement;
/// <summary>
/// The Y component editor.
/// </summary>
protected IntegerValueElement YElement;
/// <summary>
/// The Z component editor.
/// </summary>
protected IntegerValueElement ZElement;
/// <summary>
/// The W component editor.
/// </summary>
protected IntegerValueElement WElement;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
var grid = layout.CustomContainer<UniformGridPanel>();
var gridControl = grid.CustomControl;
gridControl.ClipChildren = false;
gridControl.Height = TextBox.DefaultHeight;
gridControl.SlotsHorizontally = 4;
gridControl.SlotsVertically = 1;
LimitAttribute limit = null;
var attributes = Values.GetAttributes();
if (attributes != null)
{
limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute);
}
XElement = grid.IntegerValue();
XElement.SetLimits(limit);
XElement.IntValue.ValueChanged += OnValueChanged;
XElement.IntValue.SlidingEnd += ClearToken;
YElement = grid.IntegerValue();
YElement.SetLimits(limit);
YElement.IntValue.ValueChanged += OnValueChanged;
YElement.IntValue.SlidingEnd += ClearToken;
ZElement = grid.IntegerValue();
ZElement.SetLimits(limit);
ZElement.IntValue.ValueChanged += OnValueChanged;
ZElement.IntValue.SlidingEnd += ClearToken;
WElement = grid.IntegerValue();
WElement.SetLimits(limit);
WElement.IntValue.ValueChanged += OnValueChanged;
WElement.IntValue.SlidingEnd += ClearToken;
}
private void OnValueChanged()
{
if (IsSetBlocked)
return;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding || WElement.IsSliding;
var token = isSliding ? this : null;
var value = new Int4(XElement.IntValue.Value, YElement.IntValue.Value, ZElement.IntValue.Value, WElement.IntValue.Value);
SetValue(value, token);
}
@@ -100,11 +331,11 @@ namespace FlaxEditor.CustomEditors.Editors
}
else
{
var value = (Vector4)Values[0];
XElement.FloatValue.Value = value.X;
YElement.FloatValue.Value = value.Y;
ZElement.FloatValue.Value = value.Z;
WElement.FloatValue.Value = value.W;
var value = (Int4)Values[0];
XElement.IntValue.Value = value.X;
YElement.IntValue.Value = value.Y;
ZElement.IntValue.Value = value.Z;
WElement.IntValue.Value = value.W;
}
}
}

View File

@@ -17,14 +17,20 @@ namespace FlaxEditor.CustomEditors.Elements
/// <summary>
/// The double value box.
/// </summary>
public readonly DoubleValueBox DoubleValue;
public readonly DoubleValueBox ValueBox;
/// <summary>
/// [Deprecated on 26.05.2022, expires on 26.05.2024]
/// </summary>
[System.Obsolete("Deprecated in 1.4")]
public DoubleValueBox DoubleValue => ValueBox;
/// <summary>
/// Initializes a new instance of the <see cref="FloatValueElement"/> class.
/// </summary>
public DoubleValueElement()
{
DoubleValue = new DoubleValueBox(0);
ValueBox = new DoubleValueBox(0);
}
/// <summary>
@@ -40,7 +46,7 @@ namespace FlaxEditor.CustomEditors.Elements
var limit = attributes.FirstOrDefault(x => x is LimitAttribute);
if (limit != null)
{
DoubleValue.SetLimits((LimitAttribute)limit);
ValueBox.SetLimits((LimitAttribute)limit);
}
}
}
@@ -53,7 +59,7 @@ namespace FlaxEditor.CustomEditors.Elements
{
if (limit != null)
{
DoubleValue.SetLimits(limit);
ValueBox.SetLimits(limit);
}
}
@@ -65,25 +71,25 @@ namespace FlaxEditor.CustomEditors.Elements
{
if (other != null)
{
DoubleValue.SetLimits(other.DoubleValue);
ValueBox.SetLimits(other.ValueBox);
}
}
/// <inheritdoc />
public override Control Control => DoubleValue;
public override Control Control => ValueBox;
/// <summary>
/// Gets or sets the value.
/// </summary>
public double Value
{
get => DoubleValue.Value;
set => DoubleValue.Value = value;
get => ValueBox.Value;
set => ValueBox.Value = value;
}
/// <summary>
/// Gets a value indicating whether user is using a slider.
/// </summary>
public bool IsSliding => DoubleValue.IsSliding;
public bool IsSliding => ValueBox.IsSliding;
}
}

View File

@@ -17,14 +17,20 @@ namespace FlaxEditor.CustomEditors.Elements
/// <summary>
/// The float value box.
/// </summary>
public readonly FloatValueBox FloatValue;
public readonly FloatValueBox ValueBox;
/// <summary>
/// [Deprecated on 26.05.2022, expires on 26.05.2024]
/// </summary>
[System.Obsolete("Deprecated in 1.4")]
public FloatValueBox FloatValue => ValueBox;
/// <summary>
/// Initializes a new instance of the <see cref="FloatValueElement"/> class.
/// </summary>
public FloatValueElement()
{
FloatValue = new FloatValueBox(0);
ValueBox = new FloatValueBox(0);
}
/// <summary>
@@ -40,7 +46,7 @@ namespace FlaxEditor.CustomEditors.Elements
var limit = attributes.FirstOrDefault(x => x is LimitAttribute);
if (limit != null)
{
FloatValue.SetLimits((LimitAttribute)limit);
ValueBox.SetLimits((LimitAttribute)limit);
}
}
}
@@ -53,7 +59,7 @@ namespace FlaxEditor.CustomEditors.Elements
{
if (limit != null)
{
FloatValue.SetLimits(limit);
ValueBox.SetLimits(limit);
}
}
@@ -65,21 +71,21 @@ namespace FlaxEditor.CustomEditors.Elements
{
if (other != null)
{
FloatValue.SetLimits(other.FloatValue);
ValueBox.SetLimits(other.ValueBox);
}
}
/// <inheritdoc />
public override Control Control => FloatValue;
public override Control Control => ValueBox;
/// <inheritdoc />
public float Value
{
get => FloatValue.Value;
set => FloatValue.Value = value;
get => ValueBox.Value;
set => ValueBox.Value = value;
}
/// <inheritdoc />
public bool IsSliding => FloatValue.IsSliding;
public bool IsSliding => ValueBox.IsSliding;
}
}

View File

@@ -28,7 +28,7 @@ namespace FlaxEditor.CustomEditors.Elements
{
Label = new ClickableLabel
{
Size = new Vector2(100, 18),
Size = new Float2(100, 18),
HorizontalAlignment = TextAlignment.Near,
};
// TODO: auto height for label

View File

@@ -31,7 +31,7 @@ namespace FlaxEditor.CustomEditors.GUI
CheckBox = new CheckBox(2, 2)
{
Checked = true,
Size = new Vector2(14),
Size = new Float2(14),
Parent = this
};
CheckBox.StateChanged += OnCheckChanged;

View File

@@ -16,7 +16,7 @@ namespace FlaxEditor.CustomEditors.GUI
/// </summary>
/// <param name="label">The label.</param>
/// <param name="location">The mouse location.</param>
public delegate void MouseDelegate(ClickablePropertyNameLabel label, Vector2 location);
public delegate void MouseDelegate(ClickablePropertyNameLabel label, Float2 location);
/// <summary>
/// The mouse left button clicks on the label.
@@ -45,7 +45,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
// Fire events
if (button == MouseButton.Left)
@@ -69,7 +69,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
// Fire events
if (button == MouseButton.Left)

View File

@@ -33,7 +33,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -45,7 +45,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{

View File

@@ -117,7 +117,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mouseOverSplitter = _splitterRect.Contains(location);
@@ -130,7 +130,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -146,7 +146,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (_splitterClicked)
{

View File

@@ -89,7 +89,7 @@ namespace FlaxEditor.CustomEditors.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Right)
{
@@ -100,7 +100,7 @@ namespace FlaxEditor.CustomEditors.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;

View File

@@ -55,7 +55,7 @@ namespace FlaxEditor.CustomEditors
return element;
}
private void OnGroupPanelMouseButtonRightClicked(DropPanel groupPanel, Vector2 location)
private void OnGroupPanelMouseButtonRightClicked(DropPanel groupPanel, Float2 location)
{
var linkedEditor = (CustomEditor)groupPanel.Tag;
var menu = new ContextMenu();

View File

@@ -1292,43 +1292,43 @@ namespace FlaxEditor
return false;
}
internal void Internal_ScreenToGameViewport(ref Vector2 pos)
internal void Internal_ScreenToGameViewport(ref Float2 pos)
{
if (Windows.GameWin != null && Windows.GameWin.ContainsFocus)
{
var win = Windows.GameWin.Root;
if (win?.RootWindow is WindowRootControl root && root.Window && root.Window.IsFocused)
{
pos = Vector2.Round(Windows.GameWin.Viewport.PointFromScreen(pos) * root.DpiScale);
pos = Float2.Round(Windows.GameWin.Viewport.PointFromScreen(pos) * root.DpiScale);
}
else
{
pos = Vector2.Minimum;
pos = Float2.Minimum;
}
}
else
{
pos = Vector2.Minimum;
pos = Float2.Minimum;
}
}
internal void Internal_GameViewportToScreen(ref Vector2 pos)
internal void Internal_GameViewportToScreen(ref Float2 pos)
{
if (Windows.GameWin != null && Windows.GameWin.ContainsFocus)
{
var win = Windows.GameWin.Root;
if (win?.RootWindow is WindowRootControl root && root.Window && root.Window.IsFocused)
{
pos = Vector2.Round(Windows.GameWin.Viewport.PointToScreen(pos / root.DpiScale));
pos = Float2.Round(Windows.GameWin.Viewport.PointToScreen(pos / root.DpiScale));
}
else
{
pos = Vector2.Minimum;
pos = Float2.Minimum;
}
}
else
{
pos = Vector2.Minimum;
pos = Float2.Minimum;
}
}
@@ -1343,9 +1343,9 @@ namespace FlaxEditor
}
}
internal void Internal_GetGameWindowSize(out Vector2 resultAsRef)
internal void Internal_GetGameWindowSize(out Float2 resultAsRef)
{
resultAsRef = Vector2.Zero;
resultAsRef = Float2.Zero;
var gameWin = Windows.GameWin;
if (gameWin != null)
{
@@ -1359,7 +1359,7 @@ namespace FlaxEditor
else
resultAsRef = gameWin.Size * root.DpiScale;
resultAsRef = Vector2.Round(resultAsRef);
resultAsRef = Float2.Round(resultAsRef);
}
}
}
@@ -1448,7 +1448,7 @@ namespace FlaxEditor
internal static extern bool Internal_CookMeshCollision(string path, CollisionDataType type, IntPtr model, int modelLodIndex, uint materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Internal_GetCollisionWires(IntPtr collisionData, out Vector3[] triangles, out int[] indices);
internal static extern void Internal_GetCollisionWires(IntPtr collisionData, out Float3[] triangles, out int[] indices);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Internal_GetEditorBoxWithChildren(IntPtr obj, out BoundingBox resultAsRef);

View File

@@ -26,8 +26,8 @@ namespace FlaxEditor.GUI
private ScriptType _type;
private bool _isMouseDown;
private Vector2 _mouseDownPos;
private Vector2 _mousePos;
private Float2 _mouseDownPos;
private Float2 _mousePos;
private DragAssets _dragOverElement;
/// <summary>
@@ -180,7 +180,7 @@ namespace FlaxEditor.GUI
/// Initializes a new instance of the <see cref="AssetPicker"/> class.
/// </summary>
public AssetPicker()
: this(new ScriptType(typeof(Asset)), Vector2.Zero)
: this(new ScriptType(typeof(Asset)), Float2.Zero)
{
}
@@ -189,11 +189,11 @@ namespace FlaxEditor.GUI
/// </summary>
/// <param name="assetType">The assets types that this picker accepts.</param>
/// <param name="location">The control location.</param>
public AssetPicker(ScriptType assetType, Vector2 location)
: base(location, new Vector2(DefaultIconSize + ButtonsOffset + ButtonsSize, DefaultIconSize))
public AssetPicker(ScriptType assetType, Float2 location)
: base(location, new Float2(DefaultIconSize + ButtonsOffset + ButtonsSize, DefaultIconSize))
{
_type = assetType;
_mousePos = Vector2.Minimum;
_mousePos = Float2.Minimum;
}
/// <summary>
@@ -207,7 +207,7 @@ namespace FlaxEditor.GUI
private void DoDrag()
{
// Do the drag drop operation if has selected element
if (_selected != null && new Rectangle(Vector2.Zero, Size).Contains(ref _mouseDownPos))
if (_selected != null && new Rectangle(Float2.Zero, Size).Contains(ref _mouseDownPos))
{
DoDragDrop(DragAssets.GetDragData(_selected));
}
@@ -334,7 +334,7 @@ namespace FlaxEditor.GUI
/// <inheritdoc />
public override void OnMouseLeave()
{
_mousePos = Vector2.Minimum;
_mousePos = Float2.Minimum;
// Check if start drag drop
if (_isMouseDown)
@@ -350,21 +350,21 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
_mousePos = location;
_mouseDownPos = Vector2.Minimum;
_mouseDownPos = Float2.Minimum;
base.OnMouseEnter(location);
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
// Check if start drag drop
if (_isMouseDown && Vector2.Distance(location, _mouseDownPos) > 10.0f && IconRect.Contains(_mouseDownPos))
if (_isMouseDown && Float2.Distance(location, _mouseDownPos) > 10.0f && IconRect.Contains(_mouseDownPos))
{
// Do the drag
_isMouseDown = false;
@@ -375,7 +375,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isMouseDown)
{
@@ -422,7 +422,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -435,7 +435,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
// Focus
Focus();
@@ -452,7 +452,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
base.OnDragEnter(ref location, data);
@@ -467,7 +467,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
base.OnDragMove(ref location, data);
@@ -484,7 +484,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
{
base.OnDragDrop(ref location, data);

View File

@@ -32,7 +32,7 @@ namespace FlaxEditor.GUI
public Action RightClick;
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
DoubleClick?.Invoke();
@@ -40,7 +40,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
_leftClick = true;
@@ -51,7 +51,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _leftClick)
{

View File

@@ -389,7 +389,7 @@ namespace FlaxEditor.GUI
_popupMenu.VisibleChanged += cm =>
{
var win = Root;
_blockPopup = win != null && new Rectangle(Vector2.Zero, Size).Contains(PointFromWindow(win.MousePosition));
_blockPopup = win != null && new Rectangle(Float2.Zero, Size).Contains(PointFromWindow(win.MousePosition));
if (!_blockPopup)
Focus();
};
@@ -436,7 +436,7 @@ namespace FlaxEditor.GUI
// Show dropdown list
_popupMenu.MinimumWidth = Width;
_popupMenu.Show(this, new Vector2(1, Height));
_popupMenu.Show(this, new Float2(1, Height));
}
}
@@ -473,7 +473,7 @@ namespace FlaxEditor.GUI
public override void Draw()
{
// 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;
@@ -542,7 +542,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -555,7 +555,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (_mouseDown && !_blockPopup)
{

View File

@@ -341,12 +341,12 @@ namespace FlaxEditor.GUI.ContextMenu
}
/// <inheritdoc />
public override bool ContainsPoint(ref Vector2 location)
public override bool ContainsPoint(ref Float2 location)
{
if (base.ContainsPoint(ref location))
return true;
Vector2 cLocation = location - Location;
var cLocation = location - Location;
for (int i = 0; i < _panel.Children.Count; i++)
{
if (_panel.Children[i].ContainsPoint(ref cLocation))
@@ -380,10 +380,10 @@ namespace FlaxEditor.GUI.ContextMenu
maxWidth = Mathf.Max(maxWidth + 20, MinimumWidth);
// Resize container
Size = new Vector2(Mathf.Ceil(maxWidth), Mathf.Ceil(height));
Size = new Float2(Mathf.Ceil(maxWidth), Mathf.Ceil(height));
// Arrange items view panel
var panelBounds = new Rectangle(Vector2.Zero, Size);
var panelBounds = new Rectangle(Float2.Zero, Size);
_itemsAreaMargin.ShrinkRectangle(ref panelBounds);
_panel.Bounds = panelBounds;

View File

@@ -105,7 +105,7 @@ namespace FlaxEditor.GUI.ContextMenu
/// </summary>
/// <param name="parent">Parent control to attach to it.</param>
/// <param name="location">Popup menu origin location in parent control coordinates.</param>
public virtual void Show(Control parent, Vector2 location)
public virtual void Show(Control parent, Float2 location)
{
Assert.IsNotNull(parent);
@@ -130,12 +130,12 @@ namespace FlaxEditor.GUI.ContextMenu
// Calculate popup direction and initial location (fit on a single monitor)
var dpiScale = parentWin.DpiScale;
Vector2 dpiSize = Size * dpiScale;
Vector2 locationWS = parent.PointToWindow(location);
Vector2 locationSS = parentWin.PointToScreen(locationWS);
Location = Vector2.Zero;
Rectangle monitorBounds = Platform.GetMonitorBounds(locationSS);
Vector2 rightBottomLocationSS = locationSS + dpiSize;
var dpiSize = Size * dpiScale;
var locationWS = parent.PointToWindow(location);
var locationSS = parentWin.PointToScreen(locationWS);
Location = Float2.Zero;
var monitorBounds = Platform.GetMonitorBounds(locationSS);
var rightBottomLocationSS = locationSS + dpiSize;
bool isUp = false, isLeft = false;
if (UseAutomaticDirectionFix)
{
@@ -250,7 +250,7 @@ namespace FlaxEditor.GUI.ContextMenu
/// <param name="child">The child menu.</param>
/// <param name="location">The child menu initial location.</param>
/// <param name="isSubMenu">True if context menu is a normal sub-menu, otherwise it is a custom menu popup linked as child.</param>
public void ShowChild(ContextMenuBase child, Vector2 location, bool isSubMenu = true)
public void ShowChild(ContextMenuBase child, Float2 location, bool isSubMenu = true)
{
// Hide current child
HideChild();
@@ -376,7 +376,7 @@ namespace FlaxEditor.GUI.ContextMenu
{
// Draw background
var style = Style.Current;
var bounds = new Rectangle(Vector2.Zero, Size);
var bounds = new Rectangle(Float2.Zero, Size);
Render2D.FillRectangle(bounds, style.Background);
Render2D.DrawRectangle(bounds, Color.Lerp(style.BackgroundSelected, style.Background, 0.6f));
@@ -384,14 +384,14 @@ namespace FlaxEditor.GUI.ContextMenu
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
base.OnMouseDown(location, button);
return true;
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
base.OnMouseUp(location, button);
return true;

View File

@@ -146,7 +146,7 @@ namespace FlaxEditor.GUI.ContextMenu
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (base.OnMouseDown(location, button))
return true;
@@ -156,7 +156,7 @@ namespace FlaxEditor.GUI.ContextMenu
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (base.OnMouseUp(location, button))
return true;

View File

@@ -47,7 +47,7 @@ namespace FlaxEditor.GUI.ContextMenu
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
base.OnMouseEnter(location);
@@ -61,7 +61,7 @@ namespace FlaxEditor.GUI.ContextMenu
return;
// Hide parent CM popups and set itself as child
parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Vector2(Width, 0)));
parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Float2(Width, 0)));
}
}
}

View File

@@ -53,7 +53,7 @@ namespace FlaxEditor.GUI.ContextMenu
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
ParentContextMenu?.HideChild();

View File

@@ -1,5 +1,10 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#if USE_LARGE_WORLDS
using Real = System.Double;
#else
using Real = System.Single;
#endif
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using FlaxEngine;
// ReSharper disable RedundantAssignment
@@ -51,6 +56,12 @@ namespace FlaxEditor.GUI
IKeyframeAccess<Vector2>,
IKeyframeAccess<Vector3>,
IKeyframeAccess<Vector4>,
IKeyframeAccess<Float2>,
IKeyframeAccess<Float3>,
IKeyframeAccess<Float4>,
IKeyframeAccess<Double2>,
IKeyframeAccess<Double3>,
IKeyframeAccess<Double4>,
IKeyframeAccess<Quaternion>,
IKeyframeAccess<Color32>,
IKeyframeAccess<Color>
@@ -112,7 +123,7 @@ namespace FlaxEditor.GUI
void IKeyframeAccess<double>.SetCurveValue(float curve, ref double value, int component)
{
value = curve;
value = (double)curve;
}
void IKeyframeAccess<float>.GetDefaultValue(out float value)
@@ -132,7 +143,7 @@ namespace FlaxEditor.GUI
void IKeyframeAccess<float>.SetCurveValue(float curve, ref float value, int component)
{
value = curve;
value = (float)curve;
}
void IKeyframeAccess<Vector2>.GetDefaultValue(out Vector2 value)
@@ -147,12 +158,12 @@ namespace FlaxEditor.GUI
float IKeyframeAccess<Vector2>.GetCurveValue(ref Vector2 value, int component)
{
return value[component];
return (float)value[component];
}
void IKeyframeAccess<Vector2>.SetCurveValue(float curve, ref Vector2 value, int component)
{
value[component] = curve;
value[component] = (Real)curve;
}
void IKeyframeAccess<Vector3>.GetDefaultValue(out Vector3 value)
@@ -167,12 +178,12 @@ namespace FlaxEditor.GUI
float IKeyframeAccess<Vector3>.GetCurveValue(ref Vector3 value, int component)
{
return value[component];
return (float)value[component];
}
void IKeyframeAccess<Vector3>.SetCurveValue(float curve, ref Vector3 value, int component)
{
value[component] = curve;
value[component] = (Real)curve;
}
void IKeyframeAccess<Vector4>.GetDefaultValue(out Vector4 value)
@@ -187,10 +198,130 @@ namespace FlaxEditor.GUI
float IKeyframeAccess<Vector4>.GetCurveValue(ref Vector4 value, int component)
{
return value[component];
return (float)value[component];
}
void IKeyframeAccess<Vector4>.SetCurveValue(float curve, ref Vector4 value, int component)
{
value[component] = (Real)curve;
}
void IKeyframeAccess<Float2>.GetDefaultValue(out Float2 value)
{
value = Float2.Zero;
}
int IKeyframeAccess<Float2>.GetCurveComponents()
{
return 2;
}
float IKeyframeAccess<Float2>.GetCurveValue(ref Float2 value, int component)
{
return value[component];
}
void IKeyframeAccess<Float2>.SetCurveValue(float curve, ref Float2 value, int component)
{
value[component] = curve;
}
void IKeyframeAccess<Float3>.GetDefaultValue(out Float3 value)
{
value = Float3.Zero;
}
int IKeyframeAccess<Float3>.GetCurveComponents()
{
return 3;
}
float IKeyframeAccess<Float3>.GetCurveValue(ref Float3 value, int component)
{
return value[component];
}
void IKeyframeAccess<Float3>.SetCurveValue(float curve, ref Float3 value, int component)
{
value[component] = curve;
}
void IKeyframeAccess<Float4>.GetDefaultValue(out Float4 value)
{
value = Float4.Zero;
}
int IKeyframeAccess<Float4>.GetCurveComponents()
{
return 4;
}
float IKeyframeAccess<Float4>.GetCurveValue(ref Float4 value, int component)
{
return value[component];
}
void IKeyframeAccess<Float4>.SetCurveValue(float curve, ref Float4 value, int component)
{
value[component] = curve;
}
void IKeyframeAccess<Double2>.GetDefaultValue(out Double2 value)
{
value = Double2.Zero;
}
int IKeyframeAccess<Double2>.GetCurveComponents()
{
return 2;
}
float IKeyframeAccess<Double2>.GetCurveValue(ref Double2 value, int component)
{
return (float)value[component];
}
void IKeyframeAccess<Double2>.SetCurveValue(float curve, ref Double2 value, int component)
{
value[component] = curve;
}
void IKeyframeAccess<Double3>.GetDefaultValue(out Double3 value)
{
value = Double3.Zero;
}
int IKeyframeAccess<Double3>.GetCurveComponents()
{
return 3;
}
float IKeyframeAccess<Double3>.GetCurveValue(ref Double3 value, int component)
{
return (float)value[component];
}
void IKeyframeAccess<Double3>.SetCurveValue(float curve, ref Double3 value, int component)
{
value[component] = curve;
}
void IKeyframeAccess<Double4>.GetDefaultValue(out Double4 value)
{
value = Double4.Zero;
}
int IKeyframeAccess<Double4>.GetCurveComponents()
{
return 4;
}
float IKeyframeAccess<Double4>.GetCurveValue(ref Double4 value, int component)
{
return (float)value[component];
}
void IKeyframeAccess<Double4>.SetCurveValue(float curve, ref Double4 value, int component)
{
value[component] = curve;
}
@@ -213,7 +344,7 @@ namespace FlaxEditor.GUI
void IKeyframeAccess<Quaternion>.SetCurveValue(float curve, ref Quaternion value, int component)
{
var euler = value.EulerAngles;
euler[component] = curve;
euler[component] = (float)curve;
Quaternion.Euler(euler.X, euler.Y, euler.Z, out value);
}
@@ -234,7 +365,7 @@ namespace FlaxEditor.GUI
void IKeyframeAccess<Color>.SetCurveValue(float curve, ref Color value, int component)
{
value[component] = curve;
value[component] = (float)curve;
}
void IKeyframeAccess<Color32>.GetDefaultValue(out Color32 value)

View File

@@ -58,7 +58,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The function for custom view panning. Gets input movement delta (in curve control space) and returns the renaming input delta to process by curve editor itself.
/// </summary>
public Func<Vector2, Vector2> CustomViewPanning;
public Func<Float2, Float2> CustomViewPanning;
/// <summary>
/// The maximum amount of keyframes to use in a single curve.
@@ -113,12 +113,12 @@ namespace FlaxEditor.GUI
/// <summary>
/// Gets or sets the view offset (via scroll bars).
/// </summary>
public abstract Vector2 ViewOffset { get; set; }
public abstract Float2 ViewOffset { get; set; }
/// <summary>
/// Gets or sets the view scale.
/// </summary>
public abstract Vector2 ViewScale { get; set; }
public abstract Float2 ViewScale { get; set; }
/// <summary>
/// Gets the amount of keyframes added to the curve.
@@ -174,8 +174,8 @@ namespace FlaxEditor.GUI
/// </summary>
public void ResetView()
{
ViewScale = ApplyUseModeMask(EnableZoom, Vector2.One, ViewScale);
ViewOffset = ApplyUseModeMask(EnablePanning, Vector2.Zero, ViewOffset);
ViewScale = ApplyUseModeMask(EnableZoom, Float2.One, ViewScale);
ViewOffset = ApplyUseModeMask(EnablePanning, Float2.Zero, ViewOffset);
UpdateKeyframes();
}
@@ -247,16 +247,16 @@ namespace FlaxEditor.GUI
/// <param name="index">The keyframe index.</param>
/// <param name="component">The keyframe value component index.</param>
/// <returns>The point in time/value space.</returns>
public abstract Vector2 GetKeyframePoint(int index, int component);
public abstract Float2 GetKeyframePoint(int index, int component);
/// <summary>
/// Converts the <see cref="UseMode"/> into the <see cref="Vector2"/> mask.
/// Converts the <see cref="UseMode"/> into the <see cref="Float2"/> mask.
/// </summary>
/// <param name="mode">The mode.</param>
/// <returns>The mask.</returns>
protected static Vector2 GetUseModeMask(UseMode mode)
protected static Float2 GetUseModeMask(UseMode mode)
{
return new Vector2((mode & UseMode.Horizontal) == UseMode.Horizontal ? 1.0f : 0.0f, (mode & UseMode.Vertical) == UseMode.Vertical ? 1.0f : 0.0f);
return new Float2((mode & UseMode.Horizontal) == UseMode.Horizontal ? 1.0f : 0.0f, (mode & UseMode.Vertical) == UseMode.Vertical ? 1.0f : 0.0f);
}
/// <summary>
@@ -266,12 +266,12 @@ namespace FlaxEditor.GUI
/// <param name="value">The value to process.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>The combined value.</returns>
protected static Vector2 ApplyUseModeMask(UseMode mode, Vector2 value, Vector2 defaultValue)
protected static Float2 ApplyUseModeMask(UseMode mode, Float2 value, Float2 defaultValue)
{
return new Vector2(
(mode & UseMode.Horizontal) == UseMode.Horizontal ? value.X : defaultValue.X,
(mode & UseMode.Vertical) == UseMode.Vertical ? value.Y : defaultValue.Y
);
return new Float2(
(mode & UseMode.Horizontal) == UseMode.Horizontal ? value.X : defaultValue.X,
(mode & UseMode.Vertical) == UseMode.Vertical ? value.Y : defaultValue.Y
);
}
/// <inheritdoc />
@@ -290,7 +290,7 @@ namespace FlaxEditor.GUI
public abstract void OnKeyframesDelete(IKeyframesEditor editor);
/// <inheritdoc />
public abstract void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end);
public abstract void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Float2 location, bool start, bool end);
/// <inheritdoc />
public abstract void OnKeyframesCopy(IKeyframesEditor editor, float? timeOffset, System.Text.StringBuilder data);

View File

@@ -22,17 +22,17 @@ namespace FlaxEditor.GUI
private readonly CurveEditor<T> _editor;
internal bool _leftMouseDown;
private bool _rightMouseDown;
internal Vector2 _leftMouseDownPos = Vector2.Minimum;
private Vector2 _rightMouseDownPos = Vector2.Minimum;
private Vector2 _movingViewLastPos;
internal Vector2 _mousePos = Vector2.Minimum;
internal Float2 _leftMouseDownPos = Float2.Minimum;
private Float2 _rightMouseDownPos = Float2.Minimum;
private Float2 _movingViewLastPos;
internal Float2 _mousePos = Float2.Minimum;
internal bool _isMovingSelection;
internal bool _isMovingTangent;
internal bool _movedKeyframes;
private TangentPoint _movingTangent;
private Vector2 _movingSelectionStart;
private Vector2[] _movingSelectionOffsets;
private Vector2 _cmShowPos;
private Float2 _movingSelectionStart;
private Float2[] _movingSelectionOffsets;
private Float2 _cmShowPos;
/// <summary>
/// Initializes a new instance of the <see cref="ContentsBase"/> class.
@@ -65,7 +65,7 @@ namespace FlaxEditor.GUI
_editor.UpdateTangents();
}
internal void OnMoveStart(Vector2 location)
internal void OnMoveStart(Float2 location)
{
// Start moving selected keyframes
_isMovingSelection = true;
@@ -73,13 +73,13 @@ namespace FlaxEditor.GUI
var viewRect = _editor._mainPanel.GetClientArea();
_movingSelectionStart = PointToKeyframes(location, ref viewRect);
if (_movingSelectionOffsets == null || _movingSelectionOffsets.Length != _editor._points.Count)
_movingSelectionOffsets = new Vector2[_editor._points.Count];
_movingSelectionOffsets = new Float2[_editor._points.Count];
for (int i = 0; i < _movingSelectionOffsets.Length; i++)
_movingSelectionOffsets[i] = _editor._points[i].Point - _movingSelectionStart;
_editor.OnEditingStart();
}
internal void OnMove(Vector2 location)
internal void OnMove(Float2 location)
{
var viewRect = _editor._mainPanel.GetClientArea();
var locationKeyframes = PointToKeyframes(location, ref viewRect);
@@ -145,7 +145,7 @@ namespace FlaxEditor.GUI
}
}
internal void OnMoveEnd(Vector2 location)
internal void OnMoveEnd(Float2 location)
{
if (_movedKeyframes)
{
@@ -157,7 +157,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
public override bool IntersectsContent(ref Float2 locationParent, out Float2 location)
{
// Pass all events
location = PointFromParent(ref locationParent);
@@ -165,7 +165,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
_mousePos = location;
@@ -173,7 +173,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
@@ -189,7 +189,7 @@ namespace FlaxEditor.GUI
// Moving view
if (_rightMouseDown)
{
Vector2 delta = location - _movingViewLastPos;
var delta = location - _movingViewLastPos;
if (_editor.CustomViewPanning != null)
delta = _editor.CustomViewPanning(delta);
delta *= GetUseModeMask(_editor.EnablePanning) * _editor.ViewScale;
@@ -273,7 +273,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (base.OnMouseDown(location, button))
{
@@ -403,7 +403,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
_mousePos = location;
@@ -443,7 +443,7 @@ namespace FlaxEditor.GUI
Cursor = CursorType.Default;
// Check if no move has been made at all
if (Vector2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
if (Float2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
{
var selectionCount = _editor.SelectionCount;
var point = GetChildAt(location) as KeyframePoint;
@@ -511,7 +511,7 @@ namespace FlaxEditor.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;
@@ -528,7 +528,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
protected override void SetScaleInternal(ref Vector2 scale)
protected override void SetScaleInternal(ref Float2 scale)
{
base.SetScaleInternal(ref scale);
@@ -541,13 +541,13 @@ namespace FlaxEditor.GUI
/// <param name="point">The point.</param>
/// <param name="curveContentAreaBounds">The curve contents area bounds.</param>
/// <returns>The result.</returns>
private Vector2 PointToKeyframes(Vector2 point, ref Rectangle curveContentAreaBounds)
private Float2 PointToKeyframes(Float2 point, ref Rectangle curveContentAreaBounds)
{
// Contents -> Keyframes
return new Vector2(
(point.X + Location.X) / UnitsPerSecond,
(point.Y + Location.Y - curveContentAreaBounds.Height) / -UnitsPerSecond
);
return new Float2(
(point.X + Location.X) / UnitsPerSecond,
(point.Y + Location.Y - curveContentAreaBounds.Height) / -UnitsPerSecond
);
}
}
@@ -579,7 +579,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
public override void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Float2 location, bool start, bool end)
{
if (SelectionCount == 0)
return;

View File

@@ -39,7 +39,7 @@ namespace FlaxEditor.GUI
{
_editor = editor;
const float width = 340.0f;
Size = new Vector2(width, height);
Size = new Float2(width, height);
var panel1 = new Panel(ScrollBars.Vertical)
{
Bounds = new Rectangle(0, 0.0f, width, height),
@@ -152,7 +152,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// Gets the point time and value on a curve.
/// </summary>
public Vector2 Point => Editor.GetKeyframePoint(Index, Component);
public Float2 Point => Editor.GetKeyframePoint(Index, Component);
/// <summary>
/// Gets the time of the keyframe point.
@@ -162,7 +162,7 @@ namespace FlaxEditor.GUI
/// <inheritdoc />
public override void Draw()
{
var rect = new Rectangle(Vector2.Zero, Size);
var rect = new Rectangle(Float2.Zero, Size);
var color = Editor.ShowCollapsed ? Color.Gray : Editor.Colors[Component];
if (IsSelected)
color = Editor.ContainsFocus ? Color.YellowGreen : Color.Lerp(Color.Gray, Color.YellowGreen, 0.4f);
@@ -172,7 +172,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (base.OnMouseDoubleClick(location, button))
return true;
@@ -249,7 +249,7 @@ namespace FlaxEditor.GUI
var pointPos = PointFromParent(Point.Center);
Render2D.DrawLine(Size * 0.5f, pointPos, Color.Gray);
var rect = new Rectangle(Vector2.Zero, Size);
var rect = new Rectangle(Float2.Zero, Size);
var color = Color.MediumVioletRed;
if (IsMouseOver)
color *= 1.1f;
@@ -278,7 +278,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The keyframes size.
/// </summary>
protected static readonly Vector2 KeyframesSize = new Vector2(7.0f);
protected static readonly Float2 KeyframesSize = new Float2(7.0f);
/// <summary>
/// The colors for the keyframe points.
@@ -330,7 +330,7 @@ namespace FlaxEditor.GUI
protected readonly TangentPoint[] _tangents = new TangentPoint[2];
/// <inheritdoc />
public override Vector2 ViewOffset
public override Float2 ViewOffset
{
get => _mainPanel.ViewOffset;
set
@@ -341,10 +341,10 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override Vector2 ViewScale
public override Float2 ViewScale
{
get => _contents.Scale;
set => _contents.Scale = Vector2.Clamp(value, new Vector2(0.0001f), new Vector2(1000.0f));
set => _contents.Scale = Float2.Clamp(value, new Float2(0.0001f), new Float2(1000.0f));
}
/// <summary>
@@ -520,7 +520,7 @@ namespace FlaxEditor.GUI
/// Adds a new keyframe at the given location (in keyframes space).
/// </summary>
/// <param name="keyframesPos">The new keyframe position (in keyframes space).</param>
protected abstract void AddKeyframe(Vector2 keyframesPos);
protected abstract void AddKeyframe(Float2 keyframesPos);
/// <summary>
/// Sets the keyframe data (internally).
@@ -588,13 +588,13 @@ namespace FlaxEditor.GUI
void Apply();
}
private void EditAllKeyframes(Control control, Vector2 pos)
private void EditAllKeyframes(Control control, Float2 pos)
{
_popup = new Popup(this, new object[] { GetAllKeyframesEditingProxy() }, null, 400.0f);
_popup.Show(control, pos);
}
private void EditKeyframes(Control control, Vector2 pos)
private void EditKeyframes(Control control, Float2 pos)
{
var keyframeIndices = new List<int>();
for (int i = 0; i < _points.Count; i++)
@@ -607,7 +607,7 @@ namespace FlaxEditor.GUI
EditKeyframes(control, pos, keyframeIndices);
}
private void EditKeyframes(Control control, Vector2 pos, List<int> keyframeIndices)
private void EditKeyframes(Control control, Float2 pos, List<int> keyframeIndices)
{
var selection = new object[keyframeIndices.Count];
var keyframes = GetKeyframes();
@@ -730,7 +730,7 @@ namespace FlaxEditor.GUI
/// <param name="point">The point.</param>
/// <param name="curveContentAreaBounds">The curve contents area bounds.</param>
/// <returns>The result.</returns>
protected Vector2 PointToKeyframes(Vector2 point, ref Rectangle curveContentAreaBounds)
protected Float2 PointToKeyframes(Float2 point, ref Rectangle curveContentAreaBounds)
{
// Curve Editor -> Main Panel
point = _mainPanel.PointFromParent(point);
@@ -739,10 +739,10 @@ namespace FlaxEditor.GUI
point = _contents.PointFromParent(point);
// Contents -> Keyframes
return new Vector2(
(point.X + _contents.Location.X) / UnitsPerSecond,
(point.Y + _contents.Location.Y - curveContentAreaBounds.Height) / -UnitsPerSecond
);
return new Float2(
(point.X + _contents.Location.X) / UnitsPerSecond,
(point.Y + _contents.Location.Y - curveContentAreaBounds.Height) / -UnitsPerSecond
);
}
/// <summary>
@@ -751,13 +751,13 @@ namespace FlaxEditor.GUI
/// <param name="point">The point.</param>
/// <param name="curveContentAreaBounds">The curve contents area bounds.</param>
/// <returns>The result.</returns>
protected Vector2 PointFromKeyframes(Vector2 point, ref Rectangle curveContentAreaBounds)
protected Float2 PointFromKeyframes(Float2 point, ref Rectangle curveContentAreaBounds)
{
// Keyframes -> Contents
point = new Vector2(
point.X * UnitsPerSecond - _contents.Location.X,
point.Y * -UnitsPerSecond + curveContentAreaBounds.Height - _contents.Location.Y
);
point = new Float2(
point.X * UnitsPerSecond - _contents.Location.X,
point.Y * -UnitsPerSecond + curveContentAreaBounds.Height - _contents.Location.Y
);
// Contents -> Main Panel
point = _contents.PointToParent(point);
@@ -766,7 +766,7 @@ namespace FlaxEditor.GUI
return _mainPanel.PointToParent(point);
}
private void DrawAxis(Vector2 axis, ref Rectangle viewRect, float min, float max, float pixelRange)
private void DrawAxis(Float2 axis, ref Rectangle viewRect, float min, float max, float pixelRange)
{
int minDistanceBetweenTicks = 20;
int maxDistanceBetweenTicks = 60;
@@ -819,7 +819,7 @@ namespace FlaxEditor.GUI
var lineRect = new Rectangle
(
viewRect.Location + (p - 0.5f) * axis,
Vector2.Lerp(viewRect.Size, Vector2.One, axis)
Float2.Lerp(viewRect.Size, Float2.One, axis)
);
Render2D.FillRectangle(lineRect, _linesColor.AlphaMultiplied(strength));
@@ -854,7 +854,7 @@ namespace FlaxEditor.GUI
}
var style = Style.Current;
var rect = new Rectangle(Vector2.Zero, Size);
var rect = new Rectangle(Float2.Zero, Size);
var viewRect = _mainPanel.GetClientArea();
// Draw background
@@ -869,16 +869,16 @@ namespace FlaxEditor.GUI
var upperLeft = PointToKeyframes(viewRect.Location, ref viewRect);
var bottomRight = PointToKeyframes(viewRect.Size, ref viewRect);
var min = Vector2.Min(upperLeft, bottomRight);
var max = Vector2.Max(upperLeft, bottomRight);
var min = Float2.Min(upperLeft, bottomRight);
var max = Float2.Max(upperLeft, bottomRight);
var pixelRange = (max - min) * ViewScale * UnitsPerSecond;
Render2D.PushClip(ref viewRect);
if ((ShowAxes & UseMode.Vertical) == UseMode.Vertical)
DrawAxis(Vector2.UnitX, ref viewRect, min.X, max.X, pixelRange.X);
DrawAxis(Float2.UnitX, ref viewRect, min.X, max.X, pixelRange.X);
if ((ShowAxes & UseMode.Horizontal) == UseMode.Horizontal)
DrawAxis(Vector2.UnitY, ref viewRect, min.Y, max.Y, pixelRange.Y);
DrawAxis(Float2.UnitY, ref viewRect, min.Y, max.Y, pixelRange.Y);
Render2D.PopClip();
}
@@ -1094,9 +1094,9 @@ namespace FlaxEditor.GUI
/// <param name="k">The keyframe.</param>
/// <param name="component">The keyframe value component index.</param>
/// <returns>The point in time/value space.</returns>
private Vector2 GetKeyframePoint(ref LinearCurve<T>.Keyframe k, int component)
private Float2 GetKeyframePoint(ref LinearCurve<T>.Keyframe k, int component)
{
return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
return new Float2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
}
private void DrawLine(LinearCurve<T>.Keyframe startK, LinearCurve<T>.Keyframe endK, int component, ref Rectangle viewRect)
@@ -1179,7 +1179,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
protected override void AddKeyframe(Vector2 keyframesPos)
protected override void AddKeyframe(Float2 keyframesPos)
{
var k = new LinearCurve<T>.Keyframe
{
@@ -1320,10 +1320,10 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override Vector2 GetKeyframePoint(int index, int component)
public override Float2 GetKeyframePoint(int index, int component)
{
var k = _keyframes[index];
return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
return new Float2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
}
/// <inheritdoc />
@@ -1379,7 +1379,7 @@ namespace FlaxEditor.GUI
var k = _keyframes[p.Index];
var location = GetKeyframePoint(ref k, p.Component);
var point = new Vector2
var point = new Float2
(
location.X * UnitsPerSecond - p.Width * 0.5f,
location.Y * -UnitsPerSecond - p.Height * 0.5f + curveContentAreaBounds.Height
@@ -1388,7 +1388,7 @@ namespace FlaxEditor.GUI
if (_showCollapsed)
{
point.Y = 1.0f;
p.Size = new Vector2(KeyframesSize.X / viewScale.X, Height - 2.0f);
p.Size = new Float2(KeyframesSize.X / viewScale.X, Height - 2.0f);
p.Visible = p.Component == 0;
}
else
@@ -1418,7 +1418,7 @@ namespace FlaxEditor.GUI
}
else if (_contents.Bounds == Rectangle.Empty)
{
_contents.Bounds = Rectangle.Union(bounds, new Rectangle(Vector2.Zero, Vector2.One));
_contents.Bounds = Rectangle.Union(bounds, new Rectangle(Float2.Zero, Float2.One));
}
// Offset the keyframes (parent container changed its location)
@@ -1805,9 +1805,9 @@ namespace FlaxEditor.GUI
/// <param name="k">The keyframe.</param>
/// <param name="component">The keyframe value component index.</param>
/// <returns>The point in time/value space.</returns>
private Vector2 GetKeyframePoint(ref BezierCurve<T>.Keyframe k, int component)
private Float2 GetKeyframePoint(ref BezierCurve<T>.Keyframe k, int component)
{
return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
return new Float2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
}
private void DrawLine(BezierCurve<T>.Keyframe startK, BezierCurve<T>.Keyframe endK, int component, ref Rectangle viewRect)
@@ -1890,7 +1890,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
protected override void AddKeyframe(Vector2 keyframesPos)
protected override void AddKeyframe(Float2 keyframesPos)
{
var k = new BezierCurve<T>.Keyframe
{
@@ -2042,10 +2042,10 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override Vector2 GetKeyframePoint(int index, int component)
public override Float2 GetKeyframePoint(int index, int component)
{
var k = _keyframes[index];
return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
return new Float2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
}
/// <inheritdoc />
@@ -2094,13 +2094,13 @@ namespace FlaxEditor.GUI
// Place keyframes
Rectangle curveContentAreaBounds = _mainPanel.GetClientArea();
var viewScale = ViewScale;
var pointsSize = _showCollapsed ? new Vector2(4.0f / viewScale.X, Height - 2.0f) : KeyframesSize / viewScale;
var pointsSize = _showCollapsed ? new Float2(4.0f / viewScale.X, Height - 2.0f) : KeyframesSize / viewScale;
for (int i = 0; i < _points.Count; i++)
{
var p = _points[i];
var k = _keyframes[p.Index];
var point = GetKeyframePoint(ref k, p.Component);
var location = new Vector2
var location = new Float2
(
point.X * UnitsPerSecond - pointsSize.X * 0.5f,
point.Y * -UnitsPerSecond - pointsSize.Y * 0.5f + curveContentAreaBounds.Height
@@ -2136,7 +2136,7 @@ namespace FlaxEditor.GUI
}
else if (_contents.Bounds == Rectangle.Empty)
{
_contents.Bounds = Rectangle.Union(bounds, new Rectangle(Vector2.Zero, Vector2.One));
_contents.Bounds = Rectangle.Union(bounds, new Rectangle(Float2.Zero, Float2.One));
}
// Offset the keyframes (parent container changed its location)
@@ -2191,7 +2191,7 @@ namespace FlaxEditor.GUI
var offset = 30.0f * direction;
var location = GetKeyframePoint(ref k, selectedComponent);
t.Size = KeyframesSize / ViewScale;
t.Location = new Vector2
t.Location = new Float2
(
location.X * UnitsPerSecond - t.Width * 0.5f + offset,
location.Y * -UnitsPerSecond - t.Height * 0.5f + curveContentAreaBounds.Height - offset * tangent
@@ -2272,8 +2272,8 @@ namespace FlaxEditor.GUI
var offset = (end.X - start.X) * 0.5f;
var p1 = PointFromKeyframes(start, ref viewRect);
var p2 = PointFromKeyframes(start + new Vector2(offset, startTangent * offset), ref viewRect);
var p3 = PointFromKeyframes(end - new Vector2(offset, endTangent * offset), ref viewRect);
var p2 = PointFromKeyframes(start + new Float2(offset, startTangent * offset), ref viewRect);
var p3 = PointFromKeyframes(end - new Float2(offset, endTangent * offset), ref viewRect);
var p4 = PointFromKeyframes(end, ref viewRect);
Render2D.DrawBezier(p1, p2, p3, p4, color);

View File

@@ -111,7 +111,7 @@ namespace FlaxEditor.GUI.Dialogs
// Selector
_cSelector = new ColorSelectorWithSliders(180, 18)
{
Location = new Vector2(PickerMargin, PickerMargin),
Location = new Float2(PickerMargin, PickerMargin),
Parent = this
};
_cSelector.ColorChanged += x => SelectedColor = x;
@@ -166,7 +166,7 @@ namespace FlaxEditor.GUI.Dialogs
_cValue.ValueChanged += OnHSVChanged;
// Set valid dialog size based on UI content
_dialogSize = Size = new Vector2(_cRed.Right + PickerMargin, 300);
_dialogSize = Size = new Float2(_cRed.Right + PickerMargin, 300);
// Hex
const float hexTextBoxWidth = 80;

View File

@@ -84,11 +84,11 @@ namespace FlaxEditor.GUI.Dialogs
/// Updates the color selected by the mouse.
/// </summary>
/// <param name="location">The location.</param>
protected virtual void UpdateMouse(ref Vector2 location)
protected virtual void UpdateMouse(ref Float2 location)
{
if (_isMouseDownWheel)
{
Vector2 delta = location - _wheelRect.Center;
var delta = location - _wheelRect.Center;
float distance = delta.Length;
float degrees;
@@ -171,9 +171,9 @@ namespace FlaxEditor.GUI.Dialogs
Render2D.DrawSprite(_colorWheelSprite, _wheelRect.MakeExpanded(boxExpand), enabled ? Color.White : Color.Gray);
float hAngle = hsv.X * Mathf.DegreesToRadians;
float hRadius = hsv.Y * _wheelRect.Width * 0.5f;
Vector2 hsPos = new Vector2(hRadius * Mathf.Cos(hAngle), -hRadius * Mathf.Sin(hAngle));
var hsPos = new Float2(hRadius * Mathf.Cos(hAngle), -hRadius * Mathf.Sin(hAngle));
const float wheelBoxSize = 4.0f;
Render2D.DrawRectangle(new Rectangle(hsPos - (wheelBoxSize * 0.5f) + _wheelRect.Center, new Vector2(wheelBoxSize)), _isMouseDownWheel ? Color.Gray : Color.Black);
Render2D.DrawRectangle(new Rectangle(hsPos - (wheelBoxSize * 0.5f) + _wheelRect.Center, new Float2(wheelBoxSize)), _isMouseDownWheel ? Color.Gray : Color.Black);
}
/// <inheritdoc />
@@ -185,7 +185,7 @@ namespace FlaxEditor.GUI.Dialogs
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
UpdateMouse(ref location);
@@ -193,7 +193,7 @@ namespace FlaxEditor.GUI.Dialogs
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _wheelRect.Contains(location))
{
@@ -211,7 +211,7 @@ namespace FlaxEditor.GUI.Dialogs
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isMouseDownWheel)
{
@@ -261,11 +261,11 @@ namespace FlaxEditor.GUI.Dialogs
const float slidersMargin = 8.0f;
_slider1Rect = new Rectangle(wheelSize + slidersMargin, 0, slidersThickness, wheelSize);
_slider2Rect = new Rectangle(_slider1Rect.Right + slidersMargin, _slider1Rect.Y, slidersThickness, _slider1Rect.Height);
Size = new Vector2(_slider2Rect.Right, wheelSize);
Size = new Float2(_slider2Rect.Right, wheelSize);
}
/// <inheritdoc />
protected override void UpdateMouse(ref Vector2 location)
protected override void UpdateMouse(ref Float2 location)
{
if (_isMouseDownSlider1)
{
@@ -327,7 +327,7 @@ namespace FlaxEditor.GUI.Dialogs
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _slider1Rect.Contains(location))
{
@@ -346,7 +346,7 @@ namespace FlaxEditor.GUI.Dialogs
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && (_isMouseDownSlider1 || _isMouseDownSlider2))
{

View File

@@ -32,7 +32,7 @@ namespace FlaxEditor.GUI.Dialogs
/// <summary>
/// The dialog size.
/// </summary>
protected Vector2 _dialogSize = new Vector2(300, 100);
protected Float2 _dialogSize = new Float2(300, 100);
/// <summary>
/// Gets the dialog result.

View File

@@ -13,11 +13,11 @@ namespace FlaxEditor.GUI.Docking
{
private FloatWindowDockPanel _toMove;
private Vector2 _dragOffset;
private Vector2 _defaultWindowSize;
private Float2 _dragOffset;
private Float2 _defaultWindowSize;
private Rectangle _rectDock;
private Rectangle _rectWindow;
private Vector2 _mouse;
private Float2 _mouse;
private DockState _toSet;
private DockPanel _toDock;
private bool _lateDragOffsetUpdate;
@@ -42,7 +42,7 @@ namespace FlaxEditor.GUI.Docking
// If the _toMove window was not focused when initializing this window, the result vector only contains zeros
// and to prevent a failure, we need to perform an update for the drag offset at later time which will be done in the OnMouseMove event handler.
if (mouseScreenPosition != Vector2.Zero)
if (mouseScreenPosition != Float2.Zero)
CalculateDragOffset(mouseScreenPosition);
else
_lateDragOffsetUpdate = true;
@@ -103,7 +103,7 @@ namespace FlaxEditor.GUI.Docking
var window = _toMove.Window?.Window;
if (window == null)
return;
Vector2 mouse = FlaxEngine.Input.MouseScreenPosition;
var mouse = FlaxEngine.Input.MouseScreenPosition;
// Move base window
window.Position = mouse - _dragOffset;
@@ -183,8 +183,8 @@ namespace FlaxEditor.GUI.Docking
// Move window to the mouse position (with some offset for caption bar)
var window = (WindowRootControl)toMove.Root;
Vector2 mouse = FlaxEngine.Input.MouseScreenPosition;
window.Window.Position = mouse - new Vector2(8, 8);
var mouse = FlaxEngine.Input.MouseScreenPosition;
window.Window.Position = mouse - new Float2(8, 8);
// Get floating panel
var floatingPanelToMove = window.GetChild(0) as FloatWindowDockPanel;
@@ -225,9 +225,9 @@ namespace FlaxEditor.GUI.Docking
return result;
}
private void CalculateDragOffset(Vector2 mouseScreenPosition)
private void CalculateDragOffset(Float2 mouseScreenPosition)
{
Vector2 baseWinPos = this._toMove.Window.Window.Position;
var baseWinPos = _toMove.Window.Window.Position;
_dragOffset = mouseScreenPosition - baseWinPos;
}
@@ -258,8 +258,8 @@ namespace FlaxEditor.GUI.Docking
_rectDock = _toDock.DockAreaBounds;
// Cache dock rectangles
Vector2 size = _rectDock.Size;
Vector2 offset = _rectDock.Location;
var size = _rectDock.Size;
var offset = _rectDock.Location;
float BorderMargin = 4.0f;
float ProxyHintWindowsSize2 = Proxy.HintWindowsSize * 0.5f;
float centerX = size.X * 0.5f;
@@ -330,7 +330,7 @@ namespace FlaxEditor.GUI.Docking
Proxy.Window.ClientBounds = _rectWindow;
}
private void OnMouseUp(ref Vector2 location, MouseButton button, ref bool handled)
private void OnMouseUp(ref Float2 location, MouseButton button, ref bool handled)
{
if (button == MouseButton.Left)
{
@@ -338,7 +338,7 @@ namespace FlaxEditor.GUI.Docking
}
}
private void OnMouseMove(ref Vector2 mousePos)
private void OnMouseMove(ref Float2 mousePos)
{
// Recalculate the drag offset because the current mouse screen position was invalid when we initialized the window
if (_lateDragOffsetUpdate)
@@ -414,7 +414,7 @@ namespace FlaxEditor.GUI.Docking
/// Initializes the hint window.
/// </summary>
/// <param name="initSize">Initial size of the proxy window.</param>
public static void Init(ref Vector2 initSize)
public static void Init(ref Float2 initSize)
{
if (Window == null)
{
@@ -455,7 +455,7 @@ namespace FlaxEditor.GUI.Docking
var settings = CreateWindowSettings.Default;
settings.Title = name;
settings.Size = new Vector2(HintWindowsSize);
settings.Size = new Float2(HintWindowsSize);
settings.AllowInput = false;
settings.AllowMaximize = false;
settings.AllowMinimize = false;

View File

@@ -123,7 +123,7 @@ namespace FlaxEditor.GUI.Docking
if (parentWin == null)
throw new InvalidOperationException("Missing parent window.");
var control = _tabsProxy != null ? (Control)_tabsProxy : this;
var clientPos = control.PointToWindow(Vector2.Zero);
var clientPos = control.PointToWindow(Float2.Zero);
return new Rectangle(parentWin.PointToScreen(clientPos), control.Size * DpiScale);
}
}
@@ -305,14 +305,14 @@ namespace FlaxEditor.GUI.Docking
/// </summary>
/// <param name="position">Screen space position to test</param>
/// <returns>Dock panel that has been hit or null if nothing found</returns>
public DockPanel HitTest(ref Vector2 position)
public DockPanel HitTest(ref Float2 position)
{
// Get parent window and transform point position into local coordinates system
var parentWin = Root;
if (parentWin == null)
return null;
Vector2 clientPos = parentWin.PointFromScreen(position);
Vector2 localPos = PointFromWindow(clientPos);
var clientPos = parentWin.PointFromScreen(position);
var localPos = PointFromWindow(clientPos);
// Early out
if (localPos.X < 0 || localPos.Y < 0)

View File

@@ -42,7 +42,7 @@ namespace FlaxEditor.GUI.Docking
/// <summary>
/// The mouse position.
/// </summary>
public Vector2 MousePosition = Vector2.Minimum;
public Float2 MousePosition = Float2.Minimum;
/// <summary>
/// The start drag asynchronous window.
@@ -65,7 +65,7 @@ namespace FlaxEditor.GUI.Docking
Offsets = Margin.Zero;
}
private DockWindow GetTabAtPos(Vector2 position, out bool closeButton)
private DockWindow GetTabAtPos(Float2 position, out bool closeButton)
{
DockWindow result = null;
closeButton = false;
@@ -298,13 +298,13 @@ namespace FlaxEditor.GUI.Docking
IsMouseRightButtonDown = false;
IsMouseMiddleButtonDown = false;
MouseDownWindow = null;
MousePosition = Vector2.Minimum;
MousePosition = Float2.Minimum;
base.OnLostFocus();
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
MousePosition = location;
@@ -312,7 +312,7 @@ namespace FlaxEditor.GUI.Docking
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
// Maximize/restore on double click
var tab = GetTabAtPos(location, out _);
@@ -330,7 +330,7 @@ namespace FlaxEditor.GUI.Docking
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
MouseDownWindow = GetTabAtPos(location, out IsMouseDownOverCross);
@@ -359,7 +359,7 @@ namespace FlaxEditor.GUI.Docking
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
// Check tabs under mouse position at the beginning and at the end
var tab = GetTabAtPos(location, out var overCross);
@@ -400,7 +400,7 @@ namespace FlaxEditor.GUI.Docking
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
MousePosition = location;
if (IsMouseLeftButtonDown)
@@ -460,13 +460,13 @@ namespace FlaxEditor.GUI.Docking
}
IsMouseRightButtonDown = false;
IsMouseMiddleButtonDown = false;
MousePosition = Vector2.Minimum;
MousePosition = Float2.Minimum;
base.OnMouseLeave();
}
/// <inheritdoc />
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
{
var result = base.OnDragEnter(ref location, data);
if (result != DragDropEffect.None)
@@ -479,7 +479,7 @@ namespace FlaxEditor.GUI.Docking
}
/// <inheritdoc />
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
{
var result = base.OnDragMove(ref location, data);
if (result != DragDropEffect.None)
@@ -497,7 +497,7 @@ namespace FlaxEditor.GUI.Docking
rect = new Rectangle(0, DockPanel.DefaultHeaderHeight, Width, Height - DockPanel.DefaultHeaderHeight);
}
private bool TrySelectTabUnderLocation(ref Vector2 location)
private bool TrySelectTabUnderLocation(ref Float2 location)
{
var tab = GetTabAtPos(location, out _);
if (tab != null)
@@ -510,7 +510,7 @@ namespace FlaxEditor.GUI.Docking
return false;
}
private void ShowContextMenu(DockWindow tab, ref Vector2 location)
private void ShowContextMenu(DockWindow tab, ref Float2 location)
{
var menu = new ContextMenu.ContextMenu
{

View File

@@ -15,7 +15,7 @@ namespace FlaxEditor.GUI.Docking
public class DockWindow : Panel
{
private string _title;
private Vector2 _titleSize;
private Float2 _titleSize;
/// <summary>
/// The master panel.
@@ -67,7 +67,7 @@ namespace FlaxEditor.GUI.Docking
/// <remarks>
/// Scaled by the DPI, because the window should be large enough for its content on every monitor
/// </remarks>
public virtual Vector2 DefaultSize => new Vector2(900, 580) * DpiScale;
public virtual Float2 DefaultSize => new Float2(900, 580) * DpiScale;
/// <summary>
/// Gets the serialization typename.
@@ -85,7 +85,7 @@ namespace FlaxEditor.GUI.Docking
_title = value;
// Invalidate cached title size
_titleSize = new Vector2(-1);
_titleSize = new Float2(-1);
PerformLayoutBeforeChildren();
// Check if is docked to the floating window and is selected so update window title
@@ -104,7 +104,7 @@ namespace FlaxEditor.GUI.Docking
/// <summary>
/// Gets the size of the title.
/// </summary>
public Vector2 TitleSize => _titleSize;
public Float2 TitleSize => _titleSize;
/// <summary>
/// The input actions collection to processed during user input.
@@ -155,7 +155,7 @@ namespace FlaxEditor.GUI.Docking
/// </summary>
public void ShowFloating()
{
ShowFloating(Vector2.Zero);
ShowFloating(Float2.Zero);
}
/// <summary>
@@ -164,26 +164,26 @@ namespace FlaxEditor.GUI.Docking
/// <param name="position">Window location.</param>
public void ShowFloating(WindowStartPosition position)
{
ShowFloating(Vector2.Zero, position);
ShowFloating(Float2.Zero, position);
}
/// <summary>
/// Shows the window in a floating state.
/// </summary>
/// <param name="size">Window size, set Vector2.Zero to use default.</param>
/// <param name="size">Window size, set <see cref="Float2.Zero"/> to use default.</param>
/// <param name="position">Window location.</param>
public void ShowFloating(Vector2 size, WindowStartPosition position = WindowStartPosition.CenterParent)
public void ShowFloating(Float2 size, WindowStartPosition position = WindowStartPosition.CenterParent)
{
ShowFloating(new Vector2(200, 200), size, position);
ShowFloating(new Float2(200, 200), size, position);
}
/// <summary>
/// Shows the window in a floating state.
/// </summary>
/// <param name="location">Window location.</param>
/// <param name="size">Window size, set Vector2.Zero to use default.</param>
/// <param name="size">Window size, set <see cref="Float2.Zero"/> to use default.</param>
/// <param name="position">Window location.</param>
public void ShowFloating(Vector2 location, Vector2 size, WindowStartPosition position = WindowStartPosition.CenterParent)
public void ShowFloating(Float2 location, Float2 size, WindowStartPosition position = WindowStartPosition.CenterParent)
{
Undock();

View File

@@ -67,7 +67,7 @@ namespace FlaxEditor.GUI.Docking
/// <param name="size">Window client area size.</param>
/// <param name="startPosition">Window start position.</param>
/// <param name="title">Initial window title.</param>
internal static Window CreateFloatWindow(RootControl parent, Vector2 location, Vector2 size, WindowStartPosition startPosition, string title)
internal static Window CreateFloatWindow(RootControl parent, Float2 location, Float2 size, WindowStartPosition startPosition, string title)
{
// Setup initial window settings
var settings = CreateWindowSettings.Default;
@@ -75,8 +75,8 @@ namespace FlaxEditor.GUI.Docking
settings.Title = title;
settings.Size = size;
settings.Position = location;
settings.MinimumSize = new Vector2(1);
settings.MaximumSize = new Vector2(4096);
settings.MinimumSize = new Float2(1);
settings.MaximumSize = new Float2(4096);
settings.Fullscreen = false;
settings.HasBorder = true;
settings.SupportsTransparency = false;

View File

@@ -78,7 +78,7 @@ namespace FlaxEditor.GUI.Docking
/// <param name="position">Screen space position to test.</param>
/// <param name="excluded">Floating window to omit during searching (and all docked to that one).</param>
/// <returns>Dock panel that has been hit or null if nothing found.</returns>
public DockPanel HitTest(ref Vector2 position, FloatWindowDockPanel excluded)
public DockPanel HitTest(ref Float2 position, FloatWindowDockPanel excluded)
{
// Check all floating windows
// TODO: gather windows order and take it into account when performing test

View File

@@ -17,7 +17,7 @@ namespace FlaxEditor.GUI.Drag
/// </summary>
/// <param name="data">The data.</param>
/// <returns>The result.</returns>
public DragDropEffect OnDragEnter( /*ref Vector2 location, */ DragData data)
public DragDropEffect OnDragEnter(DragData data)
{
DragDropEffect effect = DragDropEffect.None;

View File

@@ -52,7 +52,7 @@ namespace FlaxEditor.GUI
/// <param name="location">The source movement location (in source control local space).</param>
/// <param name="start">The movement start flag.</param>
/// <param name="end">The movement end flag.</param>
void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end);
void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Float2 location, bool start, bool end);
/// <summary>
/// Called when keyframes selection should be copied.

View File

@@ -46,7 +46,7 @@ namespace FlaxEditor.GUI
/// <param name="location">The source movement location (in source control local space).</param>
/// <param name="start">The movement start flag.</param>
/// <param name="end">The movement end flag.</param>
void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end);
void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Float2 location, bool start, bool end);
/// <summary>
/// Called when keyframes selection should be copied.

View File

@@ -130,7 +130,7 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
Focus();
OnSubmit();

View File

@@ -164,7 +164,7 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -190,12 +190,12 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
if (_isSliding)
{
// Update sliding
Vector2 slidePosition = location + Root.TrackingMouseOffset;
var slidePosition = location + Root.TrackingMouseOffset;
Value = Mathf.Map(slidePosition.X, 4, TrackSize - 4, Minimum, Maximum);
}
else
@@ -205,7 +205,7 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isSliding)
{
@@ -369,8 +369,8 @@ namespace FlaxEditor.GUI.Input
{
Text = _value.ToString(CultureInfo.InvariantCulture),
Parent = this,
Location = new Vector2(split, 0),
Size = new Vector2(Height, TextBoxSize),
Location = new Float2(split, 0),
Size = new Float2(Height, TextBoxSize),
};
_textBox.EditEnd += OnTextBoxEditEnd;
}

View File

@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI.Input
/// </summary>
protected string _startEditText;
private Vector2 _startSlideLocation;
private Float2 _startSlideLocation;
private double _clickStartTime = -1;
/// <summary>
@@ -192,7 +192,7 @@ namespace FlaxEditor.GUI.Input
{
// Draw overlay
// TODO: render nicer overlay with some glow from the borders (inside)
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), Color.Orange * 0.3f);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), Color.Orange * 0.3f);
}
}
}
@@ -227,7 +227,7 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && CanUseSliding && SlideRect.Contains(location))
{
@@ -247,12 +247,12 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
if (_isSliding)
{
// Update sliding
Vector2 slideLocation = location + Root.TrackingMouseOffset;
var slideLocation = location + Root.TrackingMouseOffset;
ApplySliding(Mathf.RoundToInt(slideLocation.X - _startSlideLocation.X) * _slideSpeed);
return;
}
@@ -261,7 +261,7 @@ namespace FlaxEditor.GUI.Input
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isSliding)
{

View File

@@ -118,7 +118,7 @@ namespace FlaxEditor.GUI
// Overlay
if (IsMouseOver || IsFocused)
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), style.BackgroundHighlighted);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundHighlighted);
// Draw all highlights
if (_highlights != null)
@@ -138,7 +138,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -149,7 +149,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isMouseDown)
{
@@ -200,7 +200,7 @@ namespace FlaxEditor.GUI
public ItemsListContextMenu(float width = 320, float height = 220)
{
// Context menu dimensions
Size = new Vector2(width, height);
Size = new Float2(width, height);
// Search box
_searchBox = new TextBox(false, 1, 1)

View File

@@ -45,7 +45,7 @@ namespace FlaxEditor.GUI
if (_selected != null && _selected.ContextMenu.HasChildren)
{
_selected.ContextMenu.Show(_selected, new Vector2(0, _selected.Height));
_selected.ContextMenu.Show(_selected, new Float2(0, _selected.Height));
_selected.ContextMenu.VisibleChanged += OnSelectedContextMenuVisibleChanged;
}
}
@@ -187,7 +187,7 @@ namespace FlaxEditor.GUI
}
}
private WindowHitCodes OnHitTest(ref Vector2 mouse)
private WindowHitCodes OnHitTest(ref Float2 mouse)
{
var dpiScale = _window.DpiScale;
@@ -286,7 +286,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (base.OnMouseDoubleClick(location, button))
return true;
@@ -314,7 +314,7 @@ namespace FlaxEditor.GUI
{
// Icon
_icon.X = x;
_icon.Size = new Vector2(Height);
_icon.Size = new Float2(Height);
x += _icon.Width;
}
#endif

View File

@@ -76,7 +76,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
Focus();
@@ -87,7 +87,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
base.OnMouseEnter(location);

View File

@@ -55,8 +55,8 @@ namespace FlaxEditor.GUI
var parentSize = Parent.Size;
Bounds = new Rectangle
(
new Vector2(lastToolstripButton.Right + 8.0f, 0),
new Vector2(parentSize.X - X - 8.0f, toolstrip.Height)
new Float2(lastToolstripButton.Right + 8.0f, 0),
new Float2(parentSize.X - X - 8.0f, toolstrip.Height)
);
}
}

View File

@@ -39,7 +39,7 @@ namespace FlaxEditor.GUI
{
// Cache data
var style = Style.Current;
var clientRect = new Rectangle(Vector2.Zero, Size);
var clientRect = new Rectangle(Float2.Zero, Size);
var textRect = new Rectangle(4, 0, clientRect.Width - 4, clientRect.Height);
// Draw background

View File

@@ -95,7 +95,7 @@ namespace FlaxEditor.GUI
};
const float IconSize = 64.0f;
TileSize = new Vector2(IconSize);
TileSize = new Float2(IconSize);
AutoResize = true;
Offsets = new Margin(0, 0, 0, IconSize);

View File

@@ -99,7 +99,7 @@ namespace FlaxEditor.GUI
/// <param name="isValid">Event called to check if a given actor item is valid to be used.</param>
/// <param name="selected">Event called on actor item pick.</param>
/// <returns>The dialog.</returns>
public static ActorSearchPopup Show(Control showTarget, Vector2 showTargetLocation, IsValidDelegate isValid, Action<Actor> selected)
public static ActorSearchPopup Show(Control showTarget, Float2 showTargetLocation, IsValidDelegate isValid, Action<Actor> selected)
{
var popup = new ActorSearchPopup(isValid, selected);
popup.Show(showTarget, showTargetLocation);

View File

@@ -157,7 +157,7 @@ namespace FlaxEditor.GUI
/// <param name="isValid">Event called to check if a given asset item is valid to be used.</param>
/// <param name="selected">Event called on asset item pick.</param>
/// <returns>The dialog.</returns>
public static AssetSearchPopup Show(Control showTarget, Vector2 showTargetLocation, IsValidDelegate isValid, Action<AssetItem> selected)
public static AssetSearchPopup Show(Control showTarget, Float2 showTargetLocation, IsValidDelegate isValid, Action<AssetItem> selected)
{
var popup = new AssetSearchPopup(isValid, selected);
popup.Show(showTarget, showTargetLocation);

View File

@@ -63,7 +63,7 @@ namespace FlaxEditor.GUI
/// <param name="value">The value.</param>
/// <param name="size">The size.</param>
/// <param name="isMultiline">Enable/disable multiline text input support</param>
public RenamePopup(string value, Vector2 size, bool isMultiline)
public RenamePopup(string value, Float2 size, bool isMultiline)
{
if (!isMultiline)
size.Y = TextBox.DefaultHeight;
@@ -117,7 +117,7 @@ namespace FlaxEditor.GUI
var size = bottomRight - upperLeft;
var rename = new RenamePopup(value, size, isMultiline);
rename.Show(control, area.Location + new Vector2(0, (size.Y - rename.Height) * 0.5f));
rename.Show(control, area.Location + new Float2(0, (size.Y - rename.Height) * 0.5f));
return rename;
}

View File

@@ -114,7 +114,7 @@ namespace FlaxEditor.GUI
/// <param name="isValid">Event called to check if a given script item is valid to be used.</param>
/// <param name="selected">Event called on script item pick.</param>
/// <returns>The dialog.</returns>
public static ScriptSearchPopup Show(Control showTarget, Vector2 showTargetLocation, IsValidDelegate isValid, Action<Script> selected)
public static ScriptSearchPopup Show(Control showTarget, Float2 showTargetLocation, IsValidDelegate isValid, Action<Script> selected)
{
var popup = new ScriptSearchPopup(isValid, selected);
popup.Show(showTarget, showTargetLocation);

View File

@@ -111,7 +111,7 @@ namespace FlaxEditor.GUI
/// <param name="isValid">Event called to check if a given asset item is valid to be used.</param>
/// <param name="selected">Event called on asset item pick.</param>
/// <returns>The dialog.</returns>
public static TypeSearchPopup Show(Control showTarget, Vector2 showTargetLocation, IsValidDelegate isValid, Action<ScriptType> selected)
public static TypeSearchPopup Show(Control showTarget, Float2 showTargetLocation, IsValidDelegate isValid, Action<ScriptType> selected)
{
var popup = new TypeSearchPopup(isValid, selected);
popup.Show(showTarget, showTargetLocation);

View File

@@ -36,7 +36,7 @@ namespace FlaxEditor.GUI
public PrefabDiffContextMenu(float width = 280, float height = 260)
{
// Context menu dimensions
Size = new Vector2(width, height);
Size = new Float2(width, height);
// Buttons
float buttonsWidth = (width - 6.0f) * 0.5f;

View File

@@ -47,7 +47,7 @@ namespace FlaxEditor.GUI
if (IsMouseOver)
{
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), style.BackgroundHighlighted * 0.7f);
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundHighlighted * 0.7f);
}
if (Values != null && _table?.Columns != null)
@@ -111,7 +111,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && Values != null && _table?.Columns != null)
{

View File

@@ -114,7 +114,7 @@ namespace FlaxEditor.GUI
-ProgressNormal
*/
var size = new Vector2(r.Width / 7f, r.Height / 2f);
var size = new Float2(r.Width / 7f, r.Height / 2f);
float x = 2;
Render2D.FillRectangle(new Rectangle(x, 2, size), Value.Foreground);
@@ -162,7 +162,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (Value == null)
{

View File

@@ -17,7 +17,7 @@ namespace FlaxEditor.GUI
private ColumnDefinition[] _columns;
private float[] _splits;
private int _movingSplit = -1;
private Vector2 _mousePos;
private Float2 _mousePos;
/// <summary>
/// Gets or sets the height of the table column headers.
@@ -140,7 +140,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -170,7 +170,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
@@ -198,7 +198,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _movingSplit != -1)
{

View File

@@ -1,7 +1,6 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System;
using System.Collections;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -42,7 +41,7 @@ namespace FlaxEditor.GUI.Tabs
/// <param name="index">The tab index.</param>
/// <param name="tab">The tab.</param>
public TabHeader(Tabs tabs, int index, Tab tab)
: base(Vector2.Zero, tabs._tabsSize)
: base(Float2.Zero, tabs._tabsSize)
{
Tabs = tabs;
Index = index;
@@ -50,7 +49,7 @@ namespace FlaxEditor.GUI.Tabs
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
Tabs.SelectedTabIndex = Index;
Tabs.Focus();
@@ -64,7 +63,7 @@ namespace FlaxEditor.GUI.Tabs
// Cache data
var style = Style.Current;
var tabRect = new Rectangle(Vector2.Zero, Size);
var tabRect = new Rectangle(Float2.Zero, Size);
bool isTabSelected = Tabs._selectedIndex == Index;
bool isMouseOverTab = IsMouseOver;
var textOffset = Tabs._orientation == Orientation.Horizontal ? 0 : 8;
@@ -135,9 +134,9 @@ namespace FlaxEditor.GUI.Tabs
// Cache data
var tabsSize = Tabs._tabsSize;
var clientSize = GetClientArea();
tabsSize = Vector2.Min(tabsSize, clientSize.Size);
var tabRect = new Rectangle(Vector2.Zero, tabsSize);
var tabStripOffset = Tabs._orientation == Orientation.Horizontal ? new Vector2(tabsSize.X, 0) : new Vector2(0, tabsSize.Y);
tabsSize = Float2.Min(tabsSize, clientSize.Size);
var tabRect = new Rectangle(Float2.Zero, tabsSize);
var tabStripOffset = Tabs._orientation == Orientation.Horizontal ? new Float2(tabsSize.X, 0) : new Float2(0, tabsSize.Y);
// Arrange tab header controls
for (int i = 0; i < Children.Count; i++)
@@ -159,7 +158,7 @@ namespace FlaxEditor.GUI.Tabs
/// <summary>
/// The tabs size.
/// </summary>
protected Vector2 _tabsSize;
protected Float2 _tabsSize;
/// <summary>
/// The orientation.
@@ -169,19 +168,17 @@ namespace FlaxEditor.GUI.Tabs
/// <summary>
/// Gets the size of the tabs.
/// </summary>
public Vector2 TabsSize
public Float2 TabsSize
{
get => _tabsSize;
set
{
_tabsSize = value;
for (int i = 0; i < TabsPanel.ChildrenCount; i++)
{
if (TabsPanel.Children[i] is TabHeader tabHeader)
tabHeader.Size = value;
}
PerformLayout();
}
}
@@ -293,7 +290,7 @@ namespace FlaxEditor.GUI.Tabs
BackgroundColor = Style.Current.Background;
_selectedIndex = -1;
_tabsSize = new Vector2(70, 16);
_tabsSize = new Float2(70, 16);
_orientation = Orientation.Horizontal;
TabsPanel = new TabsHeader(this);
@@ -375,7 +372,7 @@ namespace FlaxEditor.GUI.Tabs
protected override void PerformLayoutBeforeChildren()
{
// Fit the tabs panel
TabsPanel.Size = _orientation == Orientation.Horizontal ? new Vector2(Width, _tabsSize.Y) : new Vector2(_tabsSize.X, Height);
TabsPanel.Size = _orientation == Orientation.Horizontal ? new Float2(Width, _tabsSize.Y) : new Float2(_tabsSize.X, Height);
// Hide all pages except selected one
var clientArea = _orientation == Orientation.Horizontal

View File

@@ -17,8 +17,8 @@ namespace FlaxEditor.GUI.Timeline.GUI
private float[] _tickSteps;
private float[] _tickStrengths;
private bool _isSelecting;
private Vector2 _selectingStartPos = Vector2.Minimum;
private Vector2 _mousePos = Vector2.Minimum;
private Float2 _selectingStartPos = Float2.Minimum;
private Float2 _mousePos = Float2.Minimum;
/// <summary>
/// Initializes a new instance of the <see cref="Background"/> class.
@@ -38,7 +38,7 @@ namespace FlaxEditor.GUI.Timeline.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;
@@ -59,7 +59,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
_mousePos = location;
if (_isSelecting && button == MouseButton.Left)
@@ -77,7 +77,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
@@ -113,7 +113,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
public override bool IntersectsContent(ref Float2 locationParent, out Float2 location)
{
// Pass all events
location = PointFromParent(ref locationParent);
@@ -142,14 +142,14 @@ namespace FlaxEditor.GUI.Timeline.GUI
var localRectMax = localRect.BottomRight;
// Draw lines between tracks
Render2D.DrawLine(new Vector2(areaLeft, 0.5f), new Vector2(areaRight, 0.5f), linesColor);
Render2D.DrawLine(new Float2(areaLeft, 0.5f), new Float2(areaRight, 0.5f), linesColor);
for (int i = 0; i < tracks.Count; i++)
{
var track = tracks[i];
if (track.Visible)
{
var top = track.Bottom + 0.5f;
Render2D.DrawLine(new Vector2(areaLeft, top), new Vector2(areaRight, top), linesColor);
Render2D.DrawLine(new Float2(areaLeft, top), new Float2(areaRight, top), linesColor);
}
}
@@ -167,8 +167,8 @@ namespace FlaxEditor.GUI.Timeline.GUI
var minDistanceBetweenTicks = 50.0f;
var maxDistanceBetweenTicks = 100.0f;
var zoom = Timeline.UnitsPerSecond * _timeline.Zoom;
var left = Vector2.Min(localRectMin, localRectMax).X;
var right = Vector2.Max(localRectMin, localRectMax).X;
var left = Float2.Min(localRectMin, localRectMax).X;
var right = Float2.Max(localRectMin, localRectMax).X;
var leftFrame = Mathf.Floor((left - Timeline.StartOffset) / zoom) * _timeline.FramesPerSecond;
var rightFrame = Mathf.Ceil((right - Timeline.StartOffset) / zoom) * _timeline.FramesPerSecond;
var min = leftFrame;
@@ -246,7 +246,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
// Darken area outside the duration
{
var outsideDurationAreaColor = new Color(0, 0, 0, 100);
var leftSideMin = PointFromParent(Vector2.Zero);
var leftSideMin = PointFromParent(Float2.Zero);
var leftSideMax = BottomLeft;
var rightSideMin = UpperRight;
var rightSideMax = PointFromParent(Parent.BottomRight) + mediaBackground.ControlsBounds.BottomRight;
@@ -307,7 +307,7 @@ namespace FlaxEditor.GUI.Timeline.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;

View File

@@ -12,7 +12,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
{
private Timeline _timeline;
internal bool _rightMouseButtonDown;
private Vector2 _rightMouseButtonLastPos;
private Float2 _rightMouseButtonLastPos;
private float _rightMouseButtonMovement;
public BackgroundArea(Timeline timeline)
@@ -25,7 +25,7 @@ namespace FlaxEditor.GUI.Timeline.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;
@@ -44,7 +44,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
// Panning timeline view with a right-mouse button
if (_rightMouseButtonDown)
@@ -78,7 +78,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Right && _rightMouseButtonDown)
{

View File

@@ -42,7 +42,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
public class StopControl : Control
{
private bool _isMoving;
private Vector2 _startMovePos;
private Float2 _startMovePos;
private IColorPickerDialog _currentDialog;
/// <summary>
@@ -70,7 +70,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
@@ -86,7 +86,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isMoving)
{
@@ -99,25 +99,25 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnShowTooltip(out string text, out Vector2 location, out Rectangle area)
public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area)
{
// Don't show tooltip is user is moving the stop
return base.OnShowTooltip(out text, out location, out area) && !_isMoving;
}
/// <inheritdoc />
public override bool OnTestTooltipOverControl(ref Vector2 location)
public override bool OnTestTooltipOverControl(ref Float2 location)
{
// Don't show tooltip is user is moving the stop
return base.OnTestTooltipOverControl(ref location) && !_isMoving;
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
if (_isMoving && Vector2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
{
_startMovePos = Vector2.Minimum;
_startMovePos = Float2.Minimum;
var x = PointToParent(location).X;
var frame = (int)((x - Width * 0.5f) / Gradient._scale);
Gradient.SetStopFrame(Index, frame);
@@ -127,7 +127,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (base.OnMouseDoubleClick(location, button))
return true;
@@ -347,7 +347,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
{
AutoFocus = false,
Gradient = this,
Size = new Vector2(10.0f, 10.0f),
Size = new Float2(10.0f, 10.0f),
Parent = this,
};
_stops.Add(stop);
@@ -360,7 +360,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
{
var control = _stops[i];
var stop = _data[i];
control.Location = new Vector2(stop.Frame * scale - control.Width * 0.5f, (height - control.Height) * 0.5f);
control.Location = new Float2(stop.Frame * scale - control.Width * 0.5f, (height - control.Height) * 0.5f);
control.Index = i;
control.TooltipText = stop.Value + " at frame " + stop.Frame;
}
@@ -390,7 +390,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
Render2D.PushClip(ref clientArea);
var style = Style.Current;
var bounds = new Rectangle(Vector2.Zero, Size);
var bounds = new Rectangle(Float2.Zero, Size);
var count = _data.Count;
if (count == 0)
{
@@ -409,7 +409,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
if (prevStop.Frame > 0.0f)
{
Render2D.FillRectangle(new Rectangle(Vector2.Zero, prevStop.Frame * scale, height), prevStop.Value);
Render2D.FillRectangle(new Rectangle(Float2.Zero, prevStop.Frame * scale, height), prevStop.Value);
}
for (int i = 1; i < count; i++)
@@ -435,7 +435,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (base.OnMouseDoubleClick(location, button))
return true;

View File

@@ -79,15 +79,15 @@ namespace FlaxEditor.GUI
private readonly KeyframesEditor _editor;
internal bool _leftMouseDown;
private bool _rightMouseDown;
internal Vector2 _leftMouseDownPos = Vector2.Minimum;
private Vector2 _rightMouseDownPos = Vector2.Minimum;
internal Vector2 _mousePos = Vector2.Minimum;
private Vector2 _movingViewLastPos;
internal Float2 _leftMouseDownPos = Float2.Minimum;
private Float2 _rightMouseDownPos = Float2.Minimum;
internal Float2 _mousePos = Float2.Minimum;
private Float2 _movingViewLastPos;
internal bool _isMovingSelection;
private bool _movedKeyframes;
private float _movingSelectionStart;
private float[] _movingSelectionOffsets;
private Vector2 _cmShowPos;
private Float2 _cmShowPos;
/// <summary>
/// Initializes a new instance of the <see cref="Contents"/> class.
@@ -119,7 +119,7 @@ namespace FlaxEditor.GUI
}
}
internal void OnMoveStart(Vector2 location)
internal void OnMoveStart(Float2 location)
{
// Start moving selected nodes
_isMovingSelection = true;
@@ -133,7 +133,7 @@ namespace FlaxEditor.GUI
_editor.OnEditingStart();
}
internal void OnMove(Vector2 location)
internal void OnMove(Float2 location)
{
var viewRect = _editor._mainPanel.GetClientArea();
var locationKeyframes = PointToKeyframes(location, ref viewRect);
@@ -170,7 +170,7 @@ namespace FlaxEditor.GUI
}
}
internal void OnMoveEnd(Vector2 location)
internal void OnMoveEnd(Float2 location)
{
if (_movedKeyframes)
{
@@ -183,7 +183,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
public override bool IntersectsContent(ref Float2 locationParent, out Float2 location)
{
// Pass all events
location = PointFromParent(ref locationParent);
@@ -191,7 +191,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseEnter(Vector2 location)
public override void OnMouseEnter(Float2 location)
{
_mousePos = location;
@@ -199,7 +199,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
_mousePos = location;
@@ -216,7 +216,7 @@ namespace FlaxEditor.GUI
if (_rightMouseDown)
{
// Calculate delta
Vector2 delta = location - _movingViewLastPos;
Float2 delta = location - _movingViewLastPos;
if (delta.LengthSquared > 0.01f)
{
if (_editor.CustomViewPanning != null)
@@ -272,7 +272,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (base.OnMouseDown(location, button))
{
@@ -371,7 +371,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
_mousePos = location;
@@ -400,7 +400,7 @@ namespace FlaxEditor.GUI
Cursor = CursorType.Default;
// Check if no move has been made at all
if (Vector2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
if (Float2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
{
var selectionCount = _editor.SelectionCount;
var point = GetChildAt(location) as KeyframePoint;
@@ -458,7 +458,7 @@ namespace FlaxEditor.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;
@@ -475,7 +475,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
protected override void SetScaleInternal(ref Vector2 scale)
protected override void SetScaleInternal(ref Float2 scale)
{
base.SetScaleInternal(ref scale);
@@ -488,10 +488,10 @@ namespace FlaxEditor.GUI
/// <param name="point">The point.</param>
/// <param name="keyframesContentAreaBounds">The keyframes contents area bounds.</param>
/// <returns>The result.</returns>
private Vector2 PointToKeyframes(Vector2 point, ref Rectangle keyframesContentAreaBounds)
private Float2 PointToKeyframes(Float2 point, ref Rectangle keyframesContentAreaBounds)
{
// Contents -> Keyframes
return new Vector2(
return new Float2(
(point.X + Location.X) / UnitsPerSecond,
(point.Y + Location.Y - keyframesContentAreaBounds.Height) / -UnitsPerSecond
);
@@ -526,7 +526,7 @@ namespace FlaxEditor.GUI
/// <inheritdoc />
public override void Draw()
{
var rect = new Rectangle(Vector2.Zero, Size);
var rect = new Rectangle(Float2.Zero, Size);
var color = Color.Gray;
if (IsSelected)
color = Editor.ContainsFocus ? Color.YellowGreen : Color.Lerp(Color.Gray, Color.YellowGreen, 0.4f);
@@ -544,7 +544,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (base.OnMouseDoubleClick(location, button))
return true;
@@ -576,7 +576,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The keyframes size.
/// </summary>
private static readonly Vector2 KeyframesSize = new Vector2(7.0f);
private static readonly Float2 KeyframesSize = new Float2(7.0f);
private Contents _contents;
private Panel _mainPanel;
@@ -603,7 +603,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// Gets or sets the view offset (via scroll bars).
/// </summary>
public Vector2 ViewOffset
public Float2 ViewOffset
{
get => _mainPanel.ViewOffset;
set => _mainPanel.ViewOffset = value;
@@ -612,10 +612,10 @@ namespace FlaxEditor.GUI
/// <summary>
/// Gets or sets the view scale.
/// </summary>
public Vector2 ViewScale
public Float2 ViewScale
{
get => _contents.Scale;
set => _contents.Scale = Vector2.Clamp(value, new Vector2(0.0001f), new Vector2(1000.0f));
set => _contents.Scale = Float2.Clamp(value, new Float2(0.0001f), new Float2(1000.0f));
}
/// <summary>
@@ -636,7 +636,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The function for custom view panning. Gets input movement delta (in keyframes editor control space) and returns the renaming input delta to process by keyframes editor itself.
/// </summary>
public Func<Vector2, Vector2> CustomViewPanning;
public Func<Float2, Float2> CustomViewPanning;
/// <summary>
/// The maximum amount of keyframes to use.
@@ -896,7 +896,7 @@ namespace FlaxEditor.GUI
OnEdited();
}
private void AddKeyframe(Vector2 keyframesPos)
private void AddKeyframe(Float2 keyframesPos)
{
var k = new Keyframe
{
@@ -929,7 +929,7 @@ namespace FlaxEditor.GUI
{
_editor = editor;
const float width = 280.0f;
Size = new Vector2(width, height);
Size = new Float2(width, height);
var panel1 = new Panel(ScrollBars.Vertical)
{
Bounds = new Rectangle(0, 0.0f, width, height),
@@ -1032,13 +1032,13 @@ namespace FlaxEditor.GUI
public Keyframe[] Keyframes;
}
private void EditAllKeyframes(Control control, Vector2 pos)
private void EditAllKeyframes(Control control, Float2 pos)
{
_popup = new Popup(this, new object[] { new AllKeyframesProxy { Editor = this, Keyframes = _keyframes.ToArray(), } }, null, 400.0f);
_popup.Show(control, pos);
}
private void EditKeyframes(Control control, Vector2 pos)
private void EditKeyframes(Control control, Float2 pos)
{
var keyframeIndices = new List<int>();
for (int i = 0; i < _points.Count; i++)
@@ -1051,7 +1051,7 @@ namespace FlaxEditor.GUI
EditKeyframes(control, pos, keyframeIndices);
}
private void EditKeyframes(Control control, Vector2 pos, List<int> keyframeIndices)
private void EditKeyframes(Control control, Float2 pos, List<int> keyframeIndices)
{
var selection = new object[keyframeIndices.Count];
for (int i = 0; i < keyframeIndices.Count; i++)
@@ -1130,8 +1130,8 @@ namespace FlaxEditor.GUI
/// </summary>
public void ResetView()
{
ViewScale = Vector2.One;
ViewOffset = Vector2.Zero;
ViewScale = Float2.One;
ViewOffset = Float2.Zero;
UpdateKeyframes();
}
@@ -1156,8 +1156,8 @@ namespace FlaxEditor.GUI
var p = _points[i];
var k = _keyframes[p.Index];
p.Size = new Vector2(4.0f / viewScale.X, Height - 2.0f);
p.Location = new Vector2(k.Time * UnitsPerSecond - p.Width * 0.5f, 1.0f);
p.Size = new Float2(4.0f / viewScale.X, Height - 2.0f);
p.Location = new Float2(k.Time * UnitsPerSecond - p.Width * 0.5f, 1.0f);
p.UpdateTooltip();
}
@@ -1230,7 +1230,7 @@ namespace FlaxEditor.GUI
}
var style = Style.Current;
var rect = new Rectangle(Vector2.Zero, Size);
var rect = new Rectangle(Float2.Zero, Size);
// Draw selection rectangle
if (_contents._leftMouseDown && !_contents._isMovingSelection)
@@ -1344,7 +1344,7 @@ namespace FlaxEditor.GUI
}
/// <inheritdoc />
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Float2 location, bool start, bool end)
{
if (SelectionCount == 0)
return;

View File

@@ -34,7 +34,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset);
Matrix3x3.Multiply(ref m1, ref m2, out var m3);
Render2D.PushTransform(ref m3);
Render2D.DrawSprite(icon, new Rectangle(new Vector2(4, -Width), Size), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground);
Render2D.DrawSprite(icon, new Rectangle(new Float2(4, -Width), Size), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground);
Render2D.PopTransform();
Render2D.FillRectangle(new Rectangle(Width * 0.5f, Height + timeAxisHeaderOffset, 1, _timeline.MediaPanel.Height - timeAxisHeaderOffset - timeAxisOverlap), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground.RGBMultiplied(0.8f));

View File

@@ -14,7 +14,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
{
private Timeline _timeline;
private bool _isMoving;
private Vector2 _startMoveLocation;
private Float2 _startMoveLocation;
private int _startMoveDuration;
private bool _isStart;
private bool _canEdit;
@@ -47,7 +47,7 @@ namespace FlaxEditor.GUI.Timeline.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;
@@ -67,7 +67,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
public override void OnMouseMove(Float2 location)
{
if (_isMoving)
{
@@ -97,7 +97,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
public override bool OnMouseUp(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _isMoving)
{

Some files were not shown because too many files have changed in this diff Show More