OSDN Git Service

MacGui: Removie Full Screen preview mode as its largely redundant when we have 100...
[handbrake-jp/handbrake-jp-git.git] / macosx / PictureController.m
1 /* $Id: PictureController.mm,v 1.11 2005/08/01 15:10:44 titer Exp $
2
3    This file is part of the HandBrake source code.
4    Homepage: <http://handbrake.fr/>.
5    It may be used under the terms of the GNU General Public License. */
6
7 #import "PictureController.h"
8 #import "Controller.h"
9 #import "HBPreviewController.h"
10
11
12
13 @implementation PictureController
14
15 - (id)init
16 {
17         if (self = [super initWithWindowNibName:@"PictureSettings"])
18         {
19         // NSWindowController likes to lazily load its window. However since
20         // this controller tries to set all sorts of outlets before the window
21         // is displayed, we need it to load immediately. The correct way to do
22         // this, according to the documentation, is simply to invoke the window
23         // getter once.
24         //
25         // If/when we switch a lot of this stuff to bindings, this can probably
26         // go away.
27         [self window];
28         
29         fPreviewController = [[PreviewController alloc] init];
30     }
31         return self;
32 }
33
34 //------------------------------------------------------------------------------------
35 // Displays and brings the picture window to the front
36 //------------------------------------------------------------------------------------
37 - (IBAction) showPictureWindow: (id)sender
38 {
39
40
41         if ([[self window] isVisible])
42         {
43             [[self window] close];
44         }
45         else
46         {
47             [self showWindow:sender];
48             [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"];
49             [self setToWindowedMode];
50         }
51
52     [self adjustFilterDisplay:nil];
53     [self adjustSizingDisplay:nil];
54 }
55
56
57
58 /* this method is used to detect clicking on a tab in fSizeFilterView */
59 - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
60 {
61
62 [self resizeInspectorForTab:nil];
63
64 }
65
66 #pragma mark -
67
68 /* resizeInspectorForTab is called at launch, and each time either the 
69  * Size or Filters tab is clicked. Size gives a horizontally oriented
70  * inspector and Filters is a vertically aligned inspector.
71  */
72 - (IBAction) resizeInspectorForTab: (id)sender
73 {
74     NSRect frame = [[self window] frame];
75     NSPoint windowOrigin = [[self window] frame].origin;
76     NSSize screenSize = [[[self window] screen] frame].size;
77     NSPoint screenOrigin = [[[self window] screen] frame].origin;
78     
79     /* We base our inspector size/layout on which tab is active for fSizeFilterView */
80     /* we are 1 which is Filters*/
81     if ([fSizeFilterView indexOfTabViewItem: [fSizeFilterView selectedTabViewItem]] == 1)
82     {
83         frame.size.width = 314;
84         /* we glean the height from the size of the boxes plus the extra window space
85          * needed for non boxed display
86          */
87         frame.size.height = 110.0 + [fDetelecineBox frame].size.height + [fDecombDeinterlaceBox frame].size.height + [fDenoiseBox frame].size.height + [fDeblockBox frame].size.height;
88         /* Hide the size readout at the bottom as the vertical inspector is not wide enough */
89         [fSizeInfoField setHidden:YES];
90     }
91     else // we are Tab index 0 which is size
92     {
93         frame.size.width = 50.0 + [fPictureSizeBox frame].size.width + [fPictureCropBox frame].size.width;
94         frame.size.height = [fPictureSizeBox frame].size.height + 85;
95         /* hide the size summary field at the bottom */
96         [fSizeInfoField setHidden:NO];      
97     }
98     /* get delta's for the change in window size */
99     CGFloat deltaX = frame.size.width - [[self window] frame].size.width;
100     CGFloat deltaY = frame.size.height - [[self window] frame].size.height;
101     
102     /* Check to see if we have changed the height from current */
103     //if (frame.size.height != [[self window] frame].size.height)
104     //{
105         /* change the inspector origin via the deltaY */
106         frame.origin.y -= deltaY;
107         /* keep the inspector centered so the tabs stay in place */
108         frame.origin.x -= deltaX / 2.0;
109     //}
110     
111      /* we make sure we are not horizontally off of our screen.
112      * this would be the case if we are on the vertical filter tab
113      * and we hit the size tab and the inspector grows horizontally
114      * off the screen to the right
115     */
116     if ((frame.origin.x + frame.size.width) > (screenOrigin.x + screenSize.width))
117     {
118         /* the right side of the preview is off the screen, so shift to the left */
119         frame.origin.x = (screenOrigin.x + screenSize.width) - frame.size.width;
120     }
121     
122     [[self window] setFrame:frame display:YES animate:YES];
123 }
124
125 - (IBAction) adjustSizingDisplay: (id) sender
126 {
127     NSSize pictureSizingBoxSize = [fPictureSizeBox frame].size;
128     
129     NSPoint fPictureSizeBoxOrigin = [fPictureSizeBox frame].origin;
130     NSSize pictureCropBoxSize = [fPictureCropBox frame].size;
131     NSPoint fPictureCropBoxOrigin = [fPictureCropBox frame].origin;
132     
133     if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree
134     {
135         pictureSizingBoxSize.width = 530;
136         
137         /* Set visibility of capuj widgets */
138         [fParWidthField setHidden: NO];
139         [fParHeightField setHidden: NO];
140         [fParWidthLabel setHidden: NO];
141         [fParHeightLabel setHidden: NO];
142         [fDisplayWidthField setHidden: NO];
143         [fDisplayWidthLabel setHidden: NO];
144         /* adjust/move keep ar checkbox */
145         [fRatioLabel setHidden: YES];
146         [fRatioLabel2 setHidden: NO];
147         
148         /* Optionally swith the Storage and Display width positions*/
149          /*
150          NSPoint fWidthLabelOrigin = [fWidthLabel frame].origin;
151          NSPoint fWidthFieldOrigin = [fWidthField frame].origin;
152          NSPoint fWidthStepperOrigin = [fWidthStepper frame].origin;
153          fWidthFieldOrigin.x = [fRatioLabel2 frame].origin.x + [fRatioLabel2 frame].size.width + 4;
154          [fWidthField setFrameOrigin:fWidthFieldOrigin];
155
156          fWidthStepperOrigin.x = [fWidthField frame].origin.x + [fWidthField frame].size.width + 4;
157          [fWidthStepper setFrameOrigin:fWidthStepperOrigin];
158          
159          fWidthLabelOrigin.x = [fWidthField frame].origin.x - [fWidthLabel frame].size.width - 4;
160          [fWidthLabel setFrameOrigin:fWidthLabelOrigin];
161          [fWidthLabel setStringValue:@"Storage Width:"];
162          */
163         
164         /* set the origin for fRatioCheck so origin.y == fRatioLabel2
165          * and origin.x == fDisplayWidthField
166          */
167          NSPoint fRatioCheckOrigin = [fRatioCheck frame].origin;
168          fRatioCheckOrigin.y = [fRatioLabel2 frame].origin.y - 2;
169          fRatioCheckOrigin.x = [fRatioLabel2 frame].origin.x + [fRatioLabel2 frame].size.width + 4;
170          [fRatioCheck setFrameOrigin:fRatioCheckOrigin];
171          
172     }
173     else
174     {
175         pictureSizingBoxSize.width = 200;
176         
177         /* Set visibility of capuj widgets */
178         [fParWidthField setHidden: YES];
179         [fParHeightField setHidden: YES];
180         [fParWidthLabel setHidden: YES];
181         [fParHeightLabel setHidden: YES];
182         [fDisplayWidthField setHidden: YES];
183         [fDisplayWidthLabel setHidden: YES];
184         /* adjust/move keep ar checkbox */
185         [fRatioLabel setHidden: NO];
186         [fRatioLabel2 setHidden: YES];
187         
188          /* Optionally swith the Storage and Display width positions*/
189          
190          /*
191          NSPoint fWidthLabelOrigin = [fWidthLabel frame].origin;
192          NSPoint fWidthFieldOrigin = [fWidthField frame].origin;
193          NSPoint fWidthStepperOrigin = [fWidthStepper frame].origin;
194          
195          fWidthFieldOrigin.x = [fHeightField frame].origin.x;
196          [fWidthField setFrameOrigin:fWidthFieldOrigin];
197          
198          fWidthStepperOrigin.x = [fHeightStepper frame].origin.x;
199          [fWidthStepper setFrameOrigin:fWidthStepperOrigin];
200          
201          fWidthLabelOrigin.x = [fWidthField frame].origin.x - [fWidthLabel frame].size.width -4;
202          [fWidthLabel setFrameOrigin:fWidthLabelOrigin];
203          [fWidthLabel setStringValue:@"Width:"];
204          */
205         
206         
207         /* set the origin for fRatioCheck so origin.y == fRatioLabel
208          * and origin.x == fWidthStepper
209          */
210          NSPoint fRatioCheckOrigin = [fRatioCheck frame].origin;
211          fRatioCheckOrigin.y = [fRatioLabel frame].origin.y - 2;
212          fRatioCheckOrigin.x = [fWidthStepper frame].origin.x - 2;
213          [fRatioCheck setFrameOrigin:fRatioCheckOrigin];
214         
215     }
216     
217     /* Check to see if we have changed the size from current */
218     if (pictureSizingBoxSize.height != [fPictureSizeBox frame].size.height || pictureSizingBoxSize.width != [fPictureSizeBox frame].size.width)
219     {
220         /* Get our delta for the change in picture size box height */
221         CGFloat deltaYSizeBoxShift = pictureSizingBoxSize.height - [fPictureSizeBox frame].size.height;
222         fPictureSizeBoxOrigin.y -= deltaYSizeBoxShift;
223         /* Get our delta for the change in picture size box width */
224         CGFloat deltaXSizeBoxShift = pictureSizingBoxSize.width - [fPictureSizeBox frame].size.width;
225         //fPictureSizeBoxOrigin.x += deltaXSizeBoxShift;
226         /* set our new Picture size box size */
227         [fPictureSizeBox setFrameSize:pictureSizingBoxSize];
228         [fPictureSizeBox setFrameOrigin:fPictureSizeBoxOrigin];
229         
230         pictureCropBoxSize.height += deltaYSizeBoxShift;
231         fPictureCropBoxOrigin.y -= deltaYSizeBoxShift;
232         fPictureCropBoxOrigin.x += deltaXSizeBoxShift;
233         
234         [fPictureCropBox setFrameSize:pictureCropBoxSize];
235         [[fPictureCropBox animator] setFrameOrigin:fPictureCropBoxOrigin];
236     }
237
238     
239     /* now we call to resize the entire inspector window */
240    [self resizeInspectorForTab:nil];
241 }
242
243 - (IBAction) adjustFilterDisplay: (id) sender
244 {
245     
246     NSBox * filterBox = nil;
247     NSTextField * filterField;
248     if (sender == fDetelecinePopUp)
249     {
250         filterBox = fDetelecineBox;
251         filterField = fDetelecineField;
252     }
253     
254     if (sender == fDecombDeinterlaceSlider)
255     {
256         if ([fDecombDeinterlaceSlider floatValue] == 0.0)
257         {
258             filterBox = fDecombBox;
259             filterField = fDecombField;
260         }
261         else
262         {
263             filterBox = fDeinterlaceBox;
264             filterField = fDeinterlaceField;
265         }
266     }
267     
268     if (sender == fDecombPopUp)
269     {
270         filterBox = fDecombBox;
271         filterField = fDecombField;
272     }
273     if (sender == fDeinterlacePopUp)
274     {
275         filterBox = fDeinterlaceBox;
276         filterField = fDeinterlaceField;
277     }
278     
279     if (sender == fDenoisePopUp)
280     {
281         filterBox = fDenoiseBox;
282         filterField = fDenoiseField;
283     }
284     
285     NSSize currentSize = [filterBox frame].size;
286     NSRect boxFrame = [filterBox frame];
287     
288     if ([sender titleOfSelectedItem] == @"Custom")
289     {
290         
291         currentSize.height = 60;
292         
293     }
294     else
295     {
296         currentSize.height = 30;
297         
298     }
299     /* Check to see if we have changed the size from current */
300     if (currentSize.height != [filterBox frame].size.height)
301     {
302         /* We are changing the size of the box, so recalc the origin */
303         NSPoint boxOrigin = [filterBox frame].origin;
304         /* We get the deltaY here for how much we are expanding/contracting the box vertically */
305         CGFloat deltaYBoxShift = currentSize.height - [filterBox frame].size.height;
306         boxOrigin.y -= deltaYBoxShift;
307         
308         boxFrame.size.height = currentSize.height;
309         boxFrame.origin.y = boxOrigin.y;
310         [filterBox setFrame:boxFrame];
311         
312         /* go ahead and resize the box */
313         //[[filterBox animator] setFrameSize:currentSize];
314         //[[filterBox animator] setFrameOrigin:origin];
315  
316     
317         if (filterBox == fDecombBox || filterBox == fDeinterlaceBox)
318         {
319             /* fDecombDeinterlaceBox*/
320             NSSize decombDeinterlaceBoxSize = [fDecombDeinterlaceBox frame].size;
321             NSPoint decombDeinterlaceBoxOrigin = [fDecombDeinterlaceBox frame].origin;
322             
323             //decombDeinterlaceBoxSize.height = [filterBox frame].size.height + 50;
324             if (sender == fDecombDeinterlaceSlider)
325             {
326                 [fHBController writeToActivityLog: "Sender is deinterlace decomb slider"];
327             }
328             
329             if ([fDeinterlaceBox isHidden] == YES)
330             {
331                 decombDeinterlaceBoxSize.height = [fDecombBox frame].size.height + 50;
332                 [fHBController writeToActivityLog: "Resize by Decomb box"];
333             }
334             else
335             {
336                 decombDeinterlaceBoxSize.height = [fDeinterlaceBox frame].size.height + 50;
337                 [fHBController writeToActivityLog: "Resize by Deinterlace box"];
338             }
339             /* get delta's for the change in window size */
340             
341             CGFloat deltaYdecombDeinterlace = decombDeinterlaceBoxSize.height - [fDecombDeinterlaceBox frame].size.height;
342             
343             deltaYBoxShift = deltaYdecombDeinterlace;
344             
345             decombDeinterlaceBoxOrigin.y -= deltaYdecombDeinterlace;
346             
347             [fDecombDeinterlaceBox setFrameSize:decombDeinterlaceBoxSize];
348             [fDecombDeinterlaceBox setFrameOrigin:decombDeinterlaceBoxOrigin];
349         }
350
351         /* now we must reset the origin of each box below the adjusted box*/
352         NSPoint decombDeintOrigin = [fDecombDeinterlaceBox frame].origin;
353         NSPoint denoiseOrigin = [fDenoiseBox frame].origin;
354         NSPoint deblockOrigin = [fDeblockBox frame].origin;
355         if (sender == fDetelecinePopUp)
356         {
357             decombDeintOrigin.y -= deltaYBoxShift;
358             [fDecombDeinterlaceBox setFrameOrigin:decombDeintOrigin];
359             
360             denoiseOrigin.y -= deltaYBoxShift;
361             [fDenoiseBox setFrameOrigin:denoiseOrigin];
362             
363             deblockOrigin.y -= deltaYBoxShift;
364             [fDeblockBox setFrameOrigin:deblockOrigin];
365         }
366         if (sender == fDecombPopUp || sender == fDeinterlacePopUp)
367         {
368             denoiseOrigin.y -= deltaYBoxShift;
369             [fDenoiseBox setFrameOrigin:denoiseOrigin];
370             
371             deblockOrigin.y -= deltaYBoxShift;
372             [fDeblockBox setFrameOrigin:deblockOrigin];
373         }
374         
375         if (sender == fDenoisePopUp)
376         {
377             deblockOrigin.y -= deltaYBoxShift;
378             [fDeblockBox setFrameOrigin:deblockOrigin];
379         }
380         
381         /* now we call to resize the entire inspector window */
382         [self resizeInspectorForTab:nil];
383     }
384     
385 }
386
387
388 #pragma mark -
389
390 - (IBAction) previewGoWindowed: (id)sender
391 {
392     [fPreviewController goWindowedScreen:self];
393 }
394
395 - (IBAction) showPreviewWindow: (id)sender
396 {
397     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PreviewWindowIsOpen"];
398     [fPreviewController showWindow:sender];
399 }
400
401
402
403 - (void) setToWindowedMode
404 {
405     /* Set the window back to Floating Window mode 
406      * This will put the window always on top, but
407      * since we have Hide on Deactivate set in our
408      * xib, if other apps are put in focus we will
409      * hide properly to stay out of the way
410      */
411     [[self window] setLevel:NSFloatingWindowLevel];
412 }
413
414 - (void)setHBController: (HBController *)controller
415 {
416     fHBController = controller;
417     [fPreviewController   setHBController: controller];
418     
419 }
420
421 - (void)awakeFromNib
422 {
423     [fPictureWindow setDelegate:self];
424     if( ![[self window] setFrameUsingName:@"PictureSizing"] )
425         [[self window] center];
426     [self setWindowFrameAutosaveName:@"PictureSizing"];
427     [[self window] setExcludedFromWindowsMenu:YES];
428     
429     [self setInitialPictureFilters];
430     
431     /* Setup our layers for core animation */
432     [fSizeFilterView setWantsLayer:YES];
433     [fPictureSizeBox setWantsLayer:YES];
434     [fPictureCropBox setWantsLayer:YES];
435     
436 }
437
438
439 - (void)windowWillClose:(NSNotification *)aNotification
440 {
441 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PictureSizeWindowIsOpen"];
442 }
443
444 - (BOOL)windowShouldClose:(id)fPictureWindow
445 {
446     return YES;
447 }
448
449 - (void) dealloc
450 {
451     [fPreviewController release];
452     [super dealloc];
453 }
454
455 - (void) SetHandle: (hb_handle_t *) handle
456 {
457     fHandle = handle;
458     
459     [fPreviewController SetHandle: fHandle];
460 }
461
462 - (void) SetTitle: (hb_title_t *) title
463 {
464     hb_job_t * job = title->job;
465
466     fTitle = title;
467
468     [fWidthStepper  setValueWraps: NO];
469     [fWidthStepper  setIncrement: 16];
470     [fWidthStepper  setMinValue: 64];
471     [fHeightStepper setValueWraps: NO];
472     [fHeightStepper setIncrement: 16];
473     [fHeightStepper setMinValue: 64];
474     
475     [fCropTopStepper    setIncrement: 2];
476     [fCropTopStepper    setMinValue:  0];
477     [fCropBottomStepper setIncrement: 2];
478     [fCropBottomStepper setMinValue:  0];
479     [fCropLeftStepper   setIncrement: 2];
480     [fCropLeftStepper   setMinValue:  0];
481     [fCropRightStepper  setIncrement: 2];
482     [fCropRightStepper  setMinValue:  0];
483     
484     [fWidthStepper      setMaxValue: title->width];
485     [fWidthStepper      setIntValue: job->width];
486     [fWidthField        setIntValue: job->width];
487     [fHeightStepper     setMaxValue: title->height];
488     [fHeightStepper     setIntValue: job->height];
489     [fHeightField       setIntValue: job->height];
490     [fRatioCheck        setState:    job->keep_ratio ? NSOnState : NSOffState];
491     [fCropTopStepper    setMaxValue: title->height/2-2];
492     [fCropBottomStepper setMaxValue: title->height/2-2];
493     [fCropLeftStepper   setMaxValue: title->width/2-2];
494     [fCropRightStepper  setMaxValue: title->width/2-2];
495
496     /* Populate the Anamorphic NSPopUp button here */
497     [fAnamorphicPopUp removeAllItems];
498     [fAnamorphicPopUp addItemWithTitle: @"None"];
499     [fAnamorphicPopUp addItemWithTitle: @"Strict"];
500     [fAnamorphicPopUp addItemWithTitle: @"Loose"];
501     [fAnamorphicPopUp addItemWithTitle: @"Custom"];
502     [fAnamorphicPopUp selectItemAtIndex: job->anamorphic.mode];
503     
504     //[self adjustSizingDisplay:nil];
505     
506     /* populate the modulus popup here */
507     [fModulusPopUp removeAllItems];
508     [fModulusPopUp addItemWithTitle: @"16"];
509     [fModulusPopUp addItemWithTitle: @"8"];
510     [fModulusPopUp addItemWithTitle: @"4"];
511     [fModulusPopUp addItemWithTitle: @"2"];
512     if (job->modulus)
513     {
514         [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->modulus]];
515     }
516     else
517     {
518         [fModulusPopUp selectItemAtIndex: 0];
519     }
520     
521     
522     /* We initially set the previous state of keep ar to on */
523     keepAspectRatioPreviousState = 1;
524         if (!autoCrop)
525         {
526         [fCropMatrix  selectCellAtRow: 1 column:0];
527         /* If auto, lets set the crop steppers according to current job->crop values */
528         [fCropTopStepper    setIntValue: job->crop[0]];
529         [fCropTopField      setIntValue: job->crop[0]];
530         [fCropBottomStepper setIntValue: job->crop[1]];
531         [fCropBottomField   setIntValue: job->crop[1]];
532         [fCropLeftStepper   setIntValue: job->crop[2]];
533         [fCropLeftField     setIntValue: job->crop[2]];
534         [fCropRightStepper  setIntValue: job->crop[3]];
535         [fCropRightField    setIntValue: job->crop[3]];
536         }
537         else
538         {
539         [fCropMatrix  selectCellAtRow: 0 column:0];
540         }
541         
542     /* Set filters widgets according to the filters struct */
543     [fDetelecinePopUp selectItemAtIndex:fPictureFilterSettings.detelecine];
544     [fDecombPopUp selectItemAtIndex:fPictureFilterSettings.decomb];
545     [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
546     [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
547     [fDeblockSlider setFloatValue:fPictureFilterSettings.deblock];
548     [fGrayscaleCheck setState:fPictureFilterSettings.grayscale];
549     
550     [self deblockSliderChanged: nil];
551     
552     fPicture = 0;
553     MaxOutputWidth = title->width - job->crop[2] - job->crop[3];
554     MaxOutputHeight = title->height - job->crop[0] - job->crop[1];
555     
556     titleDarWidth = job->anamorphic.dar_width;
557     titleDarHeight = job->anamorphic.dar_height;
558     
559     titleParWidth = job->anamorphic.par_width;
560     titleParHeight = job->anamorphic.par_height;
561     
562     [self SettingsChanged:nil];
563 }
564
565 - (IBAction) storageLinkChanged: (id) sender
566 {
567     /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
568     if ([fStorageLinkSlider floatValue] < 0.50)
569     {
570         [fStorageLinkSlider setFloatValue:0.0];
571         /* set slider labels to reflect choice */
572         [fStorageLinkParLabel setEnabled:YES];
573         [fStorageLinkDisplayLabel setEnabled:NO];
574
575     }
576     else
577     {
578         [fStorageLinkSlider setFloatValue:1.0];
579         /* set slider labels to reflect choice */
580         [fStorageLinkParLabel setEnabled:NO];
581         [fStorageLinkDisplayLabel setEnabled:YES];
582     }
583     
584 }
585
586 - (IBAction) parLinkChanged: (id) sender
587 {
588     /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
589     if ([fParLinkSlider floatValue] < 0.50)
590     {
591         [fParLinkSlider setFloatValue:0.0];
592         /* set slider labels to reflect choice */
593         [fParLinkStorageLabel setEnabled:YES];
594         [fParLinkDisplayLabel setEnabled:NO];
595     }
596     else
597     {
598         [fParLinkSlider setFloatValue:1.0];
599         /* set slider labels to reflect choice */
600         [fParLinkStorageLabel setEnabled:NO];
601         [fParLinkDisplayLabel setEnabled:YES];
602     }
603     
604 }
605
606 - (IBAction) displayLinkChanged: (id) sender
607 {
608     /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
609     if ([fDisplayLinkSlider floatValue] < 0.50)
610     {
611         [fDisplayLinkSlider setFloatValue:0.0];
612         /* set slider labels to reflect choice */
613         [fDisplayLinkStorageLabel setEnabled:YES];
614         [fDisplayLinkParLabel setEnabled:NO];
615     }
616     else
617     {
618         [fDisplayLinkSlider setFloatValue:1.0];
619         /* set slider labels to reflect choice */
620         [fDisplayLinkStorageLabel setEnabled:NO];
621         [fDisplayLinkParLabel setEnabled:YES];
622     }
623     
624 }    
625
626 - (IBAction) SettingsChanged: (id) sender
627 {
628     hb_job_t * job = fTitle->job;
629
630     /* if we are anything but strict anamorphic */
631     if ([fAnamorphicPopUp indexOfSelectedItem] != 1)
632     {
633         [fModulusLabel setHidden:NO];
634         [fModulusPopUp setHidden:NO];
635         if (sender == fModulusPopUp)
636         {
637             /* do a dry run with hb_fix aspect to get new modulus */
638             job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
639             job->keep_ratio  = 1;
640             hb_fix_aspect( job, HB_KEEP_WIDTH );
641             if( job->height > fTitle->height )
642             {
643                 job->height = fTitle->height;
644                 hb_fix_aspect( job, HB_KEEP_HEIGHT );
645             }
646             [fWidthStepper      setIntValue: job->width];
647             [fWidthField        setIntValue: job->width];
648             if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom
649             {
650                 [fHeightStepper     setIntValue: job->height];
651                 [fHeightField       setIntValue: job->height];
652             }    
653         }
654     }
655     else
656     {
657         /* we are strict so hide the mod popup since libhb uses mod 2 for strict anamorphic*/
658         [fModulusLabel setHidden:YES];
659         [fModulusPopUp setHidden:YES];
660     }
661
662     job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
663     
664     [fWidthStepper  setIncrement: job->modulus];
665     [fHeightStepper setIncrement: job->modulus];
666
667     /* Since custom anamorphic allows for a height setting > fTitle->height
668      * check to make sure it is returned to fTitle->height for all other modes
669      */
670      [fHeightStepper setMaxValue: fTitle->height];
671     
672     autoCrop = ( [fCropMatrix selectedRow] == 0 );
673     [fCropTopStepper    setEnabled: !autoCrop];
674     [fCropBottomStepper setEnabled: !autoCrop];
675     [fCropLeftStepper   setEnabled: !autoCrop];
676     [fCropRightStepper  setEnabled: !autoCrop];
677     
678     if( autoCrop )
679     {
680         memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) );
681     }
682     else
683     {
684         job->crop[0] = [fCropTopStepper    intValue];
685         job->crop[1] = [fCropBottomStepper intValue];
686         job->crop[2] = [fCropLeftStepper   intValue];
687         job->crop[3] = [fCropRightStepper  intValue];
688     }
689     
690     [fRatioCheck setEnabled: YES];
691
692     
693     [fParWidthField setEnabled: NO];
694     [fParHeightField setEnabled: NO];
695     [fDisplayWidthField setEnabled: NO];
696     
697     /* If we are not custom anamorphic, make sure we retain the orginal par */
698     if( [fAnamorphicPopUp indexOfSelectedItem] != 3 )
699     {
700         job->anamorphic.par_width = titleParWidth;
701         job->anamorphic.par_height = titleParHeight;
702         [fRatioLabel setHidden: NO];
703     }
704     
705         if( [fAnamorphicPopUp indexOfSelectedItem] > 0 )
706         {
707         if ([fAnamorphicPopUp indexOfSelectedItem] == 1) // strict
708         {
709             [fWidthStepper      setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
710             [fWidthField        setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
711             
712             /* This will show correct anamorphic height values, but
713              show distorted preview picture ratio */
714             [fHeightStepper      setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
715             [fHeightField        setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
716             job->width       = [fWidthStepper  intValue];
717             job->height      = [fHeightStepper intValue];
718             
719             job->anamorphic.mode = 1;
720             [fWidthStepper setEnabled: NO];
721             [fWidthField setEnabled: NO];
722             [fHeightStepper setEnabled: NO];
723             [fHeightField setEnabled: NO];
724             [fRatioCheck setEnabled: NO];
725         }
726         else if ([fAnamorphicPopUp indexOfSelectedItem] == 2) // Loose anamorphic
727         {
728             job->anamorphic.mode = 2;
729             [fWidthStepper setEnabled: YES];
730             [fWidthField setEnabled: YES];
731             [fRatioCheck setEnabled: NO];
732             [fHeightStepper setEnabled: NO];
733             [fHeightField setEnabled: NO];
734             /* We set job->width and call hb_set_anamorphic_size in libhb to do a "dry run" to get
735              * the values to be used by libhb for loose anamorphic
736              */
737             /* if the sender is the anamorphic popup, then we know that loose anamorphic has just
738              * been turned on, so snap the width to full width for the source.
739              */
740             if (sender == fAnamorphicPopUp)
741             {
742                 [fWidthStepper      setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
743                 [fWidthField        setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
744             }
745             job->width       = [fWidthStepper  intValue];
746             hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
747             [fHeightStepper      setIntValue: output_height];
748             [fHeightField        setIntValue: output_height];
749             job->height      = [fHeightStepper intValue];
750             
751         }
752         else if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree
753         {
754
755 #pragma mark - STARTCapuj
756
757             job->anamorphic.mode = 3;
758             
759             /* Set the status of our custom ana only widgets accordingly */
760             [fModulusPopUp setEnabled:YES];
761             
762             [fWidthStepper setEnabled: YES];
763             [fWidthField setEnabled: YES];
764             
765             [fHeightStepper setEnabled: YES];
766             /* for capuj the storage field is immaterial */
767             [fHeightField setEnabled: YES];
768             
769             [fRatioCheck setEnabled: YES];
770             if (sender == fRatioCheck)
771             {
772                 if ([fRatioCheck  state] == NSOnState)
773                 {
774                     [fParWidthField setEnabled: NO];
775                     [fParHeightField setEnabled: NO];   
776                 }
777                 else
778                 {
779                     [fParWidthField setEnabled: YES];
780                     [fParHeightField setEnabled: YES];
781                 }
782             }
783             
784             [fParWidthField setEnabled: YES];
785             [fParHeightField setEnabled: YES];
786             
787             [fDisplayWidthField setEnabled: YES];
788             
789             
790             /* If we are coming into custom anamorphic we reset the par to original
791              * which gives us a way back if things get hosed up.
792              */
793              
794             if (sender == fAnamorphicPopUp)
795             {
796                 /* When entering custom anamorphic, we start with keep ar on */
797                 [fRatioCheck  setState: NSOnState];
798                 /*
799                  KEEPING ASPECT RATIO
800                  Disable editing: PIXEL WIDTH, PIXEL HEIGHT
801                  */
802                 [fParWidthField setEnabled: NO];
803                 [fParHeightField setEnabled: NO];
804                 
805                 job->width = [fWidthStepper intValue];
806                 job->height = [fHeightStepper intValue];
807
808                 /* make sure our par is set back to original */
809                 job->anamorphic.par_width = titleParWidth;
810                 job->anamorphic.par_height = titleParHeight;
811                 
812                 [fParWidthField   setIntValue: titleParWidth];
813                 [fParHeightField   setIntValue: titleParHeight];
814                 
815                 /* modify our par dims from our storage dims */
816                 hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
817                 float par_display_width = (float)output_width * (float)output_par_width / (float)output_par_height;
818                 
819                 /* go ahead and mod the display dims */
820                 [fDisplayWidthField   setStringValue: [NSString stringWithFormat:@"%.2f", par_display_width]];
821                 
822                 job->anamorphic.dar_width = [fDisplayWidthField floatValue];
823                 job->anamorphic.dar_height = (float)[fHeightStepper intValue];
824                 
825                 /* Set our dar here assuming we are just coming into capuj mode */
826                 dar = [fDisplayWidthField floatValue] / (float)[fHeightField intValue];
827                 
828             }
829
830             /* For capuj we disable these fields if we are keeping the dispay aspect */
831             if ([fRatioCheck  state] == NSOnState)
832             {
833                 /*
834                  KEEPING ASPECT RATIO
835                  DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification) */
836                  /*Disable editing: PIXEL WIDTH, PIXEL HEIGHT */
837                 
838                 [fParWidthField setEnabled: NO];
839                 [fParHeightField setEnabled: NO];
840                 
841                 /* Changing DISPLAY WIDTH: */
842                 if (sender == fDisplayWidthField)
843                 {
844                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
845                     /* Changes HEIGHT to keep DAR */
846                      /* calculate the height to retain the dar  */
847                     int raw_calulated_height = (int)((int)[fDisplayWidthField floatValue] / dar);
848                     /*  now use the modulus to go lower if there is a remainder  */
849                     /* Note to me, raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]
850                      * gives me the remainder we are not mod (whatever our modulus is) subtract that from
851                      * the actual calculated value derived from the dar to round down to the nearest mod value.
852                      * This should be desireable over rounding up to the next mod value
853                      */
854                     int modulus_height = raw_calulated_height - (raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]);
855                     if (modulus_height > fTitle->height)
856                     {
857                         [fHeightStepper setMaxValue: modulus_height];
858                     }
859                     [fHeightStepper setIntValue: modulus_height];
860                     job->anamorphic.dar_height = (float)[fHeightStepper intValue];
861                     job->height = [fHeightStepper intValue];
862                     
863                     /* Changes PIXEL WIDTH to new DISPLAY WIDTH */
864                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
865                     job->anamorphic.par_width = [fParWidthField intValue];
866                     /* Changes PIXEL HEIGHT to STORAGE WIDTH */
867                     [fParHeightField  setIntValue: [fWidthField intValue]];
868                     job->anamorphic.par_height = [fParHeightField intValue];
869                     
870                 }
871                 /* Changing HEIGHT: */
872                 if (sender == fHeightStepper)
873                 {
874                    job->anamorphic.dar_height = (float)[fHeightStepper intValue];
875                    job->height = [fHeightStepper intValue];
876                    
877                     /* Changes DISPLAY WIDTH to keep DAR*/
878                     [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",[fHeightStepper intValue] * dar]];
879                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
880                     /* Changes PIXEL WIDTH to new DISPLAY WIDTH */
881                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
882                     job->anamorphic.par_width = [fParWidthField intValue];
883                     /* Changes PIXEL HEIGHT to STORAGE WIDTH */
884                     [fParHeightField  setIntValue: [fWidthField intValue]];
885                     job->anamorphic.par_height = [fParHeightField intValue];
886                 }
887                 /* Changing STORAGE_WIDTH: */
888                 if (sender == fWidthStepper)
889                 {
890                     job->width = [fWidthStepper intValue];
891                     
892                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
893                     job->anamorphic.dar_height = [fHeightStepper floatValue];
894                      
895                     /* Changes PIXEL WIDTH to DISPLAY WIDTH */
896                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
897                     job->anamorphic.par_width = [fParWidthField intValue];
898                     /* Changes PIXEL HEIGHT to new STORAGE WIDTH */
899                     [fParHeightField  setIntValue: [fWidthStepper intValue]];
900                     job->anamorphic.par_height = [fParHeightField intValue];
901                 }
902             }
903             else if ([fRatioCheck  state] == NSOffState)
904             {
905                 /* Changing STORAGE_WIDTH: */
906                 if (sender == fWidthStepper)
907                 {
908                     job->width = [fWidthStepper intValue];
909                     /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */
910                     [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]];
911                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
912                 }
913                 /* Changing PIXEL dimensions */
914                 if (sender == fParWidthField || sender == fParHeightField)
915                 {
916                     job->anamorphic.par_width = [fParWidthField intValue];
917                     job->anamorphic.par_height = [fParHeightField intValue];
918                     /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */
919                     [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]];
920                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
921                 }
922                 /* Changing DISPLAY WIDTH: */
923                 if (sender == fDisplayWidthField)
924                 {
925                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
926                     job->anamorphic.dar_height = (float)[fHeightStepper intValue];
927                     /* changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH */
928                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
929                     job->anamorphic.par_width = [fParWidthField intValue];
930                     
931                     [fParHeightField  setIntValue: [fWidthField intValue]];
932                     job->anamorphic.par_height = [fParHeightField intValue];
933                     hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
934                 }
935                 /* Changing HEIGHT: */
936                 if (sender == fHeightStepper)
937                 {
938                     /* just....changes the height.*/
939                     job->anamorphic.dar_height = [fHeightStepper intValue];
940                     job->height = [fHeightStepper intValue];
941                 }
942                 
943             }
944             
945 #pragma mark - END Capuj                       
946         }
947         
948         /* if the sender is the Anamorphic checkbox, record the state
949          of KeepAspect Ratio so it can be reset if Anamorphic is unchecked again */
950         if (sender == fAnamorphicPopUp)
951         {
952             keepAspectRatioPreviousState = [fRatioCheck state];
953         }
954         if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
955         {
956             [fRatioCheck setState:NSOffState];
957         }
958         
959     }
960     else
961         {
962         job->width       = [fWidthStepper  intValue];
963         job->height      = [fHeightStepper intValue];
964         job->anamorphic.mode = 0;
965         [fWidthStepper setEnabled: YES];
966         [fWidthField setEnabled: YES];
967         [fHeightStepper setEnabled: YES];
968         [fHeightField setEnabled: YES];
969         [fRatioCheck setEnabled: YES];
970         /* if the sender is the Anamorphic checkbox, we return the
971          keep AR checkbox to its previous state */
972         if (sender == fAnamorphicPopUp)
973         {
974             [fRatioCheck setState:keepAspectRatioPreviousState];
975         }
976         
977         }
978         
979     if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
980     {
981         job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
982         if( job->keep_ratio )
983         {
984             if( sender == fWidthStepper || sender == fRatioCheck ||
985                sender == fCropTopStepper || sender == fCropBottomStepper|| 
986                sender == fCropMatrix || sender == nil  )
987             {
988                 hb_fix_aspect( job, HB_KEEP_WIDTH );
989                 if( job->height > fTitle->height )
990                 {
991                     job->height = fTitle->height;
992                     hb_fix_aspect( job, HB_KEEP_HEIGHT );
993                 }
994             }
995             else
996             {
997                 hb_fix_aspect( job, HB_KEEP_HEIGHT );
998                 if( job->width > fTitle->width )
999                 {
1000                     job->width = fTitle->width;
1001                     hb_fix_aspect( job, HB_KEEP_WIDTH );
1002                 }
1003             }
1004             
1005         }
1006     }
1007     
1008     // hb_get_preview can't handle sizes that are larger than the original title
1009     if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
1010     {
1011         // dimensions
1012         if( job->width > fTitle->width )
1013         {
1014             job->width = fTitle->width;
1015         }
1016         
1017         if( job->height > fTitle->height )
1018         {
1019             job->height = fTitle->height;
1020         }
1021     }
1022     
1023     [fWidthStepper      setIntValue: job->width];
1024     [fWidthField        setIntValue: job->width];
1025     if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom
1026     {
1027         [fHeightStepper     setIntValue: job->height];
1028         [fHeightField       setIntValue: job->height];
1029     }
1030     
1031     [fCropTopStepper    setIntValue: job->crop[0]];
1032     [fCropTopField      setIntValue: job->crop[0]];
1033     [fCropBottomStepper setIntValue: job->crop[1]];
1034     [fCropBottomField   setIntValue: job->crop[1]];
1035     [fCropLeftStepper   setIntValue: job->crop[2]];
1036     [fCropLeftField     setIntValue: job->crop[2]];
1037     [fCropRightStepper  setIntValue: job->crop[3]];
1038     [fCropRightField    setIntValue: job->crop[3]];
1039     
1040     //[fPreviewController SetTitle:fTitle];
1041     
1042     /* Sanity Check Here for < 16 px preview to avoid
1043      crashing hb_get_preview. In fact, just for kicks
1044      lets getting previews at a min limit of 32, since
1045      no human can see any meaningful detail below that */
1046     if (job->width >= 64 && job->height >= 64)
1047     {
1048         [self reloadStillPreview];
1049     }
1050     
1051     /* we get the sizing info to display from fPreviewController */
1052     [fSizeInfoField setStringValue: [fPreviewController pictureSizeInfoString]];
1053     
1054     if (sender != nil)
1055     {
1056         [fHBController pictureSettingsDidChange];
1057     }   
1058     
1059     if ([[self window] isVisible])
1060     { 
1061         [self adjustSizingDisplay:nil];
1062     }
1063     
1064 }
1065
1066 - (NSString*) getPictureSizeInfoString
1067 {
1068     return [fSizeInfoField stringValue];
1069 }
1070
1071 - (void)reloadStillPreview
1072
1073    hb_job_t * job = fTitle->job; 
1074    
1075    [fPreviewController SetTitle:fTitle];
1076     /* Sanity Check Here for < 16 px preview to avoid
1077      crashing hb_get_preview. In fact, just for kicks
1078      lets getting previews at a min limit of 32, since
1079      no human can see any meaningful detail below that */
1080     if (job->width >= 64 && job->height >= 64)
1081     {
1082        
1083          // Purge the existing picture previews so they get recreated the next time
1084         // they are needed.
1085       //  [fPreviewController purgeImageCache];
1086         /* We actually call displayPreview now from pictureSliderChanged which keeps
1087          * our picture preview slider in sync with the previews being shown
1088          */
1089
1090     //[fPreviewController pictureSliderChanged:nil];
1091     }
1092     
1093 }
1094
1095
1096 #pragma mark -
1097
1098 - (BOOL) autoCrop
1099 {
1100     return autoCrop;
1101 }
1102 - (void) setAutoCrop: (BOOL) setting
1103 {
1104     autoCrop = setting;
1105 }
1106
1107 - (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title
1108 {
1109     //[self SetTitle:title];
1110     [self showWindow:sender];
1111     //[self adjustSizingDisplay:nil];
1112     //[self adjustFilterDisplay:nil];
1113
1114 }
1115
1116
1117 #pragma mark -
1118 /* we use this to setup the initial picture filters upon first launch, after that their states
1119 are maintained across different sources */
1120 - (void) setInitialPictureFilters
1121 {
1122         /* we use a popup to show the detelecine settings */
1123         [fDetelecinePopUp removeAllItems];
1124     [fDetelecinePopUp addItemWithTitle: @"Off"];
1125     [fDetelecinePopUp addItemWithTitle: @"Custom"];
1126     [fDetelecinePopUp addItemWithTitle: @"Default"];
1127     [fDetelecinePopUp selectItemAtIndex: fPictureFilterSettings.detelecine];
1128     
1129     [self modeDecombDeinterlaceSliderChanged:nil];
1130     /* we use a popup to show the decomb settings */
1131         [fDecombPopUp removeAllItems];
1132     [fDecombPopUp addItemWithTitle: @"Off"];
1133     [fDecombPopUp addItemWithTitle: @"Custom"];
1134     [fDecombPopUp addItemWithTitle: @"Default"];
1135     
1136     [fDecombPopUp selectItemAtIndex: fPictureFilterSettings.decomb];
1137     
1138     /* we use a popup to show the deinterlace settings */
1139         [fDeinterlacePopUp removeAllItems];
1140     [fDeinterlacePopUp addItemWithTitle: @"Off"];
1141     [fDeinterlacePopUp addItemWithTitle: @"Custom"];
1142     [fDeinterlacePopUp addItemWithTitle: @"Fast"];
1143     [fDeinterlacePopUp addItemWithTitle: @"Slow"];
1144         [fDeinterlacePopUp addItemWithTitle: @"Slower"];
1145     
1146         /* Set deinterlaces level according to the integer in the main window */
1147         [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
1148
1149         /* we use a popup to show the denoise settings */
1150         [fDenoisePopUp removeAllItems];
1151     [fDenoisePopUp addItemWithTitle: @"Off"];
1152     [fDenoisePopUp addItemWithTitle: @"Custom"];
1153     [fDenoisePopUp addItemWithTitle: @"Weak"];
1154         [fDenoisePopUp addItemWithTitle: @"Medium"];
1155     [fDenoisePopUp addItemWithTitle: @"Strong"];
1156         /* Set denoises level according to the integer in the main window */
1157         [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
1158     
1159
1160 }
1161
1162
1163
1164
1165 - (IBAction) modeDecombDeinterlaceSliderChanged: (id) sender
1166 {
1167     
1168     /* since its a tickless slider, we have to  make sure we are on or off */
1169     if ([fDecombDeinterlaceSlider floatValue] < 0.50)
1170     {
1171         [fDecombDeinterlaceSlider setFloatValue:0.0];
1172     }
1173     else
1174     {
1175         [fDecombDeinterlaceSlider setFloatValue:1.0];
1176     }
1177     
1178     
1179     /* Decomb selected*/
1180     if ([fDecombDeinterlaceSlider floatValue] == 0.0)
1181     {
1182         [fDecombBox setHidden:NO];
1183         [fDeinterlaceBox setHidden:YES];
1184         fPictureFilterSettings.decomb = [fDecombPopUp indexOfSelectedItem];
1185         fPictureFilterSettings.usedecomb = 1;
1186         fPictureFilterSettings.deinterlace = 0;
1187         [fDecombPopUp selectItemAtIndex:fPictureFilterSettings.decomb];
1188         [self adjustFilterDisplay:fDecombPopUp];
1189     }
1190     else
1191     {
1192         [fDecombBox setHidden:YES];
1193         [fDeinterlaceBox setHidden:NO];
1194         fPictureFilterSettings.usedecomb = 0;
1195         fPictureFilterSettings.decomb = 0;
1196         [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
1197         [self adjustFilterDisplay:fDeinterlacePopUp];
1198     }
1199     [self FilterSettingsChanged: fDecombDeinterlaceSlider];
1200 }
1201
1202
1203 - (IBAction) FilterSettingsChanged: (id) sender
1204 {
1205     
1206     fPictureFilterSettings.detelecine  = [fDetelecinePopUp indexOfSelectedItem];
1207     [self adjustFilterDisplay:fDetelecinePopUp];
1208     
1209     fPictureFilterSettings.decomb = [fDecombPopUp indexOfSelectedItem];
1210     [self adjustFilterDisplay:fDecombPopUp];
1211     
1212     fPictureFilterSettings.deinterlace = [fDeinterlacePopUp indexOfSelectedItem];
1213     [self adjustFilterDisplay:fDeinterlacePopUp];
1214     
1215     fPictureFilterSettings.denoise = [fDenoisePopUp indexOfSelectedItem];
1216     [self adjustFilterDisplay:fDenoisePopUp];
1217     
1218     if ([fDeblockField stringValue] == @"Off")
1219     {
1220         fPictureFilterSettings.deblock  = 0;
1221     }
1222     else
1223     {
1224         fPictureFilterSettings.deblock  = [fDeblockField intValue];
1225     }
1226     
1227     fPictureFilterSettings.grayscale = [fGrayscaleCheck state];
1228     
1229     if (sender != nil)
1230     {
1231         [fHBController pictureSettingsDidChange];
1232         
1233     }   
1234
1235 }
1236
1237
1238 #pragma mark -
1239
1240 - (IBAction) deblockSliderChanged: (id) sender
1241 {
1242     if ([fDeblockSlider floatValue] == 4.0)
1243     {
1244     [fDeblockField setStringValue: [NSString stringWithFormat: @"Off"]];
1245     }
1246     else
1247     {
1248     [fDeblockField setStringValue: [NSString stringWithFormat: @"%.0f", [fDeblockSlider floatValue]]];
1249     }
1250         [self FilterSettingsChanged: sender];
1251 }
1252
1253
1254 - (int) detelecine
1255 {
1256     return fPictureFilterSettings.detelecine;
1257 }
1258
1259 - (NSString*) detelecineCustomString
1260 {
1261     return [fDetelecineField stringValue];
1262 }
1263
1264 - (void) setDetelecine: (int) setting
1265 {
1266     fPictureFilterSettings.detelecine = setting;
1267 }
1268
1269 - (void) setDetelecineCustomString: (NSString*) string 
1270 {
1271     [fDetelecineField setStringValue:string];
1272 }
1273
1274 - (int) deinterlace
1275 {
1276     return fPictureFilterSettings.deinterlace;
1277 }
1278 - (NSString*) deinterlaceCustomString
1279 {
1280     return [fDeinterlaceField stringValue];
1281 }
1282
1283 - (void) setDeinterlaceCustomString: (NSString*) string 
1284 {
1285     [fDeinterlaceField setStringValue:string];
1286 }
1287
1288 - (void) setDeinterlace: (int) setting 
1289 {
1290     fPictureFilterSettings.deinterlace = setting;
1291 }
1292 - (int) decomb
1293 {
1294     return fPictureFilterSettings.decomb;
1295 }
1296
1297 - (NSString*) decombCustomString
1298 {
1299     return [fDecombField stringValue];
1300 }
1301
1302 - (int) useDecomb
1303 {
1304     return fPictureFilterSettings.usedecomb;
1305 }
1306
1307 - (void) setUseDecomb: (int) setting
1308 {
1309     fPictureFilterSettings.usedecomb = setting;
1310     if (fPictureFilterSettings.usedecomb == 1)
1311     {
1312         [fDecombDeinterlaceSlider setFloatValue:0.0];
1313     }
1314     else
1315     {
1316         [fDecombDeinterlaceSlider setFloatValue:1.0];
1317     }
1318     [self modeDecombDeinterlaceSliderChanged:nil];
1319 }
1320
1321 - (void) setDecomb: (int) setting {
1322     fPictureFilterSettings.decomb = setting;
1323 }
1324
1325 - (void) setDecombCustomString: (NSString*) string 
1326 {
1327     [fDecombField setStringValue:string];
1328 }
1329
1330 - (int) denoise
1331 {
1332     return fPictureFilterSettings.denoise;
1333 }
1334
1335 - (NSString*) denoiseCustomString
1336 {
1337     return [fDenoiseField stringValue];
1338 }
1339
1340 - (void) setDenoiseCustomString: (NSString*) string 
1341 {
1342     [fDenoiseField setStringValue:string];
1343 }
1344
1345 - (void) setDenoise: (int) setting
1346 {
1347     fPictureFilterSettings.denoise = setting;
1348 }
1349
1350 - (int) deblock
1351 {
1352     return fPictureFilterSettings.deblock;
1353 }
1354
1355 - (void) setDeblock: (int) setting
1356 {
1357     fPictureFilterSettings.deblock = setting;
1358 }
1359
1360 - (int) grayscale
1361 {
1362     return fPictureFilterSettings.grayscale;
1363 }
1364
1365 - (void) setGrayscale: (int) setting
1366 {
1367     fPictureFilterSettings.grayscale = setting;
1368 }
1369
1370
1371
1372 @end
1373