unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45735: Adding a flat-button style for boxes
@ 2021-01-09  8:27 Pedro Andres Aranda Gutierrez
  2021-01-10 13:10 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2021-01-09  8:27 UTC (permalink / raw)
  To: 45735


[-- Attachment #1.1: Type: text/plain, Size: 2345 bytes --]

Tags: patch

Create a flat-button style for boxes. It is based on the simple button
style but uses the background colour instead of the foreground colour
for the box.
This greatly simplifies the extension of Emacs themes to adapt them to
modern GUIs where the buttons are flat.

As an example, I like the mode-line to be a bit higher than the regular
mode line (à la doom-modeline, but not as big):

;; Definition of the styles without the patch:
;; I need to look up my theme and get the colours from it. For
;; nord-emacs it looks like this
;;
;; '(mode-line ((t (:inherit mode-line :background "#434C5E" :box
(:line-width 4 :color "#434C5E" )))))
;; '(mode-line-inactive ((t (:inherit mode-line-inactive :background
;; "#3B4252" :box (:line-width 4 :color "#3B4252" )))))

;; With the patch, I just need to indicate how many pixels higher (x 2)
;; I want the mode-line to be. I can reuse these settings across themes
;;
'(mode-line ((t (:inherit mode-line :box (:line-width 4 :style
flat-button)))))
'(mode-line-inactive ((t (:inherit mode-line-inactive :box (:line-width 4
:style flat-button )))))



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
cairo version 1.16.0)
 of 2021-01-09 built on paag-EliteBook
Repository revision: 29c7f8c915c3889dfd5b25878aa0692f826cd38f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Ubuntu 20.04.1 LTS

Configured using:
 'configure --build=x86_64-linux-gnu --prefix=/usr
 '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
 '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
 --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
 --program-suffix=28 --with-modules=yes --with-x --with-x-toolkit=gtk3
 --without-xaw3d 'CFLAGS=-g -O2
 -fdebug-prefix-map=/home/paag/Devel/emacs/emacs=. -fstack-protector-strong
 -Wformat -Werror=format-security' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

/Pedro A. Aranda
-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

[-- Attachment #1.2: Type: text/html, Size: 2829 bytes --]

[-- Attachment #2: flat.diff --]
[-- Type: text/x-patch, Size: 1117 bytes --]

diff --git a/src/xfaces.c b/src/xfaces.c
index b3b19a9cb2..6346706126 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3293,7 +3293,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
 		}
 	      else if (EQ (k, QCstyle))
 		{
-		  if (!EQ (v, Qpressed_button) && !EQ (v, Qreleased_button))
+		    if (!EQ (v, Qpressed_button) && !EQ (v, Qreleased_button) && !EQ(v, Qflat_button))
 		    break;
 		}
 	      else
@@ -6031,6 +6031,10 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
 		face->box = FACE_RAISED_BOX;
 	      else if (EQ (value, Qpressed_button))
 		face->box = FACE_SUNKEN_BOX;
+	      else if (EQ (value, Qflat_button)) {
+		  face->box = FACE_SIMPLE_BOX;
+		  face->box_color = face->background;
+	      }
 	    }
 	}
     }
@@ -6919,6 +6923,7 @@ syms_of_xfaces (void)
   DEFSYM (Qwave, "wave");
   DEFSYM (Qreleased_button, "released-button");
   DEFSYM (Qpressed_button, "pressed-button");
+  DEFSYM (Qflat_button, "flat-button");
   DEFSYM (Qnormal, "normal");
   DEFSYM (Qextra_light, "extra-light");
   DEFSYM (Qlight, "light");

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

* bug#45735: Adding a flat-button style for boxes
  2021-01-09  8:27 bug#45735: Adding a flat-button style for boxes Pedro Andres Aranda Gutierrez
@ 2021-01-10 13:10 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-10 13:10 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: 45735

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

> Create a flat-button style for boxes. It is based on the simple button
> style but uses the background colour instead of the foreground colour
> for the box.
> This greatly simplifies the extension of Emacs themes to adapt them to
> modern GUIs where the buttons are flat.

Looks good to me, so I've pushed this to Emacs 28 (with added
documentation).

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-01-10 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09  8:27 bug#45735: Adding a flat-button style for boxes Pedro Andres Aranda Gutierrez
2021-01-10 13:10 ` Lars Ingebrigtsen

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