Browse Source

Removed ActualSize property - use Bounds instead.

pull/39/head
Steven Kirk 12 years ago
parent
commit
c27ddbb17c
  1. 2
      Perspex.Controls/Border.cs
  2. 2
      Perspex.Controls/Control.cs
  3. 4
      Perspex.Controls/Image.cs
  4. 2
      Perspex.Controls/Popup.cs
  5. 2
      Perspex.Controls/Primitives/TemplatedControl.cs
  6. 4
      Perspex.Controls/Primitives/Track.cs
  7. 6
      Perspex.Controls/Shapes/Ellipse.cs
  8. 6
      Perspex.Controls/Shapes/Rectangle.cs
  9. 2
      Perspex.Controls/TextBlock.cs
  10. 12
      Perspex.Layout/Layoutable.cs
  11. 21
      Perspex.SceneGraph/Visual.cs
  12. 2
      Perspex.Themes.Default/DropDownStyle.cs
  13. 16
      Tests/Perspex.Layout.UnitTests/FullLayoutTests.cs

2
Perspex.Controls/Border.cs

@ -51,7 +51,7 @@ namespace Perspex.Controls
Brush background = this.Background;
Brush borderBrush = this.BorderBrush;
double borderThickness = this.BorderThickness;
Rect rect = new Rect(this.ActualSize).Deflate(this.BorderThickness / 2);
Rect rect = new Rect(this.Bounds.Size).Deflate(this.BorderThickness / 2);
if (background != null)
{

2
Perspex.Controls/Control.cs

@ -170,7 +170,7 @@ namespace Perspex.Controls
public void BringIntoView()
{
this.BringIntoView(new Rect(this.ActualSize));
this.BringIntoView(new Rect(this.Bounds.Size));
}
public void BringIntoView(Rect rect)

4
Perspex.Controls/Image.cs

@ -36,9 +36,9 @@ namespace Perspex.Controls
if (source != null)
{
Rect viewPort = new Rect(this.ActualSize);
Rect viewPort = new Rect(this.Bounds.Size);
Size sourceSize = new Size(source.PixelWidth, source.PixelHeight);
Vector scale = CalculateScaling(this.ActualSize, sourceSize, this.Stretch);
Vector scale = CalculateScaling(this.Bounds.Size, sourceSize, this.Stretch);
Size scaledSize = sourceSize * scale;
Rect destRect = viewPort
.CenterIn(new Rect(scaledSize))

2
Perspex.Controls/Popup.cs

@ -132,7 +132,7 @@ namespace Perspex.Controls
{
if (this.PlacementTarget != null)
{
return this.PlacementTarget.PointToScreen(new Point(0, this.PlacementTarget.ActualSize.Height));
return this.PlacementTarget.PointToScreen(new Point(0, this.PlacementTarget.Bounds.Size.Height));
}
else
{

2
Perspex.Controls/Primitives/TemplatedControl.cs

@ -151,7 +151,7 @@ namespace Perspex.Controls.Primitives
if (child != null)
{
child.Arrange(new Rect(finalSize));
return child.ActualSize;
return child.Bounds.Size;
}
else
{

4
Perspex.Controls/Primitives/Track.cs

@ -154,11 +154,11 @@ namespace Perspex.Controls.Primitives
if (this.Orientation == Orientation.Horizontal)
{
offset = e.Vector.X / ((this.ActualSize.Width - this.Thumb.ActualSize.Width) / range);
offset = e.Vector.X / ((this.Bounds.Size.Width - this.Thumb.Bounds.Size.Width) / range);
}
else
{
offset = e.Vector.Y * (range / (this.ActualSize.Height - this.Thumb.ActualSize.Height));
offset = e.Vector.Y * (range / (this.Bounds.Size.Height - this.Thumb.Bounds.Size.Height));
}
if (!double.IsNaN(offset) && !double.IsInfinity(offset))

6
Perspex.Controls/Shapes/Ellipse.cs

@ -18,12 +18,12 @@ namespace Perspex.Controls.Shapes
{
get
{
if (this.geometry == null || this.geometrySize != this.ActualSize)
if (this.geometry == null || this.geometrySize != this.Bounds.Size)
{
var rect = new Rect(0, 0, this.ActualSize.Width, this.ActualSize.Height);
var rect = new Rect(0, 0, this.Bounds.Size.Width, this.Bounds.Size.Height);
rect = rect.Deflate(this.StrokeThickness / 2);
this.geometry = new EllipseGeometry(rect);
this.geometrySize = this.ActualSize;
this.geometrySize = this.Bounds.Size;
}
return this.geometry;

6
Perspex.Controls/Shapes/Rectangle.cs

@ -18,10 +18,10 @@ namespace Perspex.Controls.Shapes
{
get
{
if (this.geometry == null || this.geometrySize != this.ActualSize)
if (this.geometry == null || this.geometrySize != this.Bounds.Size)
{
this.geometry = new RectangleGeometry(new Rect(0, 0, this.ActualSize.Width, this.ActualSize.Height));
this.geometrySize = this.ActualSize;
this.geometry = new RectangleGeometry(new Rect(0, 0, this.Bounds.Size.Width, this.Bounds.Size.Height));
this.geometrySize = this.Bounds.Size;
}
return this.geometry;

2
Perspex.Controls/TextBlock.cs

@ -120,7 +120,7 @@ namespace Perspex.Controls
if (background != null)
{
context.FillRectange(background, new Rect(this.ActualSize));
context.FillRectange(background, new Rect(this.Bounds.Size));
}
context.DrawText(this.Foreground, new Point(), this.FormattedText);

12
Perspex.Layout/Layoutable.cs

@ -29,9 +29,6 @@ namespace Perspex.Layout
public class Layoutable : Visual, ILayoutable, IEnableLogger
{
public static readonly PerspexProperty<Size> ActualSizeProperty =
PerspexProperty.Register<Layoutable, Size>("ActualSize");
public static readonly PerspexProperty<double> WidthProperty =
PerspexProperty.Register<Layoutable, double>("Width", double.NaN);
@ -131,11 +128,6 @@ namespace Perspex.Layout
set { this.SetValue(VerticalAlignmentProperty, value); }
}
public Size ActualSize
{
get { return this.GetValue(ActualSizeProperty); }
}
public Size? DesiredSize
{
get;
@ -327,9 +319,7 @@ namespace Perspex.Layout
break;
}
var bounds = new Rect(originX, originY, size.Width, size.Height);
this.SetVisualBounds(bounds);
this.SetValue(ActualSizeProperty, bounds.Size);
this.Bounds = new Rect(originX, originY, size.Width, size.Height);
}
}

21
Perspex.SceneGraph/Visual.cs

@ -21,6 +21,9 @@ namespace Perspex
public class Visual : Animatable, IVisual
{
public static readonly PerspexProperty<Rect> BoundsProperty =
PerspexProperty.Register<Visual, Rect>("Bounds");
public static readonly PerspexProperty<bool> ClipToBoundsProperty =
PerspexProperty.Register<Visual, bool>("ClipToBounds");
@ -36,8 +39,6 @@ namespace Perspex
public static readonly PerspexProperty<Origin> TransformOriginProperty =
PerspexProperty.Register<Visual, Origin>("TransformOrigin", defaultValue: Origin.Default);
private Rect bounds;
private PerspexList<IVisual> visualChildren;
private Visual visualParent;
@ -54,6 +55,12 @@ namespace Perspex
this.visualChildren.CollectionChanged += this.VisualChildrenChanged;
}
public Rect Bounds
{
get { return this.GetValue(BoundsProperty); }
protected set { this.SetValue(BoundsProperty, value); }
}
public bool ClipToBounds
{
get { return this.GetValue(ClipToBoundsProperty); }
@ -84,11 +91,6 @@ namespace Perspex
set { this.SetValue(TransformOriginProperty, value); }
}
Rect IVisual.Bounds
{
get { return this.bounds; }
}
IPerspexReadOnlyList<IVisual> IVisual.VisualChildren
{
get { return this.visualChildren; }
@ -173,11 +175,6 @@ namespace Perspex
}
}
protected void SetVisualBounds(Rect bounds)
{
this.bounds = bounds;
}
protected virtual void OnAttachedToVisualTree(IRenderRoot root)
{
}

2
Perspex.Themes.Default/DropDownStyle.cs

@ -99,7 +99,7 @@ namespace Perspex.Themes.Default
PlacementTarget = control,
StaysOpen = false,
[~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty],
[~Popup.MinWidthProperty] = control[~DropDown.ActualSizeProperty].Cast<Size>().Select(x => (object)x.Width),
[~Popup.MinWidthProperty] = control[~DropDown.BoundsProperty].Cast<Rect>().Select(x => (object)x.Width),
}
},
},

16
Tests/Perspex.Layout.UnitTests/FullLayoutTests.cs

@ -57,11 +57,11 @@ namespace Perspex.Layout.UnitTests
window.LayoutManager.ExecuteLayoutPass();
Assert.Equal(new Size(400, 400), border.ActualSize);
Assert.Equal(new Size(400, 400), border.Bounds.Size);
textBlock.Width = 200;
window.LayoutManager.ExecuteLayoutPass();
Assert.Equal(new Size(200, 400), border.ActualSize);
Assert.Equal(new Size(200, 400), border.Bounds.Size);
}
}
@ -97,10 +97,10 @@ namespace Perspex.Layout.UnitTests
window.LayoutManager.ExecuteLayoutPass();
Assert.Equal(new Size(800, 600), window.ActualSize);
Assert.Equal(new Size(200, 200), scrollViewer.ActualSize);
Assert.Equal(new Size(800, 600), window.Bounds.Size);
Assert.Equal(new Size(200, 200), scrollViewer.Bounds.Size);
Assert.Equal(new Point(300, 200), Position(scrollViewer));
Assert.Equal(new Size(400, 400), textBlock.ActualSize);
Assert.Equal(new Size(400, 400), textBlock.Bounds.Size);
var scrollBars = scrollViewer.GetTemplateChildren().OfType<ScrollBar>().ToList();
var presenters = scrollViewer.GetTemplateChildren().OfType<ScrollContentPresenter>().ToList();
@ -109,15 +109,15 @@ namespace Perspex.Layout.UnitTests
Assert.Equal(1, presenters.Count);
var presenter = presenters[0];
Assert.Equal(new Size(190, 190), presenter.ActualSize);
Assert.Equal(new Size(190, 190), presenter.Bounds.Size);
var horzScroll = scrollBars.Single(x => x.Orientation == Orientation.Horizontal);
var vertScroll = scrollBars.Single(x => x.Orientation == Orientation.Vertical);
Assert.True(horzScroll.IsVisible);
Assert.True(vertScroll.IsVisible);
Assert.Equal(new Size(190, 10), horzScroll.ActualSize);
Assert.Equal(new Size(10, 190), vertScroll.ActualSize);
Assert.Equal(new Size(190, 10), horzScroll.Bounds.Size);
Assert.Equal(new Size(10, 190), vertScroll.Bounds.Size);
Assert.Equal(new Point(0, 190), Position(horzScroll));
Assert.Equal(new Point(190, 0), Position(vertScroll));
}

Loading…
Cancel
Save