Fix rubber band drawing to respect DPI scale (eg. on macOS)
This commit is contained in:
@@ -11,7 +11,7 @@ namespace FlaxEngine.Gizmo;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class for adding viewport rubber band selection.
|
/// Class for adding viewport rubber band selection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ViewportRubberBandSelector
|
public sealed class ViewportRubberBandSelector
|
||||||
{
|
{
|
||||||
private bool _isMosueCaptured;
|
private bool _isMosueCaptured;
|
||||||
private bool _isRubberBandSpanning;
|
private bool _isRubberBandSpanning;
|
||||||
@@ -232,30 +232,15 @@ public class ViewportRubberBandSelector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to draw the rubber band. Begins render 2D.
|
/// Draws the ruber band during owner viewport UI drawing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The GPU Context.</param>
|
public void Draw()
|
||||||
/// <param name="target">The GPU texture target.</param>
|
|
||||||
/// <param name="targetDepth">The GPU texture target depth.</param>
|
|
||||||
public void Draw(GPUContext context, GPUTexture target, GPUTexture targetDepth)
|
|
||||||
{
|
|
||||||
// Draw RubberBand for rect selection
|
|
||||||
if (!_isRubberBandSpanning)
|
|
||||||
return;
|
|
||||||
Render2D.Begin(context, target, targetDepth);
|
|
||||||
Draw2D();
|
|
||||||
Render2D.End();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to draw the rubber band. Use if already rendering 2D context.
|
|
||||||
/// </summary>
|
|
||||||
public void Draw2D()
|
|
||||||
{
|
{
|
||||||
if (!_isRubberBandSpanning)
|
if (!_isRubberBandSpanning)
|
||||||
return;
|
return;
|
||||||
Render2D.FillRectangle(_rubberBandRect, Style.Current.Selection);
|
var style = Style.Current;
|
||||||
Render2D.DrawRectangle(_rubberBandRect, Style.Current.SelectionBorder);
|
Render2D.FillRectangle(_rubberBandRect, style.Selection);
|
||||||
|
Render2D.DrawRectangle(_rubberBandRect, style.SelectionBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -375,10 +375,7 @@ namespace FlaxEditor.Viewport
|
|||||||
{
|
{
|
||||||
Gizmos[i].Draw(ref renderContext);
|
Gizmos[i].Draw(ref renderContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw RubberBand for rect selection
|
|
||||||
_rubberBandSelector.Draw(context, target, targetDepth);
|
|
||||||
|
|
||||||
// Draw selected objects debug shapes and visuals
|
// Draw selected objects debug shapes and visuals
|
||||||
if (DrawDebugDraw && (renderContext.View.Flags & ViewFlags.DebugDraw) == ViewFlags.DebugDraw)
|
if (DrawDebugDraw && (renderContext.View.Flags & ViewFlags.DebugDraw) == ViewFlags.DebugDraw)
|
||||||
{
|
{
|
||||||
@@ -594,6 +591,15 @@ namespace FlaxEditor.Viewport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
base.Draw();
|
||||||
|
|
||||||
|
// Draw rubber band for rectangle selection
|
||||||
|
_rubberBandSelector.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OrientViewport(ref Quaternion orientation)
|
protected override void OrientViewport(ref Quaternion orientation)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user