VideoEffects.m 38.3 KB
Newer Older
1 2 3
/*****************************************************************************
 * VideoEffects.m: MacOS X interface module
 *****************************************************************************
4
 * Copyright (C) 2011-2012 Felix Paul Kühne
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

24
#import "CompatibilityFixes.h"
25 26
#import "intf.h"
#import <vlc_common.h>
27
#import <vlc_modules.h>
28 29
#import "VideoEffects.h"

30 31 32
#pragma mark -
#pragma mark Initialization & Generic code

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
@implementation VLCVideoEffects
static VLCVideoEffects *_o_sharedInstance = nil;

+ (VLCVideoEffects *)sharedInstance
{
    return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}

- (id)init
{
    if (_o_sharedInstance) {
        [self dealloc];
    } else {
        p_intf = VLCIntf;
        _o_sharedInstance = [super init];
    }
49

50 51 52
    return _o_sharedInstance;
}

53 54 55 56 57 58 59 60
- (IBAction)toggleWindow:(id)sender
{
    if( [o_window isVisible] )
        [o_window orderOut:sender];
    else
        [o_window makeKeyAndOrderFront:sender];
}

61 62 63 64
- (void)awakeFromNib
{
    [o_window setTitle: _NS("Video Effects")];
    [o_window setExcludedFromWindowsMenu:YES];
65
    if (OSX_LION)
66 67
        [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];

68 69 70 71
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"basic"]] setLabel:_NS("Basic")];
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"crop"]] setLabel:_NS("Crop")];
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"geometry"]] setLabel:_NS("Geometry")];
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"color"]] setLabel:_NS("Color")];
72
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"misc"]] setLabel:_NS("Miscellaneous")];
73 74 75 76 77 78 79 80

    [o_adjust_ckb setTitle:_NS("Image Adjust")];
    [o_adjust_hue_lbl setStringValue:_NS("Hue")];
    [o_adjust_contrast_lbl setStringValue:_NS("Contrast")];
    [o_adjust_brightness_lbl setStringValue:_NS("Brightness")];
    [o_adjust_brightness_ckb setTitle:_NS("Brightness Threshold")];
    [o_adjust_saturation_lbl setStringValue:_NS("Saturation")];
    [o_adjust_gamma_lbl setStringValue:_NS("Gamma")];
81
    [o_adjust_reset_btn setTitle: _NS("Reset")];
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    [o_sharpen_ckb setTitle:_NS("Sharpen")];
    [o_sharpen_lbl setStringValue:_NS("Sigma")];
    [o_banding_ckb setTitle:_NS("Banding removal")];
    [o_banding_lbl setStringValue:_NS("Radius")];
    [o_grain_ckb setTitle:_NS("Film Grain")];
    [o_grain_lbl setStringValue:_NS("Variance")];
    [o_crop_top_lbl setStringValue:_NS("Top")];
    [o_crop_left_lbl setStringValue:_NS("Left")];
    [o_crop_right_lbl setStringValue:_NS("Right")];
    [o_crop_bottom_lbl setStringValue:_NS("Bottom")];
    [o_crop_sync_top_bottom_ckb setTitle:_NS("Synchronize top and bottom")];
    [o_crop_sync_left_right_ckb setTitle:_NS("Synchronize left and right")];

    [o_transform_ckb setTitle:_NS("Transform")];
    [o_transform_pop removeAllItems];
    [o_transform_pop addItemWithTitle: _NS("Rotate by 90 degrees")];
    [[o_transform_pop lastItem] setTag: 90];
    [o_transform_pop addItemWithTitle: _NS("Rotate by 180 degrees")];
    [[o_transform_pop lastItem] setTag: 180];
    [o_transform_pop addItemWithTitle: _NS("Rotate by 270 degrees")];
    [[o_transform_pop lastItem] setTag: 270];
    [o_transform_pop addItemWithTitle: _NS("Flip horizontally")];
    [[o_transform_pop lastItem] setTag: 1];
    [o_transform_pop addItemWithTitle: _NS("Flip vertically")];
    [[o_transform_pop lastItem] setTag: 2];
    [o_zoom_ckb setTitle:_NS("Magnification/Zoom")];
    [o_puzzle_ckb setTitle:_NS("Puzzle game")];
    [o_puzzle_rows_lbl setStringValue:_NS("Rows")];
    [o_puzzle_columns_lbl setStringValue:_NS("Columns")];
    [o_puzzle_blackslot_ckb setTitle:_NS("Black Slot")];

    [o_threshold_ckb setTitle:_NS("Color threshold")];
    [o_threshold_color_lbl setStringValue:_NS("Color")];
    [o_threshold_saturation_lbl setStringValue:_NS("Saturation")];
    [o_threshold_similarity_lbl setStringValue:_NS("Similarity")];
    [o_sepia_ckb setTitle:_NS("Sepia")];
    [o_sepia_lbl setStringValue:_NS("Intensity")];
    [o_noise_ckb setTitle:_NS("Noise")];
    [o_gradient_ckb setTitle:_NS("Gradient")];
    [o_gradient_mode_lbl setStringValue:_NS("Mode")];
    [o_gradient_mode_pop removeAllItems];
    [o_gradient_mode_pop addItemWithTitle: _NS("Gradient")];
    [[o_gradient_mode_pop lastItem] setTag: 1];
    [o_gradient_mode_pop addItemWithTitle: _NS("Edge")];
    [[o_gradient_mode_pop lastItem] setTag: 2];
    [o_gradient_mode_pop addItemWithTitle: _NS("Hough")];
    [[o_gradient_mode_pop lastItem] setTag: 3];
    [o_gradient_color_ckb setTitle:_NS("Color")];
    [o_gradient_cartoon_ckb setTitle:_NS("Cartoon")];
    [o_extract_ckb setTitle:_NS("Color extraction")];
    [o_extract_lbl setStringValue:_NS("Color")];
    [o_invert_ckb setTitle:_NS("Invert colors")];
    [o_posterize_ckb setTitle:_NS("Posterize")];
    [o_posterize_lbl setStringValue:_NS("Posterize level")];
136
    [o_blur_ckb setTitle:_NS("Motion blur")];
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    [o_blur_lbl setStringValue:_NS("Factor")];
    [o_motiondetect_ckb setTitle:_NS("Motion Detect")];
    [o_watereffect_ckb setTitle:_NS("Water effect")];
    [o_waves_ckb setTitle:_NS("Waves")];
    [o_psychedelic_ckb setTitle:_NS("Psychedelic")];

    [o_addtext_ckb setTitle:_NS("Add text")];
    [o_addtext_text_lbl setStringValue:_NS("Text")];
    [o_addtext_pos_lbl setStringValue:_NS("Position")];
    [o_addtext_pos_pop removeAllItems];
    [o_addtext_pos_pop addItemWithTitle: _NS("Center")];
    [[o_addtext_pos_pop lastItem] setTag: 0];
    [o_addtext_pos_pop addItemWithTitle: _NS("Left")];
    [[o_addtext_pos_pop lastItem] setTag: 1];
    [o_addtext_pos_pop addItemWithTitle: _NS("Right")];
    [[o_addtext_pos_pop lastItem] setTag: 2];
    [o_addtext_pos_pop addItemWithTitle: _NS("Top")];
    [[o_addtext_pos_pop lastItem] setTag: 4];
    [o_addtext_pos_pop addItemWithTitle: _NS("Bottom")];
    [[o_addtext_pos_pop lastItem] setTag: 8];
    [o_addtext_pos_pop addItemWithTitle: _NS("Top-Left")];
    [[o_addtext_pos_pop lastItem] setTag: 5];
    [o_addtext_pos_pop addItemWithTitle: _NS("Top-Right")];
    [[o_addtext_pos_pop lastItem] setTag: 6];
    [o_addtext_pos_pop addItemWithTitle: _NS("Bottom-Left")];
    [[o_addtext_pos_pop lastItem] setTag: 9];
    [o_addtext_pos_pop addItemWithTitle: _NS("Bottom-Right")];
    [[o_addtext_pos_pop lastItem] setTag: 10];
    [o_addlogo_ckb setTitle:_NS("Add logo")];
    [o_addlogo_logo_lbl setStringValue:_NS("Logo")];
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
    [o_addlogo_pos_lbl setStringValue:_NS("Position")];
    [o_addlogo_pos_pop removeAllItems];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Center")];
    [[o_addlogo_pos_pop lastItem] setTag: 0];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Left")];
    [[o_addlogo_pos_pop lastItem] setTag: 1];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Right")];
    [[o_addlogo_pos_pop lastItem] setTag: 2];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Top")];
    [[o_addlogo_pos_pop lastItem] setTag: 4];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom")];
    [[o_addlogo_pos_pop lastItem] setTag: 8];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Top-Left")];
    [[o_addlogo_pos_pop lastItem] setTag: 5];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Top-Right")];
    [[o_addlogo_pos_pop lastItem] setTag: 6];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom-Left")];
    [[o_addlogo_pos_pop lastItem] setTag: 9];
    [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom-Right")];
    [[o_addlogo_pos_pop lastItem] setTag: 10];
187 188
    [o_addlogo_transparency_lbl setStringValue:_NS("Transparency")];

189 190
    [o_tableView selectFirstTabViewItem:self];

191 192 193 194 195 196
    [self resetValues];
}

- (void)resetValues
{
    NSString *tmpString;
197
    char *tmpChar;
198 199
    BOOL b_state;

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
    /* do we have any filter enabled? if yes, show it. */
    char * psz_vfilters;
    psz_vfilters = config_GetPsz( p_intf, "video-filter" );
    if( psz_vfilters ) {
        [o_adjust_ckb setState: (NSInteger)strstr( psz_vfilters, "adjust")];
        [o_sharpen_ckb setState: (NSInteger)strstr( psz_vfilters, "sharpen")];
        [o_banding_ckb setState: (NSInteger)strstr( psz_vfilters, "gradfun")];
        [o_grain_ckb setState: (NSInteger)strstr( psz_vfilters, "grain")];
        [o_transform_ckb setState: (NSInteger)strstr( psz_vfilters, "transform")];
        [o_zoom_ckb setState: (NSInteger)strstr( psz_vfilters, "magnify")];
        [o_puzzle_ckb setState: (NSInteger)strstr( psz_vfilters, "puzzle")];
        [o_threshold_ckb setState: (NSInteger)strstr( psz_vfilters, "colorthres")];
        [o_sepia_ckb setState: (NSInteger)strstr( psz_vfilters, "sepia")];
        [o_noise_ckb setState: (NSInteger)strstr( psz_vfilters, "noise")];
        [o_gradient_ckb setState: (NSInteger)strstr( psz_vfilters, "gradient")];
        [o_extract_ckb setState: (NSInteger)strstr( psz_vfilters, "extract")];
        [o_invert_ckb setState: (NSInteger)strstr( psz_vfilters, "invert")];
        [o_posterize_ckb setState: (NSInteger)strstr( psz_vfilters, "posterize")];
        [o_blur_ckb setState: (NSInteger)strstr( psz_vfilters, "motionblur")];
        [o_motiondetect_ckb setState: (NSInteger)strstr( psz_vfilters, "motiondetect")];
        [o_watereffect_ckb setState: (NSInteger)strstr( psz_vfilters, "ripple")];
        [o_waves_ckb setState: (NSInteger)strstr( psz_vfilters, "wave")];
        [o_psychedelic_ckb setState: (NSInteger)strstr( psz_vfilters, "psychedelic")];
        free( psz_vfilters );
    }
225 226 227 228 229 230
    psz_vfilters = config_GetPsz( p_intf, "sub-source" );
    if (psz_vfilters) {
        [o_addtext_ckb setState: (NSInteger)strstr( psz_vfilters, "marq" )];
        [o_addlogo_ckb setState: (NSInteger)strstr( psz_vfilters, "logo" )];
        free( psz_vfilters );
    }
231 232 233 234 235 236 237

    /* fetch and show the various values */
    [o_adjust_hue_sld setIntValue: config_GetInt( p_intf, "hue" )];
    [o_adjust_contrast_sld setFloatValue: config_GetFloat( p_intf, "contrast" )];
    [o_adjust_brightness_sld setFloatValue: config_GetFloat( p_intf, "brightness" )];
    [o_adjust_saturation_sld setFloatValue: config_GetFloat( p_intf, "saturation" )];
    [o_adjust_gamma_sld setFloatValue: config_GetFloat( p_intf, "gamma" )];
238 239 240 241 242
    [o_adjust_brightness_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "brightness" )]];
    [o_adjust_contrast_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "contrast" )]];
    [o_adjust_gamma_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "gamma" )]];
    [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "hue" )]];
    [o_adjust_saturation_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "saturation" )]];
243 244 245 246 247 248 249 250 251 252 253 254
    b_state = [o_adjust_ckb state];
    [o_adjust_brightness_sld setEnabled: b_state];
    [o_adjust_brightness_ckb setEnabled: b_state];
    [o_adjust_contrast_sld setEnabled: b_state];
    [o_adjust_gamma_sld setEnabled: b_state];
    [o_adjust_hue_sld setEnabled: b_state];
    [o_adjust_saturation_sld setEnabled: b_state];
    [o_adjust_brightness_lbl setEnabled: b_state];
    [o_adjust_contrast_lbl setEnabled: b_state];
    [o_adjust_gamma_lbl setEnabled: b_state];
    [o_adjust_hue_lbl setEnabled: b_state];
    [o_adjust_saturation_lbl setEnabled: b_state];
255
    [o_adjust_reset_btn setEnabled: b_state];
256
    [o_sharpen_sld setFloatValue: config_GetFloat( p_intf, "sharpen-sigma" )];
257
    [o_sharpen_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "sharpen-sigma" )]];
258
    [o_sharpen_sld setEnabled: [o_sharpen_ckb state]];
259
    [o_sharpen_lbl setEnabled: [o_sharpen_ckb state]];
260
    [o_banding_sld setIntValue: config_GetInt( p_intf, "gradfun-radius" )];
261
    [o_banding_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "gradfun-radius" )]];
262
    [o_banding_sld setEnabled: [o_banding_ckb state]];
263
    [o_banding_lbl setEnabled: [o_banding_ckb state]];
264
    [o_grain_sld setFloatValue: config_GetFloat( p_intf, "grain-variance" )];
265
    [o_grain_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "grain-variance" )]];
266
    [o_grain_sld setEnabled: [o_grain_ckb state]];
267
    [o_grain_lbl setEnabled: [o_grain_ckb state]];
268 269 270 271 272 273 274 275

    [o_crop_top_fld setIntValue: 0];
    [o_crop_left_fld setIntValue: 0];
    [o_crop_right_fld setIntValue: 0];
    [o_crop_bottom_fld setIntValue: 0];
    [o_crop_sync_top_bottom_ckb setState: NSOffState];
    [o_crop_sync_left_right_ckb setState: NSOffState];

276 277
    tmpChar = config_GetPsz( p_intf, "transform-type" );
    tmpString = [NSString stringWithUTF8String: tmpChar];
278 279 280 281 282 283
    if( [tmpString isEqualToString:@"hflip"] )
        [o_transform_pop selectItemWithTag: 1];
    else if( [tmpString isEqualToString:@"vflip"] )
        [o_transform_pop selectItemWithTag: 2];
    else
        [o_transform_pop selectItemWithTag:[tmpString intValue]];
284
    FREENULL( tmpChar );
285 286 287 288
    [o_transform_pop setEnabled: [o_transform_ckb state]];
    [o_puzzle_rows_fld setIntValue: config_GetInt( p_intf, "puzzle-rows" )];
    [o_puzzle_columns_fld setIntValue: config_GetInt( p_intf, "puzzle-cols" )];
    [o_puzzle_blackslot_ckb setState: config_GetInt( p_intf, "puzzle-black-slot" )];
289 290 291 292 293 294
    b_state = [o_puzzle_ckb state];
    [o_puzzle_rows_fld setEnabled: b_state];
    [o_puzzle_rows_lbl setEnabled: b_state];
    [o_puzzle_columns_fld setEnabled: b_state];
    [o_puzzle_columns_lbl setEnabled: b_state];
    [o_puzzle_blackslot_ckb setEnabled: b_state];
295

296
    [o_threshold_color_fld setStringValue: [[NSString stringWithFormat:@"%x", config_GetInt( p_intf, "colorthres-color" )] uppercaseString]];
297
    [o_threshold_saturation_sld setIntValue: config_GetInt( p_intf, "colorthres-saturationthres" )];
298
    [o_threshold_saturation_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "colorthres-saturationthres" )]];
299
    [o_threshold_similarity_sld setIntValue: config_GetInt( p_intf, "colorthres-similaritythres" )];
300
    [o_threshold_similarity_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "colorthres-similaritythres" )]];
301 302 303 304 305 306 307
    b_state = [o_threshold_ckb state];
    [o_threshold_color_fld setEnabled: b_state];
    [o_threshold_color_lbl setEnabled: b_state];
    [o_threshold_saturation_sld setEnabled: b_state];
    [o_threshold_saturation_lbl setEnabled: b_state];
    [o_threshold_similarity_sld setEnabled: b_state];
    [o_threshold_similarity_lbl setEnabled: b_state];
308 309
    [o_sepia_fld setIntValue: config_GetInt( p_intf, "sepia-intensity" )];
    [o_sepia_fld setEnabled: [o_sepia_ckb state]];
310
    [o_sepia_lbl setEnabled: [o_sepia_ckb state]];
311 312
    tmpChar = config_GetPsz( p_intf, "gradient-mode" );
    tmpString = [NSString stringWithUTF8String: tmpChar];
313 314 315 316 317 318
    if( [tmpString isEqualToString:@"hough"] )
        [o_gradient_mode_pop selectItemWithTag: 3];
    else if( [tmpString isEqualToString:@"edge"] )
        [o_gradient_mode_pop selectItemWithTag: 2];
    else
        [o_gradient_mode_pop selectItemWithTag: 1];
319
    FREENULL( tmpChar );
320 321
    [o_gradient_cartoon_ckb setState: config_GetInt( p_intf, "gradient-cartoon" )];
    [o_gradient_color_ckb setState: config_GetInt( p_intf, "gradient-type" )];
322 323 324 325 326
    b_state = [o_gradient_ckb state];
    [o_gradient_mode_pop setEnabled: b_state];
    [o_gradient_mode_lbl setEnabled: b_state];
    [o_gradient_cartoon_ckb setEnabled: b_state];
    [o_gradient_color_ckb setEnabled: b_state];
327
    [o_extract_fld setStringValue: [[NSString stringWithFormat:@"%x", config_GetInt( p_intf, "extract-component" )] uppercaseString]];
328
    [o_extract_fld setEnabled: [o_extract_ckb state]];
329
    [o_extract_lbl setEnabled: [o_extract_ckb state]];
330 331
    [o_posterize_fld setIntValue: config_GetInt( p_intf, "posterize-level" )];
    [o_posterize_fld setEnabled: [o_posterize_ckb state]];
332
    [o_posterize_lbl setEnabled: [o_posterize_ckb state]];
333
    [o_blur_sld setIntValue: config_GetInt( p_intf, "blur-factor" )];
334
    [o_blur_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "blur-factor" )]];
335
    [o_blur_sld setEnabled: [o_blur_ckb state]];
336
    [o_blur_lbl setEnabled: [o_blur_ckb state]];
337

338 339 340 341 342 343
    tmpChar = config_GetPsz( p_intf, "marq-marquee" );
    if( tmpChar )
    {
        [o_addtext_text_fld setStringValue: [NSString stringWithUTF8String: tmpChar]];
        FREENULL( tmpChar );
    }
344
    [o_addtext_pos_pop selectItemWithTag: config_GetInt( p_intf, "marq-position" )];
345 346 347 348 349
    b_state = [o_addtext_ckb state];
    [o_addtext_pos_pop setEnabled: b_state];
    [o_addtext_pos_lbl setEnabled: b_state];
    [o_addtext_text_lbl setEnabled: b_state];
    [o_addtext_text_fld setEnabled: b_state];
350

351 352 353 354 355 356
    tmpChar = config_GetPsz( p_intf, "logo-file" );
    if( tmpChar )
    {
       [o_addlogo_logo_fld setStringValue: [NSString stringWithUTF8String: tmpChar]];
        FREENULL( tmpChar );
    }
357
    [o_addlogo_pos_pop selectItemWithTag: config_GetInt( p_intf, "logo-position" )];
358
    [o_addlogo_transparency_sld setIntValue: config_GetInt( p_intf, "logo-opacity" )];
359
    [o_addlogo_transparency_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "logo-opacity" )]];
360 361 362 363 364 365 366
    b_state = [o_addlogo_ckb state];
    [o_addlogo_pos_pop setEnabled: b_state];
    [o_addlogo_pos_lbl setEnabled: b_state];
    [o_addlogo_logo_fld setEnabled: b_state];
    [o_addlogo_logo_lbl setEnabled: b_state];
    [o_addlogo_transparency_sld setEnabled: b_state];
    [o_addlogo_transparency_lbl setEnabled: b_state];
367 368 369 370
}

- (void)setVideoFilter: (char *)psz_name on:(BOOL)b_on
{
371 372
    char *psz_string, *psz_parser;
    const char *psz_filter_type;
373

374 375 376 377 378 379
    module_t *p_obj = module_find( psz_name );
    if( !p_obj )
    {
        msg_Err( p_intf, "Unable to find filter module \"%s\".", psz_name );
        return;
    }
380
    msg_Dbg( p_intf, "will set filter '%s'", psz_name );
381 382 383 384 385 386 387 388 389 390 391 392 393 394

    if( module_provides( p_obj, "video splitter" ) )
    {
        psz_filter_type = "video-splitter";
    }
    else if( module_provides( p_obj, "video filter2" ) )
    {
        psz_filter_type = "video-filter";
    }
    else if( module_provides( p_obj, "sub source" ) )
    {
        psz_filter_type = "sub-source";
    }
    else if( module_provides( p_obj, "sub filter" ) )
395
    {
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
        psz_filter_type = "sub-filter";
    }
    else
    {
        msg_Err( p_intf, "Unknown video filter type." );
        return;
    }

    psz_string = config_GetPsz( p_intf, psz_filter_type );

    if (b_on) {
        if(! psz_string)
            psz_string = psz_name;
        else if( (NSInteger)strstr( psz_string, psz_name ) == NO )
            psz_string = (char *)[[NSString stringWithFormat: @"%s:%s", psz_string, psz_name] UTF8String];
    } else {
        psz_parser = strstr( psz_string, psz_name );
        if( psz_parser )
414
        {
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
            if( *( psz_parser + strlen( psz_name ) ) == ':' )
            {
                memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
                        strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
            }
            else
            {
                *psz_parser = '\0';
            }

            /* Remove trailing : : */
            if( strlen( psz_string ) > 0 &&
               *( psz_string + strlen( psz_string ) -1 ) == ':' )
            {
                *( psz_string + strlen( psz_string ) -1 ) = '\0';
            }
431
        }
432
        else
433
        {
434 435
            free( psz_string );
            return;
436 437
        }
    }
438
    config_PutPsz( p_intf, psz_filter_type, psz_string );
439

440 441 442 443 444 445 446 447 448 449 450 451 452 453
    /* Try to set on the fly */
    if( !strcmp( psz_filter_type, "video-splitter" ) )
    {
        playlist_t *p_playlist = pl_Get( p_intf );
        var_SetString( p_playlist, psz_filter_type, psz_string );
    }
    else
    {
        vout_thread_t *p_vout = getVout();
        if( p_vout )
        {
            var_SetString( p_vout, psz_filter_type, psz_string );
            vlc_object_release( p_vout );
        }
454 455 456
    }
}

457 458
- (void)restartFilterIfNeeded: (char *)psz_filter option: (char *)psz_name
{
459 460 461 462 463 464 465
    vout_thread_t *p_vout = getVout();

    if (p_vout == NULL)
        return;
    else
        vlc_object_release( p_vout );

466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
    vlc_object_t *p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
    int i_type;
    i_type = var_Type( p_filter, psz_name );
    if( i_type == 0 )
        i_type = config_GetType( p_intf, psz_name );

    if( !(i_type & VLC_VAR_ISCOMMAND) )
    {
        msg_Warn( p_intf, "Brute-restarting filter '%s', because the last changed option isn't a command", psz_name );
        [self setVideoFilter: psz_filter on: NO];
        [self setVideoFilter: psz_filter on: YES];
    }
    else
        msg_Dbg( p_intf, "restart not needed" );

    if( p_filter )
        vlc_object_release( p_filter );
}

485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
- (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter integer: (int)i_value
{
    vout_thread_t *p_vout = getVout();
    vlc_object_t *p_filter;

    if( p_vout == NULL ) {
        config_PutInt( p_intf , psz_name , i_value );
    } else {
        p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );

        if(! p_filter ) {
            msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
            vlc_object_release( p_vout );
            return;
        }
500 501
        var_SetInteger( p_filter, psz_name, i_value );
        config_PutInt( p_intf, psz_name, i_value );
502
        vlc_object_release( p_vout );
503
        vlc_object_release( p_filter );
504
    }
505 506

    [self restartFilterIfNeeded:psz_filter option: psz_name];
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
}

- (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter float: (float)f_value
{
    vout_thread_t *p_vout = getVout();
    vlc_object_t *p_filter;

    if( p_vout == NULL ) {
        config_PutFloat( p_intf , psz_name , f_value );
    } else {
        p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );

        if(! p_filter ) {
            msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
            vlc_object_release( p_vout );
            return;
        }
        var_SetFloat( p_filter, psz_name, f_value );
        config_PutFloat( p_intf, psz_name, f_value );
        vlc_object_release( p_vout );
527 528
        vlc_object_release( p_filter );

529 530
        [self restartFilterIfNeeded:psz_filter option: psz_name];
    }
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
}

- (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter string: (char *)psz_value
{
    vout_thread_t *p_vout = getVout();
    vlc_object_t *p_filter;

    if( p_vout == NULL ) {
        config_PutPsz( p_intf, psz_name, psz_value );
    } else {
        p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );

        if(! p_filter ) {
            msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
            vlc_object_release( p_vout );
            return;
        }
        var_SetString( p_filter, psz_name, psz_value );
        config_PutPsz( p_intf, psz_name, psz_value );
        vlc_object_release( p_vout );
551 552
        vlc_object_release( p_filter );

553 554
        [self restartFilterIfNeeded:psz_filter option: psz_name];
    }
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
}

- (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter boolean: (BOOL)b_value
{
    vout_thread_t *p_vout = getVout();
    vlc_object_t *p_filter;

    if( p_vout == NULL ) {
        config_PutInt( p_intf, psz_name, b_value );
    } else {
        p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );

        if(! p_filter ) {
            msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
            vlc_object_release( p_vout );
            return;
        }
        var_SetBool( p_filter, psz_name, b_value );
        config_PutInt( p_intf, psz_name, b_value );
        vlc_object_release( p_vout );
    }
}

578 579 580 581
#pragma mark -
#pragma mark basic
- (IBAction)enableAdjust:(id)sender
{
582 583 584 585 586 587 588 589 590 591 592 593 594 595
    BOOL b_state = [o_adjust_ckb state];

    [self setVideoFilter: "adjust" on: b_state];
    [o_adjust_brightness_sld setEnabled: b_state];
    [o_adjust_brightness_ckb setEnabled: b_state];
    [o_adjust_brightness_lbl setEnabled: b_state];
    [o_adjust_contrast_sld setEnabled: b_state];
    [o_adjust_contrast_lbl setEnabled: b_state];
    [o_adjust_gamma_sld setEnabled: b_state];
    [o_adjust_gamma_lbl setEnabled: b_state];
    [o_adjust_hue_sld setEnabled: b_state];
    [o_adjust_hue_lbl setEnabled: b_state];
    [o_adjust_saturation_sld setEnabled: b_state];
    [o_adjust_saturation_lbl setEnabled: b_state];
596
    [o_adjust_reset_btn setEnabled: b_state];
597 598 599 600
}

- (IBAction)adjustSliderChanged:(id)sender
{
601
    if( sender == o_adjust_brightness_sld )
602 603 604 605 606 607 608 609 610
        [self setVideoFilterProperty: "brightness" forFilter: "adjust" float: [o_adjust_brightness_sld floatValue]];
    else if( sender == o_adjust_contrast_sld )
        [self setVideoFilterProperty: "contrast" forFilter: "adjust" float: [o_adjust_contrast_sld floatValue]];
    else if( sender == o_adjust_gamma_sld )
        [self setVideoFilterProperty: "gamma" forFilter: "adjust" float: [o_adjust_gamma_sld floatValue]];
    else if( sender == o_adjust_hue_sld )
        [self setVideoFilterProperty: "hue" forFilter: "adjust" integer: [o_adjust_hue_sld intValue]];
    else if( sender == o_adjust_saturation_sld )
        [self setVideoFilterProperty: "saturation" forFilter: "adjust" float: [o_adjust_saturation_sld floatValue]];
611 612 613 614 615

    if( sender == o_adjust_hue_sld )
        [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", [o_adjust_hue_sld intValue]]];
    else
        [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
616 617 618 619
}

- (IBAction)enableAdjustBrightnessThreshold:(id)sender
{
620 621 622 623 624
    if (sender == o_adjust_reset_btn)
    {
        [o_adjust_brightness_sld setFloatValue: 1.0];
        [o_adjust_contrast_sld setFloatValue: 1.0];
        [o_adjust_gamma_sld setFloatValue: 1.0];
625
        [o_adjust_hue_sld setIntValue: 0];
626
        [o_adjust_saturation_sld setFloatValue: 1.0];
627 628 629 630 631 632 633 634 635 636
        [o_adjust_brightness_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
        [o_adjust_contrast_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
        [o_adjust_gamma_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
        [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", 0]];
        [o_adjust_saturation_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
        [self setVideoFilterProperty: "brightness" forFilter: "adjust" float: 1.0];
        [self setVideoFilterProperty: "contrast" forFilter: "adjust" float: 1.0];
        [self setVideoFilterProperty: "gamma" forFilter: "adjust" float: 1.0];
        [self setVideoFilterProperty: "hue" forFilter: "adjust" integer: 0.0];
        [self setVideoFilterProperty: "saturation" forFilter: "adjust" float: 1.0];
637 638 639
    }
    else
        config_PutInt( p_intf, "brightness-threshold", [o_adjust_brightness_ckb state] );
640 641 642 643
}

- (IBAction)enableSharpen:(id)sender
{
644 645 646 647 648
    BOOL b_state = [o_sharpen_ckb state];

    [self setVideoFilter: "sharpen" on: b_state];
    [o_sharpen_sld setEnabled: b_state];
    [o_sharpen_lbl setEnabled: b_state];
649 650 651 652
}

- (IBAction)sharpenSliderChanged:(id)sender
{
653 654
    [self setVideoFilterProperty: "sharpen-sigma" forFilter: "sharpen" float: [sender floatValue]];
    [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
655 656 657 658
}

- (IBAction)enableBanding:(id)sender
{
659 660 661 662 663
    BOOL b_state = [o_banding_ckb state];

    [self setVideoFilter: "gradfun" on: b_state];
    [o_banding_sld setEnabled: b_state];
    [o_banding_lbl setEnabled: b_state];
664 665 666 667
}

- (IBAction)bandingSliderChanged:(id)sender
{
668 669
    [self setVideoFilterProperty: "gradfun-radius" forFilter: "gradfun" integer: [sender intValue]];
    [sender setToolTip: [NSString stringWithFormat:@"%i", [sender intValue]]];
670 671 672 673
}

- (IBAction)enableGrain:(id)sender
{
674 675 676 677 678
    BOOL b_state = [o_grain_ckb state];

    [self setVideoFilter: "grain" on: b_state];
    [o_grain_sld setEnabled: b_state];
    [o_grain_lbl setEnabled: b_state];
679 680 681 682
}

- (IBAction)grainSliderChanged:(id)sender
{
683 684
    [self setVideoFilterProperty: "grain-variance" forFilter: "grain" float: [sender floatValue]];
    [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
685 686 687 688 689
}


#pragma mark -
#pragma mark crop
690 691 692 693 694

#define updateopposite( giver, taker ) \
    if (sender == giver) \
        [taker setIntValue: [giver intValue]]

695
- (IBAction)cropObjectChanged:(id)sender
696
{
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
    updateopposite( o_crop_top_fld, o_crop_top_stp );
    updateopposite( o_crop_top_stp, o_crop_top_fld );
    updateopposite( o_crop_left_fld, o_crop_left_stp );
    updateopposite( o_crop_left_stp, o_crop_left_fld );
    updateopposite( o_crop_right_fld, o_crop_right_stp );
    updateopposite( o_crop_right_stp, o_crop_right_fld );
    updateopposite( o_crop_bottom_fld, o_crop_bottom_stp );
    updateopposite( o_crop_bottom_stp, o_crop_bottom_fld );

    if( [o_crop_sync_top_bottom_ckb state] ) {
        if (sender == o_crop_top_fld || sender == o_crop_top_stp ) {
            [o_crop_bottom_fld setIntValue: [o_crop_top_fld intValue]];
            [o_crop_bottom_stp setIntValue: [o_crop_top_fld intValue]];
        }
        else
        {
            [o_crop_top_fld setIntValue: [o_crop_bottom_fld intValue]];
            [o_crop_top_stp setIntValue: [o_crop_bottom_fld intValue]];
        }
    }
    if( [o_crop_sync_left_right_ckb state] ) {
        if (sender == o_crop_left_fld || sender == o_crop_left_stp ) {
            [o_crop_right_fld setIntValue: [o_crop_left_fld intValue]];
            [o_crop_right_stp setIntValue: [o_crop_left_fld intValue]];
        }
        else
        {
            [o_crop_left_fld setIntValue: [o_crop_right_fld intValue]];
            [o_crop_left_stp setIntValue: [o_crop_right_fld intValue]];
        }
    }
728

729 730 731 732 733 734 735 736
    vout_thread_t *p_vout = getVout();
    if( p_vout ) {
        var_SetInteger( p_vout, "crop-top", [o_crop_top_fld intValue] );
        var_SetInteger( p_vout, "crop-bottom", [o_crop_bottom_fld intValue] );
        var_SetInteger( p_vout, "crop-left", [o_crop_left_fld intValue] );
        var_SetInteger( p_vout, "crop-right", [o_crop_right_fld intValue] );
        vlc_object_release( p_vout );
    }
737 738
}

739 740
#undef updateopposite

741 742 743 744
#pragma mark -
#pragma mark geometry
- (IBAction)enableTransform:(id)sender
{
745 746
    [self setVideoFilter: "transform" on: [o_transform_ckb state]];
    [o_transform_pop setEnabled: [o_transform_ckb state]];
747 748 749 750
}

- (IBAction)transformModifierChanged:(id)sender
{
751 752 753 754 755 756 757 758
    NSInteger tag = [[o_transform_pop selectedItem] tag];
    char * psz_string = (char *)[[NSString stringWithFormat:@"%i", tag] UTF8String];
    if( tag == 1 )
        psz_string = (char *)"hflip";
    else if( tag == 2 )
        psz_string = (char *)"vflip";

    [self setVideoFilterProperty: "transform-type" forFilter: "transform" string: psz_string];
759 760 761 762
}

- (IBAction)enableZoom:(id)sender
{
763
    [self setVideoFilter: "magnify" on: [o_zoom_ckb state]];
764 765 766 767
}

- (IBAction)enablePuzzle:(id)sender
{
768 769 770 771 772 773 774 775
    BOOL b_state = [o_puzzle_ckb state];

    [self setVideoFilter: "puzzle" on: b_state];
    [o_puzzle_columns_fld setEnabled: b_state];
    [o_puzzle_columns_lbl setEnabled: b_state];
    [o_puzzle_rows_fld setEnabled: b_state];
    [o_puzzle_rows_lbl setEnabled: b_state];
    [o_puzzle_blackslot_ckb setEnabled: b_state];
776 777 778 779
}

- (IBAction)puzzleModifierChanged:(id)sender
{
780 781 782 783 784 785
    if( sender == o_puzzle_blackslot_ckb )
        [self setVideoFilterProperty: "puzzle-black-slot" forFilter: "puzzle" boolean: [o_puzzle_blackslot_ckb state]];
    else if( sender == o_puzzle_columns_fld )
        [self setVideoFilterProperty: "puzzle-cols" forFilter: "puzzle" integer: [o_puzzle_columns_fld intValue]];
    else
        [self setVideoFilterProperty: "puzzle-rows" forFilter: "puzzle" integer: [o_puzzle_rows_fld intValue]];
786 787 788 789 790 791 792
}


#pragma mark -
#pragma mark color
- (IBAction)enableThreshold:(id)sender
{
793 794 795 796 797 798 799 800 801
    BOOL b_state = [o_threshold_ckb state];

    [self setVideoFilter: "colorthres" on: b_state];
    [o_threshold_color_fld setEnabled: b_state];
    [o_threshold_color_lbl setEnabled: b_state];
    [o_threshold_saturation_sld setEnabled: b_state];
    [o_threshold_saturation_lbl setEnabled: b_state];
    [o_threshold_similarity_sld setEnabled: b_state];
    [o_threshold_similarity_lbl setEnabled: b_state];
802 803 804 805
}

- (IBAction)thresholdModifierChanged:(id)sender
{
806 807 808
    if( sender == o_threshold_color_fld )
        [self setVideoFilterProperty: "colorthres-color" forFilter: "colorthres" integer: [o_threshold_color_fld intValue]];
    else if( sender == o_threshold_saturation_sld )
809
    {
810
        [self setVideoFilterProperty: "colorthres-saturationthres" forFilter: "colorthres" integer: [o_threshold_saturation_sld intValue]];
811 812
        [o_threshold_saturation_sld setToolTip: [NSString stringWithFormat:@"%i", [o_threshold_saturation_sld intValue]]];
    }
813
    else
814
    {
815
        [self setVideoFilterProperty: "colorthres-similaritythres" forFilter: "colorthres" integer: [o_threshold_similarity_sld intValue]];
816 817
        [o_threshold_similarity_sld setToolTip: [NSString stringWithFormat:@"%i", [o_threshold_similarity_sld intValue]]];
    }
818 819 820 821
}

- (IBAction)enableSepia:(id)sender
{
822 823 824 825 826
    BOOL b_state = [o_sepia_ckb state];

    [self setVideoFilter: "sepia" on: b_state];
    [o_sepia_fld setEnabled: b_state];
    [o_sepia_lbl setEnabled: b_state];
827 828 829 830
}

- (IBAction)sepiaModifierChanged:(id)sender
{
831
    [self setVideoFilterProperty: "sepia-intensity" forFilter: "sepia" integer: [o_sepia_fld intValue]];
832 833 834 835
}

- (IBAction)enableNoise:(id)sender
{
836
    [self setVideoFilter: "noise" on: [o_noise_ckb state]];
837 838 839 840
}

- (IBAction)enableGradient:(id)sender
{
841 842 843 844 845 846 847
    BOOL b_state = [o_gradient_ckb state];

    [self setVideoFilter: "gradient" on: b_state];
    [o_gradient_mode_pop setEnabled: b_state];
    [o_gradient_mode_lbl setEnabled: b_state];
    [o_gradient_color_ckb setEnabled: b_state];
    [o_gradient_cartoon_ckb setEnabled: b_state];
848 849 850 851
}

- (IBAction)gradientModifierChanged:(id)sender
{
852 853 854 855 856 857 858 859 860 861 862 863
    if( sender == o_gradient_mode_pop ) {
        if( [[o_gradient_mode_pop selectedItem] tag] == 3 )
            [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "hough"];
        else if( [[o_gradient_mode_pop selectedItem] tag] == 2 )
            [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "edge"];
        else
            [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "gradient"];
    }
    else if( sender == o_gradient_color_ckb )
        [self setVideoFilterProperty: "gradient-type" forFilter: "gradient" integer: [o_gradient_color_ckb state]];
    else
        [self setVideoFilterProperty: "gradient-cartoon" forFilter: "gradient" boolean: [o_gradient_cartoon_ckb state]];
864 865 866 867
}

- (IBAction)enableExtract:(id)sender
{
868 869 870 871
    BOOL b_state = [o_extract_ckb state]; 
    [self setVideoFilter: "extract" on: b_state];
    [o_extract_fld setEnabled: b_state];
    [o_extract_lbl setEnabled: b_state];
872 873 874 875
}

- (IBAction)extractModifierChanged:(id)sender
{
876
    [self setVideoFilterProperty: "extract-component" forFilter: "extract" integer: [o_extract_fld intValue]];  
877 878 879 880
}

- (IBAction)enableInvert:(id)sender
{
881
    [self setVideoFilter: "invert" on: [o_invert_ckb state]];
882 883 884 885
}

- (IBAction)enablePosterize:(id)sender
{
886 887 888 889 890
    BOOL b_state = [o_posterize_ckb state];

    [self setVideoFilter: "posterize" on: b_state];
    [o_posterize_fld setEnabled: b_state];
    [o_posterize_lbl setEnabled: b_state];
891 892 893 894
}

- (IBAction)posterizeModifierChanged:(id)sender
{
895
    [self setVideoFilterProperty: "posterize-level" forFilter: "posterize" integer: [o_extract_fld intValue]];
896 897 898 899
}

- (IBAction)enableBlur:(id)sender
{
900 901 902 903 904
    BOOL b_state = [o_blur_ckb state];

    [self setVideoFilter: "motionblur" on: b_state];
    [o_blur_sld setEnabled: b_state];
    [o_blur_lbl setEnabled: b_state];
905 906 907 908
}

- (IBAction)blurModifierChanged:(id)sender
{
909 910
    [self setVideoFilterProperty: "blur-factor" forFilter: "motionblur" integer: [sender intValue]];
    [sender setToolTip: [NSString stringWithFormat:@"%i", [sender intValue]]];
911 912 913 914
}

- (IBAction)enableMotionDetect:(id)sender
{
915
    [self setVideoFilter: "motiondetect" on: [o_motiondetect_ckb state]];
916 917 918 919
}

- (IBAction)enableWaterEffect:(id)sender
{
920
    [self setVideoFilter: "ripple" on: [o_watereffect_ckb state]];
921 922 923 924
}

- (IBAction)enableWaves:(id)sender
{
925
    [self setVideoFilter: "wave" on: [o_waves_ckb state]];
926 927 928 929
}

- (IBAction)enablePsychedelic:(id)sender
{
930
    [self setVideoFilter: "psychedelic" on: [o_psychedelic_ckb state]];
931 932 933 934
}


#pragma mark -
935
#pragma mark Miscellaneous
936 937
- (IBAction)enableAddText:(id)sender
{
938 939 940 941 942 943 944
    BOOL b_state = [o_addtext_ckb state];

    [o_addtext_pos_pop setEnabled: b_state];
    [o_addtext_pos_lbl setEnabled: b_state];
    [o_addtext_text_lbl setEnabled: b_state];
    [o_addtext_text_fld setEnabled: b_state];
    [self setVideoFilter: "marq" on: b_state];
945 946 947 948
}

- (IBAction)addTextModifierChanged:(id)sender
{
949 950 951 952
    if (sender == o_addtext_text_fld)
        [self setVideoFilterProperty: "marq-marquee" forFilter: "marq" string: (char *)[[o_addtext_text_fld stringValue] UTF8String]];
    else
        [self setVideoFilterProperty: "marq-position" forFilter: "marq" integer: [[o_addtext_pos_pop selectedItem] tag]];
953 954 955 956
}

- (IBAction)enableAddLogo:(id)sender
{
957 958 959 960 961 962 963 964 965
    BOOL b_state = [o_addlogo_ckb state];

    [o_addlogo_pos_pop setEnabled: b_state];
    [o_addlogo_pos_lbl setEnabled: b_state];
    [o_addlogo_logo_fld setEnabled: b_state];
    [o_addlogo_logo_lbl setEnabled: b_state];
    [o_addlogo_transparency_sld setEnabled: b_state];
    [o_addlogo_transparency_lbl setEnabled: b_state];
    [self setVideoFilter: "logo" on: b_state];
966 967 968 969
}

- (IBAction)addLogoModifierChanged:(id)sender
{
970 971 972 973 974
    if (sender == o_addlogo_logo_fld)
        [self setVideoFilterProperty: "logo-file" forFilter: "logo" string: (char *)[[o_addlogo_logo_fld stringValue] UTF8String]];
    else if (sender == o_addlogo_pos_pop)
        [self setVideoFilterProperty: "logo-position" forFilter: "logo" integer: [[o_addlogo_pos_pop selectedItem] tag]];
    else
975
    {
976
        [self setVideoFilterProperty: "logo-opacity" forFilter: "logo" integer: [o_addlogo_transparency_sld intValue]];
977 978
        [o_addlogo_transparency_sld setToolTip: [NSString stringWithFormat:@"%i", [o_addlogo_transparency_sld intValue]]];
    }
979 980 981
}

@end