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 /// This method is needed for IDE previewer infrastructure
/// </summary> /// </summary>
public static AppBuilder BuildAvaloniaApp() public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>().UseWinit().UseSkia().UseReactiveUI(); => AppBuilder.Configure<App>().UsePlatformDetect().UseSkia().UseReactiveUI();
static void ConsoleSilencer() static void ConsoleSilencer()
{ {

4
samples/ControlCatalog/MainWindow.xaml

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

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

@ -9,17 +9,12 @@ namespace ControlCatalog.Pages
public DialogsPage() public DialogsPage()
{ {
this.InitializeComponent(); 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" Title = "Open file"
}.ShowAsync(GetWindow()); }.ShowAsync(GetWindow());
if(result?.Length == 1)
{
}
}; };
this.FindControl<Button>("SaveFile").Click += delegate this.FindControl<Button>("SaveFile").Click += delegate
{ {

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

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

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

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

66
src/Shared/WindowResizeDragHelper.cs

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

Loading…
Cancel
Save