Browse Source

revert changes.

windowing-prototype
Dan Walmsley 7 years ago
parent
commit
ae10682f00
  1. 2
      samples/ControlCatalog.NetCore/Program.cs
  2. 4
      samples/ControlCatalog/MainWindow.xaml
  3. 9
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs
  4. 1
      src/Avalonia.Controls/Primitives/AdornerLayer.cs
  5. 6
      src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs
  6. 66
      src/Shared/WindowResizeDragHelper.cs

2
samples/ControlCatalog.NetCore/Program.cs

@ -37,7 +37,7 @@ namespace ControlCatalog.NetCore
/// This method is needed for IDE previewer infrastructure
/// </summary>
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>().UseWinit().UseSkia().UseReactiveUI();
=> AppBuilder.Configure<App>().UsePlatformDetect().UseSkia().UseReactiveUI();
static void ConsoleSilencer()
{

4
samples/ControlCatalog/MainWindow.xaml

@ -2,7 +2,5 @@
Title="Avalonia Control Gallery"
Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog"
xmlns:local="clr-namespace:ControlCatalog">
<Grid>
<local:MainView/>
</Grid>
<local:MainView/>
</Window>

9
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -9,17 +9,12 @@ namespace ControlCatalog.Pages
public DialogsPage()
{
this.InitializeComponent();
this.FindControl<Button>("OpenFile").Click += async (sender, e)=>
this.FindControl<Button>("OpenFile").Click += delegate
{
var result = await new OpenFileDialog()
new OpenFileDialog()
{
Title = "Open file"
}.ShowAsync(GetWindow());
if(result?.Length == 1)
{
}
};
this.FindControl<Button>("SaveFile").Click += delegate
{

1
src/Avalonia.Controls/Primitives/AdornerLayer.cs

@ -22,7 +22,6 @@ namespace Avalonia.Controls.Primitives
static AdornerLayer()
{
AdornedElementProperty.Changed.Subscribe(AdornedElementChanged);
IsHitTestVisibleProperty.OverrideDefaultValue(typeof(AdornerLayer), false);
}
public AdornerLayer()

6
src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs

@ -61,7 +61,7 @@ namespace Avalonia.Rendering
Render(context, _root, _root.Bounds);
}
if (false)
if (DrawDirtyRects)
{
var color = (uint)new Random().Next(0xffffff) | 0x44000000;
context.FillRectangle(
@ -69,7 +69,7 @@ namespace Avalonia.Rendering
rect);
}
if (true)
if (DrawFps)
{
RenderFps(context.PlatformImpl, _root.Bounds, null);
}
@ -234,7 +234,7 @@ namespace Avalonia.Rendering
var opacity = visual.Opacity;
var clipToBounds = visual.ClipToBounds;
var bounds = new Rect(visual.Bounds.Size);
if (visual.IsVisible && opacity > 0)
{
var m = Matrix.CreateTranslation(visual.Bounds.Position);

66
src/Shared/WindowResizeDragHelper.cs

@ -12,7 +12,6 @@ namespace Avalonia
private readonly Action<Rect> _resize;
private WindowEdge? _edge;
private Point _prevPoint;
private bool _isMove;
public ManagedWindowResizeDragHelper(IWindowBaseImpl window, Action<bool> captureMouse, Action<Rect> resize = null)
{
@ -28,24 +27,15 @@ namespace Avalonia
_edge = edge;
}
public void BeginMoveDrag (Point currentMousePosition)
{
_captureMouse(true);
_prevPoint = currentMousePosition;
_edge = null;
_isMove = true;
}
public bool PreprocessInputEvent(ref RawInputEventArgs e)
{
if (_edge == null && !_isMove)
if (_edge == null)
return false;
if (e is RawMouseEventArgs args)
{
if (args.Type == RawMouseEventType.LeftButtonUp)
{
_edge = null;
_isMove = false;
_captureMouse(false);
}
if (args.Type == RawMouseEventType.Move)
@ -66,46 +56,28 @@ namespace Avalonia
var diff = position - _prevPoint;
var edge = _edge.Value;
var rc = new Rect(_window.Position, _window.ClientSize);
if (_edge == null && _isMove)
if (edge == WindowEdge.East || edge == WindowEdge.NorthEast || edge == WindowEdge.SouthEast)
{
rc = rc.WithX(diff.X).WithY(diff.Y);
if(_resize != null)
{
_resize(rc);
}
else
{
_window.Position = rc.Position;
}
rc = rc.WithWidth(rc.Width + diff.X);
_prevPoint = _prevPoint.WithX(position.X);
}
if (edge == WindowEdge.West || edge == WindowEdge.NorthWest || edge == WindowEdge.SouthWest)
rc = rc.WithX(rc.X + diff.X).WithWidth(rc.Width - diff.X);
if (edge == WindowEdge.South || edge == WindowEdge.SouthWest || edge == WindowEdge.SouthEast)
{
rc = rc.WithHeight(rc.Height + diff.Y);
_prevPoint = _prevPoint.WithY(position.Y);
}
if (edge == WindowEdge.North || edge == WindowEdge.NorthWest || edge == WindowEdge.NorthEast)
rc = rc.WithY(rc.Y + diff.Y).WithHeight(rc.Height - diff.Y);
if (_resize != null)
_resize(rc);
else
{
if (edge == WindowEdge.East || edge == WindowEdge.NorthEast || edge == WindowEdge.SouthEast)
{
rc = rc.WithWidth(rc.Width + diff.X);
_prevPoint = _prevPoint.WithX(position.X);
}
if (edge == WindowEdge.West || edge == WindowEdge.NorthWest || edge == WindowEdge.SouthWest)
rc = rc.WithX(rc.X + diff.X).WithWidth(rc.Width - diff.X);
if (edge == WindowEdge.South || edge == WindowEdge.SouthWest || edge == WindowEdge.SouthEast)
{
rc = rc.WithHeight(rc.Height + diff.Y);
_prevPoint = _prevPoint.WithY(position.Y);
}
if (edge == WindowEdge.North || edge == WindowEdge.NorthWest || edge == WindowEdge.NorthEast)
rc = rc.WithY(rc.Y + diff.Y).WithHeight(rc.Height - diff.Y);
if (_resize != null)
_resize(rc);
else
{
if (_window.Position != rc.Position)
_window.Position = rc.Position;
if (_window.ClientSize != rc.Size)
_window.Resize(rc.Size);
}
if (_window.Position != rc.Position)
_window.Position = rc.Position;
if (_window.ClientSize != rc.Size)
_window.Resize(rc.Size);
}
}
}

Loading…
Cancel
Save