diff --git a/eeshow/gui/common.h b/eeshow/gui/common.h index 0d35814..bfe2f3e 100644 --- a/eeshow/gui/common.h +++ b/eeshow/gui/common.h @@ -72,6 +72,7 @@ struct gui_ctx { bool showing_history; enum selecting { sel_only, /* select the only revision we show */ + sel_split, /* select revision to compare with */ sel_new, /* select the new revision */ sel_old, /* select the old revision */ } selecting; diff --git a/eeshow/gui/history.c b/eeshow/gui/history.c index 3c62975..8a2b117 100644 --- a/eeshow/gui/history.c +++ b/eeshow/gui/history.c @@ -49,6 +49,7 @@ static void set_history_style(struct gui_hist *h, bool current) switch (ctx->selecting) { case sel_only: + case sel_split: style.frame = COLOR(FRAME_SEL_ONLY); break; case sel_old: @@ -120,6 +121,9 @@ static void click_history(void *user) switch (ctx->selecting) { case sel_only: + ctx->new_hist = h; + break; + case sel_split: ctx->old_hist = ctx->new_hist; ctx->new_hist = h; break; @@ -135,19 +139,21 @@ static void click_history(void *user) ctx->diff_mode = diff_delta; - if (ctx->new_hist->age > ctx->old_hist->age) { - swap(ctx->new_hist, ctx->old_hist); - if (ctx->selecting == sel_old) { - go_to_sheet(ctx, sheet); + if (ctx->old_hist) { + if (ctx->new_hist->age > ctx->old_hist->age) { + swap(ctx->new_hist, ctx->old_hist); + if (ctx->selecting == sel_old) { + go_to_sheet(ctx, sheet); + } else { + go_to_sheet(ctx, old_sheet); + render_delta(ctx); + } } else { - go_to_sheet(ctx, old_sheet); - render_delta(ctx); + if (ctx->selecting != sel_old) + go_to_sheet(ctx, sheet); + else + render_delta(ctx); } - } else { - if (ctx->selecting != sel_old) - go_to_sheet(ctx, sheet); - else - render_delta(ctx); } if (ctx->old_hist == ctx->new_hist) diff --git a/eeshow/gui/sheet.c b/eeshow/gui/sheet.c index 111756b..1baf3ac 100644 --- a/eeshow/gui/sheet.c +++ b/eeshow/gui/sheet.c @@ -173,8 +173,11 @@ static void show_diff_cb(void *user) { struct gui_ctx *ctx = user; - set_diff_mode(ctx, - ctx->diff_mode == diff_delta ? diff_new : diff_delta); + if (ctx->old_hist) + set_diff_mode(ctx, + ctx->diff_mode == diff_delta ? diff_new : diff_delta); + else + show_history(ctx, sel_split); } @@ -184,11 +187,25 @@ static void toggle_old_new(struct gui_ctx *ctx) } +static void add_delta(struct gui_ctx *ctx) +{ + struct overlay *over; + struct overlay_style style; + + over = overlay_add(&ctx->hist_overlays, &ctx->aois, + NULL, show_diff_cb, ctx); + style = overlay_style_default; + if (ctx->old_hist && ctx->diff_mode == diff_delta) + style.frame = RGBA(0, 0, 0, 1); + overlay_style(over, &style); + overlay_text(over, "Δ"); +} + + static void revision_overlays_diff(struct gui_ctx *ctx) { struct gui_hist *new = ctx->new_hist; struct gui_hist *old = ctx->old_hist; - struct overlay *over; struct overlay_style style; new->over = overlay_add(&ctx->hist_overlays, &ctx->aois, @@ -199,13 +216,7 @@ static void revision_overlays_diff(struct gui_ctx *ctx) overlay_style(new->over, &style); show_history_details(new, 0); - over = overlay_add(&ctx->hist_overlays, &ctx->aois, - NULL, show_diff_cb, ctx); - style = overlay_style_default; - if (ctx->diff_mode == diff_delta) - style.frame = RGBA(0, 0, 0, 1); - overlay_style(over, &style); - overlay_text(over, "Δ"); + add_delta(ctx); old->over = overlay_add(&ctx->hist_overlays, &ctx->aois, show_history_details, show_history_cb, old); @@ -229,6 +240,8 @@ void do_revision_overlays(struct gui_ctx *ctx) ctx->new_hist); overlay_style(ctx->new_hist->over, &overlay_style_default); show_history_details(ctx->new_hist, 0); + + add_delta(ctx); } }