mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 21:01:31 +02:00
eeshow/gui-over.c (overlay_draw): use Pango
This commit is contained in:
parent
3b5daecbd6
commit
45726be08f
@ -23,6 +23,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <cairo/cairo.h>
|
#include <cairo/cairo.h>
|
||||||
|
#include <pango/pangocairo.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "gui-aoi.h"
|
#include "gui-aoi.h"
|
||||||
@ -66,14 +67,21 @@ static void rrect(cairo_t *cr, int x, int y, int w, int h, int r)
|
|||||||
|
|
||||||
struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y)
|
struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y)
|
||||||
{
|
{
|
||||||
cairo_text_extents_t ext;
|
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
cairo_set_font_size(cr, OVER_FONT_SIZE);
|
PangoLayout *layout;
|
||||||
cairo_text_extents(cr, over->s, &ext);
|
PangoFontDescription *desc;
|
||||||
|
PangoRectangle ink_rect;
|
||||||
|
|
||||||
w = ext.width + 2 * OVER_BORDER;
|
layout = pango_cairo_create_layout(cr);
|
||||||
h = ext.height + 2 * OVER_BORDER;
|
pango_layout_set_text(layout, over->s, -1);
|
||||||
|
desc = pango_font_description_from_string("Helvetica Bold 12");
|
||||||
|
pango_layout_set_font_description(layout, desc);
|
||||||
|
pango_font_description_free(desc);
|
||||||
|
|
||||||
|
pango_layout_get_extents(layout, &ink_rect, NULL);
|
||||||
|
w = ink_rect.width / PANGO_SCALE + 2 * OVER_BORDER;
|
||||||
|
h = ink_rect.height / PANGO_SCALE + 2 * OVER_BORDER;
|
||||||
|
|
||||||
rrect(cr, *x, *y, w, h, OVER_RADIUS);
|
rrect(cr, *x, *y, w, h, OVER_RADIUS);
|
||||||
|
|
||||||
@ -84,8 +92,11 @@ struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y)
|
|||||||
cairo_stroke(cr);
|
cairo_stroke(cr);
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0, 0, 0);
|
cairo_set_source_rgb(cr, 0, 0, 0);
|
||||||
cairo_move_to(cr, *x + OVER_BORDER, *y + OVER_BORDER + ext.height);
|
cairo_move_to(cr, *x - ink_rect.x / PANGO_SCALE + OVER_BORDER,
|
||||||
cairo_show_text(cr, over->s);
|
*y - ink_rect.y / PANGO_SCALE + OVER_BORDER + 0*ink_rect.height);
|
||||||
|
|
||||||
|
pango_cairo_update_layout(cr, layout);
|
||||||
|
pango_cairo_show_layout(cr, layout);
|
||||||
|
|
||||||
if (over->hover || over->click) {
|
if (over->hover || over->click) {
|
||||||
struct aoi aoi = {
|
struct aoi aoi = {
|
||||||
|
Loading…
Reference in New Issue
Block a user