Browse Source

Standardize IsDefault member in Rect

pull/9590/head
robloo 3 years ago
parent
commit
b8a1aaa329
  1. 2
      src/Avalonia.Base/Media/FormattedText.cs
  2. 2
      src/Avalonia.Base/Media/ImageDrawing.cs
  3. 2
      src/Avalonia.Base/PixelRect.cs
  4. 14
      src/Avalonia.Base/Rect.cs
  5. 6
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs
  6. 6
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionVisual.cs
  7. 2
      src/Avalonia.Base/Rendering/DeferredRenderer.cs
  8. 2
      src/Avalonia.Base/Rendering/DirtyRects.cs
  9. 4
      src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs
  10. 2
      src/Avalonia.Controls/NativeControlHost.cs
  11. 2
      src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositioner.cs
  12. 4
      src/Avalonia.Controls/Repeater/ViewportManager.cs

2
src/Avalonia.Base/Media/FormattedText.cs

@ -1383,7 +1383,7 @@ namespace Avalonia.Media
}
}
if (accumulatedBounds?.PlatformImpl == null || accumulatedBounds.PlatformImpl.Bounds.IsEmpty)
if (accumulatedBounds?.PlatformImpl == null || accumulatedBounds.PlatformImpl.Bounds.IsDefault)
{
return null;
}

2
src/Avalonia.Base/Media/ImageDrawing.cs

@ -42,7 +42,7 @@ namespace Avalonia.Media
var imageSource = ImageSource;
var rect = Rect;
if (imageSource is object && !rect.IsEmpty)
if (imageSource is object && !rect.IsDefault)
{
context.DrawImage(imageSource, rect);
}

2
src/Avalonia.Base/PixelRect.cs

@ -133,7 +133,7 @@ namespace Avalonia
public PixelPoint Center => new PixelPoint(X + (Width / 2), Y + (Height / 2));
/// <summary>
/// Gets a value indicating whether the instance has default values.
/// Gets a value indicating whether the instance has default values (the rectangle is empty).
/// </summary>
public bool IsDefault => Width == 0 && Height == 0;

14
src/Avalonia.Base/Rect.cs

@ -169,12 +169,16 @@ namespace Avalonia
public Point Center => new Point(_x + (_width / 2), _y + (_height / 2));
/// <summary>
/// Gets a value that indicates whether the rectangle is empty.
/// Gets a value indicating whether the instance has default values (the rectangle is empty).
/// </summary>
// ReSharper disable CompareOfFloatsByEqualityOperator
public bool IsEmpty => _width == 0 && _height == 0;
public bool IsDefault => _width == 0 && _height == 0;
// ReSharper restore CompareOfFloatsByEqualityOperator
/// <inheritdoc cref="IsDefault"/>
[Obsolete("Use IsDefault instead.")]
public bool IsEmpty => IsDefault;
/// <summary>
/// Checks for equality between two <see cref="Rect"/>s.
/// </summary>
@ -457,7 +461,7 @@ namespace Avalonia
/// </remarks>
public Rect Normalize()
{
Rect rect = this;
Rect rect = this;
if(double.IsNaN(rect.Right) || double.IsNaN(rect.Bottom) ||
double.IsNaN(rect.X) || double.IsNaN(rect.Y) ||
@ -493,11 +497,11 @@ namespace Avalonia
/// <returns>The union.</returns>
public Rect Union(Rect rect)
{
if (IsEmpty)
if (IsDefault)
{
return rect;
}
else if (rect.IsEmpty)
else if (rect.IsDefault)
{
return this;
}

6
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs

@ -89,7 +89,7 @@ namespace Avalonia.Rendering.Composition.Server
Compositor.UpdateServerTime();
if(_dirtyRect.IsEmpty && !_redrawRequested)
if(_dirtyRect.IsDefault && !_redrawRequested)
return;
Revision++;
@ -117,7 +117,7 @@ namespace Avalonia.Rendering.Composition.Server
_layerSize = layerSize;
}
if (!_dirtyRect.IsEmpty)
if (!_dirtyRect.IsDefault)
{
var visualBrushHelper = new CompositorDrawingContextProxy.VisualBrushRenderer();
using (var context = _layer.CreateDrawingContext(visualBrushHelper))
@ -179,7 +179,7 @@ namespace Avalonia.Rendering.Composition.Server
public void AddDirtyRect(Rect rect)
{
if(rect.IsEmpty)
if(rect.IsDefault)
return;
var snapped = SnapToDevicePixels(rect, Scaling);
DebugEvents?.RectInvalidated(rect);

6
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionVisual.cs

@ -37,7 +37,7 @@ namespace Avalonia.Rendering.Composition.Server
return;
currentTransformedClip = currentTransformedClip.Intersect(_combinedTransformedClipBounds);
if(currentTransformedClip.IsEmpty)
if(currentTransformedClip.IsDefault)
return;
Root!.RenderedVisuals++;
@ -139,7 +139,7 @@ namespace Avalonia.Rendering.Composition.Server
if (ownBounds != _oldOwnContentBounds || positionChanged)
{
_oldOwnContentBounds = ownBounds;
if (ownBounds.IsEmpty)
if (ownBounds.IsDefault)
TransformedOwnContentBounds = default;
else
TransformedOwnContentBounds =
@ -163,7 +163,7 @@ namespace Avalonia.Rendering.Composition.Server
EffectiveOpacity = Opacity * (Parent?.EffectiveOpacity ?? 1);
IsVisibleInFrame = _parent?.IsVisibleInFrame != false && Visible && EffectiveOpacity > 0.04 && !_isBackface &&
!_combinedTransformedClipBounds.IsEmpty;
!_combinedTransformedClipBounds.IsDefault;
if (wasVisible != IsVisibleInFrame || positionChanged)
{

2
src/Avalonia.Base/Rendering/DeferredRenderer.cs

@ -420,7 +420,7 @@ namespace Avalonia.Rendering
{
clipBounds = node.ClipBounds.Intersect(clipBounds);
if (!clipBounds.IsEmpty && node.Opacity > 0)
if (!clipBounds.IsDefault && node.Opacity > 0)
{
var isLayerRoot = node.Visual == layer;

2
src/Avalonia.Base/Rendering/DirtyRects.cs

@ -27,7 +27,7 @@ namespace Avalonia.Rendering
/// </remarks>
public void Add(Rect rect)
{
if (!rect.IsEmpty)
if (!rect.IsDefault)
{
for (var i = 0; i < _rects.Count; ++i)
{

4
src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs

@ -192,14 +192,14 @@ namespace Avalonia.Controls
void OnLayoutUpdated(object sender, EventArgs e)
{
if(!editingCheckBox.Bounds.IsEmpty)
if(!editingCheckBox.Bounds.IsDefault)
{
editingCheckBox.LayoutUpdated -= OnLayoutUpdated;
ProcessPointerArgs();
}
}
if(editingCheckBox.Bounds.IsEmpty)
if(editingCheckBox.Bounds.IsDefault)
{
editingCheckBox.LayoutUpdated += OnLayoutUpdated;
}

2
src/Avalonia.Controls/NativeControlHost.cs

@ -145,7 +145,7 @@ namespace Avalonia.Controls
if (IsEffectivelyVisible && bounds.HasValue)
{
if (bounds.Value.IsEmpty)
if (bounds.Value.IsDefault)
return false;
_attachment?.ShowInBounds(bounds.Value);
}

2
src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositioner.cs

@ -112,7 +112,7 @@ namespace Avalonia.Controls.Primitives.PopupPositioning
?? screens.FirstOrDefault(s => s.Bounds.Intersects(parentGeometry))
?? screens.FirstOrDefault();
if (targetScreen != null && targetScreen.WorkingArea.IsEmpty)
if (targetScreen != null && targetScreen.WorkingArea.IsDefault)
{
return targetScreen.Bounds;
}

4
src/Avalonia.Controls/Repeater/ViewportManager.cs

@ -465,7 +465,7 @@ namespace Avalonia.Controls
_pendingViewportShift = default;
_unshiftableShift = default;
if (_visibleWindow.IsEmpty)
if (_visibleWindow.IsDefault)
{
// We got cleared.
_layoutExtent = default;
@ -551,7 +551,7 @@ namespace Avalonia.Controls
private void TryInvalidateMeasure()
{
// Don't invalidate measure if we have an invalid window.
if (!_visibleWindow.IsEmpty)
if (!_visibleWindow.IsDefault)
{
// We invalidate measure instead of just invalidating arrange because
// we don't invalidate measure in UpdateViewport if the view is changing to

Loading…
Cancel
Save