unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9176: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly
@ 2011-07-26 20:13 Alp Aker
  2011-07-28 18:31 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Alp Aker @ 2011-07-26 20:13 UTC (permalink / raw)
  To: 9176

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@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#9176: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly
  2011-07-26 20:13 bug#9176: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly Alp Aker
@ 2011-07-28 18:31 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2011-07-28 18:31 UTC (permalink / raw)
  To: Alp Aker; +Cc: 9176

Alp Aker <alptekin.aker@gmail.com> writes:

> 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.

Thanks, applied.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-28 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 20:13 bug#9176: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly Alp Aker
2011-07-28 18:31 ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).