mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-17 20:04:05 +02:00
eeshow/gui/: highlight glabels
This commit is contained in:
parent
b4df01a28d
commit
6ff7d63312
@ -65,6 +65,5 @@ GUI/sheets:
|
||||
GUI/glabels:
|
||||
- maybe indicate how many times label is used on each sheet
|
||||
- maybe indicate how it is used
|
||||
- highlight occurrences of label on current sheet
|
||||
- also highlight after jumping
|
||||
- there can be "hanging" pop-ups, see comment in gui/glabel.c:hover_glabel
|
||||
- should there be a way to remove glabel highlighing ?
|
||||
|
@ -84,6 +84,7 @@ struct gui_ctx {
|
||||
int pop_x, pop_y;
|
||||
int pop_dx, pop_dy;
|
||||
const void *pop_origin; /* item that created this pop-up */
|
||||
const char *glabel; /* currenly highlighted glabel, or NULL */
|
||||
|
||||
struct aoi *aois; /* areas of interest; in canvas coord */
|
||||
|
||||
|
@ -201,12 +201,12 @@ static bool hover_glabel(void *user, bool on)
|
||||
dehover_glabel(ctx);
|
||||
}
|
||||
|
||||
|
||||
GtkAllocation alloc;
|
||||
int sx, sy, ex, ey, mx, my;
|
||||
unsigned n = 0;
|
||||
struct gui_sheet *sheet;
|
||||
|
||||
ctx->glabel = aoi_ctx->obj->u.text.s;
|
||||
ctx->pop_origin = aoi_ctx;
|
||||
|
||||
aoi_dehover();
|
||||
|
@ -375,6 +375,8 @@ int gui(unsigned n_args, char **args, bool recurse, int limit)
|
||||
.hist_overlays = NULL,
|
||||
.pop_overlays = NULL,
|
||||
.pop_underlays = NULL,
|
||||
.pop_origin = NULL,
|
||||
.glabel = NULL,
|
||||
.aois = NULL,
|
||||
.old_hist = NULL,
|
||||
.hist_y_offset = 0,
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
#include <gtk/gtk.h>
|
||||
@ -33,6 +34,8 @@
|
||||
#define SHEET_OVERLAYS_X -10
|
||||
#define SHEET_OVERLAYS_Y 10
|
||||
|
||||
#define GLABEL_HIGHLIGHT_PAD 6
|
||||
|
||||
|
||||
/* ----- Helper functions -------------------------------------------------- */
|
||||
|
||||
@ -43,6 +46,59 @@ void redraw(const struct gui_ctx *ctx)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Highlight glabel -------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* cd, cx, cy are simplified versions of what cro.c uses. Since we don't
|
||||
* support glabel highlighting in diff mode, we don't need the xe and ye offset
|
||||
* components.
|
||||
*/
|
||||
|
||||
static inline int cd(int x, float scale)
|
||||
{
|
||||
return x * scale;
|
||||
}
|
||||
|
||||
static inline int cx(int x, int xo, float scale)
|
||||
{
|
||||
return xo + x * scale;
|
||||
}
|
||||
|
||||
|
||||
static inline int cy(int y, int yo, float scale)
|
||||
{
|
||||
return yo + y * scale;
|
||||
}
|
||||
|
||||
|
||||
static void highlight_glabel(const struct gui_ctx *ctx, cairo_t *cr,
|
||||
int x, int y, float f)
|
||||
{
|
||||
const struct sch_obj *obj;
|
||||
|
||||
if (!ctx->glabel)
|
||||
return;
|
||||
|
||||
for (obj = ctx->curr_sheet->sch->objs; obj; obj = obj->next) {
|
||||
const struct dwg_bbox *bbox = &obj->u.text.bbox;
|
||||
|
||||
if (obj->type != sch_obj_glabel)
|
||||
continue;
|
||||
if (strcmp(obj->u.text.s, ctx->glabel))
|
||||
continue;
|
||||
|
||||
cairo_rectangle(cr,
|
||||
cx(bbox->x, x, f) - GLABEL_HIGHLIGHT_PAD,
|
||||
cy(bbox->y, y, f) - GLABEL_HIGHLIGHT_PAD,
|
||||
cd(bbox->w, f) + 2 * GLABEL_HIGHLIGHT_PAD,
|
||||
cd(bbox->h, f) + 2 * GLABEL_HIGHLIGHT_PAD);
|
||||
cairo_set_source_rgb(cr, 1, 0.8, 1);
|
||||
cairo_fill(cr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----- Draw to screen ---------------------------------------------------- */
|
||||
|
||||
|
||||
@ -72,6 +128,7 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
|
||||
|
||||
cro_canvas_prepare(cr);
|
||||
if (!ctx->old_hist) {
|
||||
highlight_glabel(ctx, cr, x, y, f);
|
||||
cro_canvas_draw(sheet->gfx_ctx, cr, x, y, f);
|
||||
} else {
|
||||
#if 0
|
||||
|
Loading…
Reference in New Issue
Block a user