Extracted HNHGradientView

This commit is contained in:
michael starke
2013-06-06 23:50:29 +02:00
parent b92d8cdc80
commit f84ef7208f
5 changed files with 11 additions and 136 deletions

2
HNHUi

Submodule HNHUi updated: 1dd80a57df...5246ae7342

View File

@@ -73,7 +73,7 @@
4C669BA016760ED100DD0774 /* Salsa20RandomStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B7716760ED100DD0774 /* Salsa20RandomStream.m */; };
4C669BA116760ED100DD0774 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B7916760ED100DD0774 /* Utils.m */; };
4C669BA216760ED100DD0774 /* UUID.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B7B16760ED100DD0774 /* UUID.m */; };
4C69A73A16D589DF00EC1B1A /* MPGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C69A73916D589DF00EC1B1A /* MPGradientView.m */; };
4C69A73A16D589DF00EC1B1A /* HNHGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C69A73916D589DF00EC1B1A /* HNHGradientView.m */; };
4C6B0E8C16C9B99B00A9ED23 /* PasswordInputView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C6B0E8B16C9B99B00A9ED23 /* PasswordInputView.xib */; };
4C77547516E55FE800970E02 /* MPInspectorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C77547416E55FE800970E02 /* MPInspectorViewController.m */; };
4C77547716E55FFC00970E02 /* InspectorView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77547616E55FFC00970E02 /* InspectorView.xib */; };
@@ -250,8 +250,8 @@
4C669B7916760ED100DD0774 /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utils.m; sourceTree = "<group>"; };
4C669B7A16760ED100DD0774 /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UUID.h; sourceTree = "<group>"; };
4C669B7B16760ED100DD0774 /* UUID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UUID.m; sourceTree = "<group>"; };
4C69A73816D589DF00EC1B1A /* MPGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPGradientView.h; sourceTree = "<group>"; };
4C69A73916D589DF00EC1B1A /* MPGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPGradientView.m; sourceTree = "<group>"; };
4C69A73816D589DF00EC1B1A /* HNHGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHGradientView.h; sourceTree = "<group>"; };
4C69A73916D589DF00EC1B1A /* HNHGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHGradientView.m; sourceTree = "<group>"; };
4C6B0E8B16C9B99B00A9ED23 /* PasswordInputView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordInputView.xib; sourceTree = "<group>"; };
4C77547316E55FE800970E02 /* MPInspectorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPInspectorViewController.h; sourceTree = "<group>"; };
4C77547416E55FE800970E02 /* MPInspectorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPInspectorViewController.m; sourceTree = "<group>"; };
@@ -372,8 +372,6 @@
4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */,
4C77547616E55FFC00970E02 /* InspectorView.xib */,
4CE39AC016ECE359000FE29D /* IconSelection.xib */,
4C69A73816D589DF00EC1B1A /* MPGradientView.h */,
4C69A73916D589DF00EC1B1A /* MPGradientView.m */,
4CE8247316E2F2B900573141 /* MPOverlayView.h */,
4CE8247416E2F2B900573141 /* MPOverlayView.m */,
4CFC53BD16E94729007396BE /* MPShadowBox.h */,
@@ -752,6 +750,8 @@
4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */,
4C3D4C0617594CA40038DAAC /* HNHSeparator.h */,
4C3D4C0717594CA40038DAAC /* HNHSeparator.m */,
4C69A73816D589DF00EC1B1A /* HNHGradientView.h */,
4C69A73916D589DF00EC1B1A /* HNHGradientView.m */,
4CC3AABA175F4983003EF01B /* LICENSE.MIT */,
4CC3AABB175F4983003EF01B /* README.md */,
);
@@ -970,7 +970,7 @@
4C61EA0316D2FD0800AC519E /* MPOutlineViewController.m in Sources */,
4C2C4C2C16D3BE3700D49295 /* KdbGroup+MPAdditions.m in Sources */,
4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */,
4C69A73A16D589DF00EC1B1A /* MPGradientView.m in Sources */,
4C69A73A16D589DF00EC1B1A /* HNHGradientView.m in Sources */,
4C920E2A16DCDFA00083839B /* MPLoggerProxy.m in Sources */,
4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */,
4C431BCD16E2A82800700A81 /* MPPasteBoardController.m in Sources */,

View File

@@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12D78</string>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.37</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -39,7 +39,7 @@
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="1005">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSSearchField" id="498286707">
@@ -47,7 +47,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{369, 5}, {136, 19}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSSearchFieldCell" key="NSCell" id="456364439">
@@ -122,7 +121,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{513, 5}, {42, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="791616402">
@@ -146,7 +144,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{188, 5}, {38, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="113591000"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -175,7 +172,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{104, 5}, {76, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="340435610"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -200,7 +196,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{5, 6}, {44, 14}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="7073340"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@@ -241,7 +236,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{54, 4}, {42, 19}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="902262560"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -263,10 +257,8 @@
</object>
</array>
<string key="NSFrameSize">{563, 28}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="906526407"/>
<string key="NSClassName">MPGradientView</string>
<string key="NSClassName">HNHGradientView</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -948,14 +940,6 @@
<string key="minorKey">./Classes/MPEntryViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPGradientView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPGradientView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPViewController</string>
<string key="superclassName">NSViewController</string>

View File

@@ -1,18 +0,0 @@
//
// MPGradientView.h
// MacPass
//
// Created by Michael Starke on 20.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
/*
A view just displaying a gradient
*/
@interface MPGradientView : NSView
- (id)initWithFrame:(NSRect)frame activeGradient:(NSGradient *)activeGradient inactiveGradient:(NSGradient *)inactiveGradient;
@end

View File

@@ -1,91 +0,0 @@
//
// MPGradientView.m
// MacPass
//
// Created by Michael Starke on 20.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPGradientView.h"
@interface MPGradientView ()
@property (assign, nonatomic) BOOL isRenderedActive;
@property (retain) NSGradient *activeGradient;
@property (retain) NSGradient *inactiveGradient;
- (void)_refreshActiveState;
@end
@implementation MPGradientView
- (id)initWithFrame:(NSRect)frameRect {
NSColor *activeTop = [NSColor colorWithCalibratedWhite:0.85 alpha:1];
NSColor *activeBottom = [NSColor colorWithCalibratedWhite:0.7 alpha:1];
NSColor *inactiveTop = [NSColor colorWithCalibratedWhite:0.9 alpha:1];
NSColor *inactiveBottom = [NSColor colorWithCalibratedWhite:0.85 alpha:1];
NSGradient *activeGradient = [[[NSGradient alloc] initWithColors:@[ activeBottom, activeTop ]] autorelease];
NSGradient *inactiveGradient = [[[NSGradient alloc] initWithColors:@[ inactiveBottom, inactiveTop ]] autorelease];
return [self initWithFrame:frameRect activeGradient:activeGradient inactiveGradient:inactiveGradient];
}
- (id)initWithFrame:(NSRect)frame activeGradient:(NSGradient *)activeGradient inactiveGradient:(NSGradient *)inactiveGradient {
self = [super initWithFrame:frame];
if(self) {
_activeGradient = [activeGradient retain];
_inactiveGradient = [inactiveGradient retain];
}
return self;
}
- (void)dealloc {
self.activeGradient = nil;
self.inactiveGradient = nil;
[super dealloc];
}
#pragma mark Drawing
- (void)drawRect:(NSRect)dirtyRect {
/*
We draw a Gradient, so make sure we always redraw the full view
*/
NSGradient *gradient = self.isRenderedActive ? self.activeGradient : self.inactiveGradient;
[gradient drawInRect:self.bounds angle:90];
}
- (BOOL)isOpaque {
return YES;
}
#pragma mark State Refresh
- (void)_registerWindow:(NSWindow *)newWindow {
if([self window]) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:[self window]];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:[self window]];
}
if(newWindow) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_refreshActiveState) name:NSWindowDidBecomeKeyNotification object:newWindow];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_refreshActiveState) name:NSWindowDidResignKeyNotification object:newWindow];
}
}
- (void)viewWillMoveToWindow:(NSWindow *)newWindow {
[self _registerWindow:newWindow];
[super viewWillMoveToWindow:newWindow];
}
- (void)_refreshActiveState {
self.isRenderedActive = [[self window] isKeyWindow];
}
# pragma mark Custom Properties
- (void)setIsRenderedActive:(BOOL)isRenderedActive {
if(_isRenderedActive != isRenderedActive) {
_isRenderedActive = isRenderedActive;
[self setNeedsDisplay:YES];
}
}
@end