graph: draw everything in one loop

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-12 16:14:13 +02:00
parent 4b6ba11360
commit 3fa072504f
1 changed files with 69 additions and 83 deletions

View File

@ -140,11 +140,10 @@ graph_draw(draw_context_t *ctx,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
void *p __attribute__ ((unused))) void *p __attribute__ ((unused)))
{ {
int margin_top; int margin_top, y;
int y, tmp, cur_index, test_index;
graph_data_t *d = w->widget->data; graph_data_t *d = w->widget->data;
area_t rectangle, pattern_area; area_t rectangle, pattern_area;
graph_t *graph, *graphtmp; graph_t *graph;
if(!d->graphs) if(!d->graphs)
return 0; return 0;
@ -179,13 +178,11 @@ graph_draw(draw_context_t *ctx,
else else
pattern_area.x = rectangle.x; pattern_area.x = rectangle.x;
pattern_area.y = rectangle.y - rectangle.height;
for(graph = d->graphs; graph; graph = graph->next) for(graph = d->graphs; graph; graph = graph->next)
switch(graph->draw_style)
{ {
if(graph->draw_style != Top_Style) case Top_Style:
continue; pattern_area.y = rectangle.y - rectangle.height;
if(graph->vertical_gradient) if(graph->vertical_gradient)
{ {
pattern_area.width = 0; pattern_area.width = 0;
@ -209,16 +206,9 @@ graph_draw(draw_context_t *ctx,
} }
draw_graph(ctx, rectangle , d->draw_from, d->draw_to, graph->index, d->grow, pattern_area, draw_graph(ctx, rectangle , d->draw_from, d->draw_to, graph->index, d->grow, pattern_area,
&graph->color_start, graph->pcolor_center, graph->pcolor_end); &graph->color_start, graph->pcolor_center, graph->pcolor_end);
} break;
case Bottom_Style:
pattern_area.y = rectangle.y; pattern_area.y = rectangle.y;
/* draw style = bottom */
for(graph = d->graphs; graph; graph = graph->next)
{
if(graph->draw_style != Bottom_Style)
continue;
if(graph->vertical_gradient) if(graph->vertical_gradient)
{ {
pattern_area.width = 0; pattern_area.width = 0;
@ -237,14 +227,9 @@ graph_draw(draw_context_t *ctx,
p_clear(d->draw_from, d->size); p_clear(d->draw_from, d->size);
draw_graph(ctx, rectangle, d->draw_from, graph->lines, graph->index, d->grow, pattern_area, draw_graph(ctx, rectangle, d->draw_from, graph->lines, graph->index, d->grow, pattern_area,
&graph->color_start, graph->pcolor_center, graph->pcolor_end); &graph->color_start, graph->pcolor_center, graph->pcolor_end);
} break;
case Line_Style:
/* draw style = line */ pattern_area.y = rectangle.y;
for(graph = d->graphs; graph; graph = graph->next)
{
if(graph->draw_style != Line_Style)
continue;
if(graph->vertical_gradient) if(graph->vertical_gradient)
{ {
pattern_area.width = 0; pattern_area.width = 0;
@ -261,6 +246,7 @@ graph_draw(draw_context_t *ctx,
draw_graph_line(ctx, rectangle, graph->lines, graph->index, d->grow, pattern_area, draw_graph_line(ctx, rectangle, graph->lines, graph->index, d->grow, pattern_area,
&graph->color_start, graph->pcolor_center, graph->pcolor_end); &graph->color_start, graph->pcolor_center, graph->pcolor_end);
break;
} }
/* draw border (after line-drawing, what paints 0-values to the border) */ /* draw border (after line-drawing, what paints 0-values to the border) */