1 /*****************************************************************************
2 * MainWindowTitle.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2011 Felix Paul Kühne
7 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #import <vlc_common.h>
26 #import "MainWindowTitle.h"
27 #import "CoreInteraction.h"
29 /*****************************************************************************
30 * VLCMainWindowTitleView
31 *****************************************************************************/
33 @implementation VLCMainWindowTitleView
37 [self setImageScaling: NSScaleToFit];
38 [self setImageFrameStyle: NSImageFrameNone];
39 [self setImageAlignment: NSImageAlignCenter];
40 [self setImage: [NSImage imageNamed:@"bottom-background_dark"]];
41 [self setAutoresizesSubviews: YES];
43 [o_red_btn setImage: [NSImage imageNamed:@"window-close"]];
44 [o_red_btn setAlternateImage: [NSImage imageNamed:@"window-close-on"]];
45 [[o_red_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
46 [[o_red_btn cell] setTag: 0];
47 [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize"]];
48 [o_yellow_btn setAlternateImage: [NSImage imageNamed:@"window-minimize-on"]];
49 [[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
50 [[o_yellow_btn cell] setTag: 1];
51 [o_green_btn setImage: [NSImage imageNamed:@"window-zoom"]];
52 [o_green_btn setAlternateImage: [NSImage imageNamed:@"window-zoom-on"]];
53 [[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
54 [[o_green_btn cell] setTag: 2];
55 [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
56 [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"window-fullscreen-on"]];
57 [[o_fullscreen_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
58 [[o_fullscreen_btn cell] setTag: 3];
61 - (BOOL)mouseDownCanMoveWindow
66 - (IBAction)buttonAction:(id)sender
68 if (sender == o_red_btn)
69 [[self window] orderOut: sender];
70 else if (sender == o_yellow_btn)
71 [[self window] miniaturize: sender];
72 else if (sender == o_green_btn)
73 [[self window] performZoom: sender];
74 else if (sender == o_fullscreen_btn)
75 [[VLCCoreInteraction sharedInstance] toggleFullscreen];
77 msg_Err( VLCIntf, "unknown button action sender" );
80 - (void)setWindowTitle:(NSString *)title
82 [o_title_lbl setStringValue: title];
85 - (void)setFullscreenButtonHidden:(BOOL)b_value
87 [o_fullscreen_btn setHidden: b_value];
90 - (void)setWindowButtonOver:(BOOL)b_value
94 [o_red_btn setImage: [NSImage imageNamed:@"window-close-over"]];
95 [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize-over"]];
96 [o_green_btn setImage: [NSImage imageNamed:@"window-zoom-over"]];
100 [o_red_btn setImage: [NSImage imageNamed:@"window-close"]];
101 [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize"]];
102 [o_green_btn setImage: [NSImage imageNamed:@"window-zoom"]];
106 - (void)setWindowFullscreenButtonOver:(BOOL)b_value
109 [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen-over"]];
111 [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
116 @implementation VLCWindowButtonCell
118 - (void)mouseEntered:(NSEvent *)theEvent
121 [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: YES];
123 [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES];
126 - (void)mouseExited:(NSEvent *)theEvent
129 [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: NO];
131 [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];