Skip to content
Browse files

Initial Project Commit

  • Loading branch information...
1 parent a764c06 commit c2e60ddbd275b016d93ce63e03b554ef48248559 @jnozzi committed Dec 23, 2011
View
55 JLNFadingScrollView.h
@@ -0,0 +1,55 @@
+//
+// JLNFadingScrollView.h
+// JLNFadingScrollView
+//
+// Created by Joshua Nozzi on 12/23/11.
+// Copyright (c) 2011 Joshua Nozzi. All rights reserved.
+//
+
+
+#import <AppKit/AppKit.h>
+
+
+@class JLNFadeView;
+
+
+@interface JLNFadingScrollView : NSScrollView
+{
+
+ JLNFadeView * _topFadeView;
+ JLNFadeView * _bottomFadeView;
+ CGFloat _fadeHeight;
+ NSColor * _fadeColor;
+
+}
+
+
+- (CGFloat)fadeHeight;
+- (void)setFadeHeight:(CGFloat)newHeight;
+
+- (NSColor *)fadeColor;
+- (void)setFadeColor:(NSColor *)newColor;
+
+- (void)tileFadeViews;
+
+
+@end
+
+
+
+#pragma mark -
+
+@interface JLNFadeView : NSView
+{
+ BOOL _topDown;
+ NSGradient * _fadient;
+ NSColor * _fadeColor;
+}
+
+- (NSColor *)fadeColor;
+- (void)setFadeColor:(NSColor *)newColor;
+
+@property (assign) BOOL topDown;
+
+
+@end
View
307 JLNFadingScrollView.m
@@ -0,0 +1,307 @@
+//
+// JLNFadingScrollView.m
+// JLNFadingScrollView
+//
+// Created by Joshua Nozzi on 12/23/11.
+// Copyright (c) 2011 Joshua Nozzi. All rights reserved.
+//
+// This software is supplied to you by Joshua Nozzi in consideration
+// of your agreement to the following terms, and your use, installation,
+// modification or redistribution of this software constitutes
+// acceptance of these terms. If you do not agree with these terms,
+// please do not use, install, modify or redistribute this software.
+//
+// In consideration of your agreement to abide by the following terms,
+// and subject to these terms, Joshua Nozzi grants you a personal,
+// non-exclusive license, to use, reproduce, modify and redistribute
+// the software, with or without modifications, in source and/or binary
+// forms; provided that if you redistribute the software in its entirety
+// and without modifications, you must retain this notice and the
+// following text and disclaimers in all such redistributions of the
+// software, and that in all cases attribution of Joshua Nozzi as the
+// original author of the source code shall be included in all such
+// resulting software products or distributions. Neither the name,
+// trademarks, service marks or logos of Joshua Nozzi may be used to
+// endorse or promote products derived from the software without specific
+// prior written permission from Joshua Nozzi. Except as expressly stated
+// in this notice, no other rights or licenses, express or implied, are
+// granted by Joshua Nozzi herein, including but not limited to any patent
+// rights that may be infringed by your derivative works or by other works
+// in which the software may be incorporated.
+//
+// THIS SOFTWARE IS PROVIDED BY JOSHUA NOZZI ON AN "AS IS" BASIS. JOSHUA
+// NOZZI MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT
+// LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY
+// AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE
+// AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+//
+// IN NO EVENT SHALL JOSHUA NOZZI BE LIABLE FOR ANY SPECIAL, INDIRECT,
+// INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE
+// USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE SOFTWARE,
+// HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
+// NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF JOSHUA NOZZI HAS
+// BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+
+#import "JLNFadingScrollView.h"
+
+
+#define DEFAULTFADEHEIGHT 6.0
+
+
+@implementation JLNFadingScrollView
+
+
+#pragma mark Constructors / Destructors
+
+- (id)initWithFrame:(NSRect)frameRect
+{
+ self = [super initWithFrame:frameRect];
+ if (self)
+ {
+
+ // iVars
+ _topFadeView = nil;
+ _bottomFadeView = nil;
+ _fadeHeight = DEFAULTFADEHEIGHT;
+ _fadeColor = [[NSColor blackColor] retain];
+
+ // Kill copy on scroll
+ [[self contentView] setCopiesOnScroll:NO];
+
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+
+ // iVars
+ [_topFadeView release];
+ _topFadeView = nil;
+ [_bottomFadeView release];
+ _bottomFadeView = nil;
+ [_fadeColor release];
+ _fadeColor = nil;
+
+ [super dealloc];
+
+}
+
+
+#pragma mark Nib Loading
+
+- (void)awakeFromNib
+{
+
+ // Kill copy on scroll
+ [[self contentView] setCopiesOnScroll:NO];
+
+ // Initial state
+ _fadeHeight = DEFAULTFADEHEIGHT;
+ _fadeColor = [[NSColor blackColor] retain];
+
+}
+
+
+#pragma mark Accessors
+
+- (CGFloat)fadeHeight
+{
+ return _fadeHeight;
+}
+
+- (void)setFadeHeight:(CGFloat)newHeight
+{
+ if (_fadeHeight != newHeight)
+ {
+ _fadeHeight = newHeight;
+ [self tileFadeViews];
+ }
+}
+
+- (NSColor *)fadeColor
+{
+ return _fadeColor;
+}
+
+- (void)setFadeColor:(NSColor *)newColor
+{
+
+ // Must be a different color and not be nil
+ if (_fadeColor != newColor && newColor)
+ {
+
+ // Swap the colors
+ [_fadeColor release];
+ _fadeColor = [newColor copy];
+
+ // Update the fade views
+ [_topFadeView setFadeColor:_fadeColor];
+ [_bottomFadeView setFadeColor:_fadeColor];
+
+ }
+
+}
+
+
+#pragma mark Tiling
+
+- (void)tile
+{
+
+ // Super first, then fade views
+ [super tile];
+ [self tileFadeViews];
+
+}
+
+- (void)tileFadeViews
+{
+
+ // Make sure we have our top and bottom fade views
+ if (!_topFadeView)
+ {
+ _topFadeView = [[JLNFadeView alloc] initWithFrame:NSMakeRect(0.0, 0.0, NSWidth([[self contentView] frame]), _fadeHeight)];
+ [_topFadeView setTopDown:YES];
+ [_topFadeView setFadeColor:[self backgroundColor]];
+ }
+ if (!_bottomFadeView)
+ {
+ _bottomFadeView = [[JLNFadeView alloc] initWithFrame:NSMakeRect(0.0, 0.0, NSWidth([[self contentView] frame]), _fadeHeight)];
+ [_bottomFadeView setFadeColor:[self backgroundColor]];
+ }
+
+ // Remove fade views from superview and add back ordered above all else
+ // (this is the best way I know how to make *damn* sure they stay on top)
+ [_bottomFadeView removeFromSuperviewWithoutNeedingDisplay];
+ [_topFadeView removeFromSuperviewWithoutNeedingDisplay];
+ [self addSubview:_bottomFadeView positioned:NSWindowAbove relativeTo:[self contentView]];
+ [self addSubview:_topFadeView positioned:NSWindowAbove relativeTo:[self contentView]];
+
+ // Determine inset for border type
+ CGFloat borderInset;
+ switch ([self borderType])
+ {
+
+ case NSLineBorder:
+ case NSBezelBorder:
+ borderInset = 1.0;
+ break;
+
+ case NSGrooveBorder:
+ borderInset = 2.0;
+ break;
+
+ case NSNoBorder:
+ default:
+ borderInset = 0.0;
+ break;
+
+ }
+
+ // Determine and set the fade views' frames (accounting for border)
+ NSRect topFrame = NSMakeRect(borderInset, NSMaxY([self bounds]) - (_fadeHeight + borderInset), NSWidth([self bounds]) - (2 * borderInset), _fadeHeight);
+ NSRect bottomFrame = NSMakeRect(borderInset, borderInset, NSWidth([self bounds]) - (2 * borderInset), _fadeHeight);
+ [_topFadeView setFrame:topFrame];
+ [_bottomFadeView setFrame:bottomFrame];
+
+ // Flag the fade views for display
+ [_topFadeView setNeedsDisplay:YES];
+ [_bottomFadeView setNeedsDisplay:YES];
+
+}
+
+
+@end
+
+
+
+#pragma mark -
+
+@implementation JLNFadeView
+
+
+#pragma mark Constructors / Destructors
+
+- (void)dealloc
+{
+ [_fadeColor release];
+ _fadeColor = nil;
+ [_fadient release];
+ _fadient = nil;
+ [super dealloc];
+}
+
+
+#pragma mark Accessors
+
+@synthesize topDown = _topDown;
+
+- (NSColor *)fadeColor
+{
+ return _fadeColor;
+}
+
+- (void)setFadeColor:(NSColor *)newColor
+{
+
+ // Must be different and must not be nil
+ if (_fadeColor != newColor && newColor != nil)
+ {
+
+ // Swap the color
+ [_fadeColor release];
+ _fadeColor = [newColor copy];
+
+ // Kill the current gradient
+ [_fadient release];
+ _fadient = nil;
+
+ // Flag for display
+ [self setNeedsDisplay:YES];
+
+ }
+
+}
+
+
+#pragma mark Drawing
+
+- (void)viewWillDraw
+{
+
+ // Make sure we have a sane fade color and gradient
+ if (!_fadeColor)
+ _fadeColor = [[NSColor blackColor] retain];
+ if (!_fadient)
+ _fadient = [[NSGradient alloc] initWithColors:[NSArray arrayWithObjects:
+ _fadeColor,
+ [_fadeColor colorWithAlphaComponent:0.25],
+ [_fadeColor colorWithAlphaComponent:0.00],
+ nil]];
+
+}
+
+- (void)drawRect:(NSRect)dirtyRect
+{
+
+ // Angle?
+ float angle;
+ if ([self isFlipped])
+ angle = ([self topDown]) ? -90 : 90;
+ else
+ angle = ([self topDown]) ? 90 : -90;
+
+ // Draw the gradient
+ [_fadient drawInRect:[self bounds] angle:angle];
+
+}
+
+
+@end
+
View
310 JLNFadingScrollView.xcodeproj/project.pbxproj
@@ -0,0 +1,310 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 9DEFEE4414A5090A00C25D6D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DEFEE4314A5090A00C25D6D /* Cocoa.framework */; };
+ 9DEFEE4E14A5090A00C25D6D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9DEFEE4C14A5090A00C25D6D /* InfoPlist.strings */; };
+ 9DEFEE5014A5090A00C25D6D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DEFEE4F14A5090A00C25D6D /* main.m */; };
+ 9DEFEE5414A5090A00C25D6D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 9DEFEE5214A5090A00C25D6D /* Credits.rtf */; };
+ 9DEFEE5714A5090A00C25D6D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DEFEE5614A5090A00C25D6D /* AppDelegate.m */; };
+ 9DEFEE5A14A5090A00C25D6D /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9DEFEE5814A5090A00C25D6D /* MainMenu.xib */; };
+ 9DEFEE6214A5095100C25D6D /* JLNFadingScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DEFEE6114A5095100C25D6D /* JLNFadingScrollView.m */; };
+ 9DEFEE6A14A52E7B00C25D6D /* License.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9DEFEE6814A52E7B00C25D6D /* License.txt */; };
+ 9DEFEE6B14A52E7B00C25D6D /* README in Resources */ = {isa = PBXBuildFile; fileRef = 9DEFEE6914A52E7B00C25D6D /* README */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 9DEFEE3F14A5090A00C25D6D /* JLNFadingScrollView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JLNFadingScrollView.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 9DEFEE4314A5090A00C25D6D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
+ 9DEFEE4614A5090A00C25D6D /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
+ 9DEFEE4714A5090A00C25D6D /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
+ 9DEFEE4814A5090A00C25D6D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 9DEFEE4B14A5090A00C25D6D /* JLNFadingScrollView-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JLNFadingScrollView-Info.plist"; sourceTree = "<group>"; };
+ 9DEFEE4D14A5090A00C25D6D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 9DEFEE4F14A5090A00C25D6D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 9DEFEE5114A5090A00C25D6D /* JLNFadingScrollView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JLNFadingScrollView-Prefix.pch"; sourceTree = "<group>"; };
+ 9DEFEE5314A5090A00C25D6D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
+ 9DEFEE5514A5090A00C25D6D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ 9DEFEE5614A5090A00C25D6D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ 9DEFEE5914A5090A00C25D6D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ 9DEFEE6014A5095100C25D6D /* JLNFadingScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLNFadingScrollView.h; sourceTree = "<group>"; };
+ 9DEFEE6114A5095100C25D6D /* JLNFadingScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLNFadingScrollView.m; sourceTree = "<group>"; };
+ 9DEFEE6814A52E7B00C25D6D /* License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = License.txt; sourceTree = "<group>"; };
+ 9DEFEE6914A52E7B00C25D6D /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 9DEFEE3C14A5090A00C25D6D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 9DEFEE4414A5090A00C25D6D /* Cocoa.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 9DEFEE3414A5090A00C25D6D = {
+ isa = PBXGroup;
+ children = (
+ 9DEFEE6814A52E7B00C25D6D /* License.txt */,
+ 9DEFEE6914A52E7B00C25D6D /* README */,
+ 9DEFEE6014A5095100C25D6D /* JLNFadingScrollView.h */,
+ 9DEFEE6114A5095100C25D6D /* JLNFadingScrollView.m */,
+ 9DEFEE6314A52B8000C25D6D /* Demo App */,
+ 9DEFEE4214A5090A00C25D6D /* Frameworks */,
+ 9DEFEE4014A5090A00C25D6D /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 9DEFEE4014A5090A00C25D6D /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 9DEFEE3F14A5090A00C25D6D /* JLNFadingScrollView.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 9DEFEE4214A5090A00C25D6D /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 9DEFEE4314A5090A00C25D6D /* Cocoa.framework */,
+ 9DEFEE4514A5090A00C25D6D /* Other Frameworks */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 9DEFEE4514A5090A00C25D6D /* Other Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 9DEFEE4614A5090A00C25D6D /* AppKit.framework */,
+ 9DEFEE4714A5090A00C25D6D /* CoreData.framework */,
+ 9DEFEE4814A5090A00C25D6D /* Foundation.framework */,
+ );
+ name = "Other Frameworks";
+ sourceTree = "<group>";
+ };
+ 9DEFEE4A14A5090A00C25D6D /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 9DEFEE4B14A5090A00C25D6D /* JLNFadingScrollView-Info.plist */,
+ 9DEFEE4C14A5090A00C25D6D /* InfoPlist.strings */,
+ 9DEFEE4F14A5090A00C25D6D /* main.m */,
+ 9DEFEE5114A5090A00C25D6D /* JLNFadingScrollView-Prefix.pch */,
+ 9DEFEE5214A5090A00C25D6D /* Credits.rtf */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 9DEFEE6314A52B8000C25D6D /* Demo App */ = {
+ isa = PBXGroup;
+ children = (
+ 9DEFEE5514A5090A00C25D6D /* AppDelegate.h */,
+ 9DEFEE5614A5090A00C25D6D /* AppDelegate.m */,
+ 9DEFEE5814A5090A00C25D6D /* MainMenu.xib */,
+ 9DEFEE4A14A5090A00C25D6D /* Supporting Files */,
+ );
+ name = "Demo App";
+ path = JLNFadingScrollView;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 9DEFEE3E14A5090A00C25D6D /* JLNFadingScrollView */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 9DEFEE5D14A5090A00C25D6D /* Build configuration list for PBXNativeTarget "JLNFadingScrollView" */;
+ buildPhases = (
+ 9DEFEE3B14A5090A00C25D6D /* Sources */,
+ 9DEFEE3C14A5090A00C25D6D /* Frameworks */,
+ 9DEFEE3D14A5090A00C25D6D /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = JLNFadingScrollView;
+ productName = JLNFadingScrollView;
+ productReference = 9DEFEE3F14A5090A00C25D6D /* JLNFadingScrollView.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 9DEFEE3614A5090A00C25D6D /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ ORGANIZATIONNAME = "Joshua Nozzi";
+ };
+ buildConfigurationList = 9DEFEE3914A5090A00C25D6D /* Build configuration list for PBXProject "JLNFadingScrollView" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 9DEFEE3414A5090A00C25D6D;
+ productRefGroup = 9DEFEE4014A5090A00C25D6D /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 9DEFEE3E14A5090A00C25D6D /* JLNFadingScrollView */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 9DEFEE3D14A5090A00C25D6D /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 9DEFEE4E14A5090A00C25D6D /* InfoPlist.strings in Resources */,
+ 9DEFEE5414A5090A00C25D6D /* Credits.rtf in Resources */,
+ 9DEFEE5A14A5090A00C25D6D /* MainMenu.xib in Resources */,
+ 9DEFEE6A14A52E7B00C25D6D /* License.txt in Resources */,
+ 9DEFEE6B14A52E7B00C25D6D /* README in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 9DEFEE3B14A5090A00C25D6D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 9DEFEE5014A5090A00C25D6D /* main.m in Sources */,
+ 9DEFEE5714A5090A00C25D6D /* AppDelegate.m in Sources */,
+ 9DEFEE6214A5095100C25D6D /* JLNFadingScrollView.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 9DEFEE4C14A5090A00C25D6D /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 9DEFEE4D14A5090A00C25D6D /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ 9DEFEE5214A5090A00C25D6D /* Credits.rtf */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 9DEFEE5314A5090A00C25D6D /* en */,
+ );
+ name = Credits.rtf;
+ sourceTree = "<group>";
+ };
+ 9DEFEE5814A5090A00C25D6D /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 9DEFEE5914A5090A00C25D6D /* en */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 9DEFEE5B14A5090A00C25D6D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 9DEFEE5C14A5090A00C25D6D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ 9DEFEE5E14A5090A00C25D6D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "JLNFadingScrollView/JLNFadingScrollView-Prefix.pch";
+ INFOPLIST_FILE = "JLNFadingScrollView/JLNFadingScrollView-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 9DEFEE5F14A5090A00C25D6D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "JLNFadingScrollView/JLNFadingScrollView-Prefix.pch";
+ INFOPLIST_FILE = "JLNFadingScrollView/JLNFadingScrollView-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 9DEFEE3914A5090A00C25D6D /* Build configuration list for PBXProject "JLNFadingScrollView" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 9DEFEE5B14A5090A00C25D6D /* Debug */,
+ 9DEFEE5C14A5090A00C25D6D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 9DEFEE5D14A5090A00C25D6D /* Build configuration list for PBXNativeTarget "JLNFadingScrollView" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 9DEFEE5E14A5090A00C25D6D /* Debug */,
+ 9DEFEE5F14A5090A00C25D6D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 9DEFEE3614A5090A00C25D6D /* Project object */;
+}
View
7 JLNFadingScrollView.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:JLNFadingScrollView.xcodeproj">
+ </FileRef>
+</Workspace>
View
BIN ...codeproj/project.xcworkspace/xcuserdata/jnozzi.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
10 ....xcodeproj/project.xcworkspace/xcuserdata/jnozzi.xcuserdatad/WorkspaceSettings.xcsettings
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
+ <true/>
+ <key>IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges</key>
+ <false/>
+</dict>
+</plist>
View
33 JLNFadingScrollView/AppDelegate.h
@@ -0,0 +1,33 @@
+//
+// AppDelegate.h
+// JLNFadingScrollView
+//
+// Created by Joshua Nozzi on 12/23/11.
+// Copyright (c) 2011 Joshua Nozzi. All rights reserved.
+//
+
+
+#import <Cocoa/Cocoa.h>
+
+
+@class JLNFadingScrollView;
+
+
+@interface AppDelegate : NSObject <NSApplicationDelegate>
+
+
+#pragma mark Properties
+
+@property (assign) IBOutlet JLNFadingScrollView *scrollView;
+@property (assign) IBOutlet NSWindow *window;
+@property (assign) IBOutlet NSTextField *heightField;
+@property (assign) IBOutlet NSStepper *heightStepper;
+
+
+#pragma mark Actions
+
+- (IBAction)setFadeHeight:(id)sender;
+- (IBAction)setFadeColor:(id)sender;
+
+
+@end
View
94 JLNFadingScrollView/AppDelegate.m
@@ -0,0 +1,94 @@
+//
+// AppDelegate.m
+// JLNFadingScrollView
+//
+// Created by Joshua Nozzi on 12/23/11.
+// Copyright (c) 2011 Joshua Nozzi. All rights reserved.
+//
+// This software is supplied to you by Joshua Nozzi in consideration
+// of your agreement to the following terms, and your use, installation,
+// modification or redistribution of this software constitutes
+// acceptance of these terms. If you do not agree with these terms,
+// please do not use, install, modify or redistribute this software.
+//
+// In consideration of your agreement to abide by the following terms,
+// and subject to these terms, Joshua Nozzi grants you a personal,
+// non-exclusive license, to use, reproduce, modify and redistribute
+// the software, with or without modifications, in source and/or binary
+// forms; provided that if you redistribute the software in its entirety
+// and without modifications, you must retain this notice and the
+// following text and disclaimers in all such redistributions of the
+// software, and that in all cases attribution of Joshua Nozzi as the
+// original author of the source code shall be included in all such
+// resulting software products or distributions. Neither the name,
+// trademarks, service marks or logos of Joshua Nozzi may be used to
+// endorse or promote products derived from the software without specific
+// prior written permission from Joshua Nozzi. Except as expressly stated
+// in this notice, no other rights or licenses, express or implied, are
+// granted by Joshua Nozzi herein, including but not limited to any patent
+// rights that may be infringed by your derivative works or by other works
+// in which the software may be incorporated.
+//
+// THIS SOFTWARE IS PROVIDED BY JOSHUA NOZZI ON AN "AS IS" BASIS. JOSHUA
+// NOZZI MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT
+// LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY
+// AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE
+// AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+//
+// IN NO EVENT SHALL JOSHUA NOZZI BE LIABLE FOR ANY SPECIAL, INDIRECT,
+// INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE
+// USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE SOFTWARE,
+// HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
+// NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF JOSHUA NOZZI HAS
+// BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+
+#import "AppDelegate.h"
+#import "JLNFadingScrollView.h"
+
+
+@implementation AppDelegate
+
+
+#pragma mark Properties
+
+@synthesize scrollView = _scrollView;
+@synthesize window = _window;
+@synthesize heightField = _heightField;
+@synthesize heightStepper = _heightStepper;
+
+
+#pragma mark Actions
+
+- (IBAction)setFadeHeight:(id)sender
+{
+ [[self scrollView] setFadeHeight:(CGFloat)[sender floatValue]];
+ if (sender == [self heightStepper])
+ [[self heightField] setIntegerValue:[sender integerValue]];
+ else
+ [[self heightStepper] setIntegerValue:[sender integerValue]];
+}
+
+- (IBAction)setFadeColor:(id)sender
+{
+ [[self scrollView] setFadeColor:([sender isKindOfClass:[NSColorWell class]]) ? [sender color] : [[self scrollView] backgroundColor]];
+}
+
+
+#pragma mark Table Data Source Methods
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
+{
+ return 500;
+}
+
+- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ return [NSString stringWithFormat:@"Test Row %li", rowIndex];
+}
+
+
+@end
View
34 JLNFadingScrollView/JLNFadingScrollView-Info.plist
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>name.nozzi.joshua.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2011 Joshua Nozzi. All rights reserved.</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View
7 JLNFadingScrollView/JLNFadingScrollView-Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'JLNFadingScrollView' target in the 'JLNFadingScrollView' project
+//
+
+#ifdef __OBJC__
+ #import <Cocoa/Cocoa.h>
+#endif
View
29 JLNFadingScrollView/en.lproj/Credits.rtf
@@ -0,0 +1,29 @@
+{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\paperw9840\paperh8400
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\b\fs24 \cf0 Engineering:
+\b0 \
+ Some people\
+\
+
+\b Human Interface Design:
+\b0 \
+ Some other people\
+\
+
+\b Testing:
+\b0 \
+ Hopefully not nobody\
+\
+
+\b Documentation:
+\b0 \
+ Whoever\
+\
+
+\b With special thanks to:
+\b0 \
+ Mom\
+}
View
2 JLNFadingScrollView/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
3,913 JLNFadingScrollView/en.lproj/MainMenu.xib
3,913 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
14 JLNFadingScrollView/main.m
@@ -0,0 +1,14 @@
+//
+// main.m
+// JLNFadingScrollView
+//
+// Created by Joshua Nozzi on 12/23/11.
+// Copyright (c) 2011 Joshua Nozzi. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char *argv[])
+{
+ return NSApplicationMain(argc, (const char **)argv);
+}
View
44 License.txt
@@ -0,0 +1,44 @@
+Joshua Nozzi's Free Source Code License
+=======================================
+
+
+This source code is free to use in any private, public, or commercial software products, provided you follow the license below.
+
+
+Summary of License
+------------------
+
+ 1. You can use the code in your own products, including commercial and/or closed-source products.
+ 2. You can modify the code as you wish, and use the modified code in your products.
+ 3. You can redistribute the original, unmodified code, but you have to include the full license text below.
+ 4. You can redistribute the modified code as you wish (without the full license text below).
+ 5. In all cases, you must include a credit mentioning Joshua Nozzi as the original author of the source.
+ 6. Joshua Nozzi is not liable for anything you do with the code, no matter what. So be sensible.
+ 7. You can’t use the name Joshua Nozzi or any other related marks to promote your products based on the code.
+ 8. If you agree to all of that, go ahead and use the source. Otherwise, don’t!
+
+
+
+Suggested Attribution Format
+----------------------------
+
+The license requires that you give credit to Joshua Nozzi, as the original author of any of our source that you use. The placement and format of the credit is up to you, but we prefer the credit to be in the software’s “About” window. Alternatively, you could put the credit in a list of acknowledgements within the software, in the software’s documentation, or on the web page for the software. The suggested format for the attribution is:
+
+ Includes <Name of Code> code by Joshua Nozzi.
+
+where <Name of Code> would be replaced by the name of the specific source-code package you made use of. Where possible, please link the text “Joshua Nozzi” to the following URL, or include the URL as plain text: http://joshua.nozzi.name/
+
+
+Full Source Code License Text
+-----------------------------
+
+License Agreement for Source Code provided by Joshua Nozzi
+
+This software is supplied to you by Joshua Nozzi in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Joshua Nozzi grants you a personal, non-exclusive license, to use, reproduce, modify and redistribute the software, with or without modifications, in source and/or binary forms; provided that if you redistribute the software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the software, and that in all cases attribution of Joshua Nozzi as the original author of the source code shall be included in all such resulting software products or distributions.

+Neither the name, trademarks, service marks or logos of Joshua Nozzi may be used to endorse or promote products derived from the software without specific prior written permission from Joshua Nozzi. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Joshua Nozzi herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the software may be incorporated.
+
+THIS SOFTWARE IS PROVIDED BY JOSHUA NOZZI ON AN "AS IS" BASIS. JOSHUA NOZZI MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL JOSHUA NOZZI BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF JOSHUA NOZZI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
37 README
@@ -0,0 +1,37 @@
+JLNFadingScrollView
+Written by Joshua Nozzi
+http://joshua.nozzi.name
+========================
+
+
+What is JLNFadingScrollView?
+----------------------------
+
+JLNFadingScrollView is a drop-in subclass of NSScrollView that adds a top and bottom fade of scrolled content (a la Dictionary.app's left-hand term source list). You can configure its fade color (usually a gray/black for shadow or the scroll view's background color for 'fade-to-nothing') and the fade height (small for shadow look, very large for iPhone-style-rolling-wheel effect).
+
+
+What platforms does it support?
+-------------------------------
+
+Requires 10.5 and up, because that's when NSGradient was introduced. You could use other gradient techniques to support older OS versions but really ... why bother?
+
+
+What are the licensing requirements?
+------------------------------------
+
+See the license document (License.txt) that is included with the source code. It is free to use but requires attribution. Feel free to contact me at joshua@nozzi.name with any licensing questions.
+
+
+How do I use it in my project?
+------------------------------
+
+1 - Copy JLNFadingScrollView.m and JLNFadingScrollView.h into your project.
+2 - In Interface Builder, set the class name of the desired NSScrollView to JLNFadingScrollView.
+3 - Include JLNFadingScrollView.h into any file in which you want to communicate with the scroll view (to configure its fade color/height).
+4 - Call -setFadeColor: and/or -setFadeHeight: to configure to taste
+
+
+How can I reach you?
+--------------------
+
+You can e-mail me at joshua@nozzi.name. I'm happy to answer most questions about this source code but am not willing to "hold your hand" or debug your code. It's straightforward to use if you are familiar with Cocoa and take a few moments to study the source. Please do your homework first. Questions sent to me that make it obvious the sender didn't do their homework will be ignored.

0 comments on commit c2e60dd

Please sign in to comment.
Something went wrong with that request. Please try again.