[Xfce4-commits] <xfce4-cpugraph-plugin:master> Cleanup the Normal rendering mode
Florian
noreply at xfce.org
Sat Apr 17 16:16:25 CEST 2010
Updating branch refs/heads/master
to e2ede49414d3d4aac031206e8a98e92a96de28b9 (commit)
from 19f98ab2cff4421efebfe207d4041ca48caa5fa0 (commit)
commit e2ede49414d3d4aac031206e8a98e92a96de28b9
Author: Florian <frivoal at gmail.com>
Date: Sat Feb 27 18:31:40 2010 +0900
Cleanup the Normal rendering mode
General code clean up in the normal rendering mode, and remove mistaken
shift in the normal mode even though the optional frame is drawn outside
of the graph area, the drawing code for the Normal mode tried to
compensate for it.
panel-plugin/mode.c | 41 +++++++++++++++++------------------------
1 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/panel-plugin/mode.c b/panel-plugin/mode.c
index 09600e8..1199f1c 100644
--- a/panel-plugin/mode.c
+++ b/panel-plugin/mode.c
@@ -40,48 +40,41 @@ static void MixAndApplyColors( double ratio, GdkColor *color1, GdkColor *color2,
void drawGraphModeNormal( CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h )
{
int x, y;
+ long usage;
+ double t;
+ int tmp;
- for( x = w; x >= 0; x-- )
+ if( base->m_ColorMode == 0 )
+ gdk_gc_set_rgb_fg_color( fg1, &base->colors[1] );
+
+ for( x = 0; x < w; x++ )
{
- long usage = h * base->m_History[w - x] / CPU_SCALE;
+ usage = h * base->m_History[w - 1- x] / CPU_SCALE;
if( usage == 0 ) continue;
if( base->m_ColorMode == 0 )
{
- gdk_gc_set_rgb_fg_color( fg1, &base->colors[1] );
-
- if( base->m_Frame )
- gdk_draw_line( da->window, fg1, x+1, h+1-usage, x+1, h );
- else
- gdk_draw_line( da->window, fg1, x, h-usage, x, h-1 );
+ gdk_draw_line( da->window, fg1, x, h-usage, x, h-1 );
}
else if( base->m_ColorMode == 3 ) /* cpu freq. based */
{
- double t = (double) (base->m_History[base->m_Values+ w - x] - base->m_CpuData[0].scalMinFreq)
+ t = (double) (base->m_History[base->m_Values+ w -1 - x] - base->m_CpuData[0].scalMinFreq)
/ (base->m_CpuData[0].scalMaxFreq - base->m_CpuData[0].scalMinFreq);
MixAndApplyColors( t, &base->colors[1], &base->colors[2], fg1);
-
- if( base->m_Frame )
- gdk_draw_line( da->window, fg1 , x+1, h+1-usage, x+1, h );
- else
- gdk_draw_line( da->window, fg1 , x, h-usage, x, h-1 );
+ gdk_draw_line( da->window, fg1 , x, h-usage, x, h-1 );
}
else /* 1 or 2 */
{
- int tmp = 0;
- int length = h - (h - usage);
- for( y = h; y >= h - usage; y--, tmp++ )
+ tmp = 0;
+ for( y = h-1; y >= h - usage; y--, tmp++ )
{
- if( base->m_ColorMode > 0 )
- {
- double t = (base->m_ColorMode == 1) ?
- (tmp / (double) (h)) :
- (tmp / (double) (length));
- MixAndApplyColors( t, &base->colors[1], &base->colors[2], fg1);
- }
+ t = (base->m_ColorMode == 1) ?
+ (tmp / (double) (h)) :
+ (tmp / (double) (usage));
+ MixAndApplyColors( t, &base->colors[1], &base->colors[2], fg1);
gdk_draw_point( da->window, fg1, x, y );
}
}
More information about the Xfce4-commits
mailing list