]> git.sesse.net Git - vlc/blob - modules/gui/macosx/VLCVoutWindowController.m
macosx: add new controller which handles multiple vout windows
[vlc] / modules / gui / macosx / VLCVoutWindowController.m
1 /*****************************************************************************
2  * VLCVoutWindowController.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2012 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8  *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #import "VLCVoutWindowController.h"
26 #import "Windows.h"
27
28 @implementation VLCVoutWindowController
29
30 - (id)init
31 {
32     self = [super init];
33     o_vout_dict = [[NSMutableDictionary alloc] init];
34     return self;
35 }
36
37 - (void)dealloc
38 {
39     [o_vout_dict release];
40     [super dealloc];
41 }
42
43 - (void)addVout:(VLCVideoWindowCommon *)o_window forDisplay:(vout_window_t *)p_wnd
44 {
45     [o_vout_dict setObject:o_window forKey:[NSValue valueWithPointer:p_wnd]];
46 }
47
48 - (void)removeVoutforDisplay:(NSValue *)o_key
49 {
50     VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:o_key];
51
52     if (![NSStringFromClass([o_window class]) isEqualToString:@"VLCMainWindow"]) {
53         [o_window orderOut:self];
54     }
55
56     [o_vout_dict removeObjectForKey:o_key];
57 }
58
59 - (void)updateWindowsControlsBarWithSelector:(SEL)aSel
60 {
61     [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, VLCVideoWindowCommon *o_window, BOOL *stop) {
62         id o_controlsBar = [o_window controlsBar];
63         if (o_controlsBar)
64             [o_controlsBar performSelector:aSel];
65     }];
66 }
67
68 - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
69 {
70     [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, VLCVideoWindowCommon *o_window, BOOL *stop) {
71         windowUpdater(o_window);
72     }];
73 }
74
75 @end