MunkiStatus changes:

- changed scaling behavior of backdrop window to better handle displays with different aspect ratios
- main status window now auto-centers on app launch.

git-svn-id: http://munki.googlecode.com/svn/trunk@98 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2009-05-28 17:58:17 +00:00
parent 357694b4cd
commit 861172f5d1
5 changed files with 124 additions and 1 deletions
+11 -1
View File
@@ -8,8 +8,8 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="452"/>
<integer value="431"/>
<integer value="453"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -708,6 +708,7 @@
<string>452.IBWindowTemplateEditedContentRect</string>
<string>452.NSWindowTemplate.visibleAtLaunch</string>
<string>453.IBPluginDependency</string>
<string>454.CustomClassName</string>
<string>454.IBAttributePlaceholdersKey</string>
<string>454.IBPluginDependency</string>
<string>455.IBAttributePlaceholdersKey</string>
@@ -881,6 +882,7 @@
<string>{{33, 287}, {640, 480}}</string>
<reference ref="6"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ScaledImageView</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">IBAppleScriptAttributeName</string>
<object class="IBAppleScriptInfoAttribute" key="NS.object.0">
@@ -962,6 +964,14 @@
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">ScaledImageView</string>
<string key="superclassName">NSImageView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">ScaledImageView.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
+1
View File
@@ -69,6 +69,7 @@ on awake from nib theObject
if cfuser is "" then
call method "setLevel:" of theObject with parameter (kCGScreenSaverWindowLevel - 1)
end if
call method "center" of theObject
set visible of theObject to true
activate
end if
@@ -32,6 +32,8 @@
C00B239E0FC096670016293D /* MunkiStatus.icns in Resources */ = {isa = PBXBuildFile; fileRef = C00B239D0FC096670016293D /* MunkiStatus.icns */; };
C01D090F0FBF7216001ED249 /* BorderlessWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = C01D090D0FBF7216001ED249 /* BorderlessWindow.h */; };
C01D09100FBF7216001ED249 /* BorderlessWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = C01D090E0FBF7216001ED249 /* BorderlessWindow.m */; };
C08625730FCF033C00964AE4 /* ScaledImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = C08625710FCF033C00964AE4 /* ScaledImageView.m */; };
C08625740FCF033C00964AE4 /* ScaledImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = C08625720FCF033C00964AE4 /* ScaledImageView.h */; };
C0C84CCF0F98FF7800B6518D /* Installer.tiff in Resources */ = {isa = PBXBuildFile; fileRef = C0C84CCE0F98FF7800B6518D /* Installer.tiff */; };
C0C84CD10F98FF8400B6518D /* package.tiff in Resources */ = {isa = PBXBuildFile; fileRef = C0C84CD00F98FF8400B6518D /* package.tiff */; };
/* End PBXBuildFile section */
@@ -52,6 +54,8 @@
C00B239D0FC096670016293D /* MunkiStatus.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = MunkiStatus.icns; sourceTree = "<group>"; };
C01D090D0FBF7216001ED249 /* BorderlessWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BorderlessWindow.h; sourceTree = "<group>"; };
C01D090E0FBF7216001ED249 /* BorderlessWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BorderlessWindow.m; sourceTree = "<group>"; };
C08625710FCF033C00964AE4 /* ScaledImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScaledImageView.m; sourceTree = "<group>"; };
C08625720FCF033C00964AE4 /* ScaledImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScaledImageView.h; sourceTree = "<group>"; };
C0C84CCE0F98FF7800B6518D /* Installer.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Installer.tiff; sourceTree = "<group>"; };
C0C84CD00F98FF8400B6518D /* package.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = package.tiff; sourceTree = "<group>"; };
DA206CF1015C4E2903C91932 /* AppleScriptKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppleScriptKit.framework; path = /System/Library/Frameworks/AppleScriptKit.framework; sourceTree = "<absolute>"; };
@@ -123,6 +127,8 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
C08625710FCF033C00964AE4 /* ScaledImageView.m */,
C08625720FCF033C00964AE4 /* ScaledImageView.h */,
C01D090D0FBF7216001ED249 /* BorderlessWindow.h */,
C01D090E0FBF7216001ED249 /* BorderlessWindow.m */,
29B97316FDCFA39411CA2CEA /* main.m */,
@@ -163,6 +169,7 @@
files = (
C001935C0FA117A800AC90B0 /* SystemConfigurationInterface.h in Headers */,
C01D090F0FBF7216001ED249 /* BorderlessWindow.h in Headers */,
C08625740FCF033C00964AE4 /* ScaledImageView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -229,6 +236,7 @@
257572CA072881A4000BE9CA /* main.m in Sources */,
C001935E0FA118A400AC90B0 /* SystemConfigurationInterface.m in Sources */,
C01D09100FBF7216001ED249 /* BorderlessWindow.m in Sources */,
C08625730FCF033C00964AE4 /* ScaledImageView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+28
View File
@@ -0,0 +1,28 @@
//
// MyNSView.h
// CustomNSViewTest
//
// Created by Greg Neagle on 5/27/09.
//
// Copyright 2009 Greg Neagle.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Cocoa/Cocoa.h>
@interface ScaledImageView : NSImageView
@end
+76
View File
@@ -0,0 +1,76 @@
//
// ScaledImageView.m
//
// Created by Greg Neagle on 5/27/09.
//
// Copyright 2009 Greg Neagle.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "ScaledImageView.h"
@implementation ScaledImageView
-(void)drawRect:(NSRect *)rect {
NSRect dstRect = [self bounds];
float sourceWidth = [[self image] size].width;
float sourceHeight = [[self image] size].height;
float targetWidth = dstRect.size.width;
float targetHeight = dstRect.size.height;
// Calculate aspect ratios
float sourceRatio = sourceWidth / sourceHeight;
float targetRatio = targetWidth / targetHeight;
// Determine what side of the source image to use for proportional scaling
BOOL scaleWidth = (sourceRatio <= targetRatio);
// Proportionally scale source image
float scalingFactor, scaledWidth, scaledHeight;
if (scaleWidth) {
scalingFactor = 1.0 / sourceRatio;
scaledWidth = targetWidth;
scaledHeight = round(targetWidth * scalingFactor);
} else {
scalingFactor = sourceRatio;
scaledWidth = round(targetHeight * scalingFactor);
scaledHeight = targetHeight;
}
float scaleFactor = scaledHeight / sourceHeight;
// Calculate compositing rectangles
NSRect sourceRect;
float destX, destY;
// Crop from center
destX = round((scaledWidth - targetWidth) / 2.0);
destY = round((scaledHeight - targetHeight) / 2.0);
sourceRect = NSMakeRect(destX / scaleFactor, destY / scaleFactor,
targetWidth / scaleFactor, targetHeight / scaleFactor);
[[self image] drawInRect:dstRect
fromRect:sourceRect
operation:NSCompositeSourceOver
fraction:1.0];
}
@end