Commit 2aa39237 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI: call view fixes

Change-Id: I561174a9b114833ba8c501c45c65995fd3b6d5b1
parent fbe1b2f8
This diff is collapsed.
......@@ -34,12 +34,12 @@
[aGradient drawInRect: dirtyRect angle: angle];
}
- (nullable NSView *)hitTest:(NSPoint)point {
NSView *view = [super hitTest:point];
if ([view isKindOfClass:[NSButton class]]) {
return view;
}
return nil;
}
//- (nullable NSView *)hitTest:(NSPoint)point {
// NSView *view = [super hitTest:point];
// if ([view isKindOfClass:[NSButton class]]) {
// return view;
// }
// return nil;
//}
@end
......@@ -66,58 +66,8 @@ BOOL movingToCorner;
self.frame = CGRectMake(newOrigin.x, newOrigin.y, size.width, size.height);
}
- (void)viewDidMoveToWindow {
[self.window setAcceptsMouseMovedEvents:YES];
NSTrackingAreaOptions options = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:self.frame
options:options
owner:self
userInfo:nil];
[self addTrackingArea:area];
}
- (void)mouseEntered:(NSEvent *)event {
if (!movable || movingFromCorner) {
return;
}
CGPoint currentOrigin = self.frame.origin;
CGPoint cornerPoint = [self pointForCorner: self.closestCorner];
if (currentOrigin.x != cornerPoint.x || currentOrigin.y != cornerPoint.y) {
return;
}
movingFromCorner = true;
auto currentSize = self.frame.size;
CGPoint newOrigin = [self pointToMoveFromCorner: self.closestCorner];
auto currentFrame = self.frame;
auto newFrame = currentFrame;
newFrame.origin = newOrigin;
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
context.duration = 0.1f;
context.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
self.animator.frame = newFrame;
} completionHandler:^{
movingFromCorner = false;
}];
}
- (void)mouseExited:(NSEvent *)event {
if(movingToCorner) {
return;
}
CGPoint currentOrigin = self.frame.origin;
CGPoint cornerPoint = [self pointToMoveFromCorner: self.closestCorner];
if ((currentOrigin.x != cornerPoint.x) || (currentOrigin.y != cornerPoint.y)) {
return;
}
movingToCorner = true;
[self moveToCornerWithDuration:0.1];
}
- (void)mouseUp:(NSEvent *)event {
[self moveToCornerWithDuration:0.3];
[self moveToCornerWithDuration:0.2];
}
-(void) moveToCornerWithDuration:(CGFloat) duration {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment