adium 3821:311dacbed340: Improve the drawing of the internal sha...

commits at adium.im commits at adium.im
Fri Apr 1 11:02:43 UTC 2011


details:	http://hg.adium.im/adium/rev/311dacbed340
revision:	3821:311dacbed340
branch:		FloatingMessageWindowTextField
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Fri Apr 01 13:02:28 2011 +0200

Improve the drawing of the internal shadow in the text input view.

It now uses a NSScrollView subclass to draw the shadow. It's still not perfect (breaks when it actually needs to scroll), but should be a lot more efficient as it doesn't use CoreAnimation.

diffs (327 lines):

diff -r b3ed26d0c73f -r 311dacbed340 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Fri Apr 01 02:06:46 2011 +0200
+++ b/Adium.xcodeproj/project.pbxproj	Fri Apr 01 13:02:28 2011 +0200
@@ -1422,8 +1422,8 @@
 		6EC1684D06C170A000F9FAD3 /* DCInviteToChatPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 6EC1684806C170A000F9FAD3 /* DCInviteToChatPlugin.m */; };
 		6EC1684F06C170A000F9FAD3 /* DCInviteToChatWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6EC1684A06C170A000F9FAD3 /* DCInviteToChatWindowController.m */; };
 		6EC1685006C170A000F9FAD3 /* InviteToChatWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 6EC1684B06C170A000F9FAD3 /* InviteToChatWindow.nib */; };
-		761F4ED31343F72E0028FA89 /* AIPrettyView.m in Sources */ = {isa = PBXBuildFile; fileRef = 761F4ED21343F72E0028FA89 /* AIPrettyView.m */; };
 		766ABAB61306D1020049FFB7 /* AIUnreadMessagesTooltip.m in Sources */ = {isa = PBXBuildFile; fileRef = 766ABAB51306D1020049FFB7 /* AIUnreadMessagesTooltip.m */; };
+		767EFD221345D5EE00957582 /* AIMessageEntryScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 767EFD211345D5ED00957582 /* AIMessageEntryScrollView.m */; };
 		76889DEB12D3CA17007AEF00 /* GetInfo.png in Resources */ = {isa = PBXBuildFile; fileRef = 76889DEA12D3CA17007AEF00 /* GetInfo.png */; };
 		76889DEF12D3CA40007AEF00 /* Personal.png in Resources */ = {isa = PBXBuildFile; fileRef = 76889DEE12D3CA40007AEF00 /* Personal.png */; };
 		76C1AF9C125A906A00D269A9 /* AIAdiumURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C1AF9B125A906A00D269A9 /* AIAdiumURLProtocol.m */; };
@@ -4673,10 +4673,10 @@
 		6FB330A20C7235BF00B001A8 /* EKEzvIncomingFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = EKEzvIncomingFileTransfer.m; path = Plugins/Bonjour/libezv/Classes/EKEzvIncomingFileTransfer.m; sourceTree = SOURCE_ROOT; };
 		6FB330A30C7235BF00B001A8 /* EKEzvOutgoingFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = EKEzvOutgoingFileTransfer.h; path = Plugins/Bonjour/libezv/Classes/EKEzvOutgoingFileTransfer.h; sourceTree = SOURCE_ROOT; };
 		6FB330A40C7235BF00B001A8 /* EKEzvOutgoingFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = EKEzvOutgoingFileTransfer.m; path = Plugins/Bonjour/libezv/Classes/EKEzvOutgoingFileTransfer.m; sourceTree = SOURCE_ROOT; };
-		761F4ED11343F72E0028FA89 /* AIPrettyView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIPrettyView.h; path = Source/AIPrettyView.h; sourceTree = "<group>"; };
-		761F4ED21343F72E0028FA89 /* AIPrettyView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIPrettyView.m; path = Source/AIPrettyView.m; sourceTree = "<group>"; };
 		766ABAB41306D1020049FFB7 /* AIUnreadMessagesTooltip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIUnreadMessagesTooltip.h; path = Source/AIUnreadMessagesTooltip.h; sourceTree = "<group>"; };
 		766ABAB51306D1020049FFB7 /* AIUnreadMessagesTooltip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIUnreadMessagesTooltip.m; path = Source/AIUnreadMessagesTooltip.m; sourceTree = "<group>"; };
+		767EFD201345D5ED00957582 /* AIMessageEntryScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIMessageEntryScrollView.h; path = Source/AIMessageEntryScrollView.h; sourceTree = "<group>"; };
+		767EFD211345D5ED00957582 /* AIMessageEntryScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIMessageEntryScrollView.m; path = Source/AIMessageEntryScrollView.m; sourceTree = "<group>"; };
 		76889DEA12D3CA17007AEF00 /* GetInfo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = GetInfo.png; path = Resources/GetInfo.png; sourceTree = "<group>"; };
 		76889DEE12D3CA40007AEF00 /* Personal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Personal.png; path = Resources/Personal.png; sourceTree = "<group>"; };
 		76C1AF9A125A906A00D269A9 /* AIAdiumURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIAdiumURLProtocol.h; path = "Plugins/WebKit Message View/AIAdiumURLProtocol.h"; sourceTree = "<group>"; };
@@ -6962,8 +6962,8 @@
 				F55B416E03AB8C3201A8010A /* AIPasswordPromptController.h */,
 				F55B416603AB8BFC01A8010A /* AIPasswordPromptController.m */,
 				349DDD5206406A7D00542726 /* stackImage.png */,
-				761F4ED11343F72E0028FA89 /* AIPrettyView.h */,
-				761F4ED21343F72E0028FA89 /* AIPrettyView.m */,
+				767EFD201345D5ED00957582 /* AIMessageEntryScrollView.h */,
+				767EFD211345D5ED00957582 /* AIMessageEntryScrollView.m */,
 			);
 			name = Interface;
 			sourceTree = "<group>";
@@ -10686,7 +10686,7 @@
 				5A5F8BBD12D560E400019727 /* AIDockNameOverlay.m in Sources */,
 				5A17D65D130F76B4002C852F /* AIGradientView.m in Sources */,
 				97AF5CDB13191DE200550C41 /* AIContactListUserPictureMenuController.m in Sources */,
-				761F4ED31343F72E0028FA89 /* AIPrettyView.m in Sources */,
+				767EFD221345D5EE00957582 /* AIMessageEntryScrollView.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff -r b3ed26d0c73f -r 311dacbed340 Frameworks/Adium Framework/Source/AIMessageEntryTextView.m
--- a/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Fri Apr 01 02:06:46 2011 +0200
+++ b/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Fri Apr 01 13:02:28 2011 +0200
@@ -137,7 +137,7 @@
 	historyArray = [[NSMutableArray alloc] initWithObjects:@"",nil];
 	pushArray = [[NSMutableArray alloc] init];
 	currentHistoryLocation = 0;
-	[self setDrawsBackground:YES];
+	[self setDrawsBackground:NO];
 	_desiredSizeCached = NSMakeSize(0,0);
 	characterCounter = nil;
 	characterCounterPrefix = nil;
diff -r b3ed26d0c73f -r 311dacbed340 Plugins/Dual Window Interface/MessageView.nib/keyedobjects.nib
Binary file Plugins/Dual Window Interface/MessageView.nib/keyedobjects.nib has changed
diff -r b3ed26d0c73f -r 311dacbed340 Source/AIMessageEntryScrollView.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIMessageEntryScrollView.h	Fri Apr 01 13:02:28 2011 +0200
@@ -0,0 +1,25 @@
+/* 
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ * 
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+ * Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#import <Foundation/Foundation.h>
+#import "AIMessageWindowOutgoingScrollView.h"
+
+ at interface AIMessageEntryScrollView : NSScrollView {
+ at private
+    IBOutlet AIMessageWindowOutgoingScrollView *messageView;
+}
+
+ at end
diff -r b3ed26d0c73f -r 311dacbed340 Source/AIMessageEntryScrollView.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIMessageEntryScrollView.m	Fri Apr 01 13:02:28 2011 +0200
@@ -0,0 +1,108 @@
+/* 
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ * 
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+ * Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#import "AIMessageEntryScrollView.h"
+#import "ESWebView.h"
+
+ at implementation AIMessageEntryScrollView
+
+- (id)init
+{
+    self = [super init];
+    if (self) {
+        [[self contentView] setDrawsBackground:NO];
+        [[self contentView] setBackgroundColor:[NSColor clearColor]];
+    }
+    
+    return self;
+}
+
+- (void)dealloc
+{
+    [super dealloc];
+}
+
+- (void)move
+{
+    ESWebView *webView = [[[messageView contentView] subviews] objectAtIndex:0];
+    DOMElement *box = [[webView mainFrameDocument] getElementById:@"inputBox"];
+    
+    if (box) {
+        
+        double width = box.offsetWidth;
+        double height = (box.offsetHeight < 20 ? 20 : box.offsetHeight);
+        double originX = 1 + box.offsetLeft;
+        
+        DOMElement *el = box;
+        
+        double originY = 0;
+        
+        while (el) {
+            originY += el.offsetTop;
+            
+            el = [el offsetParent];
+        }
+        
+        originY = (1 + [[webView mainFrame] frameView].frame.size.height - originY) - height;
+        
+        [self setFrame:NSMakeRect(originX, originY, width, height)];
+        
+        NSLog(@"Setting frame: %@", NSStringFromRect(NSMakeRect(originX, originY, width, height)));
+    }
+}
+
+- (void)drawRect:(NSRect)dirtyRect
+{
+    NSLog(@"drawRect");
+    [self move];
+    [super drawRect:dirtyRect];
+    
+    NSBezierPath *bp = [NSBezierPath bezierPathWithRect:self.bounds];
+    [[self backgroundColor] setFill];
+    [bp fill];
+    
+    bp = [NSBezierPath bezierPath];
+    
+    NSShadow *internalShadow = [[NSShadow alloc] init];
+    [internalShadow setShadowColor:[NSColor lightGrayColor]];
+    [internalShadow setShadowBlurRadius:2.0];
+    [internalShadow setShadowOffset:NSMakeSize(0.0, -1.0)];
+    
+    [internalShadow set];
+    
+	[bp setLineWidth:2.0];
+	
+	[bp moveToPoint:NSMakePoint(self.bounds.origin.x, self.bounds.origin.x + self.bounds.size.height)];
+	[bp lineToPoint:NSMakePoint(self.bounds.origin.x, self.bounds.origin.y)];
+	[bp lineToPoint:NSMakePoint(self.bounds.origin.x + self.bounds.size.width, self.bounds.origin.y)];
+	[bp lineToPoint:NSMakePoint(self.bounds.origin.x + self.bounds.size.width, self.bounds.origin.y + self.bounds.size.height)];
+	
+	[[NSColor lightGrayColor] setStroke];
+    
+	[bp stroke];
+	
+	bp = [NSBezierPath bezierPath];
+	[bp setLineWidth:2.0];
+	
+	[bp moveToPoint:NSMakePoint(self.bounds.origin.x, self.bounds.origin.y + self.bounds.size.height)];
+	[bp lineToPoint:NSMakePoint(self.bounds.origin.x + self.bounds.size.width, self.bounds.origin.y + self.bounds.size.height)];
+	
+	[[NSColor lightGrayColor] setStroke];
+	
+	[bp stroke];
+}
+
+ at end
diff -r b3ed26d0c73f -r 311dacbed340 Source/AIPrettyView.h
--- a/Source/AIPrettyView.h	Fri Apr 01 02:06:46 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/* 
- * Adium is the legal property of its developers, whose names are listed in the copyright file included
- * with this source distribution.
- * 
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
- * General Public License as published by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
- * Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program; if not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#import <Cocoa/Cocoa.h>
-#import <Adium/AIMessageEntryTextView.h>
-#import "AIMessageWindowOutgoingScrollView.h"
-
-/**
- *  @brief The white border around floating text input fields.
- */
- at interface AIPrettyView : NSView {
-	IBOutlet AIMessageEntryTextView *entryField;
-	IBOutlet AIMessageWindowOutgoingScrollView *messageView;
-}
-
- at end
diff -r b3ed26d0c73f -r 311dacbed340 Source/AIPrettyView.m
--- a/Source/AIPrettyView.m	Fri Apr 01 02:06:46 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/* 
- * Adium is the legal property of its developers, whose names are listed in the copyright file included
- * with this source distribution.
- * 
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
- * General Public License as published by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
- * Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program; if not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#import "AIPrettyView.h"
-#import <AIUtilities/AIBezierPathAdditions.h>
-#import <WebKit/DOMCSSStyleDeclaration.h>
-#import "ESWebView.h"
-
- at implementation AIPrettyView
-
-- (id)initWithFrame:(NSRect)frame {
-    self = [super initWithFrame:frame];
-    if (self) {
-		
-    }
-    return self;
-}
-
-- (void)drawRect:(NSRect)dirtyRect {
-	
-    ESWebView *webView = [[[messageView contentView] subviews] objectAtIndex:0];
-    DOMElement *box = [[webView mainFrameDocument] getElementById:@"inputBox"];
-    
-    if (box) {
-        
-        double width = box.offsetWidth;
-        double height = box.offsetHeight;
-        double originX = 1 + box.offsetLeft;
-        
-        DOMElement *el = box;
-        
-        double originY = 0;
-        
-        while (el) {
-            originY += el.offsetTop;
-            
-            el = [el offsetParent];
-        }
-        
-        originY = (1 + [[webView mainFrame] frameView].frame.size.height - originY) - height;
-        
-        [[self enclosingScrollView] setFrame:NSMakeRect(originX, originY, width, height)];
-        
-        NSLog(@"Setting frame: %@", NSStringFromRect(NSMakeRect(originX, originY, width, height)));
-    }
-    
-    NSBezierPath *bp = [NSBezierPath bezierPath];
-	[bp setLineWidth:2.0];
-	
-	[bp moveToPoint:NSMakePoint(0, self.frame.size.height)];
-	[bp lineToPoint:NSMakePoint(0, 0)];
-	[bp lineToPoint:NSMakePoint(self.frame.size.width, 0)];
-	[bp lineToPoint:NSMakePoint(self.frame.size.width, self.frame.size.height)];
-	
-	[[NSColor colorWithCalibratedWhite:0.745 alpha:1.0] setStroke];
-	
-	[bp stroke];
-	
-	bp = [NSBezierPath bezierPath];
-	[bp setLineWidth:2.0];
-	
-	[bp moveToPoint:NSMakePoint(0, self.frame.size.height)];
-	[bp lineToPoint:NSMakePoint(self.frame.size.width, self.frame.size.height)];
-	
-	[[NSColor colorWithCalibratedWhite:0.557 alpha:1.0] setStroke];
-	
-	[bp stroke];
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
-	[[entryField window] makeFirstResponder:entryField];
-}
-
-
- at end




More information about the commits mailing list