diff options
author | handbrake <[email protected]> | 2006-01-14 12:53:59 +0000 |
---|---|---|
committer | handbrake <[email protected]> | 2006-01-14 12:53:59 +0000 |
commit | a9a84221af31ca7d11d1aa182d8b152270203f9f (patch) | |
tree | da452de9a4d3bb509d59de4a65fe12e9fb8e7825 /macosx | |
parent | 939b35fc70bb688d38b086afebd8d14d8193d2c9 (diff) |
HandBrake 0.3
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/English.lproj/InfoPlist.strings | bin | 0 -> 488 bytes | |||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 70 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/info.nib | 29 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/objects.nib | bin | 0 -> 14905 bytes | |||
-rw-r--r-- | macosx/HBController.h | 88 | ||||
-rw-r--r-- | macosx/HBController.mm | 627 | ||||
-rw-r--r-- | macosx/HandBrake.icns | bin | 0 -> 64031 bytes | |||
-rw-r--r-- | macosx/HandBrake.pbproj/project.pbxproj | 577 | ||||
-rw-r--r-- | macosx/PictureGLView.h | 20 | ||||
-rw-r--r-- | macosx/PictureGLView.mm | 114 | ||||
-rw-r--r-- | macosx/main.mm | 12 |
11 files changed, 1537 insertions, 0 deletions
diff --git a/macosx/English.lproj/InfoPlist.strings b/macosx/English.lproj/InfoPlist.strings Binary files differnew file mode 100644 index 000000000..ae4f04858 --- /dev/null +++ b/macosx/English.lproj/InfoPlist.strings diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 000000000..df2438f40 --- /dev/null +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,70 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = { + BrowseDVD = id; + BrowseFile = id; + Cancel = id; + ClosePanel = id; + NextPicture = id; + PreviousPicture = id; + Resume = id; + Rip = id; + Scan = id; + ScanEnableIntf = id; + ShowPicturePanel = id; + Suspend = id; + UpdatePicture = id; + UpdatePopUp = id; + }; + CLASS = HBController; + LANGUAGE = ObjC; + OUTLETS = { + fAudioField = NSTextField; + fAudioPopUp = NSPopUpButton; + fAudioStepper = NSStepper; + fBlankView = NSView; + fBottomField = NSTextField; + fBottomStepper = NSStepper; + fCropButton = NSButton; + fDVDFolderField = NSTextField; + fDVDPopUp = NSPopUpButton; + fDeinterlaceCheck = NSButton; + fDonePanel = NSPanel; + fFileField = NSTextField; + fInfoField = NSTextField; + fLeftField = NSTextField; + fLeftStepper = NSStepper; + fPictureGLView = PictureGLView; + fPicturePanel = NSPanel; + fRightField = NSTextField; + fRightStepper = NSStepper; + fRipBrowseButton = NSButton; + fRipButton = NSButton; + fRipProgress = NSProgressIndicator; + fRipStatusField = NSTextField; + fRipView = NSView; + fScanBrowseButton = NSButton; + fScanButton = NSButton; + fScanMatrix = NSMatrix; + fScanProgress = NSProgressIndicator; + fScanStatusField = NSTextField; + fScanView = NSView; + fSuspendButton = NSButton; + fTitlePopUp = NSPopUpButton; + fTopField = NSTextField; + fTopStepper = NSStepper; + fTwoPassCheck = NSButton; + fVideoField = NSTextField; + fVideoStepper = NSStepper; + fWidthField = NSTextField; + fWidthStepper = NSStepper; + fWindow = NSWindow; + }; + SUPERCLASS = NSObject; + }, + {CLASS = PictureGLView; LANGUAGE = ObjC; SUPERCLASS = NSOpenGLView; } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/macosx/English.lproj/MainMenu.nib/info.nib b/macosx/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 000000000..0dbd97023 --- /dev/null +++ b/macosx/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>109 136 381 380 0 0 1440 878 </string> + <key>IBEditorPositions</key> + <dict> + <key>249</key> + <string>510 472 420 258 0 0 1440 878 </string> + <key>256</key> + <string>454 372 420 466 0 0 1440 878 </string> + <key>29</key> + <string>407 469 205 44 0 0 1440 878 </string> + </dict> + <key>IBFramework Version</key> + <string>291.0</string> + <key>IBOpenObjects</key> + <array> + <integer>249</integer> + <integer>256</integer> + <integer>21</integer> + <integer>434</integer> + <integer>29</integer> + </array> + <key>IBSystem Version</key> + <string>6R73</string> +</dict> +</plist> diff --git a/macosx/English.lproj/MainMenu.nib/objects.nib b/macosx/English.lproj/MainMenu.nib/objects.nib Binary files differnew file mode 100644 index 000000000..a7849eb54 --- /dev/null +++ b/macosx/English.lproj/MainMenu.nib/objects.nib diff --git a/macosx/HBController.h b/macosx/HBController.h new file mode 100644 index 000000000..2e3339c74 --- /dev/null +++ b/macosx/HBController.h @@ -0,0 +1,88 @@ +/* $Id: HBController.h,v 1.19 2003/10/06 21:13:45 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://beos.titer.org/handbrake/>. + It may be used under the terms of the GNU General Public License. */ + +#include <Cocoa/Cocoa.h> + +#include "Manager.h" +#include "PictureGLView.h" + +@interface HBController : NSObject + +{ + IBOutlet NSWindow * fWindow; + + IBOutlet NSView * fScanView; + IBOutlet NSMatrix * fScanMatrix; + IBOutlet NSPopUpButton * fDVDPopUp; + IBOutlet NSTextField * fDVDFolderField; + IBOutlet NSButton * fScanBrowseButton; + IBOutlet NSTextField * fScanStatusField; + IBOutlet NSProgressIndicator * fScanProgress; + IBOutlet NSButton * fScanButton; + + IBOutlet NSView * fRipView; + IBOutlet NSPopUpButton * fTitlePopUp; + IBOutlet NSPopUpButton * fAudioPopUp; + IBOutlet NSTextField * fVideoField; + IBOutlet NSStepper * fVideoStepper; + IBOutlet NSTextField * fAudioField; + IBOutlet NSStepper * fAudioStepper; + IBOutlet NSButton * fTwoPassCheck; + IBOutlet NSButton * fCropButton; + IBOutlet NSTextField * fFileField; + IBOutlet NSButton * fRipBrowseButton; + IBOutlet NSTextField * fRipStatusField; + IBOutlet NSProgressIndicator * fRipProgress; + IBOutlet NSButton * fSuspendButton; + IBOutlet NSButton * fRipButton; + IBOutlet NSPanel * fDonePanel; + + IBOutlet NSPanel * fPicturePanel; + IBOutlet PictureGLView * fPictureGLView; + IBOutlet NSTextField * fWidthField; + IBOutlet NSStepper * fWidthStepper; + IBOutlet NSButton * fDeinterlaceCheck; + IBOutlet NSTextField * fTopField; + IBOutlet NSStepper * fTopStepper; + IBOutlet NSTextField * fBottomField; + IBOutlet NSStepper * fBottomStepper; + IBOutlet NSTextField * fLeftField; + IBOutlet NSStepper * fLeftStepper; + IBOutlet NSTextField * fRightField; + IBOutlet NSStepper * fRightStepper; + IBOutlet NSTextField * fInfoField; + int fPicture; + + IBOutlet NSView * fBlankView; + HBManager * fManager; + HBList * fTitleList; +} + +- (IBAction) BrowseDVD: (id) sender; +- (void) BrowseDVDDone: (NSOpenPanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo; +- (IBAction) Scan: (id) sender; + +- (IBAction) BrowseFile: (id) sender; +- (void) BrowseFileDone: (NSSavePanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo; +- (IBAction) ShowPicturePanel: (id) sender; +- (IBAction) ClosePanel: (id) sender; +- (IBAction) Rip: (id) sender; +- (IBAction) Cancel: (id) sender; +- (IBAction) Suspend: (id) sender; +- (IBAction) Resume: (id) sender; + +- (IBAction) PreviousPicture: (id) sender; +- (IBAction) NextPicture: (id) sender; +- (IBAction) UpdatePicture: (id) sender; + +- (void) UpdateIntf: (NSTimer *) timer; +- (void) DetectDrives; +- (void) ScanEnableIntf: (id) sender; +- (void) UpdatePopUp: (id) sender; + +@end diff --git a/macosx/HBController.mm b/macosx/HBController.mm new file mode 100644 index 000000000..f46d0221a --- /dev/null +++ b/macosx/HBController.mm @@ -0,0 +1,627 @@ +/* $Id: HBController.mm,v 1.24 2003/10/06 21:13:45 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://beos.titer.org/handbrake/>. + It may be used under the terms of the GNU General Public License. */ + +#include <paths.h> +#include <IOKit/IOKitLib.h> +#include <IOKit/IOBSD.h> +#include <IOKit/storage/IOMedia.h> +#include <IOKit/storage/IODVDMedia.h> + +#include "HBController.h" +#include "Manager.h" + +@implementation HBController + +- (void) applicationDidFinishLaunching: (NSNotification *) notification +{ + /* Init libhb */ + fManager = new HBManager( true ); + + /* Update the GUI every 1/10 sec */ + [NSTimer scheduledTimerWithTimeInterval: 0.1 + target: self selector: @selector( UpdateIntf: ) + userInfo: nil repeats: FALSE]; +} + +- (NSApplicationTerminateReply) applicationShouldTerminate: + (NSApplication *) app +{ + /* Clean up */ + delete fManager; + + return NSTerminateNow; +} + +- (void) awakeFromNib +{ + [[fScanMatrix cellAtRow: 0 column: 0] + setAction: @selector( ScanEnableIntf: )]; + [[fScanMatrix cellAtRow: 0 column: 0] setTarget: self]; + [[fScanMatrix cellAtRow: 1 column: 0] + setAction: @selector( ScanEnableIntf: )]; + [[fScanMatrix cellAtRow: 1 column: 0] setTarget: self]; + [fScanProgress setStyle: NSProgressIndicatorSpinningStyle]; + [fScanProgress setDisplayedWhenStopped: NO]; + [fRipProgress setIndeterminate: NO]; + [fTitlePopUp removeAllItems]; + [fAudioPopUp removeAllItems]; + + char string[1024]; memset( string, 0, 1024 ); + snprintf( string, 1024, "%s/Desktop/Movie.avi", getenv( "HOME" ) ); + [fFileField setStringValue: [NSString stringWithCString: string]]; + + /* Show the scan view */ + [fWindow setContentSize: [fScanView frame].size]; + [fWindow setContentView: fScanView]; + [fWindow center]; + + /* Detect DVD drives */ + [self DetectDrives]; + [self ScanEnableIntf: self]; + + /* Init a blank view, used in window resizing animation */ + fBlankView = [[NSView alloc] init]; +} + +- (BOOL) windowShouldClose: (id) sender +{ + /* Stop the application when the user closes the window */ + [NSApp terminate: self]; + return YES; +} + +- (IBAction) BrowseDVD: (id) sender +{ + /* Open a panel to let the user choose and update the text field */ + NSOpenPanel * panel = [NSOpenPanel openPanel]; + + [panel setAllowsMultipleSelection: NO]; + [panel setCanChooseFiles: NO]; + [panel setCanChooseDirectories: YES ]; + + [panel beginSheetForDirectory: nil file: nil types: nil + modalForWindow: fWindow modalDelegate: self + didEndSelector: @selector( BrowseDVDDone:returnCode:contextInfo: ) + contextInfo: nil]; +} + +- (void) BrowseDVDDone: (NSOpenPanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo +{ + if( returnCode == NSOKButton ) + { + [fDVDFolderField setStringValue: + [[sheet filenames] objectAtIndex: 0]]; + } +} + +- (IBAction) BrowseFile: (id) sender +{ + /* Open a panel to let the user choose and update the text field */ + NSSavePanel * panel = [NSSavePanel savePanel]; + + [panel beginSheetForDirectory: nil file: nil + modalForWindow: fWindow modalDelegate: self + didEndSelector: @selector( BrowseFileDone:returnCode:contextInfo: ) + contextInfo: nil]; +} + +- (void) BrowseFileDone: (NSSavePanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo +{ + if( returnCode == NSOKButton ) + { + [fFileField setStringValue: [sheet filename]]; + } +} + +- (IBAction) Scan: (id) sender +{ + /* Ask the manager to start scanning the specified volume */ + + if( ![fScanMatrix selectedRow] ) + { + /* DVD drive */ + fManager->ScanVolumes( (char*) [[fDVDPopUp titleOfSelectedItem] + cString] ); + } + else + { + /* DVD folder */ + fManager->ScanVolumes( (char*) [[fDVDFolderField stringValue] + cString] ); + } +} + +- (IBAction) ShowPicturePanel: (id) sender +{ + HBTitle * title = (HBTitle*) + fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + + [fPictureGLView SetManager: fManager]; + [fPictureGLView SetTitle: title]; + + fPicture = 0; + [fPictureGLView ShowPicture: fPicture]; + + [fWidthStepper setValueWraps: NO]; + [fWidthStepper setIncrement: 16]; + [fWidthStepper setMinValue: 16]; + [fWidthStepper setMaxValue: title->fOutWidthMax]; + [fWidthStepper setIntValue: title->fOutWidth]; + [fWidthField setIntValue: title->fOutWidth]; + [fTopStepper setValueWraps: NO]; + [fTopStepper setIncrement: 2]; + [fTopStepper setMinValue: 0]; + [fTopStepper setMaxValue: title->fInHeight / 4]; + [fTopStepper setIntValue: title->fTopCrop]; + [fTopField setIntValue: title->fTopCrop]; + [fBottomStepper setValueWraps: NO]; + [fBottomStepper setIncrement: 2]; + [fBottomStepper setMinValue: 0]; + [fBottomStepper setMaxValue: title->fInHeight / 4]; + [fBottomStepper setIntValue: title->fBottomCrop]; + [fBottomField setIntValue: title->fBottomCrop]; + [fLeftStepper setValueWraps: NO]; + [fLeftStepper setIncrement: 2]; + [fLeftStepper setMinValue: 0]; + [fLeftStepper setMaxValue: title->fInWidth / 4]; + [fLeftStepper setIntValue: title->fLeftCrop]; + [fLeftField setIntValue: title->fLeftCrop]; + [fRightStepper setValueWraps: NO]; + [fRightStepper setIncrement: 2]; + [fRightStepper setMinValue: 0]; + [fRightStepper setMaxValue: title->fInWidth / 4]; + [fRightStepper setIntValue: title->fRightCrop]; + [fRightField setIntValue: title->fRightCrop]; + + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "Final size: %dx%d", + title->fOutWidth, title->fOutHeight ); + [fInfoField setStringValue: [NSString stringWithCString: string]]; + + /* Resize the panel */ + NSSize newSize; + /* XXX */ + newSize.width = 762 /*fPicturePanelSize.width*/ + + title->fOutWidthMax - 720; + newSize.height = 754 /*fPicturePanelSize.height*/ + + title->fOutHeightMax - 576; + [fPicturePanel setContentSize: newSize]; + + [NSApp beginSheet: fPicturePanel + modalForWindow: fWindow + modalDelegate: nil + didEndSelector: nil + contextInfo: nil]; + [NSApp runModalForWindow: fPicturePanel]; + [NSApp endSheet: fPicturePanel]; + [fPicturePanel orderOut: self]; +} + +- (IBAction) ClosePanel: (id) sender +{ + [NSApp stopModal]; +} + +- (IBAction) Rip: (id) sender +{ + /* Rip or Cancel ? */ + if( [[fRipButton title] compare: @"Cancel" ] == NSOrderedSame ) + { + [self Cancel: self]; + return; + } + + /* Get the specified title & audio track(s) */ + HBTitle * title = (HBTitle*) + fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + HBAudio * audio = (HBAudio*) + title->fAudioList->ItemAt( [fAudioPopUp indexOfSelectedItem] ); + + /* Use user settings */ + title->fBitrate = [fVideoStepper intValue]; + audio->fOutBitrate = [fAudioStepper intValue]; + title->fTwoPass = ( [fTwoPassCheck state] == NSOnState ); + + /* Let libhb do the job */ + fManager->StartRip( title, audio, NULL, + (char*) [[fFileField stringValue] cString] ); +} + +- (IBAction) Cancel: (id) sender +{ + fManager->StopRip(); +} + +- (IBAction) Suspend: (id) sender +{ + if( [[fSuspendButton title] compare: @"Resume" ] == NSOrderedSame ) + { + [self Resume: self]; + return; + } + + fManager->SuspendRip(); +} + +- (IBAction) Resume: (id) sender +{ + fManager->ResumeRip(); +} + +- (IBAction) PreviousPicture: (id) sender +{ + if( fPicture > 0 ) + { + fPicture--; + [fPictureGLView ShowPicture: fPicture]; + } +} + +- (IBAction) NextPicture: (id) sender +{ + if( fPicture < 9 ) + { + fPicture++; + [fPictureGLView ShowPicture: fPicture]; + } +} + +- (IBAction) UpdatePicture: (id) sender +{ + HBTitle * title = (HBTitle*) + fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + title->fOutWidth = [fWidthStepper intValue]; + title->fDeinterlace = ( [fDeinterlaceCheck state] == NSOnState ); + title->fTopCrop = [fTopStepper intValue]; + title->fBottomCrop = [fBottomStepper intValue]; + title->fLeftCrop = [fLeftStepper intValue]; + title->fRightCrop = [fRightStepper intValue]; + + [fPictureGLView ShowPicture: fPicture]; + + [fWidthStepper setIntValue: title->fOutWidth]; + [fTopStepper setIntValue: title->fTopCrop]; + [fBottomStepper setIntValue: title->fBottomCrop]; + [fLeftStepper setIntValue: title->fLeftCrop]; + [fRightStepper setIntValue: title->fRightCrop]; + [fWidthField setIntValue: [fWidthStepper intValue]]; + [fTopField setIntValue: [fTopStepper intValue]]; + [fBottomField setIntValue: [fBottomStepper intValue]]; + [fLeftField setIntValue: [fLeftStepper intValue]]; + [fRightField setIntValue: [fRightStepper intValue]]; + + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "Final size: %dx%d", + title->fOutWidth, title->fOutHeight ); + [fInfoField setStringValue: [NSString stringWithCString: string]]; +} + +- (void) UpdateIntf: (NSTimer *) timer +{ + /* Ask libhb about what's happening now */ + if( fManager->NeedUpdate() ) + { + HBStatus status = fManager->GetStatus(); + + switch( status.fMode ) + { + case HB_MODE_NEED_VOLUME: + break; + + case HB_MODE_SCANNING: + { + [fScanMatrix setEnabled: NO]; + [fDVDPopUp setEnabled: NO]; + [fDVDFolderField setEnabled: NO]; + [fScanBrowseButton setEnabled: NO]; + [fScanProgress startAnimation: self]; + [fScanButton setEnabled: NO]; + + char string[1024]; memset( string, 0, 1024 ); + if( status.fScannedTitle ) + { + sprintf( string, "Scanning %s, title %d...", + status.fScannedVolume, + status.fScannedTitle ); + } + else + { + sprintf( string, "Opening %s...", + status.fScannedVolume ); + } + [fScanStatusField setStringValue: + [NSString stringWithCString: string]]; + + break; + } + + case HB_MODE_INVALID_VOLUME: + { + [fScanMatrix setEnabled: YES]; + [self ScanEnableIntf: self]; + [fScanProgress stopAnimation: self]; + [fScanButton setEnabled: YES]; + + [fScanStatusField setStringValue: + @"Invalid volume, try again" ]; + break; + } + + case HB_MODE_READY_TO_RIP: + { + fTitleList = status.fTitleList; + + /* Show a temporary empty view while the window + resizing animation */ + [fWindow setContentView: fBlankView ]; + + /* Actually resize it */ + NSRect newFrame; + newFrame = [NSWindow contentRectForFrameRect: [fWindow frame] + styleMask: [fWindow styleMask]]; + newFrame.origin.y += newFrame.size.height - + [fRipView frame].size.height; + newFrame.size.height = [fRipView frame].size.height; + newFrame.size.width = [fRipView frame].size.width; + newFrame = [NSWindow frameRectForContentRect: newFrame + styleMask: [fWindow styleMask]]; + [fWindow setFrame: newFrame display: YES animate: YES]; + + /* Show the new GUI */ + [fWindow setContentView: fRipView ]; + [fSuspendButton setEnabled: NO]; + + HBTitle * title; + for( uint32_t i = 0; i < fTitleList->CountItems(); i++ ) + { + title = (HBTitle*) fTitleList->ItemAt( i ); + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "%d (%02lld:%02lld:%02lld)", + title->fIndex, title->fLength / 3600, + ( title->fLength % 3600 ) / 60, + title->fLength % 60 ); + [[fTitlePopUp menu] addItemWithTitle: + [NSString stringWithCString: string] + action: @selector( UpdatePopUp: ) + keyEquivalent: @""]; + } + [self UpdatePopUp: self]; + + break; + } + + case HB_MODE_ENCODING: + { + [fTitlePopUp setEnabled: NO]; + [fAudioPopUp setEnabled: NO]; + [fVideoField setEnabled: NO]; + [fVideoStepper setEnabled: NO]; + [fAudioField setEnabled: NO]; + [fAudioStepper setEnabled: NO]; + [fTwoPassCheck setEnabled: NO]; + [fCropButton setEnabled: NO]; + [fFileField setEnabled: NO]; + [fRipBrowseButton setEnabled: NO]; + [fRipButton setTitle: @"Cancel"]; + [fSuspendButton setEnabled: YES]; + [fSuspendButton setTitle: @"Suspend"]; + + if( !status.fPosition ) + { + [fRipStatusField setStringValue: @"Starting..."]; + [fRipProgress setIndeterminate: YES]; + [fRipProgress startAnimation: self];; + } + else + { + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "Encoding: %.2f %%, %.2f fps " + "(%02d:%02d:%02d remaining)", + 100 * status.fPosition, status.fFrameRate, + status.fRemainingTime / 3600, + ( status.fRemainingTime % 3600 ) / 60, + status.fRemainingTime % 60 ); + [fRipStatusField setStringValue: + [NSString stringWithCString: string]]; + [fRipProgress setIndeterminate: NO]; + [fRipProgress setDoubleValue: 100 * status.fPosition]; + } + + break; + } + + case HB_MODE_SUSPENDED: + { + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "Encoding: %.2f %%, %.2f fps (PAUSED)", + 100 * status.fPosition, status.fFrameRate) ; + [fRipStatusField setStringValue: + [NSString stringWithCString: string]]; + + [fRipProgress setDoubleValue: 100 * status.fPosition]; + + [fSuspendButton setTitle: @"Resume"]; + break; + } + + case HB_MODE_DONE: + case HB_MODE_CANCELED: + case HB_MODE_ERROR: + [fTitlePopUp setEnabled: YES]; + [fAudioPopUp setEnabled: YES]; + [fVideoField setEnabled: YES]; + [fVideoStepper setEnabled: YES]; + [fAudioField setEnabled: YES]; + [fAudioStepper setEnabled: YES]; + [fTwoPassCheck setEnabled: YES]; + [fCropButton setEnabled: YES]; + [fFileField setEnabled: YES]; + [fRipBrowseButton setEnabled: YES]; + [fRipButton setEnabled: YES]; + [fRipButton setTitle: @"Rip"]; + [fSuspendButton setEnabled: NO]; + [fSuspendButton setTitle: @"Suspend"]; + + if( status.fMode == HB_MODE_DONE ) + { + [fRipStatusField setStringValue: @"Done." ]; + [fRipProgress setDoubleValue: 100]; + NSBeep(); + [NSApp requestUserAttention: NSInformationalRequest]; + [NSApp beginSheet: fDonePanel + modalForWindow: fWindow + modalDelegate: nil + didEndSelector: nil + contextInfo: nil]; + [NSApp runModalForWindow: fDonePanel]; + [NSApp endSheet: fDonePanel]; + [fDonePanel orderOut: self]; + } + else if( status.fMode == HB_MODE_CANCELED ) + { + [fRipStatusField setStringValue: @"Canceled." ]; + [fRipProgress setDoubleValue: 0]; + } + else + { + [fRipStatusField setStringValue: @"An error occured." ]; + [fRipProgress setDoubleValue: 0]; + } + + /* Warn the finder to update itself */ + [[NSWorkspace sharedWorkspace] noteFileSystemChanged: + [fFileField stringValue]]; + break; + + default: + break; + } + } + + /* Do it again 1/10 second later */ + [NSTimer scheduledTimerWithTimeInterval: 0.1 + target: self selector: @selector( UpdateIntf: ) + userInfo: nil repeats: FALSE]; +} + +- (void) DetectDrives +{ + /* Empty the current popup */ + [fDVDPopUp removeAllItems]; + + /* Scan DVD drives (stolen from VLC) */ + io_object_t next_media; + mach_port_t master_port; + kern_return_t kern_result; + io_iterator_t media_iterator; + CFMutableDictionaryRef classes_to_match; + + kern_result = IOMasterPort( MACH_PORT_NULL, &master_port ); + if( kern_result != KERN_SUCCESS ) + { + return; + } + + classes_to_match = IOServiceMatching( kIODVDMediaClass ); + if( classes_to_match == NULL ) + { + return; + } + + CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectable ), + kCFBooleanTrue ); + + kern_result = + IOServiceGetMatchingServices( master_port, classes_to_match, + &media_iterator ); + if( kern_result != KERN_SUCCESS ) + { + return; + } + + next_media = IOIteratorNext( media_iterator ); + if( next_media != NULL ) + { + char psz_buf[0x32]; + size_t dev_path_length; + CFTypeRef str_bsd_path; + do + { + str_bsd_path = + IORegistryEntryCreateCFProperty( next_media, + CFSTR( kIOBSDName ), + kCFAllocatorDefault, + 0 ); + if( str_bsd_path == NULL ) + { + IOObjectRelease( next_media ); + continue; + } + + snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' ); + dev_path_length = strlen( psz_buf ); + + if( CFStringGetCString( (CFStringRef) str_bsd_path, + (char*)&psz_buf + dev_path_length, + sizeof(psz_buf) - dev_path_length, + kCFStringEncodingASCII ) ) + { + [[fDVDPopUp menu] addItemWithTitle: + [NSString stringWithCString: psz_buf] + action: nil keyEquivalent: @""]; + } + + CFRelease( str_bsd_path ); + + IOObjectRelease( next_media ); + + } while( ( next_media = IOIteratorNext( media_iterator ) ) != NULL ); + } + + IOObjectRelease( media_iterator ); +} + +- (void) ScanEnableIntf: (id) sender +{ + if( ![fScanMatrix selectedRow] ) + { + [fDVDPopUp setEnabled: YES]; + [fDVDFolderField setEnabled: NO]; + [fScanBrowseButton setEnabled: NO]; + [fScanButton setEnabled: ( [fDVDPopUp selectedItem] != nil )]; + } + else + { + [fDVDPopUp setEnabled: NO]; + [fDVDFolderField setEnabled: YES]; + [fScanBrowseButton setEnabled: YES]; + [fScanButton setEnabled: YES]; + } +} + +- (void) UpdatePopUp: (id) sender +{ + HBTitle * title = (HBTitle*) + fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + + [fAudioPopUp removeAllItems]; + + HBAudio * audio; + for( uint32_t i = 0; i < title->fAudioList->CountItems(); i++ ) + { + audio = (HBAudio*) title->fAudioList->ItemAt( i ); + + /* We cannot use NSPopUpButton's addItemWithTitle because + it checks for duplicate entries */ + [[fAudioPopUp menu] addItemWithTitle: + [NSString stringWithCString: audio->fDescription] + action: nil keyEquivalent: @""]; + } +} + +@end diff --git a/macosx/HandBrake.icns b/macosx/HandBrake.icns Binary files differnew file mode 100644 index 000000000..f1d08d36f --- /dev/null +++ b/macosx/HandBrake.icns diff --git a/macosx/HandBrake.pbproj/project.pbxproj b/macosx/HandBrake.pbproj/project.pbxproj new file mode 100644 index 000000000..b4ea5fef5 --- /dev/null +++ b/macosx/HandBrake.pbproj/project.pbxproj @@ -0,0 +1,577 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 38; + objects = { + 080E96DCFE201CFB7F000001 = { + fileRef = 29B97318FDCFA39411CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 080E96DDFE201D6D7F000001 = { + children = ( + 4DF3C8CB052889CD00A80101, + 4DF3C8CC052889CD00A80101, + 4D85758E052B78E300C39CA9, + 4D85758F052B78E300C39CA9, + ); + isa = PBXGroup; + name = Classes; + refType = 4; + }; + 089C165CFE840E0CC02AAC07 = { + children = ( + 089C165DFE840E0CC02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + }; + 089C165DFE840E0CC02AAC07 = { + fileEncoding = 10; + isa = PBXFileReference; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + }; + 089C165EFE840E0CC02AAC07 = { + fileRef = 089C165CFE840E0CC02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; +//080 +//081 +//082 +//083 +//084 +//100 +//101 +//102 +//103 +//104 + 1058C7A0FEA54F0111CA2CBB = { + children = ( + 1058C7A1FEA54F0111CA2CBB, + 4DEB2024052B055F00C39CA9, + 4DDE9724052B7B2B00C39CA9, + ); + isa = PBXGroup; + name = "Linked Frameworks"; + refType = 4; + }; + 1058C7A1FEA54F0111CA2CBB = { + isa = PBXFrameworkReference; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + }; + 1058C7A2FEA54F0111CA2CBB = { + children = ( + 29B97325FDCFA39411CA2CEA, + 29B97324FDCFA39411CA2CEA, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + }; + 1058C7A3FEA54F0111CA2CBB = { + fileRef = 1058C7A1FEA54F0111CA2CBB; + isa = PBXBuildFile; + settings = { + }; + }; +//100 +//101 +//102 +//103 +//104 +//170 +//171 +//172 +//173 +//174 + 17587328FF379C6511CA2CBB = { + isa = PBXApplicationReference; + path = HandBrake.app; + refType = 3; + }; +//170 +//171 +//172 +//173 +//174 +//190 +//191 +//192 +//193 +//194 + 19C28FACFE9D520D11CA2CBB = { + children = ( + 17587328FF379C6511CA2CBB, + ); + isa = PBXGroup; + name = Products; + refType = 4; + }; +//190 +//191 +//192 +//193 +//194 +//290 +//291 +//292 +//293 +//294 + 29B97313FDCFA39411CA2CEA = { + buildStyles = ( + 4A9504CCFFE6A4B311CA0CBA, + 4A9504CDFFE6A4B311CA0CBA, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 29B97314FDCFA39411CA2CEA; + projectDirPath = ""; + targets = ( + 29B97326FDCFA39411CA2CEA, + ); + }; + 29B97314FDCFA39411CA2CEA = { + children = ( + 080E96DDFE201D6D7F000001, + 29B97315FDCFA39411CA2CEA, + 29B97317FDCFA39411CA2CEA, + 29B97323FDCFA39411CA2CEA, + 19C28FACFE9D520D11CA2CBB, + ); + isa = PBXGroup; + name = HandBrake; + path = ""; + refType = 4; + }; + 29B97315FDCFA39411CA2CEA = { + children = ( + 29B97316FDCFA39411CA2CEA, + 4D929FEB0527903D00A80101, + ); + isa = PBXGroup; + name = "Other Sources"; + path = ""; + refType = 4; + }; + 29B97316FDCFA39411CA2CEA = { + fileEncoding = 30; + isa = PBXFileReference; + path = main.mm; + refType = 4; + }; + 29B97317FDCFA39411CA2CEA = { + children = ( + 29B97318FDCFA39411CA2CEA, + 4D929FED0527907200A80101, + 4D69F5C80527944A00A80101, + 4D69F5C90527944A00A80101, + 4D69F5CA0527944A00A80101, + 4D69F5CB0527944A00A80101, + 4D69F5CC0527944A00A80101, + 4D69F5CD0527944A00A80101, + 4D69F5CE0527944A00A80101, + 4D118405053054CD00C39CA9, + 089C165CFE840E0CC02AAC07, + ); + isa = PBXGroup; + name = Resources; + path = ""; + refType = 4; + }; + 29B97318FDCFA39411CA2CEA = { + children = ( + 29B97319FDCFA39411CA2CEA, + ); + isa = PBXVariantGroup; + name = MainMenu.nib; + path = ""; + refType = 4; + }; + 29B97319FDCFA39411CA2CEA = { + isa = PBXFileReference; + name = English; + path = English.lproj/MainMenu.nib; + refType = 4; + }; + 29B97323FDCFA39411CA2CEA = { + children = ( + 1058C7A0FEA54F0111CA2CBB, + 1058C7A2FEA54F0111CA2CBB, + ); + isa = PBXGroup; + name = Frameworks; + path = ""; + refType = 4; + }; + 29B97324FDCFA39411CA2CEA = { + isa = PBXFrameworkReference; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + }; + 29B97325FDCFA39411CA2CEA = { + isa = PBXFrameworkReference; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + }; + 29B97326FDCFA39411CA2CEA = { + buildPhases = ( + 29B97327FDCFA39411CA2CEA, + 29B97328FDCFA39411CA2CEA, + 29B9732BFDCFA39411CA2CEA, + 29B9732DFDCFA39411CA2CEA, + ); + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ""; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + HEADER_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = ../core; + OPTIMIZATION_CFLAGS = "-O3"; + OTHER_CFLAGS = "-DSYS_MACOSX"; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = HandBrake; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = app; + }; + dependencies = ( + ); + isa = PBXApplicationTarget; + name = HandBrake; + productName = HandBrake; + productReference = 17587328FF379C6511CA2CBB; + productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>HandBrake</string> + <key>CFBundleGetInfoString</key> + <string>HandBrake 0.3 - By Eric Petit <[email protected]></string> + <key>CFBundleIconFile</key> + <string>HandBrake.icns</string> + <key>CFBundleIdentifier</key> + <string>org.m0k.handbrake</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>HandBrake</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>0.3</string> + <key>CFBundleSignature</key> + <string>HB##</string> + <key>CFBundleVersion</key> + <string>0.3</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> +"; + }; + 29B97327FDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 4D929FEC0527903D00A80101, + 4D6615EA05288C2300A80101, + 4D857591052B78E300C39CA9, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 29B97328FDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 080E96DCFE201CFB7F000001, + 089C165EFE840E0CC02AAC07, + 4D118406053054CD00C39CA9, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 29B9732BFDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 29B9732CFDCFA39411CA2CEA, + 4DF3C8CE052889CD00A80101, + 4D857590052B78E300C39CA9, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 29B9732CFDCFA39411CA2CEA = { + fileRef = 29B97316FDCFA39411CA2CEA; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 29B9732DFDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 1058C7A3FEA54F0111CA2CBB, + 4D929FEE0527907200A80101, + 4D69F5CF0527944A00A80101, + 4D69F5D00527944A00A80101, + 4D69F5D10527944A00A80101, + 4D69F5D20527944A00A80101, + 4D69F5D30527944A00A80101, + 4D69F5D40527944A00A80101, + 4D69F5D50527944A00A80101, + 4DEB2025052B055F00C39CA9, + 4DDE9725052B7B2B00C39CA9, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; +//290 +//291 +//292 +//293 +//294 +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 + 4A9504CCFFE6A4B311CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + OPTIMIZATION_CFLAGS = "-O0"; + }; + isa = PBXBuildStyle; + name = Development; + }; + 4A9504CDFFE6A4B311CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = YES; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 +//4D0 +//4D1 +//4D2 +//4D3 +//4D4 + 4D118405053054CD00C39CA9 = { + isa = PBXFileReference; + path = HandBrake.icns; + refType = 4; + }; + 4D118406053054CD00C39CA9 = { + fileRef = 4D118405053054CD00C39CA9; + isa = PBXBuildFile; + settings = { + }; + }; + 4D6615EA05288C2300A80101 = { + fileRef = 4DF3C8CB052889CD00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5C80527944A00A80101 = { + isa = PBXFileReference; + name = liba52.a; + path = /usr/local/lib/liba52.a; + refType = 0; + }; + 4D69F5C90527944A00A80101 = { + isa = PBXFileReference; + name = libavcodec.a; + path = /usr/local/lib/libavcodec.a; + refType = 0; + }; + 4D69F5CA0527944A00A80101 = { + isa = PBXFileReference; + name = libdvdcss.a; + path = /usr/local/lib/libdvdcss.a; + refType = 0; + }; + 4D69F5CB0527944A00A80101 = { + isa = PBXFileReference; + name = libdvdplay.a; + path = /usr/local/lib/libdvdplay.a; + refType = 0; + }; + 4D69F5CC0527944A00A80101 = { + isa = PBXFileReference; + name = libdvdread.a; + path = /usr/local/lib/libdvdread.a; + refType = 0; + }; + 4D69F5CD0527944A00A80101 = { + isa = PBXFileReference; + name = libmp3lame.a; + path = /usr/local/lib/libmp3lame.a; + refType = 0; + }; + 4D69F5CE0527944A00A80101 = { + isa = PBXFileReference; + name = libmpeg2.a; + path = /usr/local/lib/libmpeg2.a; + refType = 0; + }; + 4D69F5CF0527944A00A80101 = { + fileRef = 4D69F5C80527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5D00527944A00A80101 = { + fileRef = 4D69F5C90527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5D10527944A00A80101 = { + fileRef = 4D69F5CA0527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5D20527944A00A80101 = { + fileRef = 4D69F5CB0527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5D30527944A00A80101 = { + fileRef = 4D69F5CC0527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5D40527944A00A80101 = { + fileRef = 4D69F5CD0527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D69F5D50527944A00A80101 = { + fileRef = 4D69F5CE0527944A00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D85758E052B78E300C39CA9 = { + fileEncoding = 30; + isa = PBXFileReference; + path = PictureGLView.mm; + refType = 4; + }; + 4D85758F052B78E300C39CA9 = { + fileEncoding = 30; + isa = PBXFileReference; + path = PictureGLView.h; + refType = 4; + }; + 4D857590052B78E300C39CA9 = { + fileRef = 4D85758E052B78E300C39CA9; + isa = PBXBuildFile; + settings = { + }; + }; + 4D857591052B78E300C39CA9 = { + fileRef = 4D85758F052B78E300C39CA9; + isa = PBXBuildFile; + settings = { + }; + }; + 4D929FEB0527903D00A80101 = { + fileEncoding = 30; + isa = PBXFileReference; + name = Manager.h; + path = ../core/Manager.h; + refType = 4; + }; + 4D929FEC0527903D00A80101 = { + fileRef = 4D929FEB0527903D00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4D929FED0527907200A80101 = { + isa = PBXFileReference; + name = libhb.a; + path = ../core/libhb.a; + refType = 4; + }; + 4D929FEE0527907200A80101 = { + fileRef = 4D929FED0527907200A80101; + isa = PBXBuildFile; + settings = { + }; + }; + 4DDE9724052B7B2B00C39CA9 = { + isa = PBXFrameworkReference; + name = OpenGL.framework; + path = /System/Library/Frameworks/OpenGL.framework; + refType = 0; + }; + 4DDE9725052B7B2B00C39CA9 = { + fileRef = 4DDE9724052B7B2B00C39CA9; + isa = PBXBuildFile; + settings = { + }; + }; + 4DEB2024052B055F00C39CA9 = { + isa = PBXFrameworkReference; + name = IOKit.framework; + path = /System/Library/Frameworks/IOKit.framework; + refType = 0; + }; + 4DEB2025052B055F00C39CA9 = { + fileRef = 4DEB2024052B055F00C39CA9; + isa = PBXBuildFile; + settings = { + }; + }; + 4DF3C8CB052889CD00A80101 = { + fileEncoding = 30; + isa = PBXFileReference; + path = HBController.h; + refType = 4; + }; + 4DF3C8CC052889CD00A80101 = { + fileEncoding = 30; + isa = PBXFileReference; + path = HBController.mm; + refType = 4; + }; + 4DF3C8CE052889CD00A80101 = { + fileRef = 4DF3C8CC052889CD00A80101; + isa = PBXBuildFile; + settings = { + }; + }; + }; + rootObject = 29B97313FDCFA39411CA2CEA; +} diff --git a/macosx/PictureGLView.h b/macosx/PictureGLView.h new file mode 100644 index 000000000..effbf3ee2 --- /dev/null +++ b/macosx/PictureGLView.h @@ -0,0 +1,20 @@ +/* PictureGLView */ + +#include <Cocoa/Cocoa.h> + +#include "Manager.h" + +@interface PictureGLView : NSOpenGLView + +{ + HBManager * fManager; + HBTitle * fTitle; + + uint8_t * fPicture; +} + +- (void) SetManager: (HBManager*) manager; +- (void) SetTitle: (HBTitle*) title; +- (void) ShowPicture: (int) picture; + +@end diff --git a/macosx/PictureGLView.mm b/macosx/PictureGLView.mm new file mode 100644 index 000000000..72e564141 --- /dev/null +++ b/macosx/PictureGLView.mm @@ -0,0 +1,114 @@ +#include <OpenGL/gl.h> + +#include "PictureGLView.h" + +@implementation PictureGLView + +- (void) SetManager: (HBManager*) manager +{ + fManager = manager; +} + +- (void) SetTitle: (HBTitle*) title +{ + fTitle = title; + + /* This is needed as the view's size may have changed */ + [self clearGLContext]; + [self openGLContext]; +} + +- (void) ShowPicture: (int) index +{ + /* Get the picture */ + uint8_t * tmp = fManager->GetPreview( fTitle, index ); + + /* Make it be upside-down */ + if( fPicture ) free( fPicture ); + fPicture = (uint8_t*) malloc( 4 * ( fTitle->fOutWidthMax + 2 ) * + ( fTitle->fOutHeightMax + 2 ) ); + for( uint32_t i = 0; i < fTitle->fOutHeightMax + 2; i++ ) + { + memcpy( fPicture + 4 * ( fTitle->fOutWidthMax + 2 ) * i, + tmp + 4 * ( fTitle->fOutWidthMax + 2 ) * + ( fTitle->fOutHeightMax + 1 - i ), + 4 * ( fTitle->fOutWidthMax + 2 ) ); + } + free( tmp ); + + /* Grrr - should find a way to give ARGB to OpenGL */ + uint8_t r, g, b, a; + for( uint32_t i = 0; i < fTitle->fOutHeightMax + 2; i++ ) + { + for( uint32_t j = 0; j < fTitle->fOutWidthMax + 2; j++ ) + { + a = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)]; + r = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+1]; + g = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+2]; + b = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+3]; + + fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)] = r; + fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+1] = g; + fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+2] = b; + fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+3] = a; + } + } + + [self setNeedsDisplay: YES]; +} + +/* Override NSView's initWithFrame: to specify our pixel format */ +- (id) initWithFrame: (NSRect) frame +{ + fManager = NULL; + fTitle = NULL; + fPicture = NULL; + + GLuint attribs[] = + { + NSOpenGLPFANoRecovery, + NSOpenGLPFAWindow, + NSOpenGLPFAAccelerated, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAColorSize, 24, + NSOpenGLPFAAlphaSize, 8, + NSOpenGLPFADepthSize, 24, + NSOpenGLPFAStencilSize, 8, + NSOpenGLPFAAccumSize, 0, + 0 + }; + + NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc] + initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs]; + + if( !fmt ) + { + fprintf( stderr, "Sarass\n" ); + } + + return self = [super initWithFrame:frame pixelFormat: + [fmt autorelease]]; +} + +/* Override the view's drawRect: to draw our GL content */ +- (void) drawRect: (NSRect) rect +{ + glViewport( 0, 0, (GLsizei) rect.size.width, + (GLsizei) rect.size.height ); + + /* Black background */ + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + /* Show it */ + if( fPicture ) + { + glDrawPixels( fTitle->fOutWidthMax + 2, + fTitle->fOutHeightMax + 2, GL_RGBA, + GL_UNSIGNED_BYTE, fPicture ); + } + + [[self openGLContext] flushBuffer]; +} + +@end diff --git a/macosx/main.mm b/macosx/main.mm new file mode 100644 index 000000000..56aa102fa --- /dev/null +++ b/macosx/main.mm @@ -0,0 +1,12 @@ +/* $Id: main.mm,v 1.5 2003/09/30 14:38:15 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://beos.titer.org/handbrake/>. + It may be used under the terms of the GNU General Public License. */ + +#import <Cocoa/Cocoa.h> + +int main( int argc, const char ** argv ) +{ + return NSApplicationMain( argc, argv ); +} |