1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-19 07:33:44 +02:00

eeshow/gui/sheet.c: clicking on the revision overlays changes diff mode

This commit is contained in:
Werner Almesberger 2016-08-19 07:34:31 -03:00
parent c012addf4a
commit 133a9c8ae3
3 changed files with 26 additions and 12 deletions

View File

@ -47,8 +47,6 @@ GUI:
to new_sheet and old_sheet. to new_sheet and old_sheet.
GUI/history GUI/history
- revision selection is still a bit inconvenient and lacks quick way for
showing un-diffed sheets. Should add "delta" button.
- use Tab to rapidly toggle between old/new sheet - use Tab to rapidly toggle between old/new sheet
- should have quick way to show diff of a single commit - should have quick way to show diff of a single commit
- in history, set font to non-bold if showing details - in history, set font to non-bold if showing details

View File

@ -95,7 +95,7 @@ struct gui_ctx {
struct gui_sheet *curr_sheet; struct gui_sheet *curr_sheet;
/* current sheet, always on new_hist */ /* current sheet, always on new_hist */
enum { enum diff_mode {
diff_new, /* show only new sheet */ diff_new, /* show only new sheet */
diff_old, /* show only old sheet */ diff_old, /* show only old sheet */
diff_delta, /* show delta */ diff_delta, /* show delta */

View File

@ -139,6 +139,14 @@ static bool show_history_details(void *user, bool on)
} }
static void set_diff_mode(struct gui_ctx *ctx, enum diff_mode mode)
{
ctx->diff_mode = mode;
do_revision_overlays(ctx);
redraw(ctx);
}
static void show_history_cb(void *user) static void show_history_cb(void *user)
{ {
struct gui_hist *h = user; struct gui_hist *h = user;
@ -147,13 +155,11 @@ static void show_history_cb(void *user)
if (ctx->old_hist) { if (ctx->old_hist) {
if (h == ctx->new_hist && ctx->diff_mode != diff_new) { if (h == ctx->new_hist && ctx->diff_mode != diff_new) {
ctx->diff_mode = diff_new; set_diff_mode(ctx, diff_new);
redraw(ctx);
return; return;
} }
if (h == ctx->old_hist && ctx->diff_mode != diff_old) { if (h == ctx->old_hist && ctx->diff_mode != diff_old) {
ctx->diff_mode = diff_old; set_diff_mode(ctx, diff_old);
redraw(ctx);
return; return;
} }
sel = h == ctx->new_hist ? sel_new : sel_old; sel = h == ctx->new_hist ? sel_new : sel_old;
@ -166,8 +172,8 @@ static void show_diff_cb(void *user)
{ {
struct gui_ctx *ctx = user; struct gui_ctx *ctx = user;
ctx->diff_mode = diff_delta; set_diff_mode(ctx,
redraw(ctx); ctx->diff_mode == diff_delta ? diff_new : diff_delta);
} }
@ -176,20 +182,30 @@ static void revision_overlays_diff(struct gui_ctx *ctx)
struct gui_hist *new = ctx->new_hist; struct gui_hist *new = ctx->new_hist;
struct gui_hist *old = ctx->old_hist; struct gui_hist *old = ctx->old_hist;
struct overlay *over; struct overlay *over;
struct overlay_style style;
new->over = overlay_add(&ctx->hist_overlays, &ctx->aois, new->over = overlay_add(&ctx->hist_overlays, &ctx->aois,
show_history_details, show_history_cb, new); show_history_details, show_history_cb, new);
overlay_style(new->over, &overlay_style_diff_new); style = overlay_style_diff_new;
if (ctx->diff_mode == diff_new)
style.frame = RGBA(0, 0, 0, 1);
overlay_style(new->over, &style);
show_history_details(new, 0); show_history_details(new, 0);
over = overlay_add(&ctx->hist_overlays, &ctx->aois, over = overlay_add(&ctx->hist_overlays, &ctx->aois,
NULL, show_diff_cb, ctx); NULL, show_diff_cb, ctx);
overlay_style(over, &overlay_style_default); style = overlay_style_default;
if (ctx->diff_mode == diff_delta)
style.frame = RGBA(0, 0, 0, 1);
overlay_style(over, &style);
overlay_text(over, "Δ"); overlay_text(over, "Δ");
old->over = overlay_add(&ctx->hist_overlays, &ctx->aois, old->over = overlay_add(&ctx->hist_overlays, &ctx->aois,
show_history_details, show_history_cb, old); show_history_details, show_history_cb, old);
overlay_style(old->over, &overlay_style_diff_old); style = overlay_style_diff_old;
if (ctx->diff_mode == diff_old)
style.frame = RGBA(0, 0, 0, 1);
overlay_style(old->over, &style);
show_history_details(old, 0); show_history_details(old, 0);
} }