diff options
| author | YAMAMOTO Mitsuharu | 2015-02-17 10:14:56 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2015-02-17 10:14:56 +0900 |
| commit | 47bca7253b8c3c7cf1fb988f42a2219701571528 (patch) | |
| tree | 1d82ffe292bc125a787e54bc389089317069d3a2 /src | |
| parent | 016b9ec0c84124bc7754014c447fb08ae2f2df47 (diff) | |
| download | emacs-47bca7253b8c3c7cf1fb988f42a2219701571528.tar.gz emacs-47bca7253b8c3c7cf1fb988f42a2219701571528.zip | |
Draw outermost line using black relief and erase corners also for cairo.
* xterm.c [USE_CAIRO]: Include math.h.
(enum corners) [USE_CAIRO]: New enum.
(x_erase_corners_for_relief) [USE_CAIRO]: New function.
(x_draw_relief_rect) [USE_CAIRO]: Use it. If box width is larger
than 1, draw the outermost line using the black relief.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/xterm.c | 80 |
2 files changed, 84 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 052bf6985c0..fea9e379d73 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2015-02-17 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * xterm.c [USE_CAIRO]: Include math.h. | ||
| 4 | (enum corners) [USE_CAIRO]: New enum. | ||
| 5 | (x_erase_corners_for_relief) [USE_CAIRO]: New function. | ||
| 6 | (x_draw_relief_rect) [USE_CAIRO]: Use it. If box width is larger | ||
| 7 | than 1, draw the outermost line using the black relief. | ||
| 8 | |||
| 1 | 2015-02-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 9 | 2015-02-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | 10 | ||
| 3 | * gtkutil.c (xg_page_setup_dialog, xg_get_page_setup, draw_page) | 11 | * gtkutil.c (xg_page_setup_dialog, xg_get_page_setup, draw_page) |
diff --git a/src/xterm.c b/src/xterm.c index c1970cc4334..99ebaad4715 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -22,6 +22,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 22 | 22 | ||
| 23 | #include <config.h> | 23 | #include <config.h> |
| 24 | #include <stdio.h> | 24 | #include <stdio.h> |
| 25 | #ifdef USE_CAIRO | ||
| 26 | #include <math.h> | ||
| 27 | #endif | ||
| 25 | 28 | ||
| 26 | #include "lisp.h" | 29 | #include "lisp.h" |
| 27 | #include "blockinput.h" | 30 | #include "blockinput.h" |
| @@ -824,6 +827,48 @@ x_fill_trapezoid_for_relief (struct frame *f, GC gc, int x, int y, | |||
| 824 | x_end_cr_clip (f); | 827 | x_end_cr_clip (f); |
| 825 | } | 828 | } |
| 826 | 829 | ||
| 830 | enum corners | ||
| 831 | { | ||
| 832 | CORNER_BOTTOM_RIGHT, /* 0 -> pi/2 */ | ||
| 833 | CORNER_BOTTOM_LEFT, /* pi/2 -> pi */ | ||
| 834 | CORNER_TOP_LEFT, /* pi -> 3pi/2 */ | ||
| 835 | CORNER_TOP_RIGHT, /* 3pi/2 -> 2pi */ | ||
| 836 | CORNER_LAST | ||
| 837 | }; | ||
| 838 | |||
| 839 | static void | ||
| 840 | x_erase_corners_for_relief (struct frame *f, GC gc, int x, int y, | ||
| 841 | int width, int height, | ||
| 842 | double radius, double margin, int corners) | ||
| 843 | { | ||
| 844 | cairo_t *cr; | ||
| 845 | int i; | ||
| 846 | |||
| 847 | cr = x_begin_cr_clip (f, gc); | ||
| 848 | x_set_cr_source_with_gc_background (f, gc); | ||
| 849 | for (i = 0; i < CORNER_LAST; i++) | ||
| 850 | if (corners & (1 << i)) | ||
| 851 | { | ||
| 852 | double xm, ym, xc, yc; | ||
| 853 | |||
| 854 | if (i == CORNER_TOP_LEFT || i == CORNER_BOTTOM_LEFT) | ||
| 855 | xm = x - margin, xc = xm + radius; | ||
| 856 | else | ||
| 857 | xm = x + width + margin, xc = xm - radius; | ||
| 858 | if (i == CORNER_TOP_LEFT || i == CORNER_TOP_RIGHT) | ||
| 859 | ym = y - margin, yc = ym + radius; | ||
| 860 | else | ||
| 861 | ym = y + height + margin, yc = ym - radius; | ||
| 862 | |||
| 863 | cairo_move_to (cr, xm, ym); | ||
| 864 | cairo_arc (cr, xc, yc, radius, i * M_PI_2, (i + 1) * M_PI_2); | ||
| 865 | } | ||
| 866 | cairo_clip (cr); | ||
| 867 | cairo_rectangle (cr, x, y, width, height); | ||
| 868 | cairo_fill (cr); | ||
| 869 | x_end_cr_clip (f); | ||
| 870 | } | ||
| 871 | |||
| 827 | static void | 872 | static void |
| 828 | x_draw_horizontal_wave (struct frame *f, GC gc, int x, int y, | 873 | x_draw_horizontal_wave (struct frame *f, GC gc, int x, int y, |
| 829 | int width, int height, int wave_length) | 874 | int width, int height, int wave_length) |
| @@ -2505,6 +2550,7 @@ x_draw_relief_rect (struct frame *f, | |||
| 2505 | { | 2550 | { |
| 2506 | #ifdef USE_CAIRO | 2551 | #ifdef USE_CAIRO |
| 2507 | GC top_left_gc, bottom_right_gc; | 2552 | GC top_left_gc, bottom_right_gc; |
| 2553 | int corners = 0; | ||
| 2508 | 2554 | ||
| 2509 | if (raised_p) | 2555 | if (raised_p) |
| 2510 | { | 2556 | { |
| @@ -2521,11 +2567,23 @@ x_draw_relief_rect (struct frame *f, | |||
| 2521 | x_set_clip_rectangles (f, bottom_right_gc, clip_rect, 1); | 2567 | x_set_clip_rectangles (f, bottom_right_gc, clip_rect, 1); |
| 2522 | 2568 | ||
| 2523 | if (left_p) | 2569 | if (left_p) |
| 2524 | x_fill_rectangle (f, top_left_gc, left_x, top_y, | 2570 | { |
| 2525 | width, bottom_y + 1 - top_y); | 2571 | x_fill_rectangle (f, top_left_gc, left_x, top_y, |
| 2572 | width, bottom_y + 1 - top_y); | ||
| 2573 | if (top_p) | ||
| 2574 | corners |= 1 << CORNER_TOP_LEFT; | ||
| 2575 | if (bot_p) | ||
| 2576 | corners |= 1 << CORNER_BOTTOM_LEFT; | ||
| 2577 | } | ||
| 2526 | if (right_p) | 2578 | if (right_p) |
| 2527 | x_fill_rectangle (f, bottom_right_gc, right_x + 1 - width, top_y, | 2579 | { |
| 2528 | width, bottom_y + 1 - top_y); | 2580 | x_fill_rectangle (f, bottom_right_gc, right_x + 1 - width, top_y, |
| 2581 | width, bottom_y + 1 - top_y); | ||
| 2582 | if (top_p) | ||
| 2583 | corners |= 1 << CORNER_TOP_RIGHT; | ||
| 2584 | if (bot_p) | ||
| 2585 | corners |= 1 << CORNER_BOTTOM_RIGHT; | ||
| 2586 | } | ||
| 2529 | if (top_p) | 2587 | if (top_p) |
| 2530 | { | 2588 | { |
| 2531 | if (!right_p) | 2589 | if (!right_p) |
| @@ -2545,6 +2603,20 @@ x_draw_relief_rect (struct frame *f, | |||
| 2545 | left_x, bottom_y + 1 - width, | 2603 | left_x, bottom_y + 1 - width, |
| 2546 | right_x + 1 - left_x, width, 0); | 2604 | right_x + 1 - left_x, width, 0); |
| 2547 | } | 2605 | } |
| 2606 | if (left_p && width != 1) | ||
| 2607 | x_fill_rectangle (f, bottom_right_gc, left_x, top_y, | ||
| 2608 | 1, bottom_y + 1 - top_y); | ||
| 2609 | if (top_p && width != 1) | ||
| 2610 | x_fill_rectangle (f, bottom_right_gc, left_x, top_y, | ||
| 2611 | right_x + 1 - left_x, 1); | ||
| 2612 | if (corners) | ||
| 2613 | { | ||
| 2614 | XSetBackground (FRAME_X_DISPLAY (f), top_left_gc, | ||
| 2615 | FRAME_BACKGROUND_PIXEL (f)); | ||
| 2616 | x_erase_corners_for_relief (f, top_left_gc, left_x, top_y, | ||
| 2617 | right_x - left_x + 1, bottom_y - top_y + 1, | ||
| 2618 | 6, 1, corners); | ||
| 2619 | } | ||
| 2548 | 2620 | ||
| 2549 | x_reset_clip_rectangles (f, top_left_gc); | 2621 | x_reset_clip_rectangles (f, top_left_gc); |
| 2550 | x_reset_clip_rectangles (f, bottom_right_gc); | 2622 | x_reset_clip_rectangles (f, bottom_right_gc); |