Browse Source

Made test pass.

pull/10/head
Steven Kirk 12 years ago
parent
commit
d0cec392f7
  1. 4
      Perspex.Layout.UnitTests/FullLayoutTests.cs
  2. 9
      Perspex.Layout/LayoutManager.cs
  3. 65
      TestApplication/Program.cs
  4. 12
      Windows/Perspex.Direct2D1/Renderer.cs

4
Perspex.Layout.UnitTests/FullLayoutTests.cs

@ -73,8 +73,8 @@ namespace Perspex.Layout.UnitTests
Assert.IsTrue(horzScroll.IsVisible);
Assert.IsTrue(vertScroll.IsVisible);
Assert.AreEqual(new Size(200, 10), horzScroll.ActualSize);
Assert.AreEqual(new Size(10, 200), vertScroll.ActualSize);
Assert.AreEqual(new Size(190, 10), horzScroll.ActualSize);
Assert.AreEqual(new Size(10, 190), vertScroll.ActualSize);
Assert.AreEqual(new Point(0, 190), Position(horzScroll));
Assert.AreEqual(new Point(190, 0), Position(vertScroll));
}

9
Perspex.Layout/LayoutManager.cs

@ -7,7 +7,6 @@
namespace Perspex.Layout
{
using System;
using System.Linq;
using System.Reactive;
using System.Reactive.Subjects;
using NGenerics.DataStructures.General;
@ -157,14 +156,14 @@ namespace Perspex.Layout
{
if (!item.Control.IsMeasureValid)
{
var control = item.Control;
var parent = item.Control.GetVisualParent<ILayoutable>();
while (!control.PreviousMeasure.HasValue)
while (parent.PreviousMeasure == null)
{
control = (ILayoutable)control.VisualParent;
parent = parent.GetVisualParent<ILayoutable>();
}
control.Measure(control.PreviousMeasure.Value);
parent.Measure(parent.PreviousMeasure.Value);
}
}
}

65
TestApplication/Program.cs

@ -113,49 +113,36 @@ namespace TestApplication
Window window = new Window
{
Title = "Perspex Test Application",
Content = new ScrollViewer
Content = new Grid
{
Width = 200,
Height = 200,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = new Image
RowDefinitions = new RowDefinitions
{
Source = new Bitmap("github_icon.png"),
Width = 400,
Height = 400,
new RowDefinition(1, GridUnitType.Star),
new RowDefinition(GridLength.Auto),
},
Children = new Controls
{
new TabControl
{
Items = new[]
{
ButtonsTab(),
TextTab(),
ImagesTab(),
ListsTab(),
SlidersTab(),
LayoutTab(),
}
},
new TextBlock
{
Text = "Press F12 for Dev Tools",
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(2),
[Grid.RowProperty] = 1,
}
}
},
//Content = new Grid
//{
// RowDefinitions = new RowDefinitions
// {
// new RowDefinition(1, GridUnitType.Star),
// new RowDefinition(GridLength.Auto),
// },
// Children = new Controls
// {
// new TabControl
// {
// Items = new[]
// {
// ButtonsTab(),
// TextTab(),
// ImagesTab(),
// ListsTab(),
// SlidersTab(),
// LayoutTab(),
// }
// },
// new TextBlock
// {
// Text = "Press F12 for Dev Tools",
// HorizontalAlignment = HorizontalAlignment.Right,
// Margin = new Thickness(2),
// [Grid.RowProperty] = 1,
// }
// }
//},
};
DevTools.Attach(window);

12
Windows/Perspex.Direct2D1/Renderer.cs

@ -133,21 +133,11 @@ namespace Perspex.Direct2D1
transform *= Matrix.Translation(visual.Bounds.Position);
//using (context.PushClip(visual.Bounds))
using (context.PushClip(visual.Bounds))
using (context.PushTransform(transform))
{
visual.Render(context);
context.DrawRectange(new Pen(Brushes.Red, 0.5), visual.Bounds);
context.DrawText(Brushes.Red, visual.Bounds, new FormattedText
{
Text = visual.GetType().Name,
FontFamilyName = "Seguo UI",
FontSize = 16,
FontStyle = FontStyle.Normal,
});
foreach (var child in visual.VisualChildren)
{
this.Render(child, context);

Loading…
Cancel
Save