]> git.sesse.net Git - vlc/commitdiff
macosx: re-write the resize control used in the black window style to use the MouseDo...
authorFelix Paul Kühne <fkuehne@videolan.org>
Sat, 11 Feb 2012 14:25:34 +0000 (15:25 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sat, 11 Feb 2012 14:25:34 +0000 (15:25 +0100)
modules/gui/macosx/MainWindowTitle.m

index e01c6f11b5ad0d759ec685d7c28c1a3c82c8f98e..b5bfa976daccd3de7db6ae69e852d63507e4ba3a 100644 (file)
 
 @implementation VLCResizeControl
 
-- (void)mouseDragged:(NSEvent *)theEvent
-{
-    NSRect windowFrame = [[self window] frame];
-    CGFloat deltaX, deltaY, oldOriginY;
-    deltaX = [theEvent deltaX];
-    deltaY = [theEvent deltaY];
-    oldOriginY = windowFrame.origin.y;
-
-    windowFrame.origin.y = (oldOriginY + windowFrame.size.height) - (windowFrame.size.height + deltaY);
-    windowFrame.size.width += deltaX;
-    windowFrame.size.height += deltaY;
-
-    NSSize winMinSize = [self window].minSize;
-    if (windowFrame.size.width < winMinSize.width)
-        windowFrame.size.width = winMinSize.width;
+- (void)mouseDown:(NSEvent *)theEvent {
+    BOOL keepOn = YES;
+
+    while (keepOn) {
+        theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |
+                    NSLeftMouseDraggedMask];
+
+        switch ([theEvent type]) {
+            case NSLeftMouseDragged:
+            {
+                NSRect windowFrame = [[self window] frame];
+                CGFloat deltaX, deltaY, oldOriginY;
+                deltaX = [theEvent deltaX];
+                deltaY = [theEvent deltaY];
+                oldOriginY = windowFrame.origin.y;
+
+                windowFrame.origin.y = (oldOriginY + windowFrame.size.height) - (windowFrame.size.height + deltaY);
+                windowFrame.size.width += deltaX;
+                windowFrame.size.height += deltaY;
+
+                NSSize winMinSize = [self window].minSize;
+                if (windowFrame.size.width < winMinSize.width)
+                    windowFrame.size.width = winMinSize.width;
+
+                if (windowFrame.size.height < winMinSize.height)
+                {
+                    windowFrame.size.height = winMinSize.height;
+                    windowFrame.origin.y = oldOriginY;
+                }
+
+                [[self window] setFrame: windowFrame display: YES animate: NO];
+                break;
+            }
+                break;
+            case NSLeftMouseUp:
+                keepOn = NO;
+                break;
+            default:
+                /* Ignore any other kind of event. */
+                break;
+        }
 
-    if (windowFrame.size.height < winMinSize.height)
-    {
-        windowFrame.size.height = winMinSize.height;
-        windowFrame.origin.y = oldOriginY;
-    }
+    };
 
-    [[self window] setFrame: windowFrame display: YES animate: NO];
+    return;
 }
 
 @end