[Xfce4-commits] <xfce4-cpugraph-plugin:master> Clean up the grid rendring code
Florian
noreply at xfce.org
Sat Apr 17 16:16:27 CEST 2010
Updating branch refs/heads/master
to 358c62c0c9abb7e4f74d5fa802a2a53a8303a520 (commit)
from 10e904cee3dd59e1efee1f6cb2d25488cead1d5c (commit)
commit 358c62c0c9abb7e4f74d5fa802a2a53a8303a520
Author: Florian <frivoal at gmail.com>
Date: Sat Feb 27 23:29:01 2010 +0900
Clean up the grid rendring code
The grid rendering code was a bit dusty, now it is shiny.
panel-plugin/mode.c | 27 ++++++++++++---------------
1 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/panel-plugin/mode.c b/panel-plugin/mode.c
index 2d19ed2..5206daf 100644
--- a/panel-plugin/mode.c
+++ b/panel-plugin/mode.c
@@ -139,32 +139,29 @@ typedef struct
void drawGraphGrid( CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h )
{
- int nrx = w / 6.0;
- int nry = h / 4.0;
int x, y;
-
+ long usage;
point last, current;
- last.x = -1;
+ last.x = 0;
+ last.y = h;
- /* draw grid */
gdk_gc_set_rgb_fg_color( fg1, &base->colors[1] );
- for( x = nrx; x >= 0; x-- )
+ for( x = 0; x * 6 < w; x++ )
{
- gdk_draw_line( da->window, fg1, x*6, 0, x*6, h );
+ gdk_draw_line( da->window, fg1, x*6, 0, x*6, h-1 );
}
- for( y = nry; y>=0; y-- )
+ for( y = 0; y * 4 < h; y++ )
{
- gdk_draw_line( da->window, fg1, 0, y*4, w, y*4 );
+ gdk_draw_line( da->window, fg1, 0, y*4, w-1, y*4 );
}
- /* draw data */
- gdk_gc_set_rgb_fg_color( fg2, &base->colors[2] );
- for( x = w; x >= 0; x-- )
+ gdk_gc_set_rgb_fg_color( fg1, &base->colors[2] );
+ for( x = 0; x < w; x++ )
{
+ usage = h * base->m_History[w - 1- x] / CPU_SCALE;
current.x = x;
- current.y = ((h - 1)*(CPU_SCALE - base->m_History[w - x]))/CPU_SCALE;
- if( last.x == -1 ) last = current;
- gdk_draw_line( da->window, fg2, current.x, current.y, last.x, last.y );
+ current.y = h - usage;
+ gdk_draw_line( da->window, fg1, current.x, current.y, last.x, last.y );
last = current;
}
}
More information about the Xfce4-commits
mailing list