summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-10 20:41:33 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-10 20:41:33 -0300
commit5c35e1a30a1d6a541f037541ca9bc56e198762f9 (patch)
treefb06f0354691708a96965c296d1015a1b99ce5d6
parent6461152e588b4740ff896280bcf1d461af546f10 (diff)
downloadeeshow-5c35e1a30a1d6a541f037541ca9bc56e198762f9.tar.gz
eeshow-5c35e1a30a1d6a541f037541ca9bc56e198762f9.tar.bz2
eeshow-5c35e1a30a1d6a541f037541ca9bc56e198762f9.zip
eeshow/gui.c: show sheet number on hover
-rw-r--r--TODO3
-rw-r--r--gui.c55
2 files changed, 41 insertions, 17 deletions
diff --git a/TODO b/TODO
index 123de40..7ca755b 100644
--- a/TODO
+++ b/TODO
@@ -42,6 +42,8 @@ GUI:
will help ?
- glabels: on hover, show clickable list of sheets where else label is used
- highlight nets ?
+- we use find_corresponding_sheet way too often. Consider changing curr_sheet
+ to new_sheet and old_sheet.
GUI/history
- revision selection is still a bit inconvenient and lacks quick way for
@@ -56,6 +58,5 @@ GUI/history
is not very clear.
GUI/sheets:
-- show sheet number (e.g., on hover)
- need a way to change new/old sheet association, in case automatic selection
fails (reserved hotkeys: Left/Rigth)
diff --git a/gui.c b/gui.c
index 9e867be..09f76b7 100644
--- a/gui.c
+++ b/gui.c
@@ -45,7 +45,7 @@ struct gui_ctx;
struct gui_sheet {
const struct sheet *sch;
- struct gui_ctx *ctx; /* back link */
+ struct gui_ctx *ctx; /* back link */
struct cro_ctx *gfx_ctx;
int w, h; /* in eeschema coordinates */
@@ -53,22 +53,23 @@ struct gui_sheet {
bool rendered; /* 0 if still have to render it */
+ struct overlay *over; /* current overlay */
struct aoi *aois; /* areas of interest; in schematics coord */
struct gui_sheet *next;
};
struct gui_hist {
- struct gui_ctx *ctx; /* back link */
- struct hist *vcs_hist; /* NULL if not from repo */
- struct overlay *over; /* current overlay */
- struct gui_sheet *sheets; /* NULL if failed */
- unsigned age; /* 0-based; uncommitted or HEAD = 0 */
+ struct gui_ctx *ctx; /* back link */
+ struct hist *vcs_hist; /* NULL if not from repo */
+ struct overlay *over; /* current overlay */
+ struct gui_sheet *sheets; /* NULL if failed */
+ unsigned age; /* 0-based; uncommitted or HEAD = 0 */
/* caching support */
- void **oids; /* file object IDs */
+ void **oids; /* file object IDs */
struct sch_ctx sch_ctx;
- struct lib lib; /* combined library */
+ struct lib lib; /* combined library */
struct gui_hist *next;
};
@@ -562,6 +563,33 @@ static void close_subsheet(void *user)
}
+static bool hover_sheet(void *user, bool on)
+{
+ struct gui_sheet *sheet = user;
+ struct gui_ctx *ctx = sheet->ctx;
+ const char *title = sheet->sch->title;
+
+ if (!title)
+ title = "(unnamed)";
+ if (on) {
+ const struct gui_sheet *s;
+ int n = 0, this = -1;
+
+ for (s = ctx->new_hist->sheets; s; s = s->next) {
+ n++;
+ if (s == sheet)
+ this = n;
+ }
+ overlay_text(sheet->over, "<b>%s</b>\n<big>%d / %d</big>",
+ title, this, n);
+ } else {
+ overlay_text(sheet->over, "<b>%s</b>", title);
+ }
+ redraw(ctx);
+ return 1;
+}
+
+
static bool show_history_details(void *user, bool on)
{
struct gui_hist *h = user;
@@ -631,18 +659,13 @@ static struct gui_sheet *find_parent_sheet(struct gui_sheet *sheets,
static void sheet_selector_recurse(struct gui_ctx *ctx, struct gui_sheet *sheet)
{
struct gui_sheet *parent;
- const char *title;
- struct overlay *over;
parent = find_parent_sheet(ctx->new_hist->sheets, sheet);
if (parent)
sheet_selector_recurse(ctx, parent);
- title = sheet->sch->title;
- if (!title)
- title = "(unnamed)";
- over = overlay_add(&ctx->sheet_overlays, &ctx->aois,
- NULL, close_subsheet, sheet);
- overlay_text(over, "<b>%s</b>", title);
+ sheet->over = overlay_add(&ctx->sheet_overlays, &ctx->aois,
+ hover_sheet, close_subsheet, sheet);
+ hover_sheet(sheet, 0);
}