From 5271381d5e8a351bcf83299de36d334bbf0f4d80 Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 11 Mar 2013 00:50:04 +0100 Subject: [PATCH] Introduced Custom Image View for editing-popup --- MacPass.xcodeproj/project.pbxproj | 16 + MacPass/EntryView.xib | 20 +- MacPass/IconSelection.xib | 538 +++++++++++++++++++++++++ MacPass/InspectorTabView.xib | 10 +- MacPass/MPIconSelectViewController.h | 13 + MacPass/MPIconSelectViewController.m | 27 ++ MacPass/MPInspectorTabViewController.m | 3 +- MacPass/MPPopupImageView.h | 13 + MacPass/MPPopupImageView.m | 103 +++++ MacPass/MacPass-Info.plist | 2 +- MacPass/en.lproj/Localizable.strings | Bin 2774 -> 2896 bytes 11 files changed, 732 insertions(+), 13 deletions(-) create mode 100644 MacPass/IconSelection.xib create mode 100644 MacPass/MPIconSelectViewController.h create mode 100644 MacPass/MPIconSelectViewController.m create mode 100644 MacPass/MPPopupImageView.h create mode 100644 MacPass/MPPopupImageView.m diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 68eef658..0a58e8fd 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -102,6 +102,9 @@ 4CD78AC016D155FF00768A1D /* 11_CameraTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */; }; 4CD884B715BD47080042BBF8 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD884B615BD47080042BBF8 /* MainWindow.xib */; }; 4CDF01A316D1B76700D0AC08 /* MPEntryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */; }; + 4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */; }; + 4CE39AC116ECE359000FE29D /* IconSelection.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CE39AC016ECE359000FE29D /* IconSelection.xib */; }; + 4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */; }; 4CE8246F16E2E93400573141 /* MPOverlayWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */; }; 4CE8247516E2F2B900573141 /* MPOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8247416E2F2B900573141 /* MPOverlayView.m */; }; 4CFC53BF16E94729007396BE /* MPShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFC53BE16E94729007396BE /* MPShadowBox.m */; }; @@ -280,6 +283,11 @@ 4CD884B615BD47080042BBF8 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 4CDF01A116D1B76700D0AC08 /* MPEntryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryViewController.h; sourceTree = ""; }; 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryViewController.m; sourceTree = ""; }; + 4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIconSelectViewController.h; sourceTree = ""; }; + 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconSelectViewController.m; sourceTree = ""; }; + 4CE39AC016ECE359000FE29D /* IconSelection.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IconSelection.xib; sourceTree = ""; }; + 4CE39AC216ECE4F7000FE29D /* MPPopupImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPopupImageView.h; sourceTree = ""; }; + 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPopupImageView.m; sourceTree = ""; }; 4CE8246D16E2E93400573141 /* MPOverlayWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOverlayWindowController.h; sourceTree = ""; }; 4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOverlayWindowController.m; sourceTree = ""; }; 4CE8247316E2F2B900573141 /* MPOverlayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOverlayView.h; sourceTree = ""; }; @@ -315,12 +323,15 @@ 4C25D58416CF0F8800F6806C /* WelcomeView.xib */, 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */, 4C77547616E55FFC00970E02 /* InspectorTabView.xib */, + 4CE39AC016ECE359000FE29D /* IconSelection.xib */, 4C69A73816D589DF00EC1B1A /* MPGradientView.h */, 4C69A73916D589DF00EC1B1A /* MPGradientView.m */, 4CE8247316E2F2B900573141 /* MPOverlayView.h */, 4CE8247416E2F2B900573141 /* MPOverlayView.m */, 4CFC53BD16E94729007396BE /* MPShadowBox.h */, 4CFC53BE16E94729007396BE /* MPShadowBox.m */, + 4CE39AC216ECE4F7000FE29D /* MPPopupImageView.h */, + 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */, ); name = Views; sourceTree = ""; @@ -579,6 +590,8 @@ 4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */, 4C77547316E55FE800970E02 /* MPInspectorTabViewController.h */, 4C77547416E55FE800970E02 /* MPInspectorTabViewController.m */, + 4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */, + 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */, ); name = "View Controller"; sourceTree = ""; @@ -775,6 +788,7 @@ 4C431BCF16E2BAB000700A81 /* OverlayWindow.xib in Resources */, 4C77547716E55FFC00970E02 /* InspectorTabView.xib in Resources */, 4C888C9016EB6C91003D34A1 /* Localizable.strings in Resources */, + 4CE39AC116ECE359000FE29D /* IconSelection.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -870,6 +884,8 @@ 4C888C9316EB6F5E003D34A1 /* MPToolbarItem.m in Sources */, 4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */, 4C811C8316ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m in Sources */, + 4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */, + 4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index a245ec9e..d5c01b5f 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -2,7 +2,7 @@ 1080 - 12C60 + 12C3103 3084 1187.34 625.00 @@ -1534,7 +1534,7 @@ - 672 + 675 @@ -1542,13 +1542,13 @@ MPEntryViewController MPViewController - toggleFilterSpace: + _toggleFilterSpace: id - toggleFilterSpace: + _toggleFilterSpace: - toggleFilterSpace: + _toggleFilterSpace: id @@ -1557,10 +1557,10 @@ NSView NSButton NSTextField + NSSearchField NSButton NSButton NSButton - NSView NSLayoutConstraint NSLayoutConstraint @@ -1581,6 +1581,10 @@ filterLabelTextField NSTextField + + filterSearchField + NSSearchField + filterTitleButton NSButton @@ -1593,10 +1597,6 @@ filterUsernameButton NSButton - - pathBar - NSView - tableToBottom NSLayoutConstraint diff --git a/MacPass/IconSelection.xib b/MacPass/IconSelection.xib new file mode 100644 index 00000000..48334397 --- /dev/null +++ b/MacPass/IconSelection.xib @@ -0,0 +1,538 @@ + + + + 1080 + 12C3103 + 3084 + 1187.34 + 625.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 3084 + + + IBNSLayoutConstraint + NSCollectionView + NSCollectionViewItem + NSCustomObject + NSCustomView + NSImageCell + NSImageView + NSScrollView + NSScroller + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + NSObject + + + FirstResponder + + + NSApplication + + + + 268 + + + + 268 + + + + 2304 + + + + 274 + {277, 219} + + + + _NS:80 + {0, 0} + {0, 0} + 0 + 0 + + + 6 + System + controlBackgroundColor + + 3 + MC42NjY2NjY2NjY3AA + + + + -1 + 0 + + + {{1, 1}, {277, 219}} + + + + _NS:78 + + + 6 + System + controlColor + + + 4 + + + + -2147483392 + {{234, 1}, {15, 143}} + + + + _NS:82 + NO + + _doScroller: + 1 + 0.89655172824859619 + + + + -2147483392 + {{1, 144}, {233, 15}} + + + + _NS:91 + NO + 1 + + _doScroller: + 0.63157892227172852 + + + {{20, 20}, {279, 221}} + + + + _NS:76 + 133682 + + + + 0.25 + 4 + 1 + + + {319, 261} + + + + NSView + + + + + 268 + + + + 268 + + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + {{2, 2}, {40, 40}} + + + + _NS:9 + YES + + 134217728 + 33554432 + + NSImage + NSActionTemplate + + _NS:9 + 0 + 3 + 2 + NO + + NO + YES + + + {44, 44} + + + + _NS:9 + NSView + + + + + + + itemPrototype + + + + 8 + + + + view + + + + 50 + + + + imageView + + + + 51 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + + + + 4 + 0 + + 4 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + + + 2 + + + + + + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 11 + + + + + 13 + + + + + 14 + + + + + 15 + + + + + 16 + + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + + + + 17 + + + + + + 8 + 0 + + 0 + 1 + + 34 + + 1000 + + 3 + 9 + 1 + + + + 7 + 0 + + 0 + 1 + + 34 + + 1000 + + 3 + 9 + 1 + + + + + + 18 + + + + + 30 + + + + + 44 + + + + + 48 + + + + + 49 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 51 + + + + + NSLayoutConstraint + NSObject + + IBProjectSource + ./Classes/NSLayoutConstraint.h + + + + + 0 + IBCocoaFramework + YES + 3 + + NSActionTemplate + {15, 15} + + YES + + diff --git a/MacPass/InspectorTabView.xib b/MacPass/InspectorTabView.xib index 312e2686..b416c820 100644 --- a/MacPass/InspectorTabView.xib +++ b/MacPass/InspectorTabView.xib @@ -483,7 +483,6 @@ 256 {280, 482} - _NS:28 Notes @@ -1909,6 +1908,7 @@ com.apple.InterfaceBuilder.CocoaPlugin + MPPopupImageView @@ -1957,6 +1957,14 @@ ./Classes/MPInspectorTabViewController.h + + MPPopupImageView + NSImageView + + IBProjectSource + ./Classes/MPPopupImageView.h + + MPShadowBox NSView diff --git a/MacPass/MPIconSelectViewController.h b/MacPass/MPIconSelectViewController.h new file mode 100644 index 00000000..1072fe69 --- /dev/null +++ b/MacPass/MPIconSelectViewController.h @@ -0,0 +1,13 @@ +// +// MPIconSelectViewController.h +// MacPass +// +// Created by Michael Starke on 10.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPViewController.h" + +@interface MPIconSelectViewController : MPViewController + +@end diff --git a/MacPass/MPIconSelectViewController.m b/MacPass/MPIconSelectViewController.m new file mode 100644 index 00000000..2eb5c56d --- /dev/null +++ b/MacPass/MPIconSelectViewController.m @@ -0,0 +1,27 @@ +// +// MPIconSelectViewController.m +// MacPass +// +// Created by Michael Starke on 10.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPIconSelectViewController.h" + +@interface MPIconSelectViewController () + +@end + +@implementation MPIconSelectViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Initialization code here. + } + + return self; +} + +@end diff --git a/MacPass/MPInspectorTabViewController.m b/MacPass/MPInspectorTabViewController.m index bf889379..10ca3bc3 100644 --- a/MacPass/MPInspectorTabViewController.m +++ b/MacPass/MPInspectorTabViewController.m @@ -12,11 +12,12 @@ #import "MPDatabaseController.h" #import "MPShadowBox.h" #import "MPIconHelper.h" +#import "MPPopupImageView.h" #import "KdbLib.h" @interface MPInspectorTabViewController () -@property (assign) IBOutlet NSImageView *itemImageView; +@property (assign) IBOutlet MPPopupImageView *itemImageView; @property (assign) IBOutlet NSTextField *itemNameTextfield; @property (assign) IBOutlet NSTabView *tabView; @property (assign) IBOutlet NSSegmentedControl *tabControl; diff --git a/MacPass/MPPopupImageView.h b/MacPass/MPPopupImageView.h new file mode 100644 index 00000000..1d53e58f --- /dev/null +++ b/MacPass/MPPopupImageView.h @@ -0,0 +1,13 @@ +// +// MPPopupImageView.h +// MacPass +// +// Created by Michael Starke on 10.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface MPPopupImageView : NSImageView + +@end diff --git a/MacPass/MPPopupImageView.m b/MacPass/MPPopupImageView.m new file mode 100644 index 00000000..e98bb634 --- /dev/null +++ b/MacPass/MPPopupImageView.m @@ -0,0 +1,103 @@ +// +// MPPopupImageView.m +// MacPass +// +// Created by Michael Starke on 10.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPPopupImageView.h" + +@interface MPPopupImageView () + +@property (assign) BOOL showOverlay; +@property (retain) NSString *overlayText; +@property (retain) NSDictionary *fontAttributes; +@property (assign) NSSize textSize; + +- (void)_setupView; +- (NSRect)_centeredFontRectangle; + +@end + +@implementation MPPopupImageView + +- (id)initWithFrame:(NSRect)frameRect { + self = [super initWithFrame:frameRect]; + if(self) { + [self _setupView]; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + if(self) { + [self _setupView]; + } + return self; +} + +- (void)drawRect:(NSRect)dirtyRect +{ + [super drawRect:dirtyRect]; + if(self.showOverlay) { + [[NSGraphicsContext currentContext] saveGraphicsState]; + NSRect rect = NSInsetRect([self bounds], 2, 14); + rect.origin.x = 2; + rect.origin.y = 14; + [[NSColor greenColor] set]; + NSShadow *shadow = [[NSShadow alloc] init]; + [shadow setShadowBlurRadius:2]; + [shadow setShadowOffset:NSMakeSize(0, -1)]; + [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0 alpha:0.5]]; + [shadow set]; + [[NSColor whiteColor] set]; + NSRectFill([self _centeredFontRectangle]); + [self.overlayText drawInRect:[self _centeredFontRectangle] withAttributes:self.fontAttributes]; + [shadow release]; + [[NSGraphicsContext currentContext] restoreGraphicsState]; + } + /* Draw Overlay */ +} + +- (void)mouseEntered:(NSEvent *)theEvent { + self.showOverlay = YES; + [self setNeedsDisplay:YES]; + [super mouseEntered:theEvent]; +} + +- (void)mouseExited:(NSEvent *)theEvent { + self.showOverlay = NO; + [self setNeedsDisplay:YES]; + [super mouseExited:theEvent]; +} + +- (NSRect)_centeredFontRectangle { + CGFloat leftMargin = floor( 0.5 * [self bounds].size.width - self.textSize.width ); + CGFloat bottomMargin = floor( 0.5 * [self bounds].size.height - self.textSize.height); + return NSMakeRect(leftMargin, bottomMargin, self.textSize.width, self.textSize.height); +} + +- (void)_setupView { + /* Setup font for drawing an precalulate some things */ + _overlayText = [NSLocalizedString(@"CHANGE_IMAGE", @"Overlay text for popup image") retain]; + NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + paragraphStyle.alignment = NSCenterTextAlignment; + _fontAttributes = [@{ + NSFontAttributeName :[NSFont boldSystemFontOfSize:11], + NSForegroundColorAttributeName : [NSColor whiteColor], + } retain]; + [paragraphStyle release]; + _textSize = [self.overlayText sizeWithAttributes:_fontAttributes]; + + /* Add tracking area for mouse events */ + NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] + options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow) + owner:self + userInfo:nil]; + [self addTrackingArea:trackingArea]; + [trackingArea release]; +} + +@end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 985c71cd..5963ed38 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 4EB + 53C LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 7d866716ed84077dce6be5ca01922b13f97537bd..f5fa101a66574c1083f638e954a74800486af416 100644 GIT binary patch delta 106 zcmca6dO>VMA7i9HLm5LVLlHv`Ln1>Zg91YdkXHdD6&TVO@`2(C3Ov>5amxEPceoEbbA92xu=+!