mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 05:29:26 +00:00
Extracted HNHGradientView
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user