well i implemented a progress bar into my os (or rather tried) and it works for the most part.....
i have this for my ProgressBarSetFill() function:
Code: Select all
void ProgressBarSetFill(PROGBAR bar, byte fill)
{
float tmp = (float)fill / 100;//Make fill a percent
tmp = tmp * bar.width;//Get percentage of bar width for drawing
bar.fill = (int)tmp;//Load the value into the PROGBAR struct
}
Code: Select all
void ProgressBarDraw(PROGBAR bar)
{
VGA::clearScreen(15);//Clear the screen
int x,y,x2,y2;//Some variables used
byte color;
x = bar.x;//x1
y = bar.y;//y1
x2 = x + bar.width;//get x2 by adding the width to x1
y2 = y + bar.height;//get y2 by adding height to y1
color = bar.color;//the color of the bar
VGA::drawRectangle(x,y,x2,y2,color,false);//draw the progress bar outline
x2 = bar.x + bar.fill;//get x2 of the filled rectangle by adding the fill
y2 = bar.y + bar.height;//same as y2 above
VGA::drawRectangle(x,y,x2,y2,color,true);//draw the fill of the progress bar
}
Code: Select all
static void drawRectangle(int x1=0,int y1=0, int x2=0, int y2=0, byte color=0, bool fill = false);
i have this in my main kernel file:
Code: Select all
PROGBAR Progbar = CreateProgressBar(10,10,100,5,0);
ProgressBarSetFill(Progbar, 50);
ProgressBarDraw(Progbar);
