mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-23 08:15:31 +02:00
eeshow/gui.c: proof-of-concept implementation of jumping by glabel
What's still missing: - don't require click to dehover - help to find glabel on destination sheet - help with finding glabel on current sheet - avoid darkened overlap - maybe indicate in/out/bidir/passive
This commit is contained in:
parent
cfa25b4b4c
commit
f5c908c36f
99
eeshow/gui.c
99
eeshow/gui.c
@ -22,6 +22,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
@ -694,6 +695,7 @@ static void do_sheet_overlays(struct gui_ctx *ctx)
|
||||
static void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet)
|
||||
{
|
||||
aoi_dehover();
|
||||
overlay_remove_all(&ctx->pop_overlays);
|
||||
if (!sheet->rendered) {
|
||||
render_sheet(sheet);
|
||||
mark_aois(ctx, sheet);
|
||||
@ -784,6 +786,8 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
|
||||
break;
|
||||
if (ctx->showing_history)
|
||||
hide_history(ctx);
|
||||
overlay_remove_all(&ctx->pop_overlays);
|
||||
redraw(ctx);
|
||||
break;
|
||||
case 2:
|
||||
pan_begin(ctx, event->x, event->y);
|
||||
@ -934,6 +938,14 @@ struct glabel_aoi_ctx {
|
||||
#define CHEAT 1
|
||||
|
||||
|
||||
static void glabel_dest_click(void *user)
|
||||
{
|
||||
struct gui_sheet *sheet = user;
|
||||
|
||||
go_to_sheet(sheet->ctx, sheet);
|
||||
}
|
||||
|
||||
|
||||
static bool hover_glabel(void *user, bool on)
|
||||
{
|
||||
struct glabel_aoi_ctx *aoi_ctx = user;
|
||||
@ -941,39 +953,66 @@ static bool hover_glabel(void *user, bool on)
|
||||
const struct gui_sheet *curr_sheet = ctx->curr_sheet;
|
||||
const struct dwg_bbox *bbox = &aoi_ctx->bbox;
|
||||
|
||||
if (on) {
|
||||
GtkAllocation alloc;
|
||||
struct overlay_style style = overlay_style_default;
|
||||
int sx, sy, ex, ey, mx, my;
|
||||
|
||||
aoi_ctx->over = overlay_add(&ctx->pop_overlays, NULL,// aois
|
||||
NULL, NULL, NULL);
|
||||
overlay_text_raw(aoi_ctx->over, aoi_ctx->obj->u.text.s);
|
||||
|
||||
style.radius = 0;
|
||||
style.bg = RGBA(1.0, 0.8, 0.4, 0.8);
|
||||
style.frame = RGBA(0.6, 0.0, 0.2, 0.8);
|
||||
|
||||
overlay_style(aoi_ctx->over, &style);
|
||||
|
||||
eeschema_coord(ctx,
|
||||
bbox->x - curr_sheet->xmin, bbox->y - curr_sheet->ymin,
|
||||
&sx, &sy);
|
||||
eeschema_coord(ctx, bbox->x + bbox->w - curr_sheet->xmin,
|
||||
bbox->y + bbox->h - curr_sheet->ymin, &ex, &ey);
|
||||
|
||||
gtk_widget_get_allocation(ctx->da, &alloc);
|
||||
mx = (sx + ex) / 2;
|
||||
my = (sy + ey) / 2;
|
||||
ctx->pop_x = mx < alloc.width / 2 ?
|
||||
sx - CHEAT : -(alloc.width - ex) + CHEAT;
|
||||
ctx->pop_y = my < alloc.height / 2 ?
|
||||
sy - CHEAT : -(alloc.height - ey) + CHEAT;
|
||||
} else {
|
||||
if (!on) {
|
||||
overlay_remove(&ctx->pop_overlays, aoi_ctx->over);
|
||||
redraw(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
GtkAllocation alloc;
|
||||
struct overlay_style style = {
|
||||
.font = BOLD_FONT,
|
||||
.wmin = 100,
|
||||
.wmax = 100,
|
||||
.radius = 0,
|
||||
.pad = 4,
|
||||
.skip = -4,
|
||||
.fg = { 0.0, 0.0, 0.0, 1.0 },
|
||||
.bg = { 1.0, 0.8, 0.4, 0.8 },
|
||||
.frame = { 1.0, 1.0, 1.0, 1.0 }, /* debugging */
|
||||
.width = 0,
|
||||
};
|
||||
int sx, sy, ex, ey, mx, my;
|
||||
unsigned n = 0;
|
||||
struct gui_sheet *sheet;
|
||||
const struct sch_obj *obj;
|
||||
struct overlay *over;
|
||||
|
||||
aoi_dehover();
|
||||
overlay_remove_all(&ctx->pop_overlays);
|
||||
for (sheet = ctx->new_hist->sheets; sheet; sheet = sheet->next) {
|
||||
n++;
|
||||
for (obj = sheet->sch->objs; obj; obj = obj->next) {
|
||||
if (sheet == curr_sheet)
|
||||
continue;
|
||||
if (obj->type != sch_obj_glabel)
|
||||
continue;
|
||||
if (strcmp(obj->u.text.s, aoi_ctx->obj->u.text.s))
|
||||
continue;
|
||||
over = overlay_add(&ctx->pop_overlays,
|
||||
&ctx->aois, NULL, glabel_dest_click, sheet);
|
||||
overlay_text(over, "%d %s", n, sheet->sch->title);
|
||||
overlay_style(over, &style);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eeschema_coord(ctx,
|
||||
bbox->x - curr_sheet->xmin, bbox->y - curr_sheet->ymin,
|
||||
&sx, &sy);
|
||||
eeschema_coord(ctx, bbox->x + bbox->w - curr_sheet->xmin,
|
||||
bbox->y + bbox->h - curr_sheet->ymin, &ex, &ey);
|
||||
|
||||
gtk_widget_get_allocation(ctx->da, &alloc);
|
||||
mx = (sx + ex) / 2;
|
||||
my = (sy + ey) / 2;
|
||||
ctx->pop_x = mx < alloc.width / 2 ?
|
||||
sx - CHEAT : -(alloc.width - ex) + CHEAT;
|
||||
ctx->pop_y = my < alloc.height / 2 ?
|
||||
sy - CHEAT : -(alloc.height - ey) + CHEAT;
|
||||
|
||||
redraw(ctx);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user