From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#62562: 30.0.50; [PATCH] Some new SVG icons Date: Tue, 02 May 2023 20:10:15 +0300 Organization: LINKOV.NET Message-ID: <86sfcehd6w.fsf@mail.linkov.net> References: <4AF38B23-5E3A-41F3-9790-5BBBE9C69236@gmail.com> <86355ieljw.fsf@mail.linkov.net> <86lej9a2tv.fsf@mail.linkov.net> <1B6A1735-D9B5-4A18-B4F0-821BF2BF22CB@gmail.com> <86ttxx85wz.fsf@mail.linkov.net> <8015AB82-BA23-4844-8E48-CAF2519E4754@gmail.com> <86jzysxh3g.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12109"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , Stefan Kangas , 62562@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 02 19:15:20 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pttax-0002yi-W9 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 May 2023 19:15:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pttam-0008Tw-Ap; Tue, 02 May 2023 13:15:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pttag-0008TT-Qn for bug-gnu-emacs@gnu.org; Tue, 02 May 2023 13:15:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pttag-0001GD-5X for bug-gnu-emacs@gnu.org; Tue, 02 May 2023 13:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pttag-0002ep-0w for bug-gnu-emacs@gnu.org; Tue, 02 May 2023 13:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 May 2023 17:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62562 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62562-submit@debbugs.gnu.org id=B62562.168304766210151 (code B ref 62562); Tue, 02 May 2023 17:15:01 +0000 Original-Received: (at 62562) by debbugs.gnu.org; 2 May 2023 17:14:22 +0000 Original-Received: from localhost ([127.0.0.1]:44930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptta1-0002dc-PF for submit@debbugs.gnu.org; Tue, 02 May 2023 13:14:22 -0400 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:45979) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pttZx-0002dD-Kr for 62562@debbugs.gnu.org; Tue, 02 May 2023 13:14:19 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 21CCD40002; Tue, 2 May 2023 17:14:09 +0000 (UTC) In-Reply-To: <86jzysxh3g.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 04 Apr 2023 09:50:23 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:260947 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit >>>> Looks nice! BTW, how could I apply a mouse-face to the buttons in the >>>> tab-bar? I poked around and mouse-face doesn’t seem to take an effect? >>> >>> Currently mouse-face is not supported neither by define-icon not by tab-bar. >> >> Ah, I see. How are the buttons implemented then? If I move my >> pointer on top of it, it shows the “pressed” face. I’m trying to >> style the buttons on the tab-bar. > > Mouse pointer hovering is handled in 'note_tab_bar_highlight' by using > DRAW_IMAGE_SUNKEN. But you could try to style the image attributes > such as :margin and :ascent in define-icon. The tab line has a different implementation - with own problems. Currently when the icon from tabs/close.xpm is used, then hovering the mouse pointer changes the background of this image to the background color of mouse-face. But when the new image symbols/cross_16.svg is used, then on hovering the original background color is preserved in the svg image, not replaced with the background color of mouse-face. I have no idea why there is such idiosyncrasy for svg images with transparent background. If this is not an important detail then below is a patch that adds the new svg images to the tab line as well. Another problem is that by default the foreground of new svg images is black. To tone down the black color, add-face-text-property was added to tab-bar-tab-name-format-default to use the shadow face in the previous patch. The same way to support grayed color for icons on the tab line the following patch uses add-face-text-property in tab-line-tab-name-format-default. The third problem was that using 'define-icon' broke the tab-line auto-scrolling feature, because for some reason 'define-icon' sets 'rear-nonsticky' to t. So the fix below is to override it and set 'rear-nonsticky' to nil. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=tab-line-symbols-shadow.patch diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 1958f12975f..ca990726cbc 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -185,12 +205,19 @@ tab-line-new-button-show :group 'tab-line :version "27.1") +(define-icon tab-line-new nil + `((image "symbols/plus_16.svg" "tabs/new.xpm" + :face shadow + :margin (2 . 0) + :ascent center) + (text " + ")) + "Icon for creating a new tab." + :version "30.1" + :help-echo "New tab") + (defvar tab-line-new-button - (propertize " + " - 'display '(image :type xpm - :file "tabs/new.xpm" - :margin (2 . 0) - :ascent center) + (propertize (icon-string 'tab-line-new) + 'rear-nonsticky nil 'keymap tab-line-add-map 'mouse-face 'tab-line-highlight 'help-echo "Click to add tab") @@ -213,34 +240,53 @@ tab-line-close-button-show :group 'tab-line :version "27.1") +(define-icon tab-line-close nil + `((image "symbols/cross_16.svg" "tabs/close.xpm" + :face shadow + :margin (2 . 0) + :ascent center) + (text " x")) + "Icon for closing the clicked tab." + :version "30.1" + :help-echo "Click to close tab") + (defvar tab-line-close-button - (propertize " x" - 'display '(image :type xpm - :file "tabs/close.xpm" - :margin (2 . 0) - :ascent center) + (propertize (icon-string 'tab-line-close) + 'rear-nonsticky nil ;; important to not break auto-scroll 'keymap tab-line-tab-close-map 'mouse-face 'tab-line-close-highlight 'help-echo "Click to close tab") "Button for closing the clicked tab.") +(define-icon tab-line-left nil + `((image "symbols/chevron_left_16.svg" "tabs/left-arrow.xpm" + :face shadow + :margin (2 . 0) + :ascent center) + (text " <")) + "Icon for scrolling horizontally to the left." + :version "30.1") + (defvar tab-line-left-button - (propertize " <" - 'display '(image :type xpm - :file "tabs/left-arrow.xpm" - :margin (2 . 0) - :ascent center) + (propertize (icon-string 'tab-line-left) + 'rear-nonsticky nil 'keymap tab-line-left-map 'mouse-face 'tab-line-highlight 'help-echo "Click to scroll left") "Button for scrolling horizontally to the left.") +(define-icon tab-line-right nil + `((image "symbols/chevron_right_16.svg" "tabs/right-arrow.xpm" + :face shadow + :margin (2 . 0) + :ascent center) + (text "> ")) + "Icon for scrolling horizontally to the right." + :version "30.1") + (defvar tab-line-right-button - (propertize "> " - 'display '(image :type xpm - :file "tabs/right-arrow.xpm" - :margin (2 . 0) - :ascent center) + (propertize (icon-string 'tab-line-right) + 'rear-nonsticky nil 'keymap tab-line-right-map 'mouse-face 'tab-line-highlight 'help-echo "Click to scroll right") @@ -484,21 +541,27 @@ tab-line-tab-name-format-default (setf face (funcall fn tab tabs face buffer-p selected-p))) (apply 'propertize (concat (propertize (string-replace "%" "%%" name) ;; (bug#57848) + 'face face 'keymap tab-line-tab-map 'help-echo (if selected-p "Current tab" "Click to select tab") ;; Don't turn mouse-1 into mouse-2 (bug#49247) 'follow-link 'ignore) - (or (and (or buffer-p (assq 'buffer tab) (assq 'close tab)) - tab-line-close-button-show - (not (eq tab-line-close-button-show - (if selected-p 'non-selected 'selected))) - tab-line-close-button) - "")) + (let ((close (or (and (or buffer-p (assq 'buffer tab) + (assq 'close tab)) + tab-line-close-button-show + (not (eq tab-line-close-button-show + (if selected-p 'non-selected + 'selected))) + tab-line-close-button) + ""))) + (setq close (copy-sequence close)) + ;; Don't overwrite the icon face + (add-face-text-property 0 (length close) face t close) + close)) `( tab ,tab ,@(if selected-p '(selected t)) - face ,face mouse-face tab-line-highlight)))) (defun tab-line-format-template (tabs) --=-=-=--