unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29823: NS port tooltip colours
@ 2017-12-23 11:21 Alan Third
  2018-01-04 20:57 ` Charles A. Roelli
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Third @ 2017-12-23 11:21 UTC (permalink / raw)
  To: 29823

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

The NS port doesn’t support customising tooltips as described in the
Emacs manual. I’ve attached a patch that allows you to customise the
background and foreground colours.

It may be better to try using the existing frame code to generate the
tooltips as they would then support all parameters, but I’m not sure
how to go about doing that.
-- 
Alan Third

[-- Attachment #2: 0001-Allow-setting-tooltip-colors-in-NS-port.patch --]
[-- Type: text/plain, Size: 2297 bytes --]

From fda76ad237ac01ce398796e02a2a9463027ce7c9 Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Sat, 23 Dec 2017 11:00:35 +0000
Subject: [PATCH] Allow setting tooltip colors in NS port

* src/nsfns.m (Fx_show_tip): Get face colors and apply them to the
tooltip.
* src/nsmenu.m (EmacsTooltip::setBackgroundColor):
(EmacsTooltip::setForegroundColor): New functions.
* src/nsterm.h (EmacsTooltip::setBackgroundColor):
(EmacsTooltip::setForegroundColor): New function prototypes.
---
 src/nsfns.m  | 10 ++++++++++
 src/nsmenu.m | 10 ++++++++++
 src/nsterm.h |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/nsfns.m b/src/nsfns.m
index 064b476fb4..05605bf657 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2873,6 +2873,8 @@ with offset DY added (default is -10).
   struct frame *f;
   char *str;
   NSSize size;
+  NSColor *color;
+  Lisp_Object t;
 
   specbind (Qinhibit_redisplay, Qt);
 
@@ -2900,6 +2902,14 @@ with offset DY added (default is -10).
   else
     Fx_hide_tip ();
 
+  t = x_get_arg (NULL, parms, Qbackground_color, NULL, NULL, RES_TYPE_STRING);
+  if (ns_lisp_to_color (t, &color) == 0)
+    [ns_tooltip setBackgroundColor: color];
+
+  t = x_get_arg (NULL, parms, Qforeground_color, NULL, NULL, RES_TYPE_STRING);
+  if (ns_lisp_to_color (t, &color) == 0)
+    [ns_tooltip setForegroundColor: color];
+
   [ns_tooltip setText: str];
   size = [ns_tooltip frame].size;
 
diff --git a/src/nsmenu.m b/src/nsmenu.m
index d2e102a2a9..63ed4f5d1d 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1373,6 +1373,16 @@ - (void) setText: (char *)text
   [textField setFrame: r];
 }
 
+- (void) setBackgroundColor: (NSColor *)col
+{
+  [textField setBackgroundColor: col];
+}
+
+- (void) setForegroundColor: (NSColor *)col
+{
+  [textField setTextColor: col];
+}
+
 - (void) showAtX: (int)x Y: (int)y for: (int)seconds
 {
   NSRect wr = [win frame];
diff --git a/src/nsterm.h b/src/nsterm.h
index e669c95931..184ada99ae 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -585,6 +585,8 @@ typedef id instancetype;
   }
 - (instancetype) init;
 - (void) setText: (char *)text;
+- (void) setBackgroundColor: (NSColor *)col;
+- (void) setForegroundColor: (NSColor *)col;
 - (void) showAtX: (int)x Y: (int)y for: (int)seconds;
 - (void) hide;
 - (BOOL) isActive;
-- 
2.14.3


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

* bug#29823: NS port tooltip colours
  2017-12-23 11:21 bug#29823: NS port tooltip colours Alan Third
@ 2018-01-04 20:57 ` Charles A. Roelli
  2018-01-04 21:21   ` Alan Third
  0 siblings, 1 reply; 3+ messages in thread
From: Charles A. Roelli @ 2018-01-04 20:57 UTC (permalink / raw)
  To: Alan Third; +Cc: 29823

> Date: Sat, 23 Dec 2017 11:21:29 +0000
> From: Alan Third <alan@idiocy.org>
> 
> The NS port doesn’t support customising tooltips as described in the
> Emacs manual. I’ve attached a patch that allows you to customise the
> background and foreground colours.
> 
> It may be better to try using the existing frame code to generate the
> tooltips as they would then support all parameters, but I’m not sure
> how to go about doing that.
> -- 
> Alan Third

Looks good to me.  Thanks for adding this feature.

It looks like using the existing frame code to generate tooltips would
involve rewriting "x-show-tip" in nsfns.m to make it pop up a frame
instead of a native tooltip.  Could that not be done using the "child
frame" functionality (or some subset of it) that you've already added?

And by the way, do you know how this bug was tagged as "minor"?  It
seems like a lot of bugs get that designation, and it's not clear
whether the submitter chooses to do that or if it is somehow done
automatically.





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

* bug#29823: NS port tooltip colours
  2018-01-04 20:57 ` Charles A. Roelli
@ 2018-01-04 21:21   ` Alan Third
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Third @ 2018-01-04 21:21 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 29823

On Thu, Jan 04, 2018 at 09:57:32PM +0100, Charles A. Roelli wrote:
> > Date: Sat, 23 Dec 2017 11:21:29 +0000
> > From: Alan Third <alan@idiocy.org>
> > 
> > The NS port doesn’t support customising tooltips as described in the
> > Emacs manual. I’ve attached a patch that allows you to customise the
> > background and foreground colours.
> > 
> > It may be better to try using the existing frame code to generate the
> > tooltips as they would then support all parameters, but I’m not sure
> > how to go about doing that.
> 
> Looks good to me.  Thanks for adding this feature.

Thanks.

> It looks like using the existing frame code to generate tooltips would
> involve rewriting "x-show-tip" in nsfns.m to make it pop up a frame
> instead of a native tooltip.  Could that not be done using the "child
> frame" functionality (or some subset of it) that you've already added?

Yeah. I assume it should also be possible to modify tooltip.el to use
undecorated frames instead of tooltips defined at the C level.

Perhaps there’s some advantage to using native tooltips, but the NS
port doesn’t use native tooltips anyway.

> And by the way, do you know how this bug was tagged as "minor"?  It
> seems like a lot of bugs get that designation, and it's not clear
> whether the submitter chooses to do that or if it is somehow done
> automatically.

I assume someone else set it, I certainly didn’t.
-- 
Alan Third





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

end of thread, other threads:[~2018-01-04 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-23 11:21 bug#29823: NS port tooltip colours Alan Third
2018-01-04 20:57 ` Charles A. Roelli
2018-01-04 21:21   ` Alan Third

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