[gnumeric] Sheet Objects: handle figuring out the extent in sheet_update.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Sheet Objects: handle figuring out the extent in sheet_update.
- Date: Fri, 5 Jun 2020 01:00:26 +0000 (UTC)
commit c168405234688ad5a16eab94eaceb6a0fe45308f
Author: Morten Welinder <terra gnome org>
Date: Thu Jun 4 20:59:31 2020 -0400
Sheet Objects: handle figuring out the extent in sheet_update.
This was envisioned a decade or two ago.
ChangeLog | 10 ++++++++++
src/gnm-pane.c | 8 ++++++--
src/sheet-object.c | 42 +++++++-----------------------------------
src/sheet-private.h | 1 +
src/sheet.c | 34 ++++++++++++++++++++++++++++++++++
5 files changed, 58 insertions(+), 37 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c20c99c14..ed7a77a06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-06-04 Morten Welinder <terra gnome org>
+
+ * src/sheet-private.h (_SheetPrivate): Add objects_changed flag
+ for updating sheet objects extents.
+
+ * src/sheet-object.c: Don't update sheet object extents right now,
+ just set the flag.
+
+ * src/sheet.c (sheet_update_only_grid): Handle objects_changed.
+
2020-06-03 Morten Welinder <terra gnome org>
* src/sheet-object.c (sheet_object_view_get_item): New function
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 999ffa455..eddbba478 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -3119,9 +3119,9 @@ gnm_pane_object_register (SheetObject *so, GocItem *view, gboolean selectable)
}
/**
- * gnm_pane_object_widget_register:
+ * gnm_pane_widget_register:
* @so: A sheet object
- * @widget: The widget for the sheet object view
+ * @w: The widget for the sheet object view
* @view: A canvas item acting as a view for @so
*
* Setup some standard callbacks for manipulating widgets as views of sheet
@@ -3130,12 +3130,16 @@ gnm_pane_object_register (SheetObject *so, GocItem *view, gboolean selectable)
void
gnm_pane_widget_register (SheetObject *so, GtkWidget *w, GocItem *view)
{
+ // There was a time when this did something. Right now it does
+ // not, so don't walk the tree.
+#if 0
if (GTK_IS_CONTAINER (w)) {
GList *ptr, *children = gtk_container_get_children (GTK_CONTAINER (w));
for (ptr = children ; ptr != NULL; ptr = ptr->next)
gnm_pane_widget_register (so, ptr->data, view);
g_list_free (children);
}
+#endif
}
void
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 5c07c46c7..19c005587 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -310,34 +310,6 @@ sheet_object_populate_menu (SheetObject *so, GPtrArray *actions)
GNM_SO_CLASS (G_OBJECT_GET_CLASS(so))->populate_menu (so, actions);
}
-/**
- * sheet_objects_max_extent:
- * @sheet:
- *
- * Utility routine to calculate the maximum extent of objects in this sheet.
- */
-static void
-sheet_objects_max_extent (Sheet *sheet)
-{
- GnmCellPos max_pos = { 0, 0 };
- GSList *ptr;
-
- for (ptr = sheet->sheet_objects; ptr != NULL ; ptr = ptr->next ) {
- SheetObject *so = GNM_SO (ptr->data);
-
- if (max_pos.col < so->anchor.cell_bound.end.col)
- max_pos.col = so->anchor.cell_bound.end.col;
- if (max_pos.row < so->anchor.cell_bound.end.row)
- max_pos.row = so->anchor.cell_bound.end.row;
- }
-
- if (sheet->max_object_extent.col != max_pos.col ||
- sheet->max_object_extent.row != max_pos.row) {
- sheet->max_object_extent = max_pos;
- sheet_scrollbar_config (sheet);
- }
-}
-
void
sheet_object_set_name (SheetObject *so, const char *name)
{
@@ -618,8 +590,8 @@ sheet_object_set_sheet (SheetObject *so, Sheet *sheet)
sheet_object_anchor_to_pts (&so->anchor, sheet, x);
sheet_object_pts_to_anchor (&so->anchor, sheet, x);
}
- /* FIXME : add a flag to sheet to have sheet_update do this */
- sheet_objects_max_extent (sheet);
+
+ sheet->priv->objects_changed = TRUE;
g_ptr_array_add (so_create_view_sos, so);
if (!so_create_view_src) {
@@ -681,9 +653,9 @@ sheet_object_clear_sheet (SheetObject *so)
so->sheet->sheet_objects = g_slist_remove_link (so->sheet->sheet_objects, ptr);
g_slist_free (ptr);
- if (so->anchor.cell_bound.end.col == so->sheet->max_object_extent.col &&
+ if (so->anchor.cell_bound.end.col == so->sheet->max_object_extent.col ||
so->anchor.cell_bound.end.row == so->sheet->max_object_extent.row)
- sheet_objects_max_extent (so->sheet);
+ so->sheet->priv->objects_changed = TRUE;
so->sheet = NULL;
g_object_unref (so);
@@ -903,7 +875,7 @@ sheet_object_set_anchor (SheetObject *so, SheetObjectAnchor const *anchor)
so->anchor = *anchor;
if (so->sheet != NULL) {
- sheet_objects_max_extent (so->sheet);
+ so->sheet->priv->objects_changed = TRUE;
sheet_object_update_bounds (so, NULL);
}
}
@@ -1198,9 +1170,9 @@ sheet_objects_relocate (GnmExprRelocateInfo const *rinfo, gboolean update,
}
}
- sheet_objects_max_extent (rinfo->origin_sheet);
+ rinfo->origin_sheet->priv->objects_changed = TRUE;
if (change_sheets)
- sheet_objects_max_extent (rinfo->target_sheet);
+ rinfo->target_sheet->priv->objects_changed = TRUE;
}
/**
diff --git a/src/sheet-private.h b/src/sheet-private.h
index 2ba2b1047..772b8c6f6 100644
--- a/src/sheet-private.h
+++ b/src/sheet-private.h
@@ -17,6 +17,7 @@ struct _SheetPrivate {
unsigned char resize;
GnmCellPos reposition_objects;
unsigned char filters_changed;
+ unsigned char objects_changed;
};
/* for internal use only */
diff --git a/src/sheet.c b/src/sheet.c
index 7bd69e3c6..7d2d2af95 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -1975,6 +1975,34 @@ sheet_colrow_fit_gutter (Sheet const *sheet, gboolean is_cols)
return outline_level;
}
+/**
+ * sheet_objects_max_extent:
+ * @sheet:
+ *
+ * Utility routine to calculate the maximum extent of objects in this sheet.
+ */
+static void
+sheet_objects_max_extent (Sheet *sheet)
+{
+ GnmCellPos max_pos = { 0, 0 };
+ GSList *ptr;
+
+ for (ptr = sheet->sheet_objects; ptr != NULL ; ptr = ptr->next ) {
+ SheetObject *so = GNM_SO (ptr->data);
+
+ if (max_pos.col < so->anchor.cell_bound.end.col)
+ max_pos.col = so->anchor.cell_bound.end.col;
+ if (max_pos.row < so->anchor.cell_bound.end.row)
+ max_pos.row = so->anchor.cell_bound.end.row;
+ }
+
+ if (sheet->max_object_extent.col != max_pos.col ||
+ sheet->max_object_extent.row != max_pos.row) {
+ sheet->max_object_extent = max_pos;
+ sheet_scrollbar_config (sheet);
+ }
+}
+
/**
* sheet_update_only_grid:
* @sheet: #Sheet
@@ -1991,6 +2019,11 @@ sheet_update_only_grid (Sheet const *sheet)
p = sheet->priv;
+ if (p->objects_changed) {
+ p->objects_changed = FALSE;
+ sheet_objects_max_extent ((Sheet *)sheet);
+ }
+
/* be careful these can toggle flags */
if (p->recompute_max_col_group) {
sheet_colrow_gutter ((Sheet *)sheet, TRUE,
@@ -2077,6 +2110,7 @@ sheet_update_only_grid (Sheet const *sheet)
sheet_scrollbar_config (sheet);
p->resize_scrollbar = FALSE;
}
+
if (p->filters_changed) {
p->filters_changed = FALSE;
SHEET_FOREACH_CONTROL (sheet, sv, sc,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]