From: Felix Paul Kühne Date: Sat, 3 Dec 2005 13:36:54 +0000 (+0000) Subject: * ALL: first development version of a GUI for the SubPicture Filters (refs #350) X-Git-Tag: 0.9.0-test0~13104 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a67fd4f9c8b11883bf84a421d7c924a7b75f0ccd;p=vlc * ALL: first development version of a GUI for the SubPicture Filters (refs #350) - the marquee section is already completely usable, more to come - TODO: - fix all FIXMEs - implement the logo and time settings completely - implement l10n - fix 10.3 compatibility (runs under Tiger only atm) - save the preferences, if requested - close a current vout and re-open it, when a filter is (de-)activated - redesign the GUI to a smaller panel --- diff --git a/Makefile.am b/Makefile.am index 628da69ba0..f311dc22d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -181,6 +181,9 @@ EXTRA_DIST += \ extras/MacOSX/Resources/English.lproj/Extended.nib/classes.nib \ extras/MacOSX/Resources/English.lproj/Extended.nib/info.nib \ extras/MacOSX/Resources/English.lproj/Extended.nib/keyedobjects.nib \ + extras/MacOSX/Resources/English.lproj/SFilters.nib/classes.nib \ + extras/MacOSX/Resources/English.lproj/SFilters.nib/info.nib \ + extras/MacOSX/Resources/English.lproj/SFilters.nib/keyedobjects.nib \ extras/MacOSX/Resources/English.lproj/InfoPlist.strings \ extras/MacOSX/Resources/a52.icns \ extras/MacOSX/Resources/aac.icns \ @@ -609,6 +612,8 @@ VLC-release.app: vlc extended.m \ bookmarks.h \ bookmarks.m \ + sfilters.h \ + sfilters.m \ vout.m; do \ cp "$(srcdir)/modules/gui/macosx/$$i" \ $(top_builddir)/tmp/modules/gui/macosx; \ @@ -723,6 +728,8 @@ VLC.app: vlc extended.m \ bookmarks.h \ bookmarks.m \ + sfilters.h \ + sfilters.m \ vout.m; do \ cp "$(srcdir)/modules/gui/macosx/$$i" \ $(top_builddir)/tmp/modules/gui/macosx; \ diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib index fe1d778da4..2ac428c6ff 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib @@ -110,6 +110,7 @@ reportABug = id; showBookmarks = id; showExtended = id; + showSFilters = id; showWizard = id; timesliderUpdate = id; togglePlaylist = id; diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib index 9f6dae4985..ba302359d0 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib @@ -11,21 +11,21 @@ 2197 422 532 596 143 0 0 1440 878 29 - 423 907 438 44 0 0 1280 1002 + 503 790 438 44 0 0 1440 878 915 678 573 187 249 0 0 1280 1002 IBFramework Version - 439.0 + 437.0 IBLockedObjects IBOpenObjects - 21 - 2029 29 + 2029 + 21 IBSystem Version - 8C46 + 8F46 diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib index 4b925b4ed8..f24ab61df4 100644 Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/extras/MacOSX/Resources/English.lproj/SFilters.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/SFilters.nib/classes.nib new file mode 100644 index 0000000000..c06bdff6d5 --- /dev/null +++ b/extras/MacOSX/Resources/English.lproj/SFilters.nib/classes.nib @@ -0,0 +1,80 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = { + enableFilter = id; + "logo_selectFile" = id; + otherPositionForLogo = id; + otherPositionForMarq = id; + otherPositionForTime = id; + propertyChanged = id; + }; + CLASS = VLCsFilters; + LANGUAGE = ObjC; + OUTLETS = { + "o_logo_enabled_ckb" = id; + "o_logo_image_btn" = id; + "o_logo_image_fld" = id; + "o_logo_image_lbl" = id; + "o_logo_opaque_lbl" = id; + "o_logo_opaque_sld" = id; + "o_logo_pos_fix_X_fld" = id; + "o_logo_pos_fix_X_lbl" = id; + "o_logo_pos_fix_Y_fld" = id; + "o_logo_pos_fix_Y_lbl" = id; + "o_logo_pos_fix_btn" = id; + "o_logo_pos_lbl" = id; + "o_logo_pos_matrix" = id; + "o_logo_pos_rel_btn" = id; + "o_logo_pos_rel_pop" = id; + "o_marq_color_lbl" = id; + "o_marq_color_pop" = id; + "o_marq_enabled_ckb" = id; + "o_marq_marq_fld" = id; + "o_marq_marq_lbl" = id; + "o_marq_opaque_lbl" = id; + "o_marq_opaque_sld" = id; + "o_marq_pos_fix_X_fld" = id; + "o_marq_pos_fix_X_lbl" = id; + "o_marq_pos_fix_Y_fld" = id; + "o_marq_pos_fix_Y_lbl" = id; + "o_marq_pos_fix_btn" = id; + "o_marq_pos_lbl" = id; + "o_marq_pos_matrix" = id; + "o_marq_pos_rel_btn" = id; + "o_marq_pos_rel_pop" = id; + "o_marq_size_inPx_lbl" = id; + "o_marq_size_lbl" = id; + "o_marq_size_pop" = id; + "o_marq_tmOut_fld" = id; + "o_marq_tmOut_lbl" = id; + "o_marq_tmOut_ms_lbl" = id; + "o_sfilter_saveSettings_ckb" = id; + "o_sfilter_tabView" = id; + "o_sfilter_win" = id; + "o_time_color_lbl" = id; + "o_time_color_pop" = id; + "o_time_enabled_ckb" = id; + "o_time_opaque_lbl" = id; + "o_time_opaque_sld" = id; + "o_time_pos_fix_X_fld" = id; + "o_time_pos_fix_X_lbl" = id; + "o_time_pos_fix_Y_fld" = id; + "o_time_pos_fix_Y_lbl" = id; + "o_time_pos_fix_btn" = id; + "o_time_pos_lbl" = id; + "o_time_pos_matrix" = id; + "o_time_pos_rel_btn" = id; + "o_time_pos_rel_pop" = id; + "o_time_size_inPx_lbl" = id; + "o_time_size_lbl" = id; + "o_time_size_pop" = id; + "o_time_stamp_fld" = id; + "o_time_stamp_lbl" = id; + }; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/extras/MacOSX/Resources/English.lproj/SFilters.nib/info.nib b/extras/MacOSX/Resources/English.lproj/SFilters.nib/info.nib new file mode 100644 index 0000000000..c89da72fab --- /dev/null +++ b/extras/MacOSX/Resources/English.lproj/SFilters.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 69 67 356 240 0 0 1440 878 + IBFramework Version + 437.0 + IBOpenObjects + + 5 + + IBSystem Version + 8F46 + + diff --git a/extras/MacOSX/Resources/English.lproj/SFilters.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/SFilters.nib/keyedobjects.nib new file mode 100644 index 0000000000..6fffb093b9 Binary files /dev/null and b/extras/MacOSX/Resources/English.lproj/SFilters.nib/keyedobjects.nib differ diff --git a/extras/MacOSX/vlc.pbproj/project.pbxproj b/extras/MacOSX/vlc.pbproj/project.pbxproj index c1c2287f2f..7039265966 100644 --- a/extras/MacOSX/vlc.pbproj/project.pbxproj +++ b/extras/MacOSX/vlc.pbproj/project.pbxproj @@ -837,6 +837,7 @@ DC7F46ED08A183FC0027DB24, DCE7BD0508A56C8B007B10AE, DCDA5E6508F94518009D93A8, + CCF3C64C0923B99D00401862, ); isa = PBXResourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -923,6 +924,8 @@ DC7F46F108A187F60027DB24, DCE7BD0708A5724D007B10AE, DCE7BD0608A5724D007B10AE, + CCF3C6500923B9D100401862, + CCF3C6510923B9D100401862, ); isa = PBXGroup; name = Classes; @@ -2166,6 +2169,58 @@ //A02 //A03 //A04 +//CC0 +//CC1 +//CC2 +//CC3 +//CC4 + CCF3C64A0923B99D00401862 = { + children = ( + CCF3C64B0923B99D00401862, + ); + isa = PBXVariantGroup; + name = SFilters.nib; + path = ""; + refType = 4; + sourceTree = ""; + }; + CCF3C64B0923B99D00401862 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = English; + path = Resources/English.lproj/SFilters.nib; + refType = 4; + sourceTree = ""; + }; + CCF3C64C0923B99D00401862 = { + fileRef = CCF3C64A0923B99D00401862; + isa = PBXBuildFile; + settings = { + }; + }; + CCF3C6500923B9D100401862 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = sfilters.h; + path = ../../modules/gui/macosx/sfilters.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + CCF3C6510923B9D100401862 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + name = sfilters.m; + path = ../../modules/gui/macosx/sfilters.m; + refType = 2; + sourceTree = SOURCE_ROOT; + }; +//CC0 +//CC1 +//CC2 +//CC3 +//CC4 //DC0 //DC1 //DC2 @@ -2379,6 +2434,7 @@ DCFCCDB7085CE18F001E36AF, DC7F46EB08A183FC0027DB24, DCE7BD0308A56C8B007B10AE, + CCF3C64A0923B99D00401862, ); isa = PBXGroup; name = nibs; diff --git a/modules/gui/macosx/Modules.am b/modules/gui/macosx/Modules.am index 14c369baa4..85076c9c6c 100644 --- a/modules/gui/macosx/Modules.am +++ b/modules/gui/macosx/Modules.am @@ -34,5 +34,7 @@ SOURCES_macosx = \ extended.m \ bookmarks.h \ bookmarks.m \ + sfilters.h \ + sfilters.m \ $(NULL) diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index 5413436300..13ecd74e19 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -93,13 +93,15 @@ struct intf_sys_t id o_wizard; /* VLCWizard */ id o_extended; /* VLCExtended */ id o_bookmarks; /* VLCBookmarks */ + id o_sfilters; /* VLCsFilters */ /*id o_update; VLCUpdate */ BOOL nib_main_loaded; /* reference to the main-nib */ BOOL nib_open_loaded; /* reference to the open-nib */ BOOL nib_about_loaded; /* reference to the about-nib */ BOOL nib_wizard_loaded; /* reference to the wizard-nib */ BOOL nib_extended_loaded; /* reference to the extended-nib */ - BOOL nib_bookmarks_loaded; /* reference to the bookmarks-nib */ + BOOL nib_bookmarks_loaded; /* reference to the bookmarks-nib */ + BOOL nib_sfilters_loaded; /* reference to the sfilters-nib */ /*BOOL nib_update_loaded; reference to the update-nib */ IBOutlet id o_window; /* main window */ @@ -307,6 +309,7 @@ struct intf_sys_t - (IBAction)showWizard:(id)sender; - (IBAction)showExtended:(id)sender; - (IBAction)showBookmarks:(id)sender; +- (IBAction)showSFilters:(id)sender; - (IBAction)viewAbout:(id)sender; - (IBAction)viewPreferences:(id)sender; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index f55a693cd2..649e5cf1a2 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -41,6 +41,7 @@ #include "wizard.h" #include "extended.h" #include "bookmarks.h" +#include "sfilters.h" /*#include "update.h"*/ /***************************************************************************** @@ -303,6 +304,7 @@ static VLCMain *_o_sharedMainInstance = nil; o_wizard = [[VLCWizard alloc] init]; o_extended = nil; o_bookmarks = [[VLCBookmarks alloc] init]; + o_sfilters = nil; /*o_update = [[VLCUpdate alloc] init];*/ i_lastShownVolume = -1; @@ -1524,6 +1526,22 @@ static VLCMain *_o_sharedMainInstance = nil; } } +- (IBAction)showSFilters:(id)sender +{ + if ( o_sfilters == nil ) + { + o_sfilters = [[VLCsFilters alloc] init]; + } + if (!nib_sfilters_loaded) + { + nib_sfilters_loaded = [NSBundle loadNibNamed:@"SFilters" owner:self]; + [o_sfilters initStrings]; + [o_sfilters showAsPanel]; + } else { + [o_sfilters showAsPanel]; + } +} + - (IBAction)showBookmarks:(id)sender { /* we need the wizard-nib for the bookmarks's extract functionality */ diff --git a/modules/gui/macosx/sfilters.h b/modules/gui/macosx/sfilters.h new file mode 100644 index 0000000000..e922b4268b --- /dev/null +++ b/modules/gui/macosx/sfilters.h @@ -0,0 +1,116 @@ +/***************************************************************************** + * sfilter.h: MacOS X Subpicture filters dialogue + ***************************************************************************** + * Copyright (C) 2005 the VideoLAN team + * $Id:$ + * + * Authors: Felix KŸhne + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#import +#import + +@interface VLCsFilters : NSObject +{ + /* window stuff */ + IBOutlet id o_sfilter_tabView; + IBOutlet id o_sfilter_win; + + /* logo section */ + IBOutlet id o_logo_enabled_ckb; + IBOutlet id o_logo_image_btn; + IBOutlet id o_logo_image_fld; + IBOutlet id o_logo_image_lbl; + IBOutlet id o_logo_opaque_lbl; + IBOutlet id o_logo_opaque_sld; + IBOutlet id o_logo_pos_fix_btn; + IBOutlet id o_logo_pos_fix_X_fld; + IBOutlet id o_logo_pos_fix_X_lbl; + IBOutlet id o_logo_pos_fix_Y_fld; + IBOutlet id o_logo_pos_fix_Y_lbl; + IBOutlet id o_logo_pos_lbl; + IBOutlet id o_logo_pos_rel_btn; + IBOutlet id o_logo_pos_rel_pop; + IBOutlet id o_logo_pos_matrix; + + /* marquee section */ + IBOutlet id o_marq_enabled_ckb; + IBOutlet id o_marq_color_lbl; + IBOutlet id o_marq_color_pop; + IBOutlet id o_marq_marq_fld; + IBOutlet id o_marq_marq_lbl; + IBOutlet id o_marq_opaque_lbl; + IBOutlet id o_marq_opaque_sld; + IBOutlet id o_marq_pos_fix_btn; + IBOutlet id o_marq_pos_fix_X_fld; + IBOutlet id o_marq_pos_fix_X_lbl; + IBOutlet id o_marq_pos_fix_Y_fld; + IBOutlet id o_marq_pos_fix_Y_lbl; + IBOutlet id o_marq_pos_lbl; + IBOutlet id o_marq_pos_rel_btn; + IBOutlet id o_marq_pos_rel_pop; + IBOutlet id o_marq_size_inPx_lbl; + IBOutlet id o_marq_size_lbl; + IBOutlet id o_marq_size_pop; + IBOutlet id o_marq_tmOut_fld; + IBOutlet id o_marq_tmOut_lbl; + IBOutlet id o_marq_tmOut_ms_lbl; + IBOutlet id o_marq_pos_matrix; + + /* time section */ + IBOutlet id o_time_enabled_ckb; + IBOutlet id o_time_color_lbl; + IBOutlet id o_time_color_pop; + IBOutlet id o_time_opaque_lbl; + IBOutlet id o_time_opaque_sld; + IBOutlet id o_time_pos_fix_btn; + IBOutlet id o_time_pos_fix_X_fld; + IBOutlet id o_time_pos_fix_X_lbl; + IBOutlet id o_time_pos_fix_Y_fld; + IBOutlet id o_time_pos_fix_Y_lbl; + IBOutlet id o_time_pos_lbl; + IBOutlet id o_time_pos_rel_btn; + IBOutlet id o_time_pos_rel_pop; + IBOutlet id o_time_size_inPx_lbl; + IBOutlet id o_time_size_lbl; + IBOutlet id o_time_size_pop; + IBOutlet id o_time_stamp_fld; + IBOutlet id o_time_stamp_lbl; + IBOutlet id o_time_pos_matrix; + + BOOL o_config_changed; + BOOL o_save_settings; + NSArray * o_colors; +} + + ++ (VLCsFilters *)sharedInstance; +- (IBAction)logo_selectFile:(id)sender; +- (IBAction)propertyChanged:(id)sender; +- (IBAction)enableFilter:(id)sender; +- (IBAction)otherPositionForLogo:(id)sender; +- (IBAction)otherPositionForMarq:(id)sender; +- (IBAction)otherPositionForTime:(id)sender; + +- (void)showAsPanel; +- (void)initStrings; +- (void)changeFiltersString: (char *)psz_name onOrOff: (vlc_bool_t )b_add; +- (void)enableTime; +- (void)enableLogo; +- (void)enableMarq; + +@end diff --git a/modules/gui/macosx/sfilters.m b/modules/gui/macosx/sfilters.m new file mode 100644 index 0000000000..e9f2b35ed9 --- /dev/null +++ b/modules/gui/macosx/sfilters.m @@ -0,0 +1,610 @@ +/***************************************************************************** + * sfilter.m: MacOS X Subpicture filters dialogue + ***************************************************************************** + * Copyright (C) 2005 the VideoLAN team + * $Id:$ + * + * Authors: Felix KŸhne + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + + +/***************************************************************************** + * Note: + * the code used to bind with VLC's core is partially based upon the + * RC-interface, written by Antoine Cellerier and Mark F. Moriarty + * (members of the VideoLAN team) + *****************************************************************************/ + +#import "sfilters.h" +#import "intf.h" +#import + +/* TODO: + - fix all FIXMEs + - if a vout closes and another is opened, the marquee is shown at marq-x / + marq-y regardless of the fact whether the user wants it to be positioned + fixed or not. This needs fixing in marq.c and a new global config-variable + - That will probably happen with logo and time as well. + - implement initStrings + - check for memory leaks + - save the preferences, if requested + - fix 10.3 compatibility +*/ + +@implementation VLCsFilters + +static VLCsFilters *_o_sharedInstance = nil; + ++ (VLCsFilters *)sharedInstance +{ + return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; +} + +- (id)init +{ + if (_o_sharedInstance) { + [self dealloc]; + } else { + _o_sharedInstance = [super init]; + } + + return _o_sharedInstance; +} + +- (void)dealloc +{ + [o_colors release]; + + [super dealloc]; +} + +- (void)initStrings +{ +} + +- (void)awakeFromNib +{ + /* colors as implemented at the beginning of marq.c and time.c + * feel free to add more colors, but remember to add them to these files + * as well to keep a certain level of consistency across the interfaces */ + NSArray * o_default; + NSArray * o_black; + NSArray * o_gray; + NSArray * o_silver; + NSArray * o_white; + NSArray * o_maroon; + NSArray * o_red; + NSArray * o_fuchsia; + NSArray * o_yellow; + NSArray * o_olive; + NSArray * o_green; + NSArray * o_teal; + NSArray * o_lime; + NSArray * o_purple; + NSArray * o_navy; + NSArray * o_blue; + NSArray * o_aqua; + o_default = [NSArray arrayWithObjects: _NS("Default"), @"-1", nil]; + o_black = [NSArray arrayWithObjects: _NS("Black"), @"0x000000", nil]; + o_gray = [NSArray arrayWithObjects: _NS("Gray"), @"0x808080", nil]; + o_silver = [NSArray arrayWithObjects: _NS("Silver"), @"0xC0C0C0", nil]; + o_white = [NSArray arrayWithObjects: _NS("White"), @"0xFFFFFF", nil]; + o_maroon = [NSArray arrayWithObjects: _NS("Maroon"), @"0x800000", nil]; + o_red = [NSArray arrayWithObjects: _NS("Red"), @"0xFF0000", nil]; + o_fuchsia = [NSArray arrayWithObjects: _NS("Fuchsia"), @"0xFF00FF", nil]; + o_yellow = [NSArray arrayWithObjects: _NS("Yellow"), @"0xFFFF00", nil]; + o_olive = [NSArray arrayWithObjects: _NS("Olive"), @"0x808000", nil]; + o_green = [NSArray arrayWithObjects: _NS("Green"), @"0x008000", nil]; + o_teal = [NSArray arrayWithObjects: _NS("Teal"), @"0x008080", nil]; + o_lime = [NSArray arrayWithObjects: _NS("Lime"), @"0x00FF00", nil]; + o_purple = [NSArray arrayWithObjects: _NS("Purple"), @"0x800080", nil]; + o_navy = [NSArray arrayWithObjects: _NS("Navy"), @"0x000080", nil]; + o_blue = [NSArray arrayWithObjects: _NS("Blue"), @"0x0000FF", nil]; + o_aqua = [NSArray arrayWithObjects: _NS("Aqua"), @"0x00FFFF", nil]; + o_colors = [[NSArray alloc] initWithObjects: o_default, o_black, o_gray, \ + o_silver, o_white, o_maroon, o_red, o_fuchsia, o_yellow, o_olive, \ + o_green, o_teal, o_lime, o_purple, o_navy, o_blue, o_aqua, nil]; + + unsigned int x = 0; + [o_marq_color_pop removeAllItems]; + [o_time_color_pop removeAllItems]; + + /* we are adding tags to the items, so we can easily identify them even if + * the menu was sorted */ + while (x != [o_colors count]) + { + [o_marq_color_pop addItemWithTitle: [[o_colors objectAtIndex:x] \ + objectAtIndex:0]]; + [[o_marq_color_pop lastItem] setTag: x]; + + [o_time_color_pop addItemWithTitle: [[o_colors objectAtIndex:x] \ + objectAtIndex:0]]; + [[o_time_color_pop lastItem] setTag: x]; + + x = (x + 1); + } + + [o_marq_color_pop selectItemAtIndex:0]; + [o_time_color_pop selectItemAtIndex:0]; + + /* define the relative positions and copy them to the menues + * we can destroy the array afterwards, because we are saving the ints + * as tags to the menu-items */ + NSArray * o_cnt_cnt; + NSArray * o_lft_cnt; + NSArray * o_rht_cnt; + NSArray * o_cnt_top; + NSArray * o_lft_top; + NSArray * o_rht_top; + NSArray * o_cnt_btm; + NSArray * o_lft_btm; + NSArray * o_rht_btm; + NSArray * o_positions; + o_cnt_cnt = [NSArray arrayWithObjects: _NS("Center-Center"), @"0", nil]; + o_lft_cnt = [NSArray arrayWithObjects: _NS("Left-Center"), @"1", nil]; + o_rht_cnt = [NSArray arrayWithObjects: _NS("Right-Center"), @"2", nil]; + o_cnt_top = [NSArray arrayWithObjects: _NS("Center-Top"), @"4", nil]; + o_lft_top = [NSArray arrayWithObjects: _NS("Left-Top"), @"5", nil]; + o_rht_top = [NSArray arrayWithObjects: _NS("Right-Top"), @"6", nil]; + o_cnt_btm = [NSArray arrayWithObjects: _NS("Center-Bottom"), @"8", nil]; + o_lft_btm = [NSArray arrayWithObjects: _NS("Left-Bottom"), @"9", nil]; + o_rht_btm = [NSArray arrayWithObjects: _NS("Right-Bottom"), @"10", nil]; + o_positions = [[NSArray alloc] initWithObjects: o_cnt_cnt, o_lft_cnt, \ + o_rht_cnt, o_cnt_top, o_lft_top, o_rht_top, o_cnt_btm, o_lft_btm, \ + o_rht_btm, nil]; + + x = 0; + [o_time_pos_rel_pop removeAllItems]; + [o_marq_pos_rel_pop removeAllItems]; + [o_logo_pos_rel_pop removeAllItems]; + + /* we are adding a tag here, so we can easily select an item later on */ + while ( x != [o_positions count] ) + { + [o_time_pos_rel_pop addItemWithTitle: [[o_positions objectAtIndex:x] \ + objectAtIndex:0]]; + [[o_time_pos_rel_pop lastItem] setTag: [[[o_positions objectAtIndex:x] \ + objectAtIndex:1] intValue]]; + [o_marq_pos_rel_pop addItemWithTitle: [[o_positions objectAtIndex:x] \ + objectAtIndex:0]]; + [[o_marq_pos_rel_pop lastItem] setTag: [[[o_positions objectAtIndex:x] \ + objectAtIndex:1] intValue]]; + [o_logo_pos_rel_pop addItemWithTitle: [[o_positions objectAtIndex:x] \ + objectAtIndex:0]]; + [[o_logo_pos_rel_pop lastItem] setTag: [[[o_positions objectAtIndex:x] \ + objectAtIndex:1] intValue]]; + + x = (x + 1); + } + [o_positions release]; + + NSArray * o_sizes; + o_sizes = [[NSArray alloc] initWithObjects: @"6", @"8", @"10", @"11", @"12",\ + @"14", @"13", @"16", @"18", @"24", @"36", @"48", @"64", @"72", @"96", \ + @"144", @"288", nil]; + [o_marq_size_pop removeAllItems]; + [o_marq_size_pop addItemsWithTitles: o_sizes]; + [o_time_size_pop removeAllItems]; + [o_time_size_pop addItemsWithTitles: o_sizes]; + [o_sizes release]; +} + +- (void)showAsPanel +{ + /* called from intf.m */ + [o_sfilter_win displayIfNeeded]; + [o_sfilter_win makeKeyAndOrderFront:nil]; + + intf_thread_t * p_intf = VLCIntf; + + /* retrieve the marquee settings from core... */ + int x = 0; + int tempInt = config_GetInt( p_intf, "marq-color" ); + while( strtol([[[o_colors objectAtIndex:x] objectAtIndex:1] UTF8String], \ + NULL, 0) != tempInt ) + { + x = (x + 1); + + if( x >= [o_marq_color_pop numberOfItems] ) + { + x = 0; + return; + } + } + [o_marq_color_pop selectItemAtIndex: x]; + [o_marq_marq_fld setStringValue: [NSString stringWithUTF8String: \ + config_GetPsz( p_intf, "marq-marquee" )]]; + [o_marq_opaque_sld setIntValue: config_GetInt( p_intf, "marq-opacity")]; + [o_marq_pos_fix_X_fld setStringValue: [[NSNumber numberWithInt: \ + config_GetInt( p_intf, "marq-x")] stringValue]]; + [o_marq_pos_fix_Y_fld setStringValue: [[NSNumber numberWithInt: \ + config_GetInt( p_intf, "marq-y")] stringValue]]; + [o_marq_pos_rel_pop selectItemWithTag: \ + config_GetInt( p_intf, "marq-position" )]; + x = 0; + tempInt = config_GetInt( p_intf, "marq-size" ); + while( [[[o_marq_size_pop itemAtIndex: x] title] intValue] != tempInt ) + x = (x + 1); + + if( x >= [o_marq_size_pop numberOfItems] ) + { + x = 0; + return; + } + [o_marq_size_pop selectItemAtIndex: x]; + [o_marq_tmOut_fld setStringValue: [[NSNumber numberWithInt: \ + config_GetInt( p_intf, "marq-timeout" )] stringValue]]; + + // FIXME: retrieve the proper values for logo and time from core, too! + + char * psz_subfilters; + psz_subfilters = config_GetPsz( p_intf, "sub-filter" ); + if( psz_subfilters ) + { + [o_marq_enabled_ckb setState: (int)strstr( psz_subfilters, "marq")]; + [o_logo_enabled_ckb setState: (int)strstr( psz_subfilters, "logo")]; + [o_time_enabled_ckb setState: (int)strstr( psz_subfilters, "time")]; + [self enableMarq]; + [self enableLogo]; + [self enableTime]; + } +} + +- (IBAction)logo_selectFile:(id)sender +{ + NSOpenPanel * openPanel = [NSOpenPanel openPanel]; + SEL sel = @selector(logo_getFile:returnCode:contextInfo:); + [openPanel beginSheetForDirectory:nil file:nil types:nil modalForWindow: \ + o_sfilter_win modalDelegate:self didEndSelector:sel contextInfo:nil]; +} + +- (void)logo_getFile: (NSOpenPanel *)sheet returnCode: \ + (int)returnCode contextInfo: (void *)contextInfo +{ + if (returnCode == NSOKButton) + { + [o_logo_image_fld setStringValue: [sheet filename]]; + } +} + +- (IBAction)propertyChanged:(id)sender +{ + intf_thread_t * p_intf = VLCIntf; + input_thread_t * p_input = (input_thread_t *)vlc_object_find( p_intf, \ + VLC_OBJECT_INPUT, FIND_ANYWHERE ); + + vlc_value_t val; + + /* general properties */ + if( sender == o_time_pos_rel_btn) + { + o_save_settings = [o_time_pos_rel_btn state]; + } + + /* marquee */ + else if( sender == o_marq_marq_fld ) + { + if( [[o_marq_marq_fld stringValue] length] == 0 ) + { + val.psz_string = ""; + } + else + { + val.psz_string = [[o_marq_marq_fld stringValue] UTF8String]; + } + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-marquee", val ); + + config_PutPsz( p_intf, "marq-marquee", val.psz_string ); + } + + else if( sender == o_marq_pos_fix_X_fld && [[sender stringValue] length] > 0 ) + { + val.i_int = [o_marq_pos_fix_X_fld intValue]; + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-x", val ); + + config_PutInt( p_intf, "marq-x", val.i_int ); + } + + else if( sender == o_marq_pos_fix_Y_fld && [[sender stringValue] length] > 0 ) + { + val.i_int = [o_marq_pos_fix_Y_fld intValue]; + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-y", val ); + + config_PutInt( p_intf, "marq-y", val.i_int ); + } + + else if( sender == o_marq_pos_rel_pop ) + { + val.i_int = [[o_marq_pos_rel_pop selectedItem] tag]; + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-position", val ); + + config_PutInt( p_intf, "marq-position", val.i_int ); + } + + else if( sender == o_marq_color_pop ) + { + val.i_int = strtol( [[[o_colors objectAtIndex: [o_marq_color_pop \ + indexOfSelectedItem]] objectAtIndex: 1] UTF8String], NULL, 0 ); + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-color", val ); + + config_PutInt( p_intf, "marq-color", val.i_int ); + } + + else if( sender == o_marq_opaque_sld ) + { + val.i_int = [o_marq_opaque_sld intValue]; + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-opacity", val ); + + config_PutInt( p_intf, "marq-opacity", val.i_int ); + } + + else if( sender == o_marq_size_pop ) + { + val.i_int = [[o_marq_size_pop titleOfSelectedItem] intValue]; + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-size", val ); + + config_PutInt( p_intf, "marq-size", val.i_int ); + } + + else if( sender == o_marq_tmOut_fld && [[sender stringValue] length] > 0 ) + { + val.i_int = [o_marq_tmOut_fld intValue]; + + if( p_input ) + var_Set( p_input->p_libvlc, "marq-timeout", val ); + + config_PutInt( p_intf, "marq-timeout", val.i_int ); + } + + /* time */ + + /* logo */ + + if ( p_input ) + { + o_config_changed = YES; + vlc_object_release( p_input ); + } +} + +- (IBAction)enableFilter:(id)sender +{ + if( sender == o_marq_enabled_ckb ) + { + if( [o_marq_enabled_ckb state] == NSOnState ) + { + [self changeFiltersString:"marq" onOrOff:VLC_TRUE]; + } + else + { + [self changeFiltersString:"marq" onOrOff:VLC_FALSE]; + } + [self enableMarq]; + } + if( sender == o_logo_enabled_ckb ) + { + if( [o_logo_enabled_ckb state] == NSOnState ) + { + [self changeFiltersString:"logo" onOrOff:VLC_TRUE]; + } + else + { + [self changeFiltersString:"logo" onOrOff:VLC_FALSE]; + } + [self enableLogo]; + } + if( sender == o_time_enabled_ckb ) + { + if( [o_time_enabled_ckb state] == NSOnState ) + { + [self changeFiltersString:"time" onOrOff:VLC_TRUE]; + } + else + { + [self changeFiltersString:"time" onOrOff:VLC_FALSE]; + } + [self enableTime]; + } +} + +- (void)enableMarq +{ + [o_marq_color_pop setEnabled: [o_marq_enabled_ckb state]]; + [o_marq_marq_fld setEnabled: [o_marq_enabled_ckb state]]; + [o_marq_opaque_sld setEnabled: [o_marq_enabled_ckb state]]; + [o_marq_pos_fix_btn setEnabled: [o_marq_enabled_ckb state]]; + [o_marq_pos_rel_btn setEnabled: [o_marq_enabled_ckb state]]; + [o_marq_size_pop setEnabled: [o_marq_enabled_ckb state]]; + [o_marq_tmOut_fld setEnabled: [o_marq_enabled_ckb state]]; + if( [o_marq_enabled_ckb state] ) + { + [self otherPositionForMarq: nil]; + } else { + [o_marq_pos_fix_X_fld setEnabled: NO]; + [o_marq_pos_fix_Y_fld setEnabled: NO]; + [o_marq_pos_rel_pop setEnabled: NO]; + } +} + +- (void)enableTime +{ + [o_time_color_pop setEnabled: [o_time_enabled_ckb state]]; + [o_time_stamp_fld setEnabled: [o_time_enabled_ckb state]]; + [o_time_opaque_sld setEnabled: [o_time_enabled_ckb state]]; + [o_time_pos_fix_btn setEnabled: [o_time_enabled_ckb state]]; + [o_time_pos_rel_btn setEnabled: [o_time_enabled_ckb state]]; + [o_time_size_pop setEnabled: [o_time_enabled_ckb state]]; + if( [o_time_enabled_ckb state] ) + { + [self otherPositionForTime: nil]; + } else { + [o_time_pos_fix_X_fld setEnabled: NO]; + [o_time_pos_fix_Y_fld setEnabled: NO]; + [o_time_pos_rel_pop setEnabled: NO]; + } +} + +- (void)enableLogo +{ + [o_logo_image_btn setEnabled: [o_logo_enabled_ckb state]]; + [o_logo_image_fld setEnabled: [o_logo_enabled_ckb state]]; + [o_logo_opaque_sld setEnabled: [o_logo_enabled_ckb state]]; + [o_logo_pos_fix_btn setEnabled: [o_logo_enabled_ckb state]]; + [o_logo_pos_rel_btn setEnabled: [o_logo_enabled_ckb state]]; + if( [o_logo_enabled_ckb state] ) + { + [self otherPositionForLogo: nil]; + } else { + [o_logo_pos_fix_X_fld setEnabled: NO]; + [o_logo_pos_fix_Y_fld setEnabled: NO]; + [o_logo_pos_rel_pop setEnabled: NO]; + } +} + +- (IBAction)otherPositionForLogo:(id)sender +{ + if( [o_logo_pos_fix_btn state] ) + { + [o_logo_pos_fix_X_fld setEnabled: YES]; + [o_logo_pos_fix_Y_fld setEnabled: YES]; + [o_logo_pos_rel_pop setEnabled: NO]; + } + else + { + [o_logo_pos_fix_X_fld setEnabled: NO]; + [o_logo_pos_fix_Y_fld setEnabled: NO]; + [o_logo_pos_rel_pop setEnabled: YES]; + } +} + +- (IBAction)otherPositionForMarq:(id)sender +{ + if( [o_marq_pos_fix_btn state] ) + { + [o_marq_pos_fix_X_fld setEnabled: YES]; + [o_marq_pos_fix_Y_fld setEnabled: YES]; + [o_marq_pos_rel_pop setEnabled: NO]; + } + else + { + [o_marq_pos_fix_X_fld setEnabled: NO]; + [o_marq_pos_fix_Y_fld setEnabled: NO]; + [o_marq_pos_rel_pop setEnabled: YES]; + } +} + +- (IBAction)otherPositionForTime:(id)sender +{ + if( [o_time_pos_fix_btn state] ) + { + [o_time_pos_fix_X_fld setEnabled: YES]; + [o_time_pos_fix_Y_fld setEnabled: YES]; + [o_time_pos_rel_pop setEnabled: NO]; + } + else + { + [o_time_pos_fix_X_fld setEnabled: NO]; + [o_time_pos_fix_Y_fld setEnabled: NO]; + [o_time_pos_rel_pop setEnabled: YES]; + } +} + +- (void)changeFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add +{ + /* copied from ../wxwidgets/extrapanel.cpp + * renamed to conform with Cocoa's rules + * and slightly modified to suit our needs */ + + intf_thread_t * p_intf = VLCIntf; + + char *psz_parser, *psz_string; + psz_string = config_GetPsz( p_intf, "sub-filter" ); + + if( !psz_string ) psz_string = strdup(""); + + psz_parser = strstr( psz_string, psz_name ); + + if( b_add ) + { + if( !psz_parser ) + { + psz_parser = psz_string; + asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s", + psz_string, psz_name ); + free( psz_parser ); + } + else + { + return; + } + } + else + { + if( psz_parser ) + { + memmove( psz_parser, psz_parser + strlen(psz_name) + + (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ), + strlen(psz_parser + strlen(psz_name)) + 1 ); + + /* Remove trailing : : */ + if( *(psz_string+strlen(psz_string ) -1 ) == ':' ) + { + *(psz_string+strlen(psz_string ) -1 ) = '\0'; + } + } + else + { + free( psz_string ); + return; + } + } + + config_PutPsz( p_intf, "sub-filter", psz_string ); + + /* Try to set on the fly */ + /* FIXME: enable this once we support on-the-fly addition of this kind of + * filters... + vout_thread_t *p_vout; + p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, + FIND_ANYWHERE ); + if( p_vout ) + { + var_SetString( p_vout, "sub-filter", psz_string ); + vlc_object_release( p_vout ); + }*/ + + free( psz_string ); + + vlc_object_release( p_intf ); + + o_config_changed = YES; +} +@end