Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
fix the display bug on retina macs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tae Won Ha committed Oct 26, 2014
1 parent d4c6d6a commit 4a22e33
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 21 deletions.
6 changes: 6 additions & 0 deletions LookThrough.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
1929B1C3CD5B2C8C7630BCD0 /* LTScreenCaptureHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 1929B655E7915B2E05A1DB81 /* LTScreenCaptureHelper.m */; };
1929B26AA0AB30B3BB915718 /* ProxyView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1929BEEDE9F4171345433CC2 /* ProxyView.m */; };
1929B572D0345EDE9B9385CA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1929BC56908A4AF94B1E7CA0 /* CoreGraphics.framework */; };
1929BBAD38402196EC88F913 /* LTScreenCaptureHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1929BAAC3C756846D7E9AC58 /* LTScreenCaptureHelper.h */; };
4B12D07219289BC600523BAF /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3EB47F16E7B5EF00374A8D /* Cocoa.framework */; };
Expand All @@ -29,6 +30,8 @@
1929B655E7915B2E05A1DB81 /* LTScreenCaptureHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTScreenCaptureHelper.m; sourceTree = "<group>"; };
1929BAAC3C756846D7E9AC58 /* LTScreenCaptureHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LTScreenCaptureHelper.h; sourceTree = "<group>"; };
1929BC56908A4AF94B1E7CA0 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
1929BEEDE9F4171345433CC2 /* ProxyView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProxyView.m; sourceTree = "<group>"; };
1929BF3B2124143010D7CCC8 /* ProxyView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyView.h; sourceTree = "<group>"; };
4B12D07119289BC600523BAF /* LookThroughProxy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LookThroughProxy.app; sourceTree = BUILT_PRODUCTS_DIR; };
4B12D07519289BC600523BAF /* LookThroughProxy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "LookThroughProxy-Info.plist"; sourceTree = "<group>"; };
4B12D07719289BC600523BAF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -84,6 +87,8 @@
4B12D08219289BC600523BAF /* MainMenu.xib */,
4B12D08519289BC600523BAF /* Images.xcassets */,
4B12D07419289BC600523BAF /* Supporting Files */,
1929BEEDE9F4171345433CC2 /* ProxyView.m */,
1929BF3B2124143010D7CCC8 /* ProxyView.h */,
);
path = LookThroughProxy;
sourceTree = "<group>";
Expand Down Expand Up @@ -281,6 +286,7 @@
4B12D09F19289C0300523BAF /* LTScreenCaptureHelper.m in Sources */,
4B12D08119289BC600523BAF /* AppDelegate.m in Sources */,
4B12D07A19289BC600523BAF /* main.m in Sources */,
1929B26AA0AB30B3BB915718 /* ProxyView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion LookThrough/LTScreenSaverView.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (void)drawRect:(NSRect)dirtyRect {
NSImage *image = [LTScreenCaptureHelper defaultHelper].screenAsImage;
NSRect screenRect = self.window.screen.frame;

[image drawAtPoint:dirtyRect.origin fromRect:screenRect operation:NSCompositeSourceOver fraction:1];
[image drawInRect:screenRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
}

- (void)animateOneFrame {
Expand Down
3 changes: 0 additions & 3 deletions LookThroughProxy/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@
@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSImageView *imageView;

- (IBAction)updateScreenshot:(id)sender;

@end
9 changes: 1 addition & 8 deletions LookThroughProxy/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
#import "LTScreenCaptureHelper.h"


@implementation AppDelegate {
LTScreenCaptureHelper *_helper;
}

- (IBAction)updateScreenshot:(id)sender {
NSImage *image = [LTScreenCaptureHelper defaultHelper].screenAsImage;
_imageView.image = image;
}
@implementation AppDelegate

@end
23 changes: 14 additions & 9 deletions LookThroughProxy/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -10,10 +11,9 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="imageView" destination="UNO-8P-li9" id="4u9-1A-o6x"/>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
Expand Down Expand Up @@ -353,7 +353,7 @@
<items>
<menuItem title="Update Screenshot" keyEquivalent="1" id="snW-S8-Cw5">
<connections>
<action selector="updateScreenshot:" target="Voe-Tx-rLC" id="wDS-xv-qXp"/>
<action selector="updateScreenshot:" target="OoA-hC-9Iz" id="62R-iq-SsO"/>
</connections>
</menuItem>
</items>
Expand Down Expand Up @@ -407,13 +407,18 @@
<rect key="frame" x="0.0" y="0.0" width="697" height="480"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView id="UNO-8P-li9">
<customView translatesAutoresizingMaskIntoConstraints="NO" id="OoA-hC-9Iz" customClass="ProxyView">
<rect key="frame" x="0.0" y="0.0" width="697" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="w0f-4h-7Sy"/>
</imageView>
</customView>
</subviews>
<constraints>
<constraint firstItem="OoA-hC-9Iz" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="KaX-pi-I4S"/>
<constraint firstAttribute="trailing" secondItem="OoA-hC-9Iz" secondAttribute="trailing" id="Z5m-yf-EIr"/>
<constraint firstAttribute="bottom" secondItem="OoA-hC-9Iz" secondAttribute="bottom" id="Z9I-cR-Sci"/>
<constraint firstItem="OoA-hC-9Iz" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="lfI-Ce-WAI"/>
</constraints>
</view>
<point key="canvasLocation" x="210.5" y="288"/>
</window>
</objects>
</document>
18 changes: 18 additions & 0 deletions LookThroughProxy/ProxyView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Tae Won Ha — @hataewon
*
* http://taewon.de
* http://qvacua.com
*
* See LICENSE
*/

#import <Cocoa/Cocoa.h>


@interface ProxyView : NSView

- (IBAction)updateScreenshot:(id)sender;
- (void)drawRect:(NSRect)dirtyRect;

@end
34 changes: 34 additions & 0 deletions LookThroughProxy/ProxyView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Tae Won Ha — @hataewon
*
* http://taewon.de
* http://qvacua.com
*
* See LICENSE
*/

#import "ProxyView.h"
#import "LTScreenCaptureHelper.h"


@implementation ProxyView {
LTScreenCaptureHelper *_helper;
NSImage *_image;
}

- (IBAction)updateScreenshot:(id)sender {
_image = [LTScreenCaptureHelper defaultHelper].screenAsImage;

self.needsDisplay = YES;

#ifdef DEBUG
[_image.TIFFRepresentation writeToFile:@"/tmp/shot.tiff" atomically:NO];
#endif
}

- (void)drawRect:(NSRect)dirtyRect {
// [_image drawAtPoint:dirtyRect.origin fromRect:screenRect operation:NSCompositeSourceOver fraction:1];
[_image drawInRect:self.frame fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
}

@end

0 comments on commit 4a22e33

Please sign in to comment.