Commit df3eb271 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

Minor optimization to decrease flicker.


2000-11-10  Jody Goldberg <jgoldberg@home.com>

	* src/workbook-format-toolbar.c (workbook_format_toolbutton_update) :
	  Minor optimization to decrease flicker.

	* src/sheet.c (sheet_cell_calc_span) : Clarify the semantics of
	  the various flags.
	(cb_max_cell_width) : If the value used a dynamic format we need to
	  rerender ignoring the current width.

	* src/rendered-value.c (rendered_value_new) : renamed from
	  rendered_value_new_ext and delete the old rendered_value_new.
	  Extend slightly to flag whether or not to handle dynamic formats.

	* src/render-ascii.c (cell_region_render_ascii) : Handle the style
	  lookup localy.

	* src/cell.c (cell_eval_content) : We need to manually render
	  the value here, but no longer need to calculate the size
	  seperately.  That is done automatically in the render.
	(cell_render_value) : Handle style localy, and calculate the size.

2000-11-09  Jody Goldberg <jgoldberg@home.com>

	* src/workbook-control-gui.c (workbook_control_gui_init) : move the
	  autosave code here.
	* src/workbook.c : from here.
parent 0a3b0578
......@@ -13,15 +13,10 @@ Release Critical
Long term breakage
------------------
- clipboard : fix duality of PASTE_FORMULAS vs PASTE_VALUES, add PASTE_COMMENT
- Why does the number matching bother comparing against formats that are
covered by 'General' ?
- Column resizing and "general". Double-clicking on column separators to
autosize columns tends to shrink columns with, say, "=22/3" in them.
We should tweak autosize to rerender a cell if it has variable width content.
- format.c: we should resolve all the separators at gnumeric_setlocale time,
not every time we need them.
......
2000-11-10 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (workbook_format_toolbutton_update) :
Minor optimization to decrease flicker.
* src/sheet.c (sheet_cell_calc_span) : Clarify the semantics of
the various flags.
(cb_max_cell_width) : If the value used a dynamic format we need to
rerender ignoring the current width.
* src/rendered-value.c (rendered_value_new) : renamed from
rendered_value_new_ext and delete the old rendered_value_new.
Extend slightly to flag whether or not to handle dynamic formats.
* src/render-ascii.c (cell_region_render_ascii) : Handle the style
lookup localy.
* src/cell.c (cell_eval_content) : We need to manually render
the value here, but no longer need to calculate the size
seperately. That is done automatically in the render.
(cell_render_value) : Handle style localy, and calculate the size.
2000-11-09 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (workbook_control_gui_init) : move the
autosave code here.
* src/workbook.c : from here.
2000-11-09 Morten Welinder <terra@diku.dk>
* src/border.c (style_border_unref): Take border out of hash table
......
2000-11-10 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (workbook_format_toolbutton_update) :
Minor optimization to decrease flicker.
* src/sheet.c (sheet_cell_calc_span) : Clarify the semantics of
the various flags.
(cb_max_cell_width) : If the value used a dynamic format we need to
rerender ignoring the current width.
* src/rendered-value.c (rendered_value_new) : renamed from
rendered_value_new_ext and delete the old rendered_value_new.
Extend slightly to flag whether or not to handle dynamic formats.
* src/render-ascii.c (cell_region_render_ascii) : Handle the style
lookup localy.
* src/cell.c (cell_eval_content) : We need to manually render
the value here, but no longer need to calculate the size
seperately. That is done automatically in the render.
(cell_render_value) : Handle style localy, and calculate the size.
2000-11-09 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (workbook_control_gui_init) : move the
autosave code here.
* src/workbook.c : from here.
2000-11-09 Morten Welinder <terra@diku.dk>
* src/border.c (style_border_unref): Take border out of hash table
......
2000-11-10 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (workbook_format_toolbutton_update) :
Minor optimization to decrease flicker.
* src/sheet.c (sheet_cell_calc_span) : Clarify the semantics of
the various flags.
(cb_max_cell_width) : If the value used a dynamic format we need to
rerender ignoring the current width.
* src/rendered-value.c (rendered_value_new) : renamed from
rendered_value_new_ext and delete the old rendered_value_new.
Extend slightly to flag whether or not to handle dynamic formats.
* src/render-ascii.c (cell_region_render_ascii) : Handle the style
lookup localy.
* src/cell.c (cell_eval_content) : We need to manually render
the value here, but no longer need to calculate the size
seperately. That is done automatically in the render.
(cell_render_value) : Handle style localy, and calculate the size.
2000-11-09 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (workbook_control_gui_init) : move the
autosave code here.
* src/workbook.c : from here.
2000-11-09 Morten Welinder <terra@diku.dk>
* src/border.c (style_border_unref): Take border out of hash table
......
2000-11-10 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (workbook_format_toolbutton_update) :
Minor optimization to decrease flicker.
* src/sheet.c (sheet_cell_calc_span) : Clarify the semantics of
the various flags.
(cb_max_cell_width) : If the value used a dynamic format we need to
rerender ignoring the current width.
* src/rendered-value.c (rendered_value_new) : renamed from
rendered_value_new_ext and delete the old rendered_value_new.
Extend slightly to flag whether or not to handle dynamic formats.
* src/render-ascii.c (cell_region_render_ascii) : Handle the style
lookup localy.
* src/cell.c (cell_eval_content) : We need to manually render
the value here, but no longer need to calculate the size
seperately. That is done automatically in the render.
(cell_render_value) : Handle style localy, and calculate the size.
2000-11-09 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (workbook_control_gui_init) : move the
autosave code here.
* src/workbook.c : from here.
2000-11-09 Morten Welinder <terra@diku.dk>
* src/border.c (style_border_unref): Take border out of hash table
......
2000-11-10 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (workbook_format_toolbutton_update) :
Minor optimization to decrease flicker.
* src/sheet.c (sheet_cell_calc_span) : Clarify the semantics of
the various flags.
(cb_max_cell_width) : If the value used a dynamic format we need to
rerender ignoring the current width.
* src/rendered-value.c (rendered_value_new) : renamed from
rendered_value_new_ext and delete the old rendered_value_new.
Extend slightly to flag whether or not to handle dynamic formats.
* src/render-ascii.c (cell_region_render_ascii) : Handle the style
lookup localy.
* src/cell.c (cell_eval_content) : We need to manually render
the value here, but no longer need to calculate the size
seperately. That is done automatically in the render.
(cell_render_value) : Handle style localy, and calculate the size.
2000-11-09 Jody Goldberg <jgoldberg@home.com>
* src/workbook-control-gui.c (workbook_control_gui_init) : move the
autosave code here.
* src/workbook.c : from here.
2000-11-09 Morten Welinder <terra@diku.dk>
* src/border.c (style_border_unref): Take border out of hash table
......
......@@ -23,7 +23,7 @@ You need:
gtk+ >= 1.2.7 (gnome-libs 1.3 is not supported)
gnome-libs >= 1.0.57 (gnome-libs 2.0 is not supported)
libglade >= 0.14
gal >= 0.2.1.2
gal >= 0.2.2.0
gnome-print >= 0.24 (Be careful, newer version may not compile)
gnome-xml >= 1.8.7 (gnome-xml 2.x not supported yet)
......
......@@ -339,14 +339,14 @@ fi
dnl ******************************
dnl Gnome App Lib checking
dnl ******************************
AC_MSG_CHECKING(for Gnome App libraries (GAL) >= 0.01)
AC_MSG_CHECKING(for Gnome App libraries (GAL) >= 0.2.2.0)
if gnome-config --libs gal > /dev/null 2>&1; then
vers=`gnome-config --modversion gal | sed -e "s/gal-//" -e 's/cvs$//' -e 's/pre$//' | \
awk 'BEGIN { FS = "."; } { print $1*1000000 + $2*10000 + $3*100 + $4; }'`
if test "$vers" -ge 20102; then
if test "$vers" -ge 20200; then
AC_MSG_RESULT(found)
else
AC_MSG_ERROR(You need at least GNOME Application libs 0.2.1.2 for this version of Gnumeric)
AC_MSG_ERROR(You need at least GNOME Application libs 0.2.2.0 for this version of Gnumeric)
fi
else
AC_MSG_ERROR(Did not find GnomeAppLib (GAL) installed)
......
......@@ -20,7 +20,7 @@ Requires: gnome-print >= 0.24
Requires: libglade >= 0.14
Requires: libxml >= 1.8.5
Requires: libole2 >= 0.1.4
Requires: gal >= 0.2.1.2
Requires: gal >= 0.2.2.0
%description
GNOME (GNU Network Object Model Environment) is a user-friendly set of
......@@ -103,6 +103,9 @@ fi
%doc HACKING AUTHORS ChangeLog NEWS BUGS README COPYING TODO
%changelog
* Thu Nov 09 2000 Jody Goldberg <jgoldberg@home.com>
- Updated version requirements for GAL
* Fri Nov 03 2000 Jody Goldberg <jgoldberg@home.com>
- Updated version requirements for GAL
......
......@@ -191,7 +191,10 @@ cell_eval_content (Cell *cell)
v = value_new_error (&pos, "Internal error");
cell_assign_value (cell, v, NULL);
rendered_value_calc_size (cell);
/* TODO : Can we Use spancalc without too much performance overhead
* Seems like a better approach may be to do this at display time */
cell_render_value (cell, TRUE);
sheet_redraw_cell (cell);
}
......@@ -312,7 +315,7 @@ cell_set_text (Cell *cell, char const *text)
cell->base.flags &= ~CELL_HAS_EXPRESSION;
cell->value = val;
cell->format = format;
cell_render_value (cell);
cell_render_value (cell, TRUE);
} else { /* String was an expression */
cell_set_expr (cell, expr, format);
if (format) style_format_unref (format);
......@@ -352,7 +355,7 @@ cell_assign_value (Cell *cell, Value *v, StyleFormat *opt_fmt)
if (cell->value != NULL)
value_release (cell->value);
cell->value = v;
cell_render_value (cell);
cell_render_value (cell, TRUE);
}
/*
......@@ -631,9 +634,10 @@ cell_is_partial_array (Cell const *cell)
/***************************************************************************/
/*
* cell_render_value
/**
* cell_render_value :
* @cell: The cell whose value needs to be rendered
* @dynamic_width : Allow format to depend on column width.
*
* TODO :
* There is no reason currently for this to allocate the rendered value as
......@@ -642,15 +646,22 @@ cell_is_partial_array (Cell const *cell)
* are shared.
*/
void
cell_render_value (Cell *cell)
cell_render_value (Cell *cell, gboolean dynamic_width)
{
RenderedValue *rv;
MStyle *mstyle;
g_return_if_fail (cell != NULL);
rv = rendered_value_new (cell, NULL);
mstyle = cell_get_mstyle (cell);
rv = rendered_value_new (cell, mstyle, dynamic_width);
if (cell->rendered_value)
rendered_value_destroy (cell->rendered_value);
cell->rendered_value = rv;
rendered_value_calc_size_ext (cell, mstyle);
mstyle_unref (mstyle);
}
......@@ -756,7 +767,7 @@ cell_make_value (Cell *cell)
cell->base.flags &= ~CELL_HAS_EXPRESSION;
if (cell->rendered_value == NULL)
cell_render_value (cell);
cell_render_value (cell, TRUE);
cell_dirty (cell);
}
......@@ -91,6 +91,6 @@ char * cell_get_format (Cell const *cell);
void cell_set_format (Cell *cell, char const *format);
void cell_make_value (Cell *cell);
void cell_render_value (Cell *cell);
void cell_render_value (Cell *cell, gboolean dynamic_width);
#endif /* GNUMERIC_CELL_H */
......@@ -12,7 +12,7 @@
#include <glade/glade.h>
#include "gnumeric.h"
#include "workbook.h"
#include "workbook-control.h"
#include "workbook-control-gui-priv.h"
#include "gnumeric-util.h"
#include "dialogs.h"
......@@ -76,11 +76,8 @@ dialog_autosave (WorkbookControlGUI *wbcg)
gint v;
gboolean autosave_flag, prompt_flag;
autosave_t p;
Workbook *wb;
wb = wb_control_workbook (WORKBOOK_CONTROL (wbcg));
if (wb->autosave_timer != 0)
gtk_timeout_remove (wb->autosave_timer);
wb_control_gui_autosave_cancel (wbcg);
gui = gnumeric_glade_xml_new (wbcg, "autosave.glade");
if (gui == NULL)
......@@ -96,7 +93,7 @@ dialog_autosave (WorkbookControlGUI *wbcg)
return;
}
sprintf(buf, "%d", wb->autosave_minutes);
sprintf(buf, "%d", wbcg->autosave_minutes);
gtk_entry_set_text (GTK_ENTRY (p.minutes_entry), buf);
gnome_dialog_editable_enters (GNOME_DIALOG (dia),
......@@ -108,17 +105,17 @@ dialog_autosave (WorkbookControlGUI *wbcg)
gtk_object_set_user_data (GTK_OBJECT (autosave_on_off), &p);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autosave_on_off),
wb->autosave);
wbcg->autosave);
if (!wb->autosave) {
if (!wbcg->autosave) {
gtk_widget_set_sensitive (p.minutes_entry, FALSE);
gtk_widget_set_sensitive (p.prompt_cb, FALSE);
}
if (wb->autosave_prompt)
if (wbcg->autosave_prompt)
gtk_toggle_button_set_active ((GtkToggleButton *)
p.prompt_cb,
wb->autosave_prompt);
wbcg->autosave_prompt);
gtk_signal_connect (GTK_OBJECT (p.prompt_cb), "toggled",
GTK_SIGNAL_FUNC (prompt_on_off_toggled),
&prompt_flag);
......@@ -140,9 +137,9 @@ loop:
goto loop;
}
if (autosave_flag)
workbook_autosave_set (wb, tmp, prompt_flag);
wb_control_gui_autosave_set (wbcg, tmp, prompt_flag);
else
workbook_autosave_cancel (wb);
wb_control_gui_autosave_cancel (wbcg);
} else if (v == 2) {
GnomeHelpMenuEntry help_ref = { "gnumeric", "autosave.html" };
gnome_help_display (NULL, &help_ref);
......
......@@ -181,7 +181,7 @@ gnumeric_goal_seek (WorkbookControlGUI *wbcg, Sheet *sheet,
(void) goal_seek_eval (oldx, &ydummy, &evaldata);
}
sheet_cell_calc_span (change_cell, SPANCALC_RESIZE);
sheet_cell_calc_span (change_cell, SPANCALC_RENDER);
sheet_flag_status_update_cell (change_cell);
sheet_redraw_cell (change_cell);
......
......@@ -100,10 +100,10 @@ typedef Value * (*ForeachCellCB)(Sheet *sheet, int col, int row,
typedef enum _SpanCalcFlags {
SPANCALC_SIMPLE = 0x0, /* Just calc spans */
SPANCALC_RESIZE = 0x1, /* Calculate the size of the rendered result */
SPANCALC_RENDER = 0x2, /* render and size any unrendered cells */
SPANCALC_RE_RENDER = 0x4, /* render of all cells */
SPANCALC_NO_DRAW = 0x8, /* Do not */
SPANCALC_RESIZE = 0x1, /* Calculate sizes of all cells */
SPANCALC_RE_RENDER = 0x2, /* Render and Size all cells */
SPANCALC_RENDER = 0x4, /* Render and Size any unrendered cells */
SPANCALC_NO_DRAW = 0x8, /* Do not queue a redraw */
} SpanCalcFlags;
#endif /* GNUMERIC_H */
......@@ -200,7 +200,7 @@ cb_grid_get_cell (int row, int col, gpointer data)
else
cell->value = controller->get_cell_content_cb (row, col, controller->cb_data);
res = rendered_value_new_ext (cell, mstyle);
res = rendered_value_new (cell, mstyle, TRUE);
cell->rendered_value = res;
......
......@@ -12,6 +12,8 @@
#include "gnumeric-util.h"
#include "render-ascii.h"
#include "rendered-value.h"
#include "sheet.h"
#include "mstyle.h"
/*
* Renders a CellRegion (we only deal with Cell Regions of type
......@@ -43,9 +45,14 @@ cell_region_render_ascii (CellRegion *cr)
char *v;
if (c_copy->type != CELL_COPY_TYPE_TEXT) {
RenderedValue *rv = rendered_value_new (c_copy->u.cell, styles);
MStyle *mstyle = sheet_style_compute_from_list (styles,
c_copy->u.cell->pos.col,
c_copy->u.cell->pos.row);
RenderedValue *rv = rendered_value_new (c_copy->u.cell,
mstyle, FALSE);
v = rendered_value_get_text (rv);
rendered_value_destroy (rv);
mstyle_unref (mstyle);
} else
v = g_strdup (c_copy->u.text);
......
......@@ -34,38 +34,17 @@
#include "application.h"
/**
* rendered_value_new
* @cell: The cell whose value needs to be rendered.
* @styles : An optional collection of styles.
*
* Returns a RenderedValue displaying the value of the cell formated according
* to the format style. If formulas are being displayed the text of the a
* formula instead of its value.
*/
RenderedValue *
rendered_value_new (Cell *cell, GList *styles)
{
MStyle *mstyle = (styles != NULL)
? sheet_style_compute_from_list (styles, cell->pos.col, cell->pos.row)
: cell_get_mstyle (cell);
RenderedValue *res = rendered_value_new_ext (cell, mstyle);
mstyle_unref (mstyle);
return res;
}
/**
* rendered_value_new_ext:
* rendered_value_new:
* @cell: The cell
* @mstyle: The mstyle associated with the cell
* @dynamic_width : Allow format to depend on column width.
*
* Formats the value of the cell according to the format style given in @mstyle
*
* Return value: a new RenderedValue
**/
RenderedValue *
rendered_value_new_ext (Cell *cell, MStyle *mstyle)
rendered_value_new (Cell *cell, MStyle *mstyle, gboolean dynamic_width)
{
RenderedValue *res;
Sheet *sheet;
......@@ -85,14 +64,16 @@ rendered_value_new_ext (Cell *cell, MStyle *mstyle)
str = g_strconcat ("=", tmpstr, NULL);
g_free (tmpstr);
color = NULL;
dynamic_width = FALSE;
} else if (mstyle_is_element_set (mstyle, MSTYLE_FORMAT)) {
/* entered text CAN be null if called by set_value */
StyleFormat *format = mstyle_get_format (mstyle);
/* For format general approximate the cell width in characters */
if (style_format_is_general(format)) {
if (cell->format == NULL ||
style_format_is_general (cell->format)) {
if (style_format_is_general (format)) {
if (dynamic_width &&
(cell->format == NULL ||
style_format_is_general (cell->format))) {
StyleFont *style_font =
sheet_view_get_style_font (sheet, mstyle);
GdkFont *gdk_font =
......@@ -114,9 +95,12 @@ rendered_value_new_ext (Cell *cell, MStyle *mstyle)
col_width = (COL_INTERNAL_WIDTH (cell->col_info)) / font_width;
style_font_unref (style_font);
} else
} else {
format = cell->format;
}
dynamic_width = FALSE;
}
} else
dynamic_width = FALSE;
str = format_value (format, cell->value, &color, col_width);
} else {
g_warning ("No format: serious error");
......@@ -129,6 +113,7 @@ rendered_value_new_ext (Cell *cell, MStyle *mstyle)
res->rendered_text = string_get (str);
res->render_color = color;
res->width_pixel = res->height_pixel = 0;
res->dynamic_width = dynamic_width;
g_free (str);
return res;
......
......@@ -24,11 +24,12 @@ struct _RenderedValue {
* Computed sizes of rendered text.
* In pixels EXCLUSIVE of margins and grid lines
*/
int width_pixel, height_pixel;
short width_pixel, height_pixel;
gboolean dynamic_width;
};
RenderedValue * rendered_value_new (Cell *cell, GList *styles);
RenderedValue * rendered_value_new_ext (Cell *cell, MStyle *mstyle);
RenderedValue * rendered_value_new (Cell *cell, MStyle *mstyle,
gboolean dynamic_width);
void rendered_value_destroy (RenderedValue *rv);
void rendered_value_calc_size (Cell const *cell);
void rendered_value_calc_size_ext (Cell const *cell, MStyle *mstyle);
......
......@@ -348,19 +348,13 @@ sheet_cell_calc_span (Cell const *cell, SpanCalcFlags flags)
g_return_if_fail (cell != NULL);
if (flags & SPANCALC_RENDER) {
RenderedValue const *rv = cell->rendered_value;
if (rv == NULL) {
render = TRUE;
resize = TRUE;
} else if (rv->width_pixel == 0 && rv->width_pixel == 0)
resize = TRUE;
}
/* Render & Size any unrendered cells */
if ((flags & SPANCALC_RENDER) && cell->rendered_value == NULL)
render = TRUE;
if (render)
cell_render_value ((Cell *)cell);
if (resize)
cell_render_value ((Cell *)cell, TRUE);
else if (resize)
rendered_value_calc_size (cell);
/* Calculate the span of the cell */
......@@ -999,7 +993,15 @@ static Value *
cb_max_cell_width (Sheet *sheet, int col, int row, Cell *cell,
int *max)
{
int const width = cell_rendered_width (cell);
int width;
g_return_val_if_fail (cell->rendered_value != NULL, NULL);
/* Dynamic cells must be rerendered */
if (cell->rendered_value->dynamic_width)
cell_render_value (cell, FALSE);
width = cell_rendered_width (cell);
if (width > *max)
*max = width;
return NULL;
......
......@@ -138,5 +138,5 @@ workbook_style_test (Workbook *wb)
sheets = g_list_remove (sheets, sheet);
}
workbook_recalc (wb);
workbook_calc_spans (wb, SPANCALC_RENDER|SPANCALC_RESIZE);
workbook_calc_spans (wb, SPANCALC_RENDER);
}
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