From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Add additional style for :box
Date: Wed, 9 Dec 2020 09:25:53 +0100 [thread overview]
Message-ID: <CAO48Bk_t1FtR=oH4dYayhrXEjt1BSTV=MZyzR5SHXzAjM0VhRw@mail.gmail.com> (raw)
In-Reply-To: <CAO48Bk_oUJ7fJQezeAsyRyKFnDogfrWKLph5Z6MQ1Q3HHpcmWA@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 3214 bytes --]
Hi Eli,
attached is a small patch with a proof of concept for the master branch
ONLY TESTED ON LINUX.
With this I can define my tab-line as
'(tab-line ((t (:inherit fringe :box (:line-width (5 . 5) :style
modern-button))))))
And changes in the fringe are taken *automatically* by the tabline.
Best, /Pedro A. Aranda
On Tue, 8 Dec 2020 at 18:09, Pedro Andres Aranda Gutierrez <
paaguti@gmail.com> wrote:
> Hi Eli,
>
> let's see if a couple of lines of code explain more than a thousand lines
> of 'literature'
>
> I use :box to make some parts of the GUI bigger than one display line.
> For example my mode-line face is
>
> '(mode-line ((t (:background "#4C566A" :foreground "#88C0D0" :weight bold
> :box (:line-width 6 :color "#4C566A")))))
>
> and yes, OK, at the beginning, I could accept to repeat the background
> definition inside the :box, however inconvenient it may be.
>
> Now, I have some some situations where I want to have a common look and
> feel:
>
> '(fringe ((,class (:foreground "#007fcf" :background "#afaf9f"))))
> '(line-number ((,class (:inherit fringe))))
>
> But when I want an element to be higher that the normal size, I need to
> repeat the background definition in the :box
> `(tab-line ((,class (:inherit fringe :box (:line-width 3 :color
> "#afaf9f")))))
>
> Which means that when I change the fringe background, I need to change it
> both in fringe and in tab-line to keep everything uniform.
> You pointed out :style t but that uses the _fore_ground for the box,
> whereas I need the _back_ground (same happens with :style nil)
>
> This is why I was proposing a new :style modern that fills the box with
> the background color of the face. How feasible would be my proposal?
>
> Best, /PA
>
> On Tue, 8 Dec 2020 at 16:16, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> > From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
>> > Date: Tue, 8 Dec 2020 07:21:42 +0100
>> > Cc: emacs-devel@gnu.org
>> >
>> > unfortunately not. :style nil takes the _fore_ground for the box and
>> I'm looking for the _back_ground
>> >
>> > :style nil
>> > Screenshot-20201208071520-101x110.png
>> >
>> > what I want
>> > Screenshot-20201208071702-126x105.png
>>
>> I'm confused: I thought you wanted to get rid of the 3D appearance,
>> which is why I suggested to use :style. But now you seem to be
>> talking about the colors, and I cannot understand what exactly is the
>> problem with that -- just change the colors to whatever you want.
>>
>> > In a general case, if you are deriving from another face, you have to
>> write the background colour twice: in the
>> > face you are deriving from and in the face :inheri ing the definition.
>> This, any change in the parent face
>> > implies a change in the derived face and that's not exactly
>> convenient...
>>
>> If the inheriting face overrides the color of the parent face, there's
>> no need to change the former when the latter changes. So here, too, I
>> don't think I follow you, please elaborate.
>>
>
>
> --
> Fragen sind nicht da um beantwortet zu werden,
> Fragen sind da um gestellt zu werden
> Georg Kreisler
>
--
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler
[-- Attachment #1.2: Type: text/html, Size: 6453 bytes --]
[-- Attachment #2: modern-box.diff --]
[-- Type: text/x-patch, Size: 3793 bytes --]
diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index 199a76e5cc..5e30590c6f 100644
--- a/lisp/cus-face.el
+++ b/lisp/cus-face.el
@@ -175,6 +175,7 @@ custom-face-attributes
(choice :tag "Style"
(const :tag "Raised" released-button)
(const :tag "Sunken" pressed-button)
+ (const :tag "Modern" modern-button)
(const :tag "None" nil))))
;; filter to make value suitable for customize
(lambda (real-value)
diff --git a/src/dispextern.h b/src/dispextern.h
index da51772b37..d23551c0b7 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1628,7 +1628,11 @@ #define FONT_TOO_HIGH(ft) \
/* Boxes with 3D shadows. Color equals the background color of the
face. Width is specified. */
FACE_RAISED_BOX,
- FACE_SUNKEN_BOX
+ FACE_SUNKEN_BOX,
+
+ /* 'Modern box: like simple box,
+ but using the *back*ground colour of the face */
+ FACE_MODERN_BOX
};
/* Underline type. */
@@ -1709,8 +1713,11 @@ #define FONT_TOO_HIGH(ft) \
around text in this face. A value of FACE_SIMPLE_BOX means a box
of width box_line_width is drawn in color box_color. A value of
FACE_RAISED_BOX or FACE_SUNKEN_BOX means a 3D box is drawn with
- shadow colors derived from the background color of the face. */
- ENUM_BF (face_box_type) box : 2;
+ shadow colors derived from the background color of the face.
+ A value of FACE_MODERN_BOX will create a FACE_SIMPLE_BOX drawn
+ with the background colour of the face.
+ */
+ ENUM_BF (face_box_type) box : 3;
/* Style of underlining. */
ENUM_BF (face_underline_type) underline : 2;
diff --git a/src/xfaces.c b/src/xfaces.c
index 73a536b19c..4b5289f65f 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, Qmodern_button))
break;
}
else
@@ -6031,6 +6031,8 @@ 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, Qmodern_button))
+ face->box = FACE_MODERN_BOX;
}
}
}
@@ -6919,6 +6921,7 @@ syms_of_xfaces (void)
DEFSYM (Qwave, "wave");
DEFSYM (Qreleased_button, "released-button");
DEFSYM (Qpressed_button, "pressed-button");
+ DEFSYM (Qmodern_button, "modern-button");
DEFSYM (Qnormal, "normal");
DEFSYM (Qextra_light, "extra-light");
DEFSYM (Qlight, "light");
diff --git a/src/xterm.c b/src/xterm.c
index 0d2452de92..10580fa003 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3005,16 +3005,26 @@ x_draw_glyph_string_box (struct glyph_string *s)
get_glyph_string_clip_rect (s, &clip_rect);
- if (s->face->box == FACE_SIMPLE_BOX)
- x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
- vwidth, left_p, right_p, &clip_rect);
- else
- {
+ switch(s->face->box) {
+ case FACE_SIMPLE_BOX:
+ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
+ vwidth, left_p, right_p, &clip_rect);
+ break;
+ case FACE_MODERN_BOX:
+ {
+ unsigned long store_color = s->face->box_color;
+ s->face->box_color = s->face->background;
+ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
+ vwidth, left_p, right_p, &clip_rect);
+ s->face->box_color = store_color;
+ }
+ break;
+ default:
x_setup_relief_colors (s);
x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, hwidth,
vwidth, raised_p, true, true, left_p, right_p,
&clip_rect);
- }
+ }
}
prev parent reply other threads:[~2020-12-09 8:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 16:01 Add additional style for :box Pedro Andres Aranda Gutierrez
2020-12-07 16:21 ` Eli Zaretskii
2020-12-08 6:21 ` Pedro Andres Aranda Gutierrez
2020-12-08 15:16 ` Eli Zaretskii
2020-12-08 17:09 ` Pedro Andres Aranda Gutierrez
2020-12-09 8:25 ` Pedro Andres Aranda Gutierrez [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAO48Bk_t1FtR=oH4dYayhrXEjt1BSTV=MZyzR5SHXzAjM0VhRw@mail.gmail.com' \
--to=paaguti@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).