]> git.sesse.net Git - vlc/blob - modules/gui/macosx/MainWindowTitle.m
macosx: added a basic traffic lights icon set for the dark window and the related...
[vlc] / modules / gui / macosx / MainWindowTitle.m
1 /*****************************************************************************
2  * MainWindowTitle.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2011 Felix Paul Kühne
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #import <vlc_common.h>
25 #import "intf.h"
26 #import "MainWindowTitle.h"
27 #import "CoreInteraction.h"
28
29 /*****************************************************************************
30  * VLCMainWindowTitleView
31  *****************************************************************************/
32
33 @implementation VLCMainWindowTitleView
34
35 - (void)awakeFromNib
36 {
37     [self setImageScaling: NSScaleToFit];
38     [self setImageFrameStyle: NSImageFrameNone];
39     [self setImageAlignment: NSImageAlignCenter];
40     [self setImage: [NSImage imageNamed:@"bottom-background_dark"]];
41     [self setAutoresizesSubviews: YES];
42
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_yellow_btn setImage: [NSImage imageNamed:@"window-minimize"]];
47     [o_yellow_btn setAlternateImage: [NSImage imageNamed:@"window-minimize-on"]];
48     [[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
49     [o_green_btn setImage: [NSImage imageNamed:@"window-zoom"]];
50     [o_green_btn setAlternateImage: [NSImage imageNamed:@"window-zoom-on"]];
51     [[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
52 }
53
54 - (BOOL)mouseDownCanMoveWindow
55 {
56     return YES;
57 }
58
59 - (IBAction)buttonAction:(id)sender
60 {
61     if (sender == o_red_btn)
62         [[self window] orderOut: sender];
63     else if (sender == o_yellow_btn)
64         [[self window] miniaturize: sender];
65     else if (sender == o_green_btn)
66         [[self window] performZoom: sender];
67     else if (sender == o_fullscreen_btn)
68         [[VLCCoreInteraction sharedInstance] toggleFullscreen];
69     else
70         msg_Err( VLCIntf, "unknown button action sender" );
71 }
72
73 - (void)setWindowTitle:(NSString *)title
74 {
75     [o_title_lbl setStringValue: title];
76 }
77
78 - (void)setFullscreenButtonHidden:(BOOL)b_value
79 {
80     [o_fullscreen_btn setHidden: b_value];
81 }
82
83 - (void)setWindowButtonOver:(BOOL)b_value
84 {
85     if( b_value )
86     {
87         [o_red_btn setImage: [NSImage imageNamed:@"window-close-over"]];
88         [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize-over"]];
89         [o_green_btn setImage: [NSImage imageNamed:@"window-zoom-over"]];
90     }
91     else
92     {
93         [o_red_btn setImage: [NSImage imageNamed:@"window-close"]];
94         [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize"]];
95         [o_green_btn setImage: [NSImage imageNamed:@"window-zoom"]];
96     }
97 }
98
99 @end
100
101 @implementation VLCWindowButtonCell
102
103 - (void)mouseEntered:(NSEvent *)theEvent
104 {
105     [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES];
106 }
107
108 - (void)mouseExited:(NSEvent *)theEvent
109 {
110     [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];
111 }
112
113 @end