]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix the preview window position between restart
authorDamiano Galassi <damiog@gmail.com>
Fri, 9 Oct 2015 18:20:50 +0000 (20:20 +0200)
committerDamiano Galassi <damiog@gmail.com>
Fri, 9 Oct 2015 18:20:50 +0000 (20:20 +0200)
macosx/English.lproj/PicturePreview.xib
macosx/HBPreviewController.m

index afb3b3dcb8fb54afd8cfd1dda5617df47420cb5a..77013fe9fa8873b5e256be6d769d24207b1ab2d9 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9052" systemVersion="15B22c" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9052" systemVersion="15B30a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
         <deployment identifier="macosx"/>
         <development version="6300" identifier="xcode"/>
@@ -29,7 +29,7 @@
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <window title="Preview" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="Preview" animationBehavior="default" id="5" userLabel="PreviewPanel">
+        <window title="Preview" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="5" userLabel="PreviewPanel">
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
             <rect key="contentRect" x="221" y="837" width="500" height="360"/>
             <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
index e3ebde36810f030f79c70af012e58be047c4407a..df6dff6a2c9ea1dc5a9b076506c2e708c618eea9 100644 (file)
@@ -81,7 +81,24 @@ typedef enum ViewMode : NSUInteger {
 {
     [self.window.contentView setWantsLayer:YES];
 
-    self.windowCenterPoint = [self centerPoint];
+    // Read the window center position
+    // We need the center and we can't use the
+    // standard NSWindow autosave because we change
+    // the window size at startup.
+    NSString *centerString = [[NSUserDefaults standardUserDefaults] objectForKey:@"HBPreviewWindowCenter"];
+    if (centerString.length)
+    {
+        NSPoint center = NSPointFromString(centerString);
+        NSRect frame = self.window.frame;
+        [self.window setFrameOrigin:NSMakePoint(center.x - floor(frame.size.width / 2),
+                                                center.y - floor(frame.size.height / 2))];
+
+        self.windowCenterPoint = center;
+    }
+    else
+    {
+        self.windowCenterPoint = [self centerPoint];
+    }
 
     self.window.excludedFromWindowsMenu = YES;
     self.window.acceptsMouseMovedEvents = YES;
@@ -231,6 +248,7 @@ typedef enum ViewMode : NSUInteger {
     if (self.previewView.fitToView == NO)
     {
         self.windowCenterPoint = [self centerPoint];
+        [[NSUserDefaults standardUserDefaults] setObject:NSStringFromPoint(self.windowCenterPoint) forKey:@"HBPreviewWindowCenter"];
     }
 }