OSDN Git Service

MacGui: Preview replace a method that was hastily removed in 3125 when removing Full...
[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
391
392 - (IBAction) showPreviewWindow: (id)sender
393 {
394     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PreviewWindowIsOpen"];
395     [fPreviewController showWindow:sender];
396 }
397
398
399
400 - (void) setToWindowedMode
401 {
402     /* Set the window back to Floating Window mode 
403      * This will put the window always on top, but
404      * since we have Hide on Deactivate set in our
405      * xib, if other apps are put in focus we will
406      * hide properly to stay out of the way
407      */
408     [[self window] setLevel:NSFloatingWindowLevel];
409 }
410
411 - (void)setHBController: (HBController *)controller
412 {
413     fHBController = controller;
414     [fPreviewController   setHBController: controller];
415     
416 }
417
418 - (void)awakeFromNib
419 {
420     [fPictureWindow setDelegate:self];
421     if( ![[self window] setFrameUsingName:@"PictureSizing"] )
422         [[self window] center];
423     [self setWindowFrameAutosaveName:@"PictureSizing"];
424     [[self window] setExcludedFromWindowsMenu:YES];
425     
426     [self setInitialPictureFilters];
427     
428     /* Setup our layers for core animation */
429     [fSizeFilterView setWantsLayer:YES];
430     [fPictureSizeBox setWantsLayer:YES];
431     [fPictureCropBox setWantsLayer:YES];
432     
433 }
434
435
436 - (void)windowWillClose:(NSNotification *)aNotification
437 {
438 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PictureSizeWindowIsOpen"];
439 }
440
441 - (BOOL)windowShouldClose:(id)fPictureWindow
442 {
443     return YES;
444 }
445
446 - (void) dealloc
447 {
448     [fPreviewController release];
449     [super dealloc];
450 }
451
452 - (void) SetHandle: (hb_handle_t *) handle
453 {
454     fHandle = handle;
455     
456     [fPreviewController SetHandle: fHandle];
457 }
458
459 - (void) SetTitle: (hb_title_t *) title
460 {
461     hb_job_t * job = title->job;
462
463     fTitle = title;
464
465     [fWidthStepper  setValueWraps: NO];
466     [fWidthStepper  setIncrement: 16];
467     [fWidthStepper  setMinValue: 64];
468     [fHeightStepper setValueWraps: NO];
469     [fHeightStepper setIncrement: 16];
470     [fHeightStepper setMinValue: 64];
471     
472     [fCropTopStepper    setIncrement: 2];
473     [fCropTopStepper    setMinValue:  0];
474     [fCropBottomStepper setIncrement: 2];
475     [fCropBottomStepper setMinValue:  0];
476     [fCropLeftStepper   setIncrement: 2];
477     [fCropLeftStepper   setMinValue:  0];
478     [fCropRightStepper  setIncrement: 2];
479     [fCropRightStepper  setMinValue:  0];
480     
481     [fWidthStepper      setMaxValue: title->width];
482     [fWidthStepper      setIntValue: job->width];
483     [fWidthField        setIntValue: job->width];
484     [fHeightStepper     setMaxValue: title->height];
485     [fHeightStepper     setIntValue: job->height];
486     [fHeightField       setIntValue: job->height];
487     [fRatioCheck        setState:    job->keep_ratio ? NSOnState : NSOffState];
488     [fCropTopStepper    setMaxValue: title->height/2-2];
489     [fCropBottomStepper setMaxValue: title->height/2-2];
490     [fCropLeftStepper   setMaxValue: title->width/2-2];
491     [fCropRightStepper  setMaxValue: title->width/2-2];
492
493     /* Populate the Anamorphic NSPopUp button here */
494     [fAnamorphicPopUp removeAllItems];
495     [fAnamorphicPopUp addItemWithTitle: @"None"];
496     [fAnamorphicPopUp addItemWithTitle: @"Strict"];
497     [fAnamorphicPopUp addItemWithTitle: @"Loose"];
498     [fAnamorphicPopUp addItemWithTitle: @"Custom"];
499     [fAnamorphicPopUp selectItemAtIndex: job->anamorphic.mode];
500     
501     //[self adjustSizingDisplay:nil];
502     
503     /* populate the modulus popup here */
504     [fModulusPopUp removeAllItems];
505     [fModulusPopUp addItemWithTitle: @"16"];
506     [fModulusPopUp addItemWithTitle: @"8"];
507     [fModulusPopUp addItemWithTitle: @"4"];
508     [fModulusPopUp addItemWithTitle: @"2"];
509     if (job->modulus)
510     {
511         [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->modulus]];
512     }
513     else
514     {
515         [fModulusPopUp selectItemAtIndex: 0];
516     }
517     
518     
519     /* We initially set the previous state of keep ar to on */
520     keepAspectRatioPreviousState = 1;
521         if (!autoCrop)
522         {
523         [fCropMatrix  selectCellAtRow: 1 column:0];
524         /* If auto, lets set the crop steppers according to current job->crop values */
525         [fCropTopStepper    setIntValue: job->crop[0]];
526         [fCropTopField      setIntValue: job->crop[0]];
527         [fCropBottomStepper setIntValue: job->crop[1]];
528         [fCropBottomField   setIntValue: job->crop[1]];
529         [fCropLeftStepper   setIntValue: job->crop[2]];
530         [fCropLeftField     setIntValue: job->crop[2]];
531         [fCropRightStepper  setIntValue: job->crop[3]];
532         [fCropRightField    setIntValue: job->crop[3]];
533         }
534         else
535         {
536         [fCropMatrix  selectCellAtRow: 0 column:0];
537         }
538         
539     /* Set filters widgets according to the filters struct */
540     [fDetelecinePopUp selectItemAtIndex:fPictureFilterSettings.detelecine];
541     [fDecombPopUp selectItemAtIndex:fPictureFilterSettings.decomb];
542     [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
543     [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
544     [fDeblockSlider setFloatValue:fPictureFilterSettings.deblock];
545     [fGrayscaleCheck setState:fPictureFilterSettings.grayscale];
546     
547     [self deblockSliderChanged: nil];
548     
549     fPicture = 0;
550     MaxOutputWidth = title->width - job->crop[2] - job->crop[3];
551     MaxOutputHeight = title->height - job->crop[0] - job->crop[1];
552     
553     titleDarWidth = job->anamorphic.dar_width;
554     titleDarHeight = job->anamorphic.dar_height;
555     
556     titleParWidth = job->anamorphic.par_width;
557     titleParHeight = job->anamorphic.par_height;
558     
559     [self SettingsChanged:nil];
560 }
561
562 - (IBAction) storageLinkChanged: (id) sender
563 {
564     /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
565     if ([fStorageLinkSlider floatValue] < 0.50)
566     {
567         [fStorageLinkSlider setFloatValue:0.0];
568         /* set slider labels to reflect choice */
569         [fStorageLinkParLabel setEnabled:YES];
570         [fStorageLinkDisplayLabel setEnabled:NO];
571
572     }
573     else
574     {
575         [fStorageLinkSlider setFloatValue:1.0];
576         /* set slider labels to reflect choice */
577         [fStorageLinkParLabel setEnabled:NO];
578         [fStorageLinkDisplayLabel setEnabled:YES];
579     }
580     
581 }
582
583 - (IBAction) parLinkChanged: (id) sender
584 {
585     /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
586     if ([fParLinkSlider floatValue] < 0.50)
587     {
588         [fParLinkSlider setFloatValue:0.0];
589         /* set slider labels to reflect choice */
590         [fParLinkStorageLabel setEnabled:YES];
591         [fParLinkDisplayLabel setEnabled:NO];
592     }
593     else
594     {
595         [fParLinkSlider setFloatValue:1.0];
596         /* set slider labels to reflect choice */
597         [fParLinkStorageLabel setEnabled:NO];
598         [fParLinkDisplayLabel setEnabled:YES];
599     }
600     
601 }
602
603 - (IBAction) displayLinkChanged: (id) sender
604 {
605     /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
606     if ([fDisplayLinkSlider floatValue] < 0.50)
607     {
608         [fDisplayLinkSlider setFloatValue:0.0];
609         /* set slider labels to reflect choice */
610         [fDisplayLinkStorageLabel setEnabled:YES];
611         [fDisplayLinkParLabel setEnabled:NO];
612     }
613     else
614     {
615         [fDisplayLinkSlider setFloatValue:1.0];
616         /* set slider labels to reflect choice */
617         [fDisplayLinkStorageLabel setEnabled:NO];
618         [fDisplayLinkParLabel setEnabled:YES];
619     }
620     
621 }    
622
623 - (IBAction) SettingsChanged: (id) sender
624 {
625     hb_job_t * job = fTitle->job;
626
627     /* if we are anything but strict anamorphic */
628     if ([fAnamorphicPopUp indexOfSelectedItem] != 1)
629     {
630         [fModulusLabel setHidden:NO];
631         [fModulusPopUp setHidden:NO];
632         if (sender == fModulusPopUp)
633         {
634             /* do a dry run with hb_fix aspect to get new modulus */
635             job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
636             job->keep_ratio  = 1;
637             hb_fix_aspect( job, HB_KEEP_WIDTH );
638             if( job->height > fTitle->height )
639             {
640                 job->height = fTitle->height;
641                 hb_fix_aspect( job, HB_KEEP_HEIGHT );
642             }
643             [fWidthStepper      setIntValue: job->width];
644             [fWidthField        setIntValue: job->width];
645             if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom
646             {
647                 [fHeightStepper     setIntValue: job->height];
648                 [fHeightField       setIntValue: job->height];
649             }    
650         }
651     }
652     else
653     {
654         /* we are strict so hide the mod popup since libhb uses mod 2 for strict anamorphic*/
655         [fModulusLabel setHidden:YES];
656         [fModulusPopUp setHidden:YES];
657     }
658
659     job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
660     
661     [fWidthStepper  setIncrement: job->modulus];
662     [fHeightStepper setIncrement: job->modulus];
663
664     /* Since custom anamorphic allows for a height setting > fTitle->height
665      * check to make sure it is returned to fTitle->height for all other modes
666      */
667      [fHeightStepper setMaxValue: fTitle->height];
668     
669     autoCrop = ( [fCropMatrix selectedRow] == 0 );
670     [fCropTopStepper    setEnabled: !autoCrop];
671     [fCropBottomStepper setEnabled: !autoCrop];
672     [fCropLeftStepper   setEnabled: !autoCrop];
673     [fCropRightStepper  setEnabled: !autoCrop];
674     
675     if( autoCrop )
676     {
677         memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) );
678     }
679     else
680     {
681         job->crop[0] = [fCropTopStepper    intValue];
682         job->crop[1] = [fCropBottomStepper intValue];
683         job->crop[2] = [fCropLeftStepper   intValue];
684         job->crop[3] = [fCropRightStepper  intValue];
685     }
686     
687     [fRatioCheck setEnabled: YES];
688
689     
690     [fParWidthField setEnabled: NO];
691     [fParHeightField setEnabled: NO];
692     [fDisplayWidthField setEnabled: NO];
693     
694     /* If we are not custom anamorphic, make sure we retain the orginal par */
695     if( [fAnamorphicPopUp indexOfSelectedItem] != 3 )
696     {
697         job->anamorphic.par_width = titleParWidth;
698         job->anamorphic.par_height = titleParHeight;
699         [fRatioLabel setHidden: NO];
700     }
701     
702         if( [fAnamorphicPopUp indexOfSelectedItem] > 0 )
703         {
704         if ([fAnamorphicPopUp indexOfSelectedItem] == 1) // strict
705         {
706             [fWidthStepper      setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
707             [fWidthField        setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
708             
709             /* This will show correct anamorphic height values, but
710              show distorted preview picture ratio */
711             [fHeightStepper      setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
712             [fHeightField        setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
713             job->width       = [fWidthStepper  intValue];
714             job->height      = [fHeightStepper intValue];
715             
716             job->anamorphic.mode = 1;
717             [fWidthStepper setEnabled: NO];
718             [fWidthField setEnabled: NO];
719             [fHeightStepper setEnabled: NO];
720             [fHeightField setEnabled: NO];
721             [fRatioCheck setEnabled: NO];
722         }
723         else if ([fAnamorphicPopUp indexOfSelectedItem] == 2) // Loose anamorphic
724         {
725             job->anamorphic.mode = 2;
726             [fWidthStepper setEnabled: YES];
727             [fWidthField setEnabled: YES];
728             [fRatioCheck setEnabled: NO];
729             [fHeightStepper setEnabled: NO];
730             [fHeightField setEnabled: NO];
731             /* We set job->width and call hb_set_anamorphic_size in libhb to do a "dry run" to get
732              * the values to be used by libhb for loose anamorphic
733              */
734             /* if the sender is the anamorphic popup, then we know that loose anamorphic has just
735              * been turned on, so snap the width to full width for the source.
736              */
737             if (sender == fAnamorphicPopUp)
738             {
739                 [fWidthStepper      setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
740                 [fWidthField        setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
741             }
742             job->width       = [fWidthStepper  intValue];
743             hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
744             [fHeightStepper      setIntValue: output_height];
745             [fHeightField        setIntValue: output_height];
746             job->height      = [fHeightStepper intValue];
747             
748         }
749         else if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree
750         {
751
752 #pragma mark - STARTCapuj
753
754             job->anamorphic.mode = 3;
755             
756             /* Set the status of our custom ana only widgets accordingly */
757             [fModulusPopUp setEnabled:YES];
758             
759             [fWidthStepper setEnabled: YES];
760             [fWidthField setEnabled: YES];
761             
762             [fHeightStepper setEnabled: YES];
763             /* for capuj the storage field is immaterial */
764             [fHeightField setEnabled: YES];
765             
766             [fRatioCheck setEnabled: YES];
767             if (sender == fRatioCheck)
768             {
769                 if ([fRatioCheck  state] == NSOnState)
770                 {
771                     [fParWidthField setEnabled: NO];
772                     [fParHeightField setEnabled: NO];   
773                 }
774                 else
775                 {
776                     [fParWidthField setEnabled: YES];
777                     [fParHeightField setEnabled: YES];
778                 }
779             }
780             
781             [fParWidthField setEnabled: YES];
782             [fParHeightField setEnabled: YES];
783             
784             [fDisplayWidthField setEnabled: YES];
785             
786             
787             /* If we are coming into custom anamorphic we reset the par to original
788              * which gives us a way back if things get hosed up.
789              */
790              
791             if (sender == fAnamorphicPopUp)
792             {
793                 /* When entering custom anamorphic, we start with keep ar on */
794                 [fRatioCheck  setState: NSOnState];
795                 /*
796                  KEEPING ASPECT RATIO
797                  Disable editing: PIXEL WIDTH, PIXEL HEIGHT
798                  */
799                 [fParWidthField setEnabled: NO];
800                 [fParHeightField setEnabled: NO];
801                 
802                 job->width = [fWidthStepper intValue];
803                 job->height = [fHeightStepper intValue];
804
805                 /* make sure our par is set back to original */
806                 job->anamorphic.par_width = titleParWidth;
807                 job->anamorphic.par_height = titleParHeight;
808                 
809                 [fParWidthField   setIntValue: titleParWidth];
810                 [fParHeightField   setIntValue: titleParHeight];
811                 
812                 /* modify our par dims from our storage dims */
813                 hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
814                 float par_display_width = (float)output_width * (float)output_par_width / (float)output_par_height;
815                 
816                 /* go ahead and mod the display dims */
817                 [fDisplayWidthField   setStringValue: [NSString stringWithFormat:@"%.2f", par_display_width]];
818                 
819                 job->anamorphic.dar_width = [fDisplayWidthField floatValue];
820                 job->anamorphic.dar_height = (float)[fHeightStepper intValue];
821                 
822                 /* Set our dar here assuming we are just coming into capuj mode */
823                 dar = [fDisplayWidthField floatValue] / (float)[fHeightField intValue];
824                 
825             }
826
827             /* For capuj we disable these fields if we are keeping the dispay aspect */
828             if ([fRatioCheck  state] == NSOnState)
829             {
830                 /*
831                  KEEPING ASPECT RATIO
832                  DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification) */
833                  /*Disable editing: PIXEL WIDTH, PIXEL HEIGHT */
834                 
835                 [fParWidthField setEnabled: NO];
836                 [fParHeightField setEnabled: NO];
837                 
838                 /* Changing DISPLAY WIDTH: */
839                 if (sender == fDisplayWidthField)
840                 {
841                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
842                     /* Changes HEIGHT to keep DAR */
843                      /* calculate the height to retain the dar  */
844                     int raw_calulated_height = (int)((int)[fDisplayWidthField floatValue] / dar);
845                     /*  now use the modulus to go lower if there is a remainder  */
846                     /* Note to me, raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]
847                      * gives me the remainder we are not mod (whatever our modulus is) subtract that from
848                      * the actual calculated value derived from the dar to round down to the nearest mod value.
849                      * This should be desireable over rounding up to the next mod value
850                      */
851                     int modulus_height = raw_calulated_height - (raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]);
852                     if (modulus_height > fTitle->height)
853                     {
854                         [fHeightStepper setMaxValue: modulus_height];
855                     }
856                     [fHeightStepper setIntValue: modulus_height];
857                     job->anamorphic.dar_height = (float)[fHeightStepper intValue];
858                     job->height = [fHeightStepper intValue];
859                     
860                     /* Changes PIXEL WIDTH to new DISPLAY WIDTH */
861                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
862                     job->anamorphic.par_width = [fParWidthField intValue];
863                     /* Changes PIXEL HEIGHT to STORAGE WIDTH */
864                     [fParHeightField  setIntValue: [fWidthField intValue]];
865                     job->anamorphic.par_height = [fParHeightField intValue];
866                     
867                 }
868                 /* Changing HEIGHT: */
869                 if (sender == fHeightStepper)
870                 {
871                    job->anamorphic.dar_height = (float)[fHeightStepper intValue];
872                    job->height = [fHeightStepper intValue];
873                    
874                     /* Changes DISPLAY WIDTH to keep DAR*/
875                     [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",[fHeightStepper intValue] * dar]];
876                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
877                     /* Changes PIXEL WIDTH to new DISPLAY WIDTH */
878                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
879                     job->anamorphic.par_width = [fParWidthField intValue];
880                     /* Changes PIXEL HEIGHT to STORAGE WIDTH */
881                     [fParHeightField  setIntValue: [fWidthField intValue]];
882                     job->anamorphic.par_height = [fParHeightField intValue];
883                 }
884                 /* Changing STORAGE_WIDTH: */
885                 if (sender == fWidthStepper)
886                 {
887                     job->width = [fWidthStepper intValue];
888                     
889                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
890                     job->anamorphic.dar_height = [fHeightStepper floatValue];
891                      
892                     /* Changes PIXEL WIDTH to DISPLAY WIDTH */
893                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
894                     job->anamorphic.par_width = [fParWidthField intValue];
895                     /* Changes PIXEL HEIGHT to new STORAGE WIDTH */
896                     [fParHeightField  setIntValue: [fWidthStepper intValue]];
897                     job->anamorphic.par_height = [fParHeightField intValue];
898                 }
899             }
900             else if ([fRatioCheck  state] == NSOffState)
901             {
902                 /* Changing STORAGE_WIDTH: */
903                 if (sender == fWidthStepper)
904                 {
905                     job->width = [fWidthStepper intValue];
906                     /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */
907                     [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]];
908                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
909                 }
910                 /* Changing PIXEL dimensions */
911                 if (sender == fParWidthField || sender == fParHeightField)
912                 {
913                     job->anamorphic.par_width = [fParWidthField intValue];
914                     job->anamorphic.par_height = [fParHeightField intValue];
915                     /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */
916                     [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]];
917                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
918                 }
919                 /* Changing DISPLAY WIDTH: */
920                 if (sender == fDisplayWidthField)
921                 {
922                     job->anamorphic.dar_width = [fDisplayWidthField floatValue];
923                     job->anamorphic.dar_height = (float)[fHeightStepper intValue];
924                     /* changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH */
925                     [fParWidthField setIntValue: [fDisplayWidthField intValue]];
926                     job->anamorphic.par_width = [fParWidthField intValue];
927                     
928                     [fParHeightField  setIntValue: [fWidthField intValue]];
929                     job->anamorphic.par_height = [fParHeightField intValue];
930                     hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
931                 }
932                 /* Changing HEIGHT: */
933                 if (sender == fHeightStepper)
934                 {
935                     /* just....changes the height.*/
936                     job->anamorphic.dar_height = [fHeightStepper intValue];
937                     job->height = [fHeightStepper intValue];
938                 }
939                 
940             }
941             
942 #pragma mark - END Capuj                       
943         }
944         
945         /* if the sender is the Anamorphic checkbox, record the state
946          of KeepAspect Ratio so it can be reset if Anamorphic is unchecked again */
947         if (sender == fAnamorphicPopUp)
948         {
949             keepAspectRatioPreviousState = [fRatioCheck state];
950         }
951         if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
952         {
953             [fRatioCheck setState:NSOffState];
954         }
955         
956     }
957     else
958         {
959         job->width       = [fWidthStepper  intValue];
960         job->height      = [fHeightStepper intValue];
961         job->anamorphic.mode = 0;
962         [fWidthStepper setEnabled: YES];
963         [fWidthField setEnabled: YES];
964         [fHeightStepper setEnabled: YES];
965         [fHeightField setEnabled: YES];
966         [fRatioCheck setEnabled: YES];
967         /* if the sender is the Anamorphic checkbox, we return the
968          keep AR checkbox to its previous state */
969         if (sender == fAnamorphicPopUp)
970         {
971             [fRatioCheck setState:keepAspectRatioPreviousState];
972         }
973         
974         }
975         
976     if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
977     {
978         job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
979         if( job->keep_ratio )
980         {
981             if( sender == fWidthStepper || sender == fRatioCheck ||
982                sender == fCropTopStepper || sender == fCropBottomStepper|| 
983                sender == fCropMatrix || sender == nil  )
984             {
985                 hb_fix_aspect( job, HB_KEEP_WIDTH );
986                 if( job->height > fTitle->height )
987                 {
988                     job->height = fTitle->height;
989                     hb_fix_aspect( job, HB_KEEP_HEIGHT );
990                 }
991             }
992             else
993             {
994                 hb_fix_aspect( job, HB_KEEP_HEIGHT );
995                 if( job->width > fTitle->width )
996                 {
997                     job->width = fTitle->width;
998                     hb_fix_aspect( job, HB_KEEP_WIDTH );
999                 }
1000             }
1001             
1002         }
1003     }
1004     
1005     // hb_get_preview can't handle sizes that are larger than the original title
1006     if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
1007     {
1008         // dimensions
1009         if( job->width > fTitle->width )
1010         {
1011             job->width = fTitle->width;
1012         }
1013         
1014         if( job->height > fTitle->height )
1015         {
1016             job->height = fTitle->height;
1017         }
1018     }
1019     
1020     [fWidthStepper      setIntValue: job->width];
1021     [fWidthField        setIntValue: job->width];
1022     if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom
1023     {
1024         [fHeightStepper     setIntValue: job->height];
1025         [fHeightField       setIntValue: job->height];
1026     }
1027     
1028     [fCropTopStepper    setIntValue: job->crop[0]];
1029     [fCropTopField      setIntValue: job->crop[0]];
1030     [fCropBottomStepper setIntValue: job->crop[1]];
1031     [fCropBottomField   setIntValue: job->crop[1]];
1032     [fCropLeftStepper   setIntValue: job->crop[2]];
1033     [fCropLeftField     setIntValue: job->crop[2]];
1034     [fCropRightStepper  setIntValue: job->crop[3]];
1035     [fCropRightField    setIntValue: job->crop[3]];
1036     
1037     //[fPreviewController SetTitle:fTitle];
1038     
1039     /* Sanity Check Here for < 16 px preview to avoid
1040      crashing hb_get_preview. In fact, just for kicks
1041      lets getting previews at a min limit of 32, since
1042      no human can see any meaningful detail below that */
1043     if (job->width >= 64 && job->height >= 64)
1044     {
1045         [self reloadStillPreview];
1046     }
1047     
1048     /* we get the sizing info to display from fPreviewController */
1049     [fSizeInfoField setStringValue: [fPreviewController pictureSizeInfoString]];
1050     
1051     if (sender != nil)
1052     {
1053         [fHBController pictureSettingsDidChange];
1054     }   
1055     
1056     if ([[self window] isVisible])
1057     { 
1058         [self adjustSizingDisplay:nil];
1059     }
1060     
1061 }
1062
1063 - (NSString*) getPictureSizeInfoString
1064 {
1065     return [fSizeInfoField stringValue];
1066 }
1067
1068 - (void)reloadStillPreview
1069
1070    hb_job_t * job = fTitle->job; 
1071    
1072    [fPreviewController SetTitle:fTitle];
1073     /* Sanity Check Here for < 16 px preview to avoid
1074      crashing hb_get_preview. In fact, just for kicks
1075      lets getting previews at a min limit of 32, since
1076      no human can see any meaningful detail below that */
1077     if (job->width >= 64 && job->height >= 64)
1078     {
1079        
1080          // Purge the existing picture previews so they get recreated the next time
1081         // they are needed.
1082       //  [fPreviewController purgeImageCache];
1083         /* We actually call displayPreview now from pictureSliderChanged which keeps
1084          * our picture preview slider in sync with the previews being shown
1085          */
1086
1087     //[fPreviewController pictureSliderChanged:nil];
1088     }
1089     
1090 }
1091
1092
1093 #pragma mark -
1094
1095 - (BOOL) autoCrop
1096 {
1097     return autoCrop;
1098 }
1099 - (void) setAutoCrop: (BOOL) setting
1100 {
1101     autoCrop = setting;
1102 }
1103
1104 - (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title
1105 {
1106     //[self SetTitle:title];
1107     [self showWindow:sender];
1108     //[self adjustSizingDisplay:nil];
1109     //[self adjustFilterDisplay:nil];
1110
1111 }
1112
1113
1114 #pragma mark -
1115 /* we use this to setup the initial picture filters upon first launch, after that their states
1116 are maintained across different sources */
1117 - (void) setInitialPictureFilters
1118 {
1119         /* we use a popup to show the detelecine settings */
1120         [fDetelecinePopUp removeAllItems];
1121     [fDetelecinePopUp addItemWithTitle: @"Off"];
1122     [fDetelecinePopUp addItemWithTitle: @"Custom"];
1123     [fDetelecinePopUp addItemWithTitle: @"Default"];
1124     [fDetelecinePopUp selectItemAtIndex: fPictureFilterSettings.detelecine];
1125     
1126     [self modeDecombDeinterlaceSliderChanged:nil];
1127     /* we use a popup to show the decomb settings */
1128         [fDecombPopUp removeAllItems];
1129     [fDecombPopUp addItemWithTitle: @"Off"];
1130     [fDecombPopUp addItemWithTitle: @"Custom"];
1131     [fDecombPopUp addItemWithTitle: @"Default"];
1132     
1133     [fDecombPopUp selectItemAtIndex: fPictureFilterSettings.decomb];
1134     
1135     /* we use a popup to show the deinterlace settings */
1136         [fDeinterlacePopUp removeAllItems];
1137     [fDeinterlacePopUp addItemWithTitle: @"Off"];
1138     [fDeinterlacePopUp addItemWithTitle: @"Custom"];
1139     [fDeinterlacePopUp addItemWithTitle: @"Fast"];
1140     [fDeinterlacePopUp addItemWithTitle: @"Slow"];
1141         [fDeinterlacePopUp addItemWithTitle: @"Slower"];
1142     
1143         /* Set deinterlaces level according to the integer in the main window */
1144         [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
1145
1146         /* we use a popup to show the denoise settings */
1147         [fDenoisePopUp removeAllItems];
1148     [fDenoisePopUp addItemWithTitle: @"Off"];
1149     [fDenoisePopUp addItemWithTitle: @"Custom"];
1150     [fDenoisePopUp addItemWithTitle: @"Weak"];
1151         [fDenoisePopUp addItemWithTitle: @"Medium"];
1152     [fDenoisePopUp addItemWithTitle: @"Strong"];
1153         /* Set denoises level according to the integer in the main window */
1154         [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
1155     
1156
1157 }
1158
1159
1160
1161
1162 - (IBAction) modeDecombDeinterlaceSliderChanged: (id) sender
1163 {
1164     
1165     /* since its a tickless slider, we have to  make sure we are on or off */
1166     if ([fDecombDeinterlaceSlider floatValue] < 0.50)
1167     {
1168         [fDecombDeinterlaceSlider setFloatValue:0.0];
1169     }
1170     else
1171     {
1172         [fDecombDeinterlaceSlider setFloatValue:1.0];
1173     }
1174     
1175     
1176     /* Decomb selected*/
1177     if ([fDecombDeinterlaceSlider floatValue] == 0.0)
1178     {
1179         [fDecombBox setHidden:NO];
1180         [fDeinterlaceBox setHidden:YES];
1181         fPictureFilterSettings.decomb = [fDecombPopUp indexOfSelectedItem];
1182         fPictureFilterSettings.usedecomb = 1;
1183         fPictureFilterSettings.deinterlace = 0;
1184         [fDecombPopUp selectItemAtIndex:fPictureFilterSettings.decomb];
1185         [self adjustFilterDisplay:fDecombPopUp];
1186     }
1187     else
1188     {
1189         [fDecombBox setHidden:YES];
1190         [fDeinterlaceBox setHidden:NO];
1191         fPictureFilterSettings.usedecomb = 0;
1192         fPictureFilterSettings.decomb = 0;
1193         [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
1194         [self adjustFilterDisplay:fDeinterlacePopUp];
1195     }
1196     [self FilterSettingsChanged: fDecombDeinterlaceSlider];
1197 }
1198
1199
1200 - (IBAction) FilterSettingsChanged: (id) sender
1201 {
1202     
1203     fPictureFilterSettings.detelecine  = [fDetelecinePopUp indexOfSelectedItem];
1204     [self adjustFilterDisplay:fDetelecinePopUp];
1205     
1206     fPictureFilterSettings.decomb = [fDecombPopUp indexOfSelectedItem];
1207     [self adjustFilterDisplay:fDecombPopUp];
1208     
1209     fPictureFilterSettings.deinterlace = [fDeinterlacePopUp indexOfSelectedItem];
1210     [self adjustFilterDisplay:fDeinterlacePopUp];
1211     
1212     fPictureFilterSettings.denoise = [fDenoisePopUp indexOfSelectedItem];
1213     [self adjustFilterDisplay:fDenoisePopUp];
1214     
1215     if ([fDeblockField stringValue] == @"Off")
1216     {
1217         fPictureFilterSettings.deblock  = 0;
1218     }
1219     else
1220     {
1221         fPictureFilterSettings.deblock  = [fDeblockField intValue];
1222     }
1223     
1224     fPictureFilterSettings.grayscale = [fGrayscaleCheck state];
1225     
1226     if (sender != nil)
1227     {
1228         [fHBController pictureSettingsDidChange];
1229         
1230     }   
1231
1232 }
1233
1234
1235 #pragma mark -
1236
1237 - (IBAction) deblockSliderChanged: (id) sender
1238 {
1239     if ([fDeblockSlider floatValue] == 4.0)
1240     {
1241     [fDeblockField setStringValue: [NSString stringWithFormat: @"Off"]];
1242     }
1243     else
1244     {
1245     [fDeblockField setStringValue: [NSString stringWithFormat: @"%.0f", [fDeblockSlider floatValue]]];
1246     }
1247         [self FilterSettingsChanged: sender];
1248 }
1249
1250
1251 - (int) detelecine
1252 {
1253     return fPictureFilterSettings.detelecine;
1254 }
1255
1256 - (NSString*) detelecineCustomString
1257 {
1258     return [fDetelecineField stringValue];
1259 }
1260
1261 - (void) setDetelecine: (int) setting
1262 {
1263     fPictureFilterSettings.detelecine = setting;
1264 }
1265
1266 - (void) setDetelecineCustomString: (NSString*) string 
1267 {
1268     [fDetelecineField setStringValue:string];
1269 }
1270
1271 - (int) deinterlace
1272 {
1273     return fPictureFilterSettings.deinterlace;
1274 }
1275 - (NSString*) deinterlaceCustomString
1276 {
1277     return [fDeinterlaceField stringValue];
1278 }
1279
1280 - (void) setDeinterlaceCustomString: (NSString*) string 
1281 {
1282     [fDeinterlaceField setStringValue:string];
1283 }
1284
1285 - (void) setDeinterlace: (int) setting 
1286 {
1287     fPictureFilterSettings.deinterlace = setting;
1288 }
1289 - (int) decomb
1290 {
1291     return fPictureFilterSettings.decomb;
1292 }
1293
1294 - (NSString*) decombCustomString
1295 {
1296     return [fDecombField stringValue];
1297 }
1298
1299 - (int) useDecomb
1300 {
1301     return fPictureFilterSettings.usedecomb;
1302 }
1303
1304 - (void) setUseDecomb: (int) setting
1305 {
1306     fPictureFilterSettings.usedecomb = setting;
1307     if (fPictureFilterSettings.usedecomb == 1)
1308     {
1309         [fDecombDeinterlaceSlider setFloatValue:0.0];
1310     }
1311     else
1312     {
1313         [fDecombDeinterlaceSlider setFloatValue:1.0];
1314     }
1315     [self modeDecombDeinterlaceSliderChanged:nil];
1316 }
1317
1318 - (void) setDecomb: (int) setting {
1319     fPictureFilterSettings.decomb = setting;
1320 }
1321
1322 - (void) setDecombCustomString: (NSString*) string 
1323 {
1324     [fDecombField setStringValue:string];
1325 }
1326
1327 - (int) denoise
1328 {
1329     return fPictureFilterSettings.denoise;
1330 }
1331
1332 - (NSString*) denoiseCustomString
1333 {
1334     return [fDenoiseField stringValue];
1335 }
1336
1337 - (void) setDenoiseCustomString: (NSString*) string 
1338 {
1339     [fDenoiseField setStringValue:string];
1340 }
1341
1342 - (void) setDenoise: (int) setting
1343 {
1344     fPictureFilterSettings.denoise = setting;
1345 }
1346
1347 - (int) deblock
1348 {
1349     return fPictureFilterSettings.deblock;
1350 }
1351
1352 - (void) setDeblock: (int) setting
1353 {
1354     fPictureFilterSettings.deblock = setting;
1355 }
1356
1357 - (int) grayscale
1358 {
1359     return fPictureFilterSettings.grayscale;
1360 }
1361
1362 - (void) setGrayscale: (int) setting
1363 {
1364     fPictureFilterSettings.grayscale = setting;
1365 }
1366
1367
1368
1369 @end
1370