Skip to content

Commit

Permalink
Invert effect when capture
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliaksandr Andrashuk committed Mar 19, 2013
1 parent 2a990bd commit f229bc7
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 73 deletions.
12 changes: 12 additions & 0 deletions Screentool.xcodeproj/project.pbxproj
Expand Up @@ -15,6 +15,9 @@
225E185916F4E79B008ECE8F /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 225E185716F4E79B008ECE8F /* MainMenu.xib */; };
225E186016F4EA89008ECE8F /* icon-gradient.png in Resources */ = {isa = PBXBuildFile; fileRef = 225E185F16F4EA89008ECE8F /* icon-gradient.png */; };
225E186216F4EB2A008ECE8F /* icon-gradient@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 225E186116F4EB2A008ECE8F /* icon-gradient@2x.png */; };
226EBD5F16F8F5C700AFA41A /* icon-wrench.png in Resources */ = {isa = PBXBuildFile; fileRef = 226EBD5E16F8F5C700AFA41A /* icon-wrench.png */; };
226EBD6116F8F5F400AFA41A /* icon-wrench@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 226EBD6016F8F5F400AFA41A /* icon-wrench@2x.png */; };
226EBD6316F8F80400AFA41A /* 19.03.2013,_21:54:53.png in Resources */ = {isa = PBXBuildFile; fileRef = 226EBD6216F8F80400AFA41A /* 19.03.2013,_21:54:53.png */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -33,6 +36,9 @@
225E185816F4E79B008ECE8F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
225E185F16F4EA89008ECE8F /* icon-gradient.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-gradient.png"; sourceTree = "<group>"; };
225E186116F4EB2A008ECE8F /* icon-gradient@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-gradient@2x.png"; sourceTree = "<group>"; };
226EBD5E16F8F5C700AFA41A /* icon-wrench.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-wrench.png"; sourceTree = "<group>"; };
226EBD6016F8F5F400AFA41A /* icon-wrench@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-wrench@2x.png"; sourceTree = "<group>"; };
226EBD6216F8F80400AFA41A /* 19.03.2013,_21:54:53.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "19.03.2013,_21:54:53.png"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -97,6 +103,9 @@
225E184916F4E79A008ECE8F /* Supporting Files */ = {
isa = PBXGroup;
children = (
226EBD6216F8F80400AFA41A /* 19.03.2013,_21:54:53.png */,
226EBD6016F8F5F400AFA41A /* icon-wrench@2x.png */,
226EBD5E16F8F5C700AFA41A /* icon-wrench.png */,
225E185F16F4EA89008ECE8F /* icon-gradient.png */,
225E186116F4EB2A008ECE8F /* icon-gradient@2x.png */,
225E184A16F4E79A008ECE8F /* Screentool-Info.plist */,
Expand Down Expand Up @@ -164,6 +173,9 @@
225E185916F4E79B008ECE8F /* MainMenu.xib in Resources */,
225E186016F4EA89008ECE8F /* icon-gradient.png in Resources */,
225E186216F4EB2A008ECE8F /* icon-gradient@2x.png in Resources */,
226EBD5F16F8F5C700AFA41A /* icon-wrench.png in Resources */,
226EBD6116F8F5F400AFA41A /* icon-wrench@2x.png in Resources */,
226EBD6316F8F80400AFA41A /* 19.03.2013,_21:54:53.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
Binary file added Screentool/19.03.2013,_21:54:53.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 6 additions & 15 deletions Screentool/AppDelegate.m
Expand Up @@ -8,19 +8,6 @@

#import "AppDelegate.h"

@interface ClearView : NSView

@end

@implementation ClearView

//- (void)drawRect:(NSRect)dirtyRect {
// [[NSColor redColor] setFill];
// NSRectFill(dirtyRect);
//}

@end

static NSString * kSettingsCaptureWindowShadow = @"captureShadows";
static NSString * kSettingSaveImages = @"saveImages";
static NSString * kSettingPlaySoundWhenCapture = @"playSoundWhenCapture";
Expand All @@ -29,6 +16,7 @@ @implementation ClearView
static NSString * kSettingSaveImagesTo = @"saveImagesTo";

@interface AppDelegate ()
@property (weak) IBOutlet NSImageView *windowPreview;
@property (unsafe_unretained) IBOutlet NSPanel *overlayWindow;
@property (weak) IBOutlet NSButton *customButton;
@property (weak) IBOutlet NSMenu *statusMenu;
Expand Down Expand Up @@ -196,8 +184,11 @@ - (NSURL *) shotWindow {
CGWindowImageOption imageOption = [self isShadowEnabled] ? 0 : kCGWindowImageBoundsIgnoreFraming;
CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOption);


if ([self isVisualEffectsEnabled]) {
CGImageRef imageWithoutShadow = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageBoundsIgnoreFraming);
NSSize size = NSMakeSize(CGImageGetWidth(imageWithoutShadow), CGImageGetHeight(imageWithoutShadow));
self.windowPreview.image = [[NSImage alloc] initWithCGImage:imageWithoutShadow size:size];

self.overlayWindow.hidesOnDeactivate = NO;
CGRect bounds;
if (CGRectMakeWithDictionaryRepresentation((__bridge CFDictionaryRef)(windowInfo[boundsKey]), &bounds)) {
Expand All @@ -208,7 +199,7 @@ - (NSURL *) shotWindow {
}
[self.overlayWindow orderFrontRegardless];

double delayInSeconds = 0.3;
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.overlayWindow orderOut:nil];
Expand Down
141 changes: 83 additions & 58 deletions Screentool/en.lproj/MainMenu.xib
Expand Up @@ -14,6 +14,8 @@
<string>NSButton</string>
<string>NSButtonCell</string>
<string>NSCustomObject</string>
<string>NSImageCell</string>
<string>NSImageView</string>
<string>NSMenu</string>
<string>NSMenuItem</string>
<string>NSPopUpButton</string>
Expand Down Expand Up @@ -1575,7 +1577,7 @@
<object class="NSMenu" id="1005678565">
<string key="NSTitle"/>
<array class="NSMutableArray" key="NSMenuItems">
<object class="NSMenuItem" id="745461496">
<object class="NSMenuItem" id="870242345">
<reference key="NSMenu" ref="1005678565"/>
<string key="NSTitle">Settings</string>
<string key="NSKeyEquiv"/>
Expand Down Expand Up @@ -1696,7 +1698,7 @@
<object class="NSUserDefaultsController" id="902206743">
<bool key="NSSharedInstance">YES</bool>
</object>
<object class="NSWindowTemplate" id="513673027">
<object class="NSWindowTemplate" id="267914245">
<int key="NSWindowStyleMask">8336</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{377, 248}, {480, 270}}</string>
Expand All @@ -1705,22 +1707,53 @@
<string key="NSWindowClass">NSPanel</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="76959853">
<object class="NSView" key="NSWindowView" id="794851952">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{480, 270}</string>
<reference key="NSSuperview"/>
<reference key="NSNextKeyView"/>
<array key="NSViewContentFilters">
<object class="CIZoomBlur">
<object class="CIVector" key="CI_inputCenter">
<int key="CICount">2</int>
<string key="CIVector">{{150, 150}, {0, 0}}</string>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSImageView" id="592834452">
<reference key="NSNextResponder" ref="794851952"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews"/>
<set class="NSMutableSet" key="NSDragTypes">
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple PNG pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
</set>
<string key="NSFrameSize">{480, 270}</string>
<reference key="NSSuperview" ref="794851952"/>
<reference key="NSNextKeyView"/>
<bool key="NSViewIsLayerTreeHost">YES</bool>
<array key="NSViewContentFilters">
<object class="CIColorInvert">
<bool key="CIEnabled">YES</bool>
</object>
</array>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="646373939">
<int key="NSCellFlags">134217728</int>
<int key="NSCellFlags2">33554432</int>
<object class="NSCustomResource" key="NSContents">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">19.03.2013,_21:54:53</string>
</object>
<string key="NSCellIdentifier">_NS:9</string>
<int key="NSAlign">0</int>
<int key="NSScale">0</int>
<int key="NSStyle">0</int>
<bool key="NSAnimates">NO</bool>
</object>
<real value="20" key="CI_inputAmount"/>
<bool key="CIEnabled">YES</bool>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<bool key="NSEditable">YES</bool>
</object>
</array>
<string key="NSFrameSize">{480, 270}</string>
<reference key="NSSuperview"/>
<reference key="NSNextKeyView" ref="592834452"/>
<string key="NSReuseIdentifierKey">_NS:21</string>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
Expand Down Expand Up @@ -2502,18 +2535,26 @@
<object class="IBOutletConnection" key="connection">
<string key="label">overlayWindow</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="513673027"/>
<reference key="destination" ref="267914245"/>
</object>
<int key="connectionID">686</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">settingsClicked:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="745461496"/>
<reference key="destination" ref="870242345"/>
</object>
<int key="connectionID">695</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">windowPreview</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="592834452"/>
</object>
<int key="connectionID">698</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: values.captureShadows</string>
Expand Down Expand Up @@ -3739,7 +3780,7 @@
<reference ref="262693198"/>
<reference ref="686971438"/>
<reference ref="552847459"/>
<reference ref="745461496"/>
<reference ref="870242345"/>
</array>
<reference key="parent" ref="0"/>
</object>
Expand Down Expand Up @@ -3944,22 +3985,38 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">684</int>
<reference key="object" ref="513673027"/>
<reference key="object" ref="267914245"/>
<array class="NSMutableArray" key="children">
<reference ref="76959853"/>
<reference ref="794851952"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">685</int>
<reference key="object" ref="76959853"/>
<reference key="parent" ref="513673027"/>
<reference key="object" ref="794851952"/>
<array class="NSMutableArray" key="children">
<reference ref="592834452"/>
</array>
<reference key="parent" ref="267914245"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">691</int>
<reference key="object" ref="745461496"/>
<reference key="object" ref="870242345"/>
<reference key="parent" ref="1005678565"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">696</int>
<reference key="object" ref="592834452"/>
<array class="NSMutableArray" key="children">
<reference ref="646373939"/>
</array>
<reference key="parent" ref="794851952"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">697</int>
<reference key="object" ref="646373939"/>
<reference key="parent" ref="592834452"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand Down Expand Up @@ -4144,6 +4201,8 @@
<boolean value="NO" key="684.NSWindowTemplate.visibleAtLaunch"/>
<string key="685.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="691.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="696.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="697.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="72.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="73.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="74.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand All @@ -4160,49 +4219,15 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">695</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">AppDelegate</string>
<string key="superclassName">NSObject</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="customButton">NSButton</string>
<string key="overlayWindow">NSPanel</string>
<string key="statusMenu">NSMenu</string>
<string key="window">NSWindow</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="customButton">
<string key="name">customButton</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBToOneOutletInfo" key="overlayWindow">
<string key="name">overlayWindow</string>
<string key="candidateClassName">NSPanel</string>
</object>
<object class="IBToOneOutletInfo" key="statusMenu">
<string key="name">statusMenu</string>
<string key="candidateClassName">NSMenu</string>
</object>
<object class="IBToOneOutletInfo" key="window">
<string key="name">window</string>
<string key="candidateClassName">NSWindow</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/AppDelegate.h</string>
</object>
</object>
</array>
<int key="maxID">698</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="19.03.2013,_21:54:53">{554, 496}</string>
<string key="NSMenuCheckmark">{11, 11}</string>
<string key="NSMenuMixedState">{10, 3}</string>
<string key="NSSwitch">{15, 15}</string>
Expand Down
Binary file added Screentool/icon-wrench.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screentool/icon-wrench@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f229bc7

Please sign in to comment.