]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/MainWindowTitle.m
macosx: add yosemite graphics to project file and use them in code
[vlc] / modules / gui / macosx / MainWindowTitle.m
index bd2bfcd69ce2599ad0cf3039ac9b744c4cb0914d..706bddd85da0993ac927bff480752dbf0e9ac8ad 100644 (file)
@@ -67,7 +67,7 @@
 - (void)awakeFromNib
 {
     [self setAutoresizesSubviews: YES];
-    [self setImagesLeft:[NSImage imageNamed:@"topbar-dark-left"] middle: [NSImage imageNamed:@"topbar-dark-center-fill"] right:[NSImage imageNamed:@"topbar-dark-right"]];
+    [self setImagesLeft:imageFromRes(@"topbar-dark-left") middle: imageFromRes(@"topbar-dark-center-fill") right:imageFromRes(@"topbar-dark-right")];
 
     [self loadButtonIcons];
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTintChanged:) name: NSControlTintDidChangeNotification object: nil];
         [contextMenu release];
 
     NSURL * representedURL = [[self window] representedURL];
-    if (! representedURL)
+    if (!representedURL)
         return;
 
     NSArray * pathComponents;
     [currentItem setImage: icon];
     [currentItem setTarget: self];
 
-    [NSMenu popUpContextMenu: contextMenu withEvent: o_event forView: [self superview]];
+    // center the context menu similar to the white interface
+    CGFloat menuWidth = [contextMenu size].width;
+    NSRect windowFrame = [[self window] frame];
+    NSPoint point;
+
+    CGFloat fullButtonWidth = 0.;
+    if([[VLCMain sharedInstance] nativeFullscreenMode])
+        fullButtonWidth = 20.;
+
+    // assumes 60 px for the window buttons
+    point.x = (windowFrame.size.width - 60. - fullButtonWidth) / 2. - menuWidth / 2. + 60. - 20.;
+    point.y = windowFrame.size.height + 1.;
+    if (point.x < 0)
+        point.x = 10;
+
+    NSEvent *fakeMouseEvent = [NSEvent mouseEventWithType:NSRightMouseDown
+                                                 location:point
+                                            modifierFlags:0
+                                                timestamp:0
+                                             windowNumber:[[self window] windowNumber]
+                                                  context:nil
+                                              eventNumber:0
+                                               clickCount:0
+                                                 pressure:0];
+    [NSMenu popUpContextMenu: contextMenu withEvent: fakeMouseEvent forView: [self superview]];
 }
 
 - (IBAction)revealInFinder:(id)sender