@@ -13,6 +13,7 @@ namespace FlaxEngine.Gizmo;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ViewportRubberBandSelector
|
public class ViewportRubberBandSelector
|
||||||
{
|
{
|
||||||
|
private bool _isMosueCaptured;
|
||||||
private bool _isRubberBandSpanning;
|
private bool _isRubberBandSpanning;
|
||||||
private bool _tryStartRubberBand;
|
private bool _tryStartRubberBand;
|
||||||
private Float2 _cachedStartingMousePosition;
|
private Float2 _cachedStartingMousePosition;
|
||||||
@@ -51,11 +52,15 @@ public class ViewportRubberBandSelector
|
|||||||
/// <returns>Returns true if rubber band is currently spanning</returns>
|
/// <returns>Returns true if rubber band is currently spanning</returns>
|
||||||
public bool ReleaseRubberBandSelection()
|
public bool ReleaseRubberBandSelection()
|
||||||
{
|
{
|
||||||
|
if (_isMosueCaptured)
|
||||||
|
{
|
||||||
|
_isMosueCaptured = false;
|
||||||
|
_owner.Viewport.EndMouseCapture();
|
||||||
|
}
|
||||||
if (_tryStartRubberBand)
|
if (_tryStartRubberBand)
|
||||||
{
|
{
|
||||||
_tryStartRubberBand = false;
|
_tryStartRubberBand = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isRubberBandSpanning)
|
if (_isRubberBandSpanning)
|
||||||
{
|
{
|
||||||
_isRubberBandSpanning = false;
|
_isRubberBandSpanning = false;
|
||||||
@@ -91,6 +96,11 @@ public class ViewportRubberBandSelector
|
|||||||
_rubberBandRect.Height = mousePosition.Y - _cachedStartingMousePosition.Y;
|
_rubberBandRect.Height = mousePosition.Y - _cachedStartingMousePosition.Y;
|
||||||
if (_lastRubberBandRect != _rubberBandRect)
|
if (_lastRubberBandRect != _rubberBandRect)
|
||||||
{
|
{
|
||||||
|
if (!_isMosueCaptured)
|
||||||
|
{
|
||||||
|
_isMosueCaptured = true;
|
||||||
|
_owner.Viewport.StartMouseCapture();
|
||||||
|
}
|
||||||
UpdateRubberBand(ref viewFrustum);
|
UpdateRubberBand(ref viewFrustum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,6 +264,11 @@ public class ViewportRubberBandSelector
|
|||||||
/// <returns>True if rubber band was active before stopping.</returns>
|
/// <returns>True if rubber band was active before stopping.</returns>
|
||||||
public bool StopRubberBand()
|
public bool StopRubberBand()
|
||||||
{
|
{
|
||||||
|
if (_isMosueCaptured)
|
||||||
|
{
|
||||||
|
_isMosueCaptured = false;
|
||||||
|
_owner.Viewport.EndMouseCapture();
|
||||||
|
}
|
||||||
var result = _tryStartRubberBand;
|
var result = _tryStartRubberBand;
|
||||||
_isRubberBandSpanning = false;
|
_isRubberBandSpanning = false;
|
||||||
_tryStartRubberBand = false;
|
_tryStartRubberBand = false;
|
||||||
|
|||||||
@@ -494,8 +494,7 @@ namespace FlaxEditor.Viewport
|
|||||||
{
|
{
|
||||||
base.OnLostFocus();
|
base.OnLostFocus();
|
||||||
|
|
||||||
if (_rubberBandSelector.StopRubberBand())
|
_rubberBandSelector.StopRubberBand();
|
||||||
EndMouseCapture();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -503,8 +502,7 @@ namespace FlaxEditor.Viewport
|
|||||||
{
|
{
|
||||||
base.OnMouseLeave();
|
base.OnMouseLeave();
|
||||||
|
|
||||||
if (_rubberBandSelector.StopRubberBand())
|
_rubberBandSelector.StopRubberBand();
|
||||||
EndMouseCapture();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -620,10 +618,7 @@ namespace FlaxEditor.Viewport
|
|||||||
{
|
{
|
||||||
base.OnLeftMouseButtonDown();
|
base.OnLeftMouseButtonDown();
|
||||||
|
|
||||||
if (_rubberBandSelector.TryStartingRubberBandSelection())
|
_rubberBandSelector.TryStartingRubberBandSelection();
|
||||||
{
|
|
||||||
StartMouseCapture();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -636,8 +631,6 @@ namespace FlaxEditor.Viewport
|
|||||||
// Select rubberbanded rect actor nodes or pick with gizmo
|
// Select rubberbanded rect actor nodes or pick with gizmo
|
||||||
if (!_rubberBandSelector.ReleaseRubberBandSelection())
|
if (!_rubberBandSelector.ReleaseRubberBandSelection())
|
||||||
{
|
{
|
||||||
EndMouseCapture();
|
|
||||||
|
|
||||||
// Try to pick something with the current gizmo
|
// Try to pick something with the current gizmo
|
||||||
Gizmos.Active?.Pick();
|
Gizmos.Active?.Pick();
|
||||||
}
|
}
|
||||||
@@ -648,6 +641,22 @@ namespace FlaxEditor.Viewport
|
|||||||
base.OnLeftMouseButtonUp();
|
base.OnLeftMouseButtonUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||||
|
{
|
||||||
|
if (base.OnMouseUp(location, button))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Handle mouse going up when using rubber band with mouse capture that click up outside the view
|
||||||
|
if (button == MouseButton.Left && !new Rectangle(Float2.Zero, Size).Contains(ref location))
|
||||||
|
{
|
||||||
|
_rubberBandSelector.ReleaseRubberBandSelection();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
|
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user