]> git.sesse.net Git - vlc/blob - modules/gui/macosx/embeddedwindow.m
* animate vout-window resizements. Patch by Pierre d'Herbement <pdherbement --at...
[vlc] / modules / gui / macosx / embeddedwindow.m
1 /*****************************************************************************
2  * embeddedwindow.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2005-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Benjamin Pracht <bigben 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 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #include "intf.h"
29 #include "vout.h"
30 #include "embeddedwindow.h"
31
32 /*****************************************************************************
33  * VLCEmbeddedWindow Implementation
34  *****************************************************************************/
35
36 @implementation VLCEmbeddedWindow
37
38 - (void)awakeFromNib
39 {
40     [self setDelegate: self];
41
42     [o_btn_backward setToolTip: _NS("Rewind")];
43     [o_btn_forward setToolTip: _NS("Fast Forward")];
44     [o_btn_fullscreen setToolTip: _NS("Fullscreen")];
45     [o_btn_play setToolTip: _NS("Play")];
46     [o_slider setToolTip: _NS("Position")];
47
48     o_img_play = [NSImage imageNamed: @"play_embedded"];
49     o_img_play_pressed = [NSImage imageNamed: @"play_embedded_blue"];
50     o_img_pause = [NSImage imageNamed: @"pause_embedded"];
51     o_img_pause_pressed = [NSImage imageNamed: @"pause_embedded_blue"];
52
53     o_saved_frame = NSMakeRect( 0.0f, 0.0f, 0.0f, 0.0f );
54 }
55
56 - (void)setTime:(NSString *)o_arg_time position:(float)f_position
57 {
58     [o_time setStringValue: o_arg_time];
59     [o_slider setFloatValue: f_position];
60 }
61
62 - (void)playStatusUpdated:(int)i_status
63 {
64     if( i_status == PLAYING_S )
65     {
66         [o_btn_play setImage: o_img_pause];
67         [o_btn_play setAlternateImage: o_img_pause_pressed];
68         [o_btn_play setToolTip: _NS("Pause")];
69     }
70     else
71     {
72         [o_btn_play setImage: o_img_play];
73         [o_btn_play setAlternateImage: o_img_play_pressed];
74         [o_btn_play setToolTip: _NS("Play")];
75     }
76 }
77
78 - (void)setSeekable:(BOOL)b_seekable
79 {
80     [o_btn_forward setEnabled: b_seekable];
81     [o_btn_backward setEnabled: b_seekable];
82     [o_slider setEnabled: b_seekable];
83 }
84
85 - (void)setFullscreen:(BOOL)b_fullscreen
86 {
87     [o_btn_fullscreen setState: b_fullscreen];
88 }
89
90 - (void)zoom:(id)sender
91 {
92     if( ![self isZoomed] )
93     {
94         NSRect zoomRect = [[self screen] frame];
95         o_saved_frame = [self frame];
96         /* we don't have to take care of the eventual menu bar and dock
97           as zoomRect will be cropped automatically by setFrame:display:
98           to the right rectangle */
99         [self setFrame: zoomRect display: YES animate: YES];
100     }
101     else
102     {
103         /* unzoom to the saved_frame if the o_saved_frame coords look sound
104            (just in case) */
105         if( o_saved_frame.size.width > 0 && o_saved_frame.size.height > 0 )
106             [self setFrame: o_saved_frame display: YES animate: YES];
107     }
108 }
109
110 - (BOOL)windowShouldClose:(id)sender
111 {
112     playlist_t * p_playlist = pl_Yield( VLCIntf );
113
114     playlist_Stop( p_playlist );
115     vlc_object_release( p_playlist );
116     return YES;
117 }
118
119 @end