X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fgtksheet%2Fpsppire-axis-impl.c;h=699e6aab5203f76e2663129adaf005898639be48;hb=be5dc743c6dca9293d3559b27e74c83bec57eaa7;hp=b722a87b16c4379a69b9ae4c5198c9b417328725;hpb=aae795eeb6eadf1381f4578b22d04001e501d32c;p=pspp-builds.git diff --git a/lib/gtksheet/psppire-axis-impl.c b/lib/gtksheet/psppire-axis-impl.c index b722a87b..699e6aab 100644 --- a/lib/gtksheet/psppire-axis-impl.c +++ b/lib/gtksheet/psppire-axis-impl.c @@ -40,6 +40,24 @@ struct axis_node struct tower_node unit_node; }; +void +psppire_axis_impl_dump (const PsppireAxisImpl *a) +{ + struct tower_node *n = tower_first (&a->unit_tower); + + g_debug ("Axis %p", a); + while (n) + { + const struct axis_node *an = tower_data (n, struct axis_node, unit_node); + const struct tower_node *pn = &an->pixel_node; + g_debug ("%ld units of height %g", + n->size, pn->size / (float) n->size); + + n = tower_next (&a->unit_tower, n); + } + g_debug ("\n"); +} + static gint unit_at_pixel (const PsppireAxis *axis, glong pixel) { @@ -419,16 +437,33 @@ psppire_axis_impl_clear (PsppireAxisImpl *a) void psppire_axis_impl_delete (PsppireAxisImpl *a, gint first, gint n_units) { - gint i; - g_warning ("%s FIXME: This is an inefficient implementation", __FUNCTION__); - + gint units_to_delete = n_units; + unsigned long int start; g_return_if_fail (first + n_units < tower_height (&a->unit_tower)); - for (i = first; i < first + n_units; ++i) + split (a, first); + split (a, first + n_units); + + struct tower_node *unit_node = tower_lookup (&a->unit_tower, first, &start); + g_assert (start == first); + + while (units_to_delete > 0) { - struct axis_node *an = make_single (a, first); + struct tower_node *next_unit_node; + struct axis_node *an = tower_data (unit_node, + struct axis_node, unit_node); + + g_assert (unit_node == &an->unit_node); + g_assert (unit_node->size <= n_units); - tower_delete (&a->unit_tower, &an->unit_node); + units_to_delete -= unit_node->size; + + next_unit_node = tower_next (&a->unit_tower, unit_node); + + tower_delete (&a->unit_tower, unit_node); tower_delete (&a->pixel_tower, &an->pixel_node); + + + unit_node = next_unit_node; } }