summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-18 14:32:46 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-18 16:07:33 -0300
commitbf9fb110c93f0b3d93bbe5932975880815cf4ccb (patch)
tree60c1a7fd75a81419a55df0df2146fffaf5697283 /gui
parent10b93cfc5c839937ca79a78724a955039ec6dff2 (diff)
downloadeeshow-bf9fb110c93f0b3d93bbe5932975880815cf4ccb.tar.gz
eeshow-bf9fb110c93f0b3d93bbe5932975880815cf4ccb.tar.bz2
eeshow-bf9fb110c93f0b3d93bbe5932975880815cf4ccb.zip
eeshow/gui/glabel.c (hover_glabel): separate addition of destination overlay
Diffstat (limited to 'gui')
-rw-r--r--gui/glabel.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/gui/glabel.c b/gui/glabel.c
index 4dc37d2..13f520b 100644
--- a/gui/glabel.c
+++ b/gui/glabel.c
@@ -68,19 +68,9 @@ void dehover_glabel(struct gui_ctx *ctx)
}
-static bool hover_glabel(void *user, bool on)
+static void add_dest_overlay(struct gui_ctx *ctx, const char *label,
+ struct gui_sheet *sheet, unsigned n)
{
- struct glabel_aoi_ctx *aoi_ctx = user;
- struct gui_ctx *ctx = aoi_ctx->sheet->ctx;
- const struct gui_sheet *curr_sheet = ctx->curr_sheet;
- const struct dwg_bbox *bbox = &aoi_ctx->bbox;
-
- if (!on) {
- dehover_glabel(ctx);
- return 1;
- }
-
- GtkAllocation alloc;
struct overlay_style style = {
.font = BOLD_FONT,
.wmin = 100,
@@ -93,30 +83,46 @@ static bool hover_glabel(void *user, bool on)
.frame = { 1.0, 1.0, 1.0, 1.0 }, /* debugging */
.width = 0,
};
+ const struct sch_obj *obj;
+ struct overlay *over;
+
+ if (sheet == ctx->curr_sheet)
+ return;
+ for (obj = sheet->sch->objs; obj; obj = obj->next) {
+ if (obj->type != sch_obj_glabel)
+ continue;
+ if (strcmp(obj->u.text.s, label))
+ 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);
+ return;
+ }
+}
+
+
+static bool hover_glabel(void *user, bool on)
+{
+ struct glabel_aoi_ctx *aoi_ctx = user;
+ struct gui_ctx *ctx = aoi_ctx->sheet->ctx;
+ const struct gui_sheet *curr_sheet = ctx->curr_sheet;
+ const struct dwg_bbox *bbox = &aoi_ctx->bbox;
+
+ if (!on) {
+ dehover_glabel(ctx);
+ return 1;
+ }
+
+ GtkAllocation alloc;
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++;
- if (sheet == curr_sheet)
- continue;
- for (obj = sheet->sch->objs; obj; obj = obj->next) {
- 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;
- }
- }
+ for (sheet = ctx->new_hist->sheets; sheet; sheet = sheet->next)
+ add_dest_overlay(ctx, aoi_ctx->obj->u.text.s, sheet, ++n);
eeschema_coord(ctx,
bbox->x - curr_sheet->xmin, bbox->y - curr_sheet->ymin,