summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-19 17:58:03 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-19 17:58:03 -0300
commit50986087676afb8ca2daaff2aa6db3ecb6019786 (patch)
tree3b733c53f6bdfad7a9cb085c221449b23f7caa38 /gui
parente75e4a5829fb252c15d0bc75f5703975080655f6 (diff)
downloadeeshow-50986087676afb8ca2daaff2aa6db3ecb6019786.tar.gz
eeshow-50986087676afb8ca2daaff2aa6db3ecb6019786.tar.bz2
eeshow-50986087676afb8ca2daaff2aa6db3ecb6019786.zip
eeshow/gui/: sel_split to select 2nd version; sel_only doesn't set old_hist
Diffstat (limited to 'gui')
-rw-r--r--gui/common.h1
-rw-r--r--gui/history.c28
-rw-r--r--gui/sheet.c33
3 files changed, 41 insertions, 21 deletions
diff --git a/gui/common.h b/gui/common.h
index 0d35814..bfe2f3e 100644
--- a/gui/common.h
+++ b/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/gui/history.c b/gui/history.c
index 3c62975..8a2b117 100644
--- a/gui/history.c
+++ b/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/gui/sheet.c b/gui/sheet.c
index 111756b..1baf3ac 100644
--- a/gui/sheet.c
+++ b/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, "&#916;");
+}
+
+
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, "&#916;");
+ 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);
}
}