Skip to content

Commit

Permalink
Merge pull request #3 from AvaloniaUI/features/begin-move-drag
Browse files Browse the repository at this point in the history
implement begin move drag.
  • Loading branch information
danwalmsley authored Sep 16, 2018
2 parents f790f10 + 8e7f709 commit e6f8076
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
23 changes: 18 additions & 5 deletions src/Avalonia.Native.OSX/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

@interface AvnView : NSView
-(AvnView*) initWithParent: (WindowBaseImpl*) parent;
-(NSEvent*) lastMouseDownEvent;
@end

@interface AvnWindow : NSWindow <NSWindowDelegate>
-(AvnWindow*) initWithParent: (WindowBaseImpl*) parent;
-(void) setCanBecomeKeyAndMain;
@end




class WindowBaseImpl : public ComSingleObject<IAvnWindowBase, &IID_IAvnWindowBase>
{
public:
Expand Down Expand Up @@ -64,6 +62,18 @@ virtual void Invalidate (AvnRect rect)
[View setNeedsDisplayInRect:[View frame]];
}

virtual void BeginMoveDrag ()
{
auto lastEvent = [View lastMouseDownEvent];

if(lastEvent == nullptr)
{
return;
}

[Window performWindowDragWithEvent:lastEvent];
}

protected:
virtual NSWindowStyleMask GetStyle()
{
Expand All @@ -74,8 +84,6 @@ void UpdateStyle()
{
[Window setStyleMask:GetStyle()];
}


};

@implementation AvnView
Expand All @@ -86,6 +94,11 @@ @implementation AvnView
NSEvent* _lastMouseDownEvent;
}

- (NSEvent*) lastMouseDownEvent
{
return _lastMouseDownEvent;
}

-(AvnView*) initWithParent: (WindowBaseImpl*) parent
{
self = [super init];
Expand Down
6 changes: 2 additions & 4 deletions src/Avalonia.Native/WindowImplBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ public void Show()

Action<double> ITopLevelImpl.ScalingChanged { get; set; }



public void SetTopmost(bool value)
{
}
Expand All @@ -197,13 +195,13 @@ public void SetCursor(IPlatformHandle cursor)
{
}



public void Hide()
{
}

public void BeginMoveDrag()
{
_native.BeginMoveDrag();
}

public void BeginResizeDrag(WindowEdge edge)
Expand Down
1 change: 1 addition & 0 deletions src/headers/avalonia-native.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ AVNCOM(IAvnWindowBase, 02) : virtual IUnknown
virtual HRESULT GetClientSize(AvnSize*ret) = 0;
virtual HRESULT Resize(double width, double height) = 0;
virtual void Invalidate (AvnRect rect) = 0;
virtual void BeginMoveDrag () = 0;
};

AVNCOM(IAvnWindow, 03) : virtual IAvnWindowBase
Expand Down

0 comments on commit e6f8076

Please sign in to comment.