summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-11-20 16:11:08 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-11-20 16:11:08 (GMT)
commit4881285222a520254a25e17c6748f638ffc2782d (patch)
treeaf4a64d448de0c9bfbe9ba1ded36cea520ef81bc /gui
parente90e81202b07f9bf036018e95d7cd1af6a7288ee (diff)
downloadeeshow-4881285222a520254a25e17c6748f638ffc2782d.zip
eeshow-4881285222a520254a25e17c6748f638ffc2782d.tar.gz
eeshow-4881285222a520254a25e17c6748f638ffc2782d.tar.bz2
gui/gui.c (current_sheet): de-duplicate sheet selection logic
Diffstat (limited to 'gui')
-rw-r--r--gui/common.h1
-rw-r--r--gui/gui.c9
-rw-r--r--gui/sheet.c18
3 files changed, 13 insertions, 15 deletions
diff --git a/gui/common.h b/gui/common.h
index efcd1c6..712469c 100644
--- a/gui/common.h
+++ b/gui/common.h
@@ -194,6 +194,7 @@ void show_index(struct gui *gui);
struct gui_sheet *find_corresponding_sheet(struct gui_sheet *pick_from,
struct gui_sheet *ref_in, const struct gui_sheet *ref);
+struct gui_sheet *current_sheet(const struct gui *gui);
void mark_aois(struct gui *gui, struct gui_sheet *sheet);
#endif /* !GUI_COMMON_H */
diff --git a/gui/gui.c b/gui/gui.c
index c5d51a2..19d5eb9 100644
--- a/gui/gui.c
+++ b/gui/gui.c
@@ -74,6 +74,15 @@ struct gui_sheet *find_corresponding_sheet(struct gui_sheet *pick_from,
}
+struct gui_sheet *current_sheet(const struct gui *gui)
+{
+ if (!gui->old_hist || gui->diff_mode != diff_old)
+ return gui->curr_sheet;
+ return find_corresponding_sheet(gui->old_hist->sheets,
+ gui->new_hist->sheets, gui->curr_sheet);
+}
+
+
/* ----- AoIs -------------------------------------------------------------- */
diff --git a/gui/sheet.c b/gui/sheet.c
index 8b66bf9..6131163 100644
--- a/gui/sheet.c
+++ b/gui/sheet.c
@@ -419,17 +419,13 @@ static bool go_next_sheet(struct gui *gui)
static bool sheet_click(void *user, int x, int y)
{
struct gui *gui = user;
- const struct gui_sheet *curr_sheet = gui->curr_sheet;
+ const struct gui_sheet *curr_sheet = current_sheet(gui);
int ex, ey;
canvas_coord(gui, x, y, &ex, &ey);
ex += curr_sheet->xmin;
ey += curr_sheet->ymin;
- if (gui->old_hist && gui->diff_mode == diff_old)
- curr_sheet = find_corresponding_sheet(gui->old_hist->sheets,
- gui->new_hist->sheets, gui->curr_sheet);
-
if (aoi_click(&gui->aois, x, y))
return 1;
if (aoi_click(&curr_sheet->aois, ex, ey))
@@ -449,15 +445,11 @@ static bool sheet_click(void *user, int x, int y)
static bool sheet_hover_update(void *user, int x, int y)
{
struct gui *gui = user;
- const struct gui_sheet *curr_sheet = gui->curr_sheet;
+ const struct gui_sheet *curr_sheet = current_sheet(gui);
int ex, ey;
canvas_coord(gui, x, y, &ex, &ey);
- if (gui->old_hist && gui->diff_mode == diff_old)
- curr_sheet = find_corresponding_sheet(gui->old_hist->sheets,
- gui->new_hist->sheets, gui->curr_sheet);
-
if (aoi_hover(&gui->aois, x, y))
return 1;
return aoi_hover(&curr_sheet->aois,
@@ -468,7 +460,7 @@ static bool sheet_hover_update(void *user, int x, int y)
static bool sheet_drag_begin(void *user, int x, int y)
{
struct gui *gui = user;
- const struct gui_sheet *curr_sheet = gui->curr_sheet;
+ const struct gui_sheet *curr_sheet = current_sheet(gui);
int ex, ey;
struct record_bbox rec_bbox;
@@ -478,10 +470,6 @@ static bool sheet_drag_begin(void *user, int x, int y)
ex += curr_sheet->xmin;
ey += curr_sheet->ymin;
- if (gui->old_hist && gui->diff_mode == diff_old)
- curr_sheet = find_corresponding_sheet(gui->old_hist->sheets,
- gui->new_hist->sheets, gui->curr_sheet);
-
gui->drag_text = record_find_text_bbox(gfx_user(curr_sheet->gfx),
show_extra, ex, ey, &rec_bbox);
if (gui->drag_text) {