summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordynaflash <[email protected]>2007-09-16 00:48:42 +0000
committerdynaflash <[email protected]>2007-09-16 00:48:42 +0000
commitae3318562ae54ad4d01e7a6bbb04cabff10abf0f (patch)
tree74725a37bc18720cffb89385b264978243210030
parentc46f48bd0a2cd5fac81bd3866b3b3191d9060912 (diff)
MacGui: Scale > 720 or > 480 Picture Previews and the Picture Settings window to fit to screen.
- Perfect for HD transport streams or any HD source - If source width is > 720 or source height is > 480, the Picture Settings window will scale appropriately to 85% of either the users screen height or width, whichever it runs into first. - The scaled size for the preview is displayed in the Picture settings detail at the bottom as a percentage. - Thanks blindjimmy !! git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@965 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--macosx/English.lproj/PictureSettings.nib/classes.nib3
-rw-r--r--macosx/English.lproj/PictureSettings.nib/info.nib2
-rw-r--r--macosx/English.lproj/PictureSettings.nib/keyedobjects.nibbin23317 -> 23812 bytes
-rw-r--r--macosx/PictureController.h3
-rw-r--r--macosx/PictureController.mm143
5 files changed, 140 insertions, 11 deletions
diff --git a/macosx/English.lproj/PictureSettings.nib/classes.nib b/macosx/English.lproj/PictureSettings.nib/classes.nib
index 0d83d8f54..bf6661763 100644
--- a/macosx/English.lproj/PictureSettings.nib/classes.nib
+++ b/macosx/English.lproj/PictureSettings.nib/classes.nib
@@ -2,6 +2,7 @@
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = HBPictureGLView; LANGUAGE = ObjC; SUPERCLASS = NSOpenGLView; },
+ {CLASS = NSObject; LANGUAGE = ObjC; },
{
ACTIONS = {
ClosePanel = id;
@@ -12,6 +13,7 @@
CLASS = PictureController;
LANGUAGE = ObjC;
OUTLETS = {
+ delegate = id;
fCropBottomField = NSTextField;
fCropBottomStepper = NSStepper;
fCropLeftField = NSTextField;
@@ -31,6 +33,7 @@
fNextButton = NSButton;
fPARCheck = NSButton;
fPictureGLView = HBPictureGLView;
+ fPictureGLViewArea = NSBox;
fPicturePanel = NSPanel;
fPrevButton = NSButton;
fRatioCheck = NSButton;
diff --git a/macosx/English.lproj/PictureSettings.nib/info.nib b/macosx/English.lproj/PictureSettings.nib/info.nib
index c710553a5..df5713deb 100644
--- a/macosx/English.lproj/PictureSettings.nib/info.nib
+++ b/macosx/English.lproj/PictureSettings.nib/info.nib
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
- <string>262 95 356 240 0 0 1440 878 </string>
+ <string>715 90 356 240 0 0 1920 1178 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
diff --git a/macosx/English.lproj/PictureSettings.nib/keyedobjects.nib b/macosx/English.lproj/PictureSettings.nib/keyedobjects.nib
index a667ae4e8..619172b48 100644
--- a/macosx/English.lproj/PictureSettings.nib/keyedobjects.nib
+++ b/macosx/English.lproj/PictureSettings.nib/keyedobjects.nib
Binary files differ
diff --git a/macosx/PictureController.h b/macosx/PictureController.h
index 81aff8517..98cf3ddcd 100644
--- a/macosx/PictureController.h
+++ b/macosx/PictureController.h
@@ -24,6 +24,7 @@
IBOutlet NSPanel * fPicturePanel;
IBOutlet HBPictureGLView * fPictureGLView;
+ IBOutlet NSBox * fPictureGLViewArea;
IBOutlet NSTextField * fWidthField;
IBOutlet NSStepper * fWidthStepper;
IBOutlet NSTextField * fHeightField;
@@ -80,7 +81,7 @@
- (int) denoise;
- (void) setDenoise: (int) setting;
-- (void) showPanelInWindow: (NSWindow *) fWindow forTitle:(hb_title_t *)title;
+- (void)showPanelInWindow: (NSWindow *)fWindow forTitle: (hb_title_t *)title;
- (BOOL) loadMyNibFile;
@end
diff --git a/macosx/PictureController.mm b/macosx/PictureController.mm
index ba89789b8..0c01d9b03 100644
--- a/macosx/PictureController.mm
+++ b/macosx/PictureController.mm
@@ -6,6 +6,14 @@
#include "PictureController.h"
+@interface PictureController (Private)
+
+- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize;
+- (void)resizeSheetForViewSize: (NSSize)viewSize;
+- (void)setViewSize: (NSSize)viewSize;
+
+@end
+
static int GetAlignedSize( int size )
{
int result = 1;
@@ -204,6 +212,7 @@ static int GetAlignedSize( int size )
int arpheight = fTitle->job->pixel_aspect_height;
int displayparwidth = titlewidth * arpwidth / arpheight;
int displayparheight = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
+
if (fTitle->job->pixel_ratio == 1)
{
@@ -221,6 +230,18 @@ static int GetAlignedSize( int size )
fTitle->job->width, fTitle->job->height]];
}
+ // Show the scaled text
+ NSSize viewSize = [fPictureGLView frame].size;
+ if( ((int)viewSize.width) != fTitle->width )
+ {
+ float scale = viewSize.width / ((float)fTitle->width);
+ NSString *scaleString = [NSString stringWithFormat:
+ NSLocalizedString( @" (Preview scaled to %.0f%% actual size)",
+ @"String shown when a preview is scaled" ),
+ scale * 100.0];
+ [fInfoField setStringValue:
+ [[fInfoField stringValue] stringByAppendingString:scaleString]];
+ }
[fPrevButton setEnabled: ( fPicture > 0 )];
[fNextButton setEnabled: ( fPicture < 9 )];
@@ -412,16 +433,20 @@ static int GetAlignedSize( int size )
fPictureFilterSettings.denoise = setting;
}
-- (void) showPanelInWindow: (NSWindow *) fWindow forTitle:(hb_title_t *)title {
- NSSize newSize;
- newSize.width = 246 + title->width;
- newSize.height = 80 + title->height;
- [fPicturePanel setContentSize: newSize];
-
- [self SetTitle: title];
+- (void)showPanelInWindow: (NSWindow *)fWindow forTitle: (hb_title_t *)title
+{
+ NSSize viewSize = [self optimalViewSizeForImageSize:NSMakeSize( title->width,
+ title->height )];
+ [self resizeSheetForViewSize:viewSize];
+ [self setViewSize:viewSize];
- [NSApp beginSheet: fPicturePanel modalForWindow: fWindow
- modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
+ [self SetTitle:title];
+
+ [NSApp beginSheet:fPicturePanel
+ modalForWindow:fWindow
+ modalDelegate:nil
+ didEndSelector:nil
+ contextInfo:NULL];
}
- (BOOL) loadMyNibFile
@@ -436,3 +461,103 @@ static int GetAlignedSize( int size )
}
@end
+
+@implementation PictureController (Private)
+
+//
+// -[PictureController(Private) optimalViewSizeForImageSize:]
+//
+// Given the size of the preview image to be shown, returns the best possible
+// size for the OpenGL view.
+//
+- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize
+{
+ // The min size is 320x240
+ float minWidth = 320.0;
+ float minHeight = 240.0;
+
+ // The max size of the view is when the sheet is taking up 85% of the screen.
+ NSSize screenSize = [[NSScreen mainScreen] frame].size;
+ NSSize sheetSize = [fPicturePanel frame].size;
+ NSSize viewAreaSize = [fPictureGLViewArea frame].size;
+ float paddingX = sheetSize.width - viewAreaSize.width;
+ float paddingY = sheetSize.height - viewAreaSize.height;
+ float maxWidth = (0.85 * screenSize.width) - paddingX;
+ float maxHeight = (0.85 * screenSize.height) - paddingY;
+
+ NSSize resultSize = imageSize;
+
+ // Its better to have a view that's too small than a view that's too big, so
+ // apply the maximum constraints last.
+ if( resultSize.width < minWidth )
+ {
+ resultSize.height *= (minWidth / resultSize.width);
+ resultSize.width = minWidth;
+ }
+ if( resultSize.height < minHeight )
+ {
+ resultSize.width *= (minHeight / resultSize.height);
+ resultSize.height = minHeight;
+ }
+ if( resultSize.width > maxWidth )
+ {
+ resultSize.height *= (maxWidth / resultSize.width);
+ resultSize.width = maxWidth;
+ }
+ if( resultSize.height > maxHeight )
+ {
+ resultSize.width *= (maxHeight / resultSize.height);
+ resultSize.height = maxHeight;
+ }
+
+ return resultSize;
+}
+
+//
+// -[PictureController(Private) resizePanelForViewSize:]
+//
+// Resizes the entire sheet to accomodate an OpenGL view of a particular size.
+//
+- (void)resizeSheetForViewSize: (NSSize)viewSize
+{
+ // Figure out the deltas for the new frame area
+ NSSize currentSize = [fPictureGLViewArea frame].size;
+ float deltaX = viewSize.width - currentSize.width;
+ float deltaY = viewSize.height - currentSize.height;
+
+ // Now resize the whole panel by those same deltas, but don't exceed the min
+ NSRect frame = [fPicturePanel frame];
+ NSSize maxSize = [fPicturePanel maxSize];
+ NSSize minSize = [fPicturePanel minSize];
+ frame.size.width += deltaX;
+ frame.size.height += deltaY;
+ if( frame.size.width < minSize.width )
+ {
+ frame.size.width = minSize.width;
+ }
+ if( frame.size.height < minSize.height )
+ {
+ frame.size.height = minSize.height;
+ }
+
+ [fPicturePanel setFrame:frame display:YES];
+}
+
+//
+// -[PictureController(Private) setViewSize:]
+//
+// Changes the OpenGL view's size and centers it vertially inside of its area.
+// Assumes resizeSheetForViewSize: has already been called.
+//
+- (void)setViewSize: (NSSize)viewSize
+{
+ [fPictureGLView setFrameSize:viewSize];
+
+ // center it vertically
+ NSPoint origin = [fPictureGLViewArea frame].origin;
+ origin.y += ([fPictureGLViewArea frame].size.height -
+ [fPictureGLView frame].size.height) / 2.0;
+ [fPictureGLView setFrameOrigin:origin];
+}
+
+@end