Commit 3d3ec8bf authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

- Switch the item-cursor over to a delayed update model in an attempt to

  fix a redraw bug.  Things are faster but not fixed.

- Fix the real problem.  More cleanup of the cursor/selection code is required.
  There is too much incest in there.  We are redoing 75% of the necessary operations
  at several level in an attempt to get all the requisite pieces.

2000-02-20  Jody Goldberg <jgoldberg@home.com>

	* src/item-cursor.c : Switch to a quartic approved delayed update
	  model.  Do not change the bounding box while drawing.

	* src/selection.c (sheet_selection_add_range) : Do NOT directly change
	  the edit/move/base characteristics of the sheet sheet_cursor_set handles
	  that.

	* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) : Use
	  item_cursor_reposition rather than pretending that the cursor moved.

	* src/item-grid.c (item_grid_button_1) : Don't call both
	  sheet_cursor_move and sheet_selection_add.  The former was moving
	  the edit cursor without redrawing it.
parent d3afbba4
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c : Switch to a quartic approved delayed update
model. Do not change the bounding box while drawing.
* src/selection.c (sheet_selection_add_range) : Do NOT directly change
the edit/move/base characteristics of the sheet sheet_cursor_set handles
that.
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) : Use
item_cursor_reposition rather than pretending that the cursor moved.
* src/item-grid.c (item_grid_button_1) : Don't call both
sheet_cursor_move and sheet_selection_add. The former was moving
the edit cursor without redrawing it.
2000-02-20 Michael Meeks <michael@helixcode.com>
* src/sheet-object-container.c (sheet_object_container_realize): pass
UI handler in straight.
2000-02-19 Mike Kestner <mkestner@ameritech.net>
*src/dialogs/dialog-simple-input.c (dialog_get_number): Fixed leaks.
(dialog_get_sheet_name): Fixed leaks.
2000-02-19 Jody Goldberg <jgoldberg@home.com>
* src/corba-workbook-factory.c (WorkbookFactory_read) : Create a tmp
......
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c : Switch to a quartic approved delayed update
model. Do not change the bounding box while drawing.
* src/selection.c (sheet_selection_add_range) : Do NOT directly change
the edit/move/base characteristics of the sheet sheet_cursor_set handles
that.
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) : Use
item_cursor_reposition rather than pretending that the cursor moved.
* src/item-grid.c (item_grid_button_1) : Don't call both
sheet_cursor_move and sheet_selection_add. The former was moving
the edit cursor without redrawing it.
2000-02-20 Michael Meeks <michael@helixcode.com>
* src/sheet-object-container.c (sheet_object_container_realize): pass
UI handler in straight.
2000-02-19 Mike Kestner <mkestner@ameritech.net>
*src/dialogs/dialog-simple-input.c (dialog_get_number): Fixed leaks.
(dialog_get_sheet_name): Fixed leaks.
2000-02-19 Jody Goldberg <jgoldberg@home.com>
* src/corba-workbook-factory.c (WorkbookFactory_read) : Create a tmp
......
......@@ -31,6 +31,7 @@ dialog_get_number (Workbook *wb, const char *glade_file, double *init_and_return
dialog = GNOME_DIALOG (glade_xml_get_widget (gui, "dialog1"));
if (dialog == NULL){
g_warning ("Can not find the `dialog1' widget in %s", glade_file);
gtk_object_destroy (GTK_OBJECT (gui));
return FALSE;
}
......@@ -49,6 +50,7 @@ dialog_get_number (Workbook *wb, const char *glade_file, double *init_and_return
res = FALSE;
break;
case -1: /* window manager close */
gtk_object_destroy (GTK_OBJECT (gui));
return FALSE;
default:
......@@ -77,6 +79,7 @@ dialog_get_sheet_name (Workbook *wb, const char *current)
dialog = GNOME_DIALOG (glade_xml_get_widget (gui, "dialog"));
if (dialog == NULL){
g_warning ("Can not find the `dialog' widget in sheet-rename.glade");
gtk_object_destroy (GTK_OBJECT (gui));
return NULL;
}
......@@ -90,6 +93,7 @@ dialog_get_sheet_name (Workbook *wb, const char *current)
case 1: /* cancel */
break;
case -1: /* window manager close */
gtk_object_destroy (GTK_OBJECT (gui));
return NULL;
default:
......
......@@ -1074,9 +1074,7 @@ gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet)
sheet_view_scrollbar_config (gsheet->sheet_view);
/* Force the cursor to update its bounds relative to the new visible region */
item_cursor_set_bounds (ic,
ic->pos.start.col, ic->pos.start.row,
ic->pos.end.col, ic->pos.end.row);
item_cursor_reposition (gsheet->item_cursor);
}
static int
......
......@@ -33,10 +33,10 @@ typedef struct {
* (ie, when the user uses the cursor keys
* to select a cell for an expression).
*/
int selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
gboolean selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
/*
* The column and row bars
......
......@@ -1074,9 +1074,7 @@ gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet)
sheet_view_scrollbar_config (gsheet->sheet_view);
/* Force the cursor to update its bounds relative to the new visible region */
item_cursor_set_bounds (ic,
ic->pos.start.col, ic->pos.start.row,
ic->pos.end.col, ic->pos.end.row);
item_cursor_reposition (gsheet->item_cursor);
}
static int
......
......@@ -33,10 +33,10 @@ typedef struct {
* (ie, when the user uses the cursor keys
* to select a cell for an expression).
*/
int selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
gboolean selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
/*
* The column and row bars
......
......@@ -20,8 +20,6 @@
static GnomeCanvasItem *item_cursor_parent_class;
static void item_cursor_request_redraw (ItemCursor *item_cursor);
#define AUTO_HANDLE_SPACE 4
#define CLIP_SAFETY_MARGIN (AUTO_HANDLE_SPACE + 5)
#define IS_LITTLE_SQUARE(item,x,y) \
......@@ -40,8 +38,10 @@ enum {
static int
item_cursor_animation_callback (ItemCursor *item_cursor)
{
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_cursor);
item_cursor->state = !item_cursor->state;
item_cursor_request_redraw (item_cursor);
gnome_canvas_item_request_update (item);
return TRUE;
}
......@@ -124,21 +124,28 @@ item_cursor_unrealize (GnomeCanvasItem *item)
}
static void
item_cursor_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
item_cursor_request_redraw (ItemCursor *item_cursor)
{
if (GNOME_CANVAS_ITEM_CLASS(item_cursor_parent_class)->update)
(*GNOME_CANVAS_ITEM_CLASS(item_cursor_parent_class)->update)(item, affine, clip_path, flags);
GnomeCanvas *canvas = GNOME_CANVAS_ITEM (item_cursor)->canvas;
int const x = item_cursor->cached_x;
int const y = item_cursor->cached_y;
int const w = item_cursor->cached_w;
int const h = item_cursor->cached_h;
gnome_canvas_request_redraw (canvas, x - 2, y - 2, x + 2, y + h + 2);
gnome_canvas_request_redraw (canvas, x - 2, y - 2, x + w + 2, y + 2);
gnome_canvas_request_redraw (canvas, x + w - 2, y - 2, x + w + 5, y + h + 5);
gnome_canvas_request_redraw (canvas, x - 2, y + h - 2, x + w + 5, y + h + 5);
}
/*
* Returns the bounding box cordinates for box delimited by the cursor
*/
static void
item_cursor_get_pixel_coords (ItemCursor *item_cursor, int *x, int *y, int *w, int *h)
item_cursor_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
{
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_cursor);
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
Sheet *sheet = item_cursor->sheet;
ItemCursor *item_cursor = ITEM_CURSOR (item);
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
Sheet *sheet = item_cursor->sheet;
int x, y, w, h, extra;
/* Clip the bounds of the cursor to the visible region of cells */
int const left = MAX (gsheet->col.first-1, item_cursor->pos.start.col);
......@@ -146,27 +153,19 @@ item_cursor_get_pixel_coords (ItemCursor *item_cursor, int *x, int *y, int *w, i
int const top = MAX (gsheet->row.first-1, item_cursor->pos.start.row);
int const bottom = MIN (gsheet->row.last_visible, item_cursor->pos.end.row);
*x = gsheet->col_offset.first +
/* Erase the old cursor */
item_cursor_request_redraw (item_cursor);
item_cursor->cached_x = x =
gsheet->col_offset.first +
sheet_col_get_distance_pixels (sheet, gsheet->col.first, left);
*y = gsheet->row_offset.first +
item_cursor->cached_y = y =
gsheet->row_offset.first +
sheet_row_get_distance_pixels (sheet, gsheet->row.first, top);
*w = sheet_col_get_distance_pixels (sheet, left, right+1);
*h = sheet_row_get_distance_pixels (sheet, top, bottom+1);
}
static void
item_cursor_configure_bounds (ItemCursor *item_cursor)
{
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_cursor);
int x, y, w, h, extra;
item_cursor_get_pixel_coords (item_cursor, &x, &y, &w, &h);
item_cursor->cached_x = x;
item_cursor->cached_y = y;
item_cursor->cached_w = w;
item_cursor->cached_h = h;
item_cursor->cached_w = w =
sheet_col_get_distance_pixels (sheet, left, right+1);
item_cursor->cached_h = h =
sheet_row_get_distance_pixels (sheet, top, bottom+1);
item->x1 = x - 1;
item->y1 = y - 1;
......@@ -179,6 +178,15 @@ item_cursor_configure_bounds (ItemCursor *item_cursor)
item->y2 = y + h + 2 + extra;
gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
/* Draw the new cursor */
item_cursor_request_redraw (item_cursor);
#if 0
fprintf (stderr, "update %d,%d %d,%d\n", x, y, w,h);
#endif
if (GNOME_CANVAS_ITEM_CLASS(item_cursor_parent_class)->update)
(*GNOME_CANVAS_ITEM_CLASS(item_cursor_parent_class)->update)(item, affine, clip_path, flags);
}
/*
......@@ -194,8 +202,7 @@ static void
item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
{
ItemCursor *item_cursor = ITEM_CURSOR (item);
int xd, yd, dx0, dy0, dx1, dy1;
int cursor_width, cursor_height, w, h;
int dx0, dy0, dx1, dy1;
GdkPoint points [40];
int draw_external, draw_internal, draw_handle;
int draw_stippled, draw_center, draw_thick;
......@@ -203,28 +210,22 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
GdkColor *fore = NULL, *back = NULL;
GdkRectangle clip_rect;
int const xd = item_cursor->cached_x;
int const yd = item_cursor->cached_y;
int const w = item_cursor->cached_w;
int const h = item_cursor->cached_h;
#if 0
fprintf (stderr, "draw %d,%d %d,%d\n", xd, yd, w,h);
#endif
if (!item_cursor->visible)
return;
item_cursor_get_pixel_coords (item_cursor, &xd, &yd,
&cursor_width, &cursor_height);
w = cursor_width;
h = cursor_height;
/* determine if we need to recompute the bounding box */
if (xd != item_cursor->cached_x ||
yd != item_cursor->cached_y ||
w != item_cursor->cached_w ||
h != item_cursor->cached_h){
item_cursor_configure_bounds (item_cursor);
}
/* Top left and bottom right corner of cursor, in pixmap coordinates */
dx0 = xd - x;
dy0 = yd - y;
dx1 = dx0 + cursor_width;
dy1 = dy0 + cursor_height;
dx1 = dx0 + w;
dy1 = dy0 + h;
draw_external = 0;
draw_internal = 0;
......@@ -411,19 +412,6 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
}
}
static void
item_cursor_request_redraw (ItemCursor *item_cursor)
{
GnomeCanvas *canvas = GNOME_CANVAS_ITEM (item_cursor)->canvas;
int x, y, w, h;
item_cursor_get_pixel_coords (item_cursor, &x, &y, &w, &h);
gnome_canvas_request_redraw (canvas, x - 2, y - 2, x + 2, y + h + 2);
gnome_canvas_request_redraw (canvas, x - 2, y - 2, x + w + 2, y + 2);
gnome_canvas_request_redraw (canvas, x + w - 2, y - 2, x + w + 5, y + h + 5);
gnome_canvas_request_redraw (canvas, x - 2, y + h - 2, x + w + 5, y + h + 5);
}
void
item_cursor_set_bounds (ItemCursor *item_cursor, int start_col, int start_row, int end_col, int end_row)
{
......@@ -437,17 +425,17 @@ item_cursor_set_bounds (ItemCursor *item_cursor, int start_col, int start_row, i
g_return_if_fail (end_row < SHEET_MAX_ROWS);
g_return_if_fail (IS_ITEM_CURSOR (item_cursor));
/* Redraw the old area */
item = GNOME_CANVAS_ITEM (item_cursor);
item_cursor_request_redraw (item_cursor);
/* Move to the new area */
item_cursor->pos.start.col = start_col;
item_cursor->pos.end.col = end_col;
item_cursor->pos.start.row = start_row;
item_cursor->pos.end.row = end_row;
item_cursor_request_redraw (item_cursor);
item_cursor_configure_bounds (item_cursor);
/* Request an update */
gnome_canvas_item_request_update (item);
}
/**
......@@ -463,8 +451,8 @@ item_cursor_reposition (ItemCursor *item_cursor)
g_return_if_fail (item != NULL);
item_cursor_request_redraw (item_cursor);
item_cursor_configure_bounds (item_cursor);
/* Request an update */
gnome_canvas_item_request_update (item);
}
static double
......@@ -763,7 +751,7 @@ item_cursor_set_bounds_visibly (ItemCursor *item_cursor,
}
void
item_cursor_set_visibility (ItemCursor *item_cursor, int visible)
item_cursor_set_visibility (ItemCursor *item_cursor, gboolean visible)
{
g_return_if_fail (IS_ITEM_CURSOR (item_cursor));
......@@ -771,7 +759,7 @@ item_cursor_set_visibility (ItemCursor *item_cursor, int visible)
return;
item_cursor->visible = visible;
item_cursor_request_redraw (item_cursor);
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (item_cursor));
}
void
......@@ -1094,4 +1082,3 @@ item_cursor_get_type (void)
return item_cursor_type;
}
#ifndef GNUMERIC_ITEM_CURSOR_H
#define GNUMERIC_ITEM_CURSOR_H
#include "sheet.h"
#include "gnumeric.h"
#include "item-grid.h"
#define ITEM_CURSOR(obj) (GTK_CHECK_CAST((obj), item_cursor_get_type (), ItemCursor))
......@@ -65,14 +65,15 @@ typedef struct {
GnomeCanvasItemClass parent_class;
} ItemCursorClass;
void item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
void item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
void item_cursor_set_spin_base (ItemCursor *item_cursor,
int col, int row);
void item_cursor_set_visibility (ItemCursor *item_cursor,
int visible);
void item_cursor_reposition (ItemCursor *item_cursor);
gboolean const visible);
void item_cursor_reposition (ItemCursor *item_cursor);
#endif /* GNUMERIC_ITEM_CURSOR_H */
......@@ -370,6 +370,9 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int
/* 2. the grids */
if (sheet->show_grid) {
#if 0
fprintf (stderr, "paint : %s%d:", col_name(paint_col), paint_row+1);
#endif
col = paint_col;
x_paint = -diff_x;
gdk_draw_line (drawable, grid_gc, x_paint, 0, x_paint, height);
......@@ -391,6 +394,9 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int
gdk_draw_line (drawable, grid_gc, 0, y_paint, width, y_paint);
}
}
#if 0
fprintf (stderr, "%s%d\n", col_name(col-1), row);
#endif
}
gdk_gc_set_function (item_grid->gc, GDK_COPY);
......@@ -831,12 +837,6 @@ item_grid_button_1 (Sheet *sheet, GdkEvent *event, ItemGrid *item_grid, int col,
*/
sheet_accept_pending_input (sheet);
if (!(event->button.state & GDK_SHIFT_MASK)) {
sheet_make_cell_visible (sheet, col, row);
/* Handle the selection localy */
sheet_cursor_move (sheet, col, row, FALSE, FALSE);
}
if (!(event->button.state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)))
sheet_selection_reset_only (sheet);
......@@ -844,8 +844,10 @@ item_grid_button_1 (Sheet *sheet, GdkEvent *event, ItemGrid *item_grid, int col,
if ((event->button.state & GDK_SHIFT_MASK) && sheet->selections)
sheet_selection_extend_to (sheet, col, row);
else
else {
sheet_selection_add (sheet, col, row);
sheet_make_cell_visible (sheet, col, row);
}
gnome_canvas_item_grab (item,
GDK_POINTER_MOTION_MASK |
......
......@@ -77,7 +77,7 @@ sheet_selection_changed_hook (Sheet *sheet)
* @base_{col,row} : stationary corner of the newly selected range.
* @move_{col,row} : moving corner of the newly selected range.
*
* Prepends a new range to the selection list.
* Prepends a range to the selection list and set the edit cursor.
*/
void
sheet_selection_add_range (Sheet *sheet,
......@@ -90,32 +90,21 @@ sheet_selection_add_range (Sheet *sheet,
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
/* Create and prepend new selection */
ss = g_new0 (SheetSelection, 1);
sheet->cursor.edit_pos.col = edit_col;
sheet->cursor.edit_pos.row = edit_row;
sheet->cursor.base_corner.col = base_col;
sheet->cursor.base_corner.row = base_row;
sheet->cursor.move_corner.col = move_col;
sheet->cursor.move_corner.row = move_row;
ss->user.start.col = MIN (base_col, move_col);
ss->user.start.row = MIN (base_row, move_row);
ss->user.end.col = MAX (base_col, move_col);
ss->user.end.row = MAX (base_row, move_row);
sheet->selections = g_list_prepend (sheet->selections, ss);
sheet_accept_pending_input (sheet);
sheet_load_cell_val (sheet);
/* Set the selection parameters, and redraw the old edit cursor */
sheet_cursor_set (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
ss->user.start.col,
ss->user.start.row,
ss->user.end.col,
ss->user.end.row);
edit_col, edit_row,
base_col, base_row,
move_col, move_row);
/* Redraw the newly added range so that it get shown as selected */
sheet_redraw_range (sheet, &ss->user);
sheet_redraw_headers (sheet, TRUE, TRUE, &ss->user);
......
......@@ -301,7 +301,7 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int col, int modifiers, She
Sheet *sheet = sheet_view->sheet;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
/* Ensure that col row exists, ignore result */
/* Ensure that the col exists, ignore result */
sheet_col_fetch (sheet, col);
if (modifiers){
......
......@@ -301,7 +301,7 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int col, int modifiers, She
Sheet *sheet = sheet_view->sheet;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
/* Ensure that col row exists, ignore result */
/* Ensure that the col exists, ignore result */
sheet_col_fetch (sheet, col);
if (modifiers){
......
......@@ -2110,6 +2110,13 @@ sheet_cursor_set (Sheet *sheet,
sheet_accept_pending_input (sheet);
/* Redraw the old edit cell */
sheet_redraw_cell_region (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->cursor.edit_pos.col = edit_col;
sheet->cursor.edit_pos.row = edit_row;
sheet->cursor.base_corner.col = base_col;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment