summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-19 11:31:46 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-19 11:31:46 (GMT)
commitefbe6faae10cefd8b0834c31ca613cb314f07da9 (patch)
tree576501e37837336e7f65ea33cd147a9353d13583
parent3c2b347da556dc5d88df3a36813dfa733f5a9d20 (diff)
downloadeeshow-efbe6faae10cefd8b0834c31ca613cb314f07da9.zip
eeshow-efbe6faae10cefd8b0834c31ca613cb314f07da9.tar.gz
eeshow-efbe6faae10cefd8b0834c31ca613cb314f07da9.tar.bz2
gui/common.h, gui/sheet.c: use dragging instead of click for copying text
This feels much more "natural", but still lacks visual feedback.
-rw-r--r--gui/common.h2
-rw-r--r--gui/sheet.c31
2 files changed, 28 insertions, 5 deletions
diff --git a/gui/common.h b/gui/common.h
index 31bf44c..6a51d76 100644
--- a/gui/common.h
+++ b/gui/common.h
@@ -126,6 +126,8 @@ struct gui {
struct gui_hist *new_hist;
struct gui_hist *old_hist; /* NULL if not comparing */
+ const char *drag_text; /* text being "dragged" (marked); or NULL */
+
int hist_y_offset; /* history list y offset */
/* progress bar */
diff --git a/gui/sheet.c b/gui/sheet.c
index 15bec46..7e701eb 100644
--- a/gui/sheet.c
+++ b/gui/sheet.c
@@ -419,7 +419,6 @@ static bool sheet_click(void *user, int x, int y)
struct gui *gui = user;
const struct gui_sheet *curr_sheet = gui->curr_sheet;
int ex, ey;
- const char *s;
canvas_coord(gui, x, y, &ex, &ey);
ex += curr_sheet->xmin;
@@ -441,10 +440,6 @@ static bool sheet_click(void *user, int x, int y)
return 1;
}
- s = record_find_text(gfx_user(curr_sheet->gfx), show_extra, ex, ey);
- if (s)
- copy_to_clipboard(s);
-
return 1;
}
@@ -470,7 +465,23 @@ 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;
+ int ex, ey;
+
dehover_pop(user);
+
+ 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);
+
+ gui->drag_text = record_find_text(gfx_user(curr_sheet->gfx),
+ show_extra, ex, ey);
+
return 1;
}
@@ -479,6 +490,9 @@ static void sheet_drag_move(void *user, int dx, int dy)
{
struct gui *gui = user;
+ if (gui->drag_text)
+ return;
+
gui->x -= dx / gui->scale;
gui->y -= dy / gui->scale;
redraw(gui);
@@ -487,6 +501,13 @@ static void sheet_drag_move(void *user, int dx, int dy)
static void sheet_drag_end(void *user)
{
+ struct gui *gui = user;
+
+ if (gui->drag_text) {
+ copy_to_clipboard(gui->drag_text);
+ gui->drag_text = NULL;
+
+ }
input_update();
}