[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/17] pspp-sheet-view: Add "special-cells" property to speed dra
From: |
Ben Pfaff |
Subject: |
[PATCH 10/17] pspp-sheet-view: Add "special-cells" property to speed drawing many columns. |
Date: |
Sun, 22 Apr 2012 11:12:28 -0700 |
A "special cell" is a cell that is editable or activatable. When a row
that contains a special cell is selected, the cursor is drawn around a
single cell; when other rows are selected, the cursor is drawn around the
entire row.
With the default of "detect" (the only mode previously supported), whether
a given row contains a special cell is detected automatically. This is the
best choice most of the time. For sheet views that contain more than 100
columns, an explicit "yes" or "no" improves performance.
---
src/ui/gui/pspp-sheet-private.h | 3 +
src/ui/gui/pspp-sheet-view.c | 116 ++++++++++++++++++++++++++++++++++-----
src/ui/gui/pspp-sheet-view.h | 30 ++++++++--
3 files changed, 129 insertions(+), 20 deletions(-)
diff --git a/src/ui/gui/pspp-sheet-private.h b/src/ui/gui/pspp-sheet-private.h
index 8a258b2..c964c52 100644
--- a/src/ui/gui/pspp-sheet-private.h
+++ b/src/ui/gui/pspp-sheet-private.h
@@ -244,6 +244,9 @@ struct _PsppSheetViewPrivate
PsppSheetViewGridLines grid_lines;
GdkGC *grid_line_gc;
+ /* Special cells. */
+ PsppSheetViewSpecialCells special_cells;
+
/* Tooltip support */
gint tooltip_column;
diff --git a/src/ui/gui/pspp-sheet-view.c b/src/ui/gui/pspp-sheet-view.c
index 0297ee4..b965b64 100644
--- a/src/ui/gui/pspp-sheet-view.c
+++ b/src/ui/gui/pspp-sheet-view.c
@@ -144,7 +144,8 @@ enum {
PROP_HOVER_SELECTION,
PROP_RUBBER_BANDING,
PROP_ENABLE_GRID_LINES,
- PROP_TOOLTIP_COLUMN
+ PROP_TOOLTIP_COLUMN,
+ PROP_SPECIAL_CELLS
};
/* object signals */
@@ -630,6 +631,15 @@ pspp_sheet_view_class_init (PsppSheetViewClass *class)
-1,
GTK_PARAM_READWRITE));
+ g_object_class_install_property (o_class,
+ PROP_SPECIAL_CELLS,
+ g_param_spec_enum ("special-cells",
+ P_("Special Cells"),
+ P_("Whether rows have
special cells."),
+
PSPP_TYPE_SHEET_VIEW_SPECIAL_CELLS,
+
PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT,
+ GTK_PARAM_READWRITE));
+
/* Style properties */
#define _TREE_VIEW_EXPANDER_SIZE 12
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
@@ -1006,6 +1016,8 @@ pspp_sheet_view_init (PsppSheetView *tree_view)
tree_view->priv->tooltip_column = -1;
+ tree_view->priv->special_cells = PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT;
+
tree_view->priv->post_validation_flag = FALSE;
tree_view->priv->last_button_x = -1;
@@ -1077,6 +1089,9 @@ pspp_sheet_view_set_property (GObject *object,
case PROP_TOOLTIP_COLUMN:
pspp_sheet_view_set_tooltip_column (tree_view, g_value_get_int (value));
break;
+ case PROP_SPECIAL_CELLS:
+ pspp_sheet_view_set_special_cells (tree_view, g_value_get_enum (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1134,6 +1149,9 @@ pspp_sheet_view_get_property (GObject *object,
case PROP_TOOLTIP_COLUMN:
g_value_set_int (value, tree_view->priv->tooltip_column);
break;
+ case PROP_SPECIAL_CELLS:
+ g_value_set_enum (value, tree_view->priv->special_cells);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -3854,21 +3872,26 @@ pspp_sheet_view_bin_expose (GtkWidget *widget,
parity = node % 2;
- /* we *need* to set cell data on all cells before the call
- * to _has_special_cell, else _has_special_cell() does not
- * return a correct value.
- */
- for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first
(tree_view->priv->columns));
- list;
- list = (rtl ? list->prev : list->next))
+ if (tree_view->priv->special_cells ==
PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT)
{
- PsppSheetViewColumn *column = list->data;
- pspp_sheet_view_column_cell_set_cell_data (column,
- tree_view->priv->model,
- &iter);
- }
+ /* we *need* to set cell data on all cells before the call
+ * to _has_special_cell, else _has_special_cell() does not
+ * return a correct value.
+ */
+ for (list = (rtl ? g_list_last (tree_view->priv->columns) :
g_list_first (tree_view->priv->columns));
+ list;
+ list = (rtl ? list->prev : list->next))
+ {
+ PsppSheetViewColumn *column = list->data;
+ pspp_sheet_view_column_cell_set_cell_data (column,
+
tree_view->priv->model,
+ &iter);
+ }
- has_special_cell = pspp_sheet_view_has_special_cell (tree_view);
+ has_special_cell = pspp_sheet_view_has_special_cell (tree_view);
+ }
+ else
+ has_special_cell = tree_view->priv->special_cells ==
PSPP_SHEET_VIEW_SPECIAL_CELLS_YES;
for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first
(tree_view->priv->columns));
list;
@@ -6427,6 +6450,9 @@ pspp_sheet_view_has_special_cell (PsppSheetView
*tree_view)
{
GList *list;
+ if (tree_view->priv->special_cells != PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT)
+ return tree_view->priv->special_cells = PSPP_SHEET_VIEW_SPECIAL_CELLS_YES;
+
for (list = tree_view->priv->columns; list; list = list->next)
{
if (!((PsppSheetViewColumn *)list->data)->visible)
@@ -12239,6 +12265,52 @@ pspp_sheet_view_set_grid_lines (PsppSheetView
*tree_view,
}
/**
+ * pspp_sheet_view_get_special_cells:
+ * @tree_view: a #PsppSheetView
+ *
+ * Returns which grid lines are enabled in @tree_view.
+ *
+ * Return value: a #PsppSheetViewSpecialCells value indicating whether rows in
+ * the sheet view contain special cells.
+ */
+PsppSheetViewSpecialCells
+pspp_sheet_view_get_special_cells (PsppSheetView *tree_view)
+{
+ g_return_val_if_fail (PSPP_IS_SHEET_VIEW (tree_view), 0);
+
+ return tree_view->priv->special_cells;
+}
+
+/**
+ * pspp_sheet_view_set_special_cells:
+ * @tree_view: a #PsppSheetView
+ * @special_cells: a #PsppSheetViewSpecialCells value indicating whether rows
in
+ * the sheet view contain special cells.
+ *
+ * Sets whether rows in the sheet view contain special cells, controlling the
+ * rendering of row selections.
+ */
+void
+pspp_sheet_view_set_special_cells (PsppSheetView *tree_view,
+ PsppSheetViewSpecialCells special_cells)
+{
+ PsppSheetViewPrivate *priv;
+ GtkWidget *widget;
+
+ g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view));
+
+ priv = tree_view->priv;
+ widget = GTK_WIDGET (tree_view);
+
+ if (priv->special_cells != special_cells)
+ {
+ priv->special_cells = special_cells;
+ gtk_widget_queue_draw (GTK_WIDGET (tree_view));
+ g_object_notify (G_OBJECT (tree_view), "special-cells");
+ }
+}
+
+/**
* pspp_sheet_view_set_tooltip_row:
* @tree_view: a #PsppSheetView
* @tooltip: a #GtkTooltip
@@ -12568,3 +12640,19 @@ pspp_sheet_view_grid_lines_get_type (void)
}
return etype;
}
+
+GType
+pspp_sheet_view_special_cells_get_type (void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const GEnumValue values[] = {
+ { PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT,
"PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT", "detect" },
+ { PSPP_SHEET_VIEW_SPECIAL_CELLS_YES,
"PSPP_SHEET_VIEW_SPECIAL_CELLS_YES", "yes" },
+ { PSPP_SHEET_VIEW_SPECIAL_CELLS_NO,
"PSPP_SHEET_VIEW_SPECIAL_CELLS_NO", "no" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static (g_intern_static_string
("PsppSheetViewSpecialCells"), values);
+ }
+ return etype;
+}
diff --git a/src/ui/gui/pspp-sheet-view.h b/src/ui/gui/pspp-sheet-view.h
index 09a89e2..3df7360 100644
--- a/src/ui/gui/pspp-sheet-view.h
+++ b/src/ui/gui/pspp-sheet-view.h
@@ -53,6 +53,25 @@ typedef enum
GType pspp_sheet_view_grid_lines_get_type (void) G_GNUC_CONST;
#define PSPP_TYPE_SHEET_VIEW_GRID_LINES (pspp_sheet_view_grid_lines_get_type
())
+/* A "special cell" is a cell that is editable or activatable. When a row that
+ * contains a special cell is selected, the cursor is drawn around a single
+ * cell; when other rows are selected, the cursor is drawn around the entire
+ * row.
+ *
+ * With the default of "detect", whether a given row contains a special cell is
+ * detected automatically. This is the best choice most of the time. For
+ * sheet views that contain more than 100 columns, an explicit "yes" or "no"
+ * improves performance. */
+typedef enum
+{
+ PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT,
+ PSPP_SHEET_VIEW_SPECIAL_CELLS_YES,
+ PSPP_SHEET_VIEW_SPECIAL_CELLS_NO,
+} PsppSheetViewSpecialCells;
+
+GType pspp_sheet_view_special_cells_get_type (void) G_GNUC_CONST;
+#define PSPP_TYPE_SHEET_VIEW_SPECIAL_CELLS
(pspp_sheet_view_special_cells_get_type ())
+
typedef enum
{
/* drop before/after this row */
@@ -367,12 +386,11 @@ gboolean pspp_sheet_view_is_rubber_banding_active
(PsppSheetView *tree_vie
PsppSheetViewGridLines pspp_sheet_view_get_grid_lines
(PsppSheetView *tree_view);
void pspp_sheet_view_set_grid_lines
(PsppSheetView *tree_view,
PsppSheetViewGridLines grid_lines);
-gboolean pspp_sheet_view_get_enable_tree_lines
(PsppSheetView *tree_view);
-void pspp_sheet_view_set_enable_tree_lines
(PsppSheetView *tree_view,
- gboolean
enabled);
-void pspp_sheet_view_set_level_indentation
(PsppSheetView *tree_view,
- gint
indentation);
-gint pspp_sheet_view_get_level_indentation
(PsppSheetView *tree_view);
+
+PsppSheetViewSpecialCells pspp_sheet_view_get_special_cells (PsppSheetView
*tree_view);
+void pspp_sheet_view_set_special_cells (PsppSheetView
*tree_view,
+
PsppSheetViewSpecialCells);
+
/* Convenience functions for setting tooltips */
void pspp_sheet_view_set_tooltip_row (PsppSheetView
*tree_view,
--
1.7.2.5
- [PATCH 00/17] Implement PsppSheetView, Ben Pfaff, 2012/04/22
- [PATCH 04/17] pspp-sheet-view: Fix visual artifacts for sheet views > 65535 pixels wide., Ben Pfaff, 2012/04/22
- [PATCH 03/17] pspp-sheet-view: Improve scrolling performance., Ben Pfaff, 2012/04/22
- [PATCH 05/17] pspp-sheet-view: Fix rendering moving cursor left or right with keyboard., Ben Pfaff, 2012/04/22
- [PATCH 06/17] pspp-sheet-view-column: Add support for tooltips on columns., Ben Pfaff, 2012/04/22
- [PATCH 07/17] pspp-sheet-view: Edit cells on the first click by default., Ben Pfaff, 2012/04/22
- [PATCH 09/17] pspp-sheet-view: Start editing upon button release, not press., Ben Pfaff, 2012/04/22
- [PATCH 10/17] pspp-sheet-view: Add "special-cells" property to speed drawing many columns.,
Ben Pfaff <=
- [PATCH 13/17] pspp-sheet-view: Improve look of sheet when there are few columns., Ben Pfaff, 2012/04/22
- [PATCH 11/17] pspp-widget-facade: New code to measure and render some GTK+ widgets., Ben Pfaff, 2012/04/22
- [PATCH 14/17] pspp-sheet-view: Make pspp_sheet_view_stop_editing() public., Ben Pfaff, 2012/04/22
- [PATCH 08/17] pspp-sheet-view: Support rectangular selection, column popup menus., Ben Pfaff, 2012/04/22
- [PATCH 12/17] pspp-sheet-view: Optimize by making column header widgets lazy., Ben Pfaff, 2012/04/22
- [PATCH 15/17] pspp-sheet-view: Add "fixed-height" and "fixed-height-set" properties., Ben Pfaff, 2012/04/22