GNU bug report logs - #9176
[PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly

Previous Next

Package: emacs;

Reported by: Alp Aker <alptekin.aker <at> gmail.com>

Date: Wed, 27 Jul 2011 19:11:02 UTC

Severity: normal

Tags: patch

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alp Aker <alptekin.aker <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly
Date: Tue, 26 Jul 2011 16:13:04 -0400
A small aesthetic issue:  Currently on NS the dimensions of tooltip
windows are determined by a small hack that introduces superfluous
padding at the bottom and left (typically 10 pixels or more).  The
patch below sizes tooltip windows precisely.

I also took the liberty of making another purely aesthetic change.
Currently on NS tooltip windows have bezels and no shadows. The
standard appearance on Mac is to have shadows and no bezels.  So I
changed the implementation to use the default appearance as well.

2011-07-26  Alp Aker  <alp.tekin.aker <at> gmail.com>

	* nsmenu.m (EmacsTooltip -init): Remove bezels and add shadows to
	tooltip windows.
	(-setText): Size tooltip dimensions precisely to contents.

=== modified file 'src/nsmenu.m'
--- src/nsmenu.m	2011-07-08 10:04:23 +0000
+++ src/nsmenu.m	2011-07-26 19:50:47 +0000
@@ -1228,8 +1228,8 @@

   [textField setEditable: NO];
   [textField setSelectable: NO];
-  [textField setBordered: YES];
-  [textField setBezeled: YES];
+  [textField setBordered: NO];
+  [textField setBezeled: NO];
   [textField setDrawsBackground: YES];

   win = [[NSWindow alloc]
@@ -1237,6 +1237,7 @@
                       styleMask: 0
                         backing: NSBackingStoreBuffered
                           defer: YES];
+  [win setHasShadow: YES];
   [win setReleasedWhenClosed: NO];
   [win setDelegate: self];
   [[win contentView] addSubview: textField];
@@ -1257,17 +1258,15 @@
 - (void) setText: (char *)text
 {
   NSString *str = [NSString stringWithUTF8String: text];
-  NSRect r = [textField frame];
-  NSSize textSize = [str sizeWithAttributes:
-     [NSDictionary dictionaryWithObject: [[textField font] screenFont]
-				 forKey: NSFontAttributeName]];
-  NSSize padSize = [[[textField font] screenFont]
-		     boundingRectForFont].size;
-
-  r.size.width = textSize.width + padSize.width/2;
-  r.size.height = textSize.height + padSize.height/2;
+  NSRect r  = [textField frame];
+  NSSize tooltipDims;
+
+  [textField setStringValue: str];
+  tooltipDims = [[textField cell] cellSize];
+
+  r.size.width = tooltipDims.width;
+  r.size.height = tooltipDims.height;
   [textField setFrame: r];
-  [textField setStringValue: str];
 }

 - (void) showAtX: (int)x Y: (int)y for: (int)seconds




This bug report was last modified 13 years and 297 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.