]> git.sesse.net Git - vlc/blob - modules/gui/macosx/MainWindowTitle.m
macosx: added placeholder artwork for the title bar's fullscreen button
[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_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];
59 }
60
61 - (BOOL)mouseDownCanMoveWindow
62 {
63     return YES;
64 }
65
66 - (IBAction)buttonAction:(id)sender
67 {
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];
76     else
77         msg_Err( VLCIntf, "unknown button action sender" );
78 }
79
80 - (void)setWindowTitle:(NSString *)title
81 {
82     [o_title_lbl setStringValue: title];
83 }
84
85 - (void)setFullscreenButtonHidden:(BOOL)b_value
86 {
87     [o_fullscreen_btn setHidden: b_value];
88 }
89
90 - (void)setWindowButtonOver:(BOOL)b_value
91 {
92     if( b_value )
93     {
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"]];
97     }
98     else
99     {
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"]];
103     }
104 }
105
106 - (void)setWindowFullscreenButtonOver:(BOOL)b_value
107 {
108     if (b_value)
109         [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen-over"]];
110     else
111         [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
112 }
113
114 @end
115
116 @implementation VLCWindowButtonCell
117
118 - (void)mouseEntered:(NSEvent *)theEvent
119 {
120     if ([self tag] == 3)
121         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: YES];
122     else
123         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES];
124 }
125
126 - (void)mouseExited:(NSEvent *)theEvent
127 {
128     if ([self tag] == 3)
129         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: NO];
130     else
131         [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];
132 }
133
134 @end