mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 01:32:49 +02:00
eeshow/: move sheet overlays to right screen edge; move history left
This commit is contained in:
parent
c908e4de0e
commit
56e36b7e9d
@ -16,6 +16,9 @@
|
|||||||
* http://zetcode.com/gfx/cairo/cairobackends/
|
* http://zetcode.com/gfx/cairo/cairobackends/
|
||||||
* https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
|
* https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
|
||||||
* https://www.cairographics.org/samples/rounded_rectangle/
|
* https://www.cairographics.org/samples/rounded_rectangle/
|
||||||
|
*
|
||||||
|
* Section "Description" in
|
||||||
|
* https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -33,12 +36,9 @@
|
|||||||
#include "gui-over.h"
|
#include "gui-over.h"
|
||||||
|
|
||||||
|
|
||||||
#define OVER_FONT_SIZE 16
|
|
||||||
#define OVER_BORDER 8
|
#define OVER_BORDER 8
|
||||||
#define OVER_RADIUS 6
|
#define OVER_RADIUS 6
|
||||||
#define OVER_SEP 8
|
#define OVER_SEP 8
|
||||||
#define OVER_X0 10
|
|
||||||
#define OVER_Y0 10
|
|
||||||
|
|
||||||
|
|
||||||
struct overlay {
|
struct overlay {
|
||||||
@ -111,8 +111,10 @@ struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y)
|
|||||||
const double *fg = style->fg;
|
const double *fg = style->fg;
|
||||||
const double *bg = style->bg;
|
const double *bg = style->bg;
|
||||||
const double *frame = style->frame;
|
const double *frame = style->frame;
|
||||||
unsigned ink_w, ink_h, w, h;
|
unsigned ink_w, ink_h; /* effectively used text area size */
|
||||||
int tx, ty;
|
unsigned w, h; /* box size */
|
||||||
|
int tx, ty; /* text start position */
|
||||||
|
int sx, sy; /* box start position */
|
||||||
|
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
@ -138,10 +140,25 @@ fprintf(stderr, "%d + %d %d + %d\n",
|
|||||||
w = ink_w + 2 * style->pad;
|
w = ink_w + 2 * style->pad;
|
||||||
h = ink_h + 2 * style->pad;
|
h = ink_h + 2 * style->pad;
|
||||||
|
|
||||||
tx = *x - ink_rect.x / PANGO_SCALE + style->pad;
|
sx = *x;
|
||||||
ty = *y - ink_rect.y / PANGO_SCALE + style->pad;
|
sy = *y;
|
||||||
|
if (sx < 0 || sy < 0) {
|
||||||
|
double x1, y1, x2, y2;
|
||||||
|
int sw, sh;
|
||||||
|
|
||||||
rrect(cr, *x, *y, w, h, style->radius);
|
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
|
||||||
|
sw = x2 - x1;
|
||||||
|
sh = y2 - y1;
|
||||||
|
if (sx < 0)
|
||||||
|
sx = sw + sx - w;
|
||||||
|
if (sy < 0)
|
||||||
|
sy = sh + sy - h;
|
||||||
|
}
|
||||||
|
|
||||||
|
tx = sx - ink_rect.x / PANGO_SCALE + style->pad;
|
||||||
|
ty = sy - ink_rect.y / PANGO_SCALE + style->pad;
|
||||||
|
|
||||||
|
rrect(cr, sx, sy, w, h, style->radius);
|
||||||
|
|
||||||
cairo_set_source_rgba(cr, bg[0], bg[1], bg[2], bg[3]);
|
cairo_set_source_rgba(cr, bg[0], bg[1], bg[2], bg[3]);
|
||||||
cairo_fill_preserve(cr);
|
cairo_fill_preserve(cr);
|
||||||
@ -180,8 +197,8 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->
|
|||||||
|
|
||||||
if (over->hover || over->click) {
|
if (over->hover || over->click) {
|
||||||
struct aoi aoi_cfg = {
|
struct aoi aoi_cfg = {
|
||||||
.x = *x,
|
.x = sx,
|
||||||
.y = *y,
|
.y = sy,
|
||||||
.w = w,
|
.w = w,
|
||||||
.h = h,
|
.h = h,
|
||||||
.hover = over->hover,
|
.hover = over->hover,
|
||||||
@ -195,17 +212,18 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->
|
|||||||
over->aoi = aoi_add(over->aois, &aoi_cfg);
|
over->aoi = aoi_add(over->aois, &aoi_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
*y += h + style->skip;
|
if (*y >= 0)
|
||||||
|
*y += h + style->skip;
|
||||||
|
else
|
||||||
|
*y -= h + style->skip;
|
||||||
|
|
||||||
return over->next;
|
return over->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void overlay_draw_all(struct overlay *overlays, cairo_t *cr)
|
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y)
|
||||||
{
|
{
|
||||||
struct overlay *over;
|
struct overlay *over;
|
||||||
int x = OVER_X0;
|
|
||||||
int y = OVER_Y0;
|
|
||||||
|
|
||||||
for (over = overlays; over; over = over->next)
|
for (over = overlays; over; over = over->next)
|
||||||
overlay_draw(over, cr, &x, &y);
|
overlay_draw(over, cr, &x, &y);
|
||||||
|
@ -41,7 +41,7 @@ extern struct overlay_style overlay_style_dense;
|
|||||||
extern struct overlay_style overlay_style_dense_selected;
|
extern struct overlay_style overlay_style_dense_selected;
|
||||||
|
|
||||||
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);
|
||||||
void overlay_draw_all(struct overlay *overlays, cairo_t *cr);
|
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y);
|
||||||
struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
||||||
bool (*hover)(void *user, bool on), void (*click)(void *user), void *user);
|
bool (*hover)(void *user, bool on), void (*click)(void *user), void *user);
|
||||||
void overlay_text_raw(struct overlay *over, const char *s);
|
void overlay_text_raw(struct overlay *over, const char *s);
|
||||||
|
18
eeshow/gui.c
18
eeshow/gui.c
@ -99,15 +99,11 @@ static void redraw(const struct gui_ctx *ctx)
|
|||||||
/* ----- Rendering --------------------------------------------------------- */
|
/* ----- Rendering --------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
static void draw_vcs_overlays(const struct gui_ctx *ctx, cairo_t *cr)
|
#define VCS_OVERLAYS_X 5
|
||||||
{
|
#define VCS_OVERLAYS_Y 5
|
||||||
struct overlay *over;
|
|
||||||
int x = 200;
|
|
||||||
int y = 5;
|
|
||||||
|
|
||||||
for (over = ctx->vcs_overlays; over;)
|
#define SHEET_OVERLAYS_X -10
|
||||||
over = overlay_draw(over, cr, &x, &y);
|
#define SHEET_OVERLAYS_Y 10
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
|
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
|
||||||
@ -125,8 +121,10 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
|
|||||||
y = -(sheet->ymin + ctx->y) * f + alloc.height / 2;
|
y = -(sheet->ymin + ctx->y) * f + alloc.height / 2;
|
||||||
cro_canvas_draw(sheet->gfx_ctx, cr, x, y, f);
|
cro_canvas_draw(sheet->gfx_ctx, cr, x, y, f);
|
||||||
|
|
||||||
overlay_draw_all(ctx->sheet_overlays, cr);
|
overlay_draw_all(ctx->sheet_overlays, cr,
|
||||||
draw_vcs_overlays(ctx, cr);
|
SHEET_OVERLAYS_X, SHEET_OVERLAYS_Y);
|
||||||
|
overlay_draw_all(ctx->vcs_overlays, cr,
|
||||||
|
VCS_OVERLAYS_X, VCS_OVERLAYS_Y);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user