Move draw_progress_bar() to SkinTheme::drawProgressBar()

This commit is contained in:
David Capello 2013-01-06 14:52:57 -03:00
parent 370e9cdd08
commit 76c4fd8243
6 changed files with 26 additions and 30 deletions

View File

@ -428,23 +428,3 @@ void draw_color_button(BITMAP* bmp,
PART_COLORBAR_BORDER_HOTFG_NW);
}
}
void draw_progress_bar(BITMAP* bmp,
int x1, int y1, int x2, int y2,
float progress)
{
SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get();
int w = x2 - x1 + 1;
int u = (int)((float)(w-2)*progress);
u = MID(0, u, w-2);
rect(bmp, x1, y1, x2, y2, ui::to_system(theme->getColor(ThemeColor::Text)));
if (u > 0)
rectfill(bmp, x1+1, y1+1, x1+u, y2-1,
ui::to_system(theme->getColor(ThemeColor::Selected)));
if (1+u < w-2)
rectfill(bmp, x1+u+1, y1+1, x2-1, y2-1,
ui::to_system(theme->getColor(ThemeColor::Background)));
}

View File

@ -44,8 +44,5 @@ void draw_color_button(BITMAP* bmp,
bool outer_se, bool outer_s, bool outer_sw, bool outer_w,
PixelFormat pixelFormat, const app::Color& color,
bool hot, bool drag);
void draw_progress_bar(BITMAP* bmp,
int x1, int y1, int x2, int y2,
float progress);
#endif

View File

@ -2142,6 +2142,23 @@ void SkinTheme::draw_part_as_vline(BITMAP* bmp, int x1, int y1, int x2, int y2,
}
}
void SkinTheme::drawProgressBar(BITMAP* bmp, int x1, int y1, int x2, int y2, float progress)
{
int w = x2 - x1 + 1;
int u = (int)((float)(w-2)*progress);
u = MID(0, u, w-2);
rect(bmp, x1, y1, x2, y2, ui::to_system(getColor(ThemeColor::Text)));
if (u > 0)
rectfill(bmp, x1+1, y1+1, x1+u, y2-1,
ui::to_system(getColor(ThemeColor::Selected)));
if (1+u < w-2)
rectfill(bmp, x1+u+1, y1+1, x2-1, y2-1,
ui::to_system(getColor(ThemeColor::Background)));
}
void SkinTheme::less_bevel(int *bevel)
{
if (bevel[0] > 0) --bevel[0];

View File

@ -168,6 +168,8 @@ public:
draw_bounds_nw(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, nw, bg);
}
void drawProgressBar(BITMAP* bmp, int x1, int y1, int x2, int y2, float progress);
protected:
void onRegenerate();

View File

@ -198,10 +198,10 @@ bool FileList::onProcessMessage(Message* msg)
ThumbnailGenerator::WorkerStatus workerStatus =
ThumbnailGenerator::instance()->getWorkerStatus(fi, progress);
if (workerStatus == ThumbnailGenerator::WorkingOnThumbnail) {
draw_progress_bar(ji_screen,
this->rc->x2-2-64, y+itemSize.h/2-3,
this->rc->x2-2, y+itemSize.h/2+3,
progress);
theme->drawProgressBar(ji_screen,
this->rc->x2-2-64, y+itemSize.h/2-3,
this->rc->x2-2, y+itemSize.h/2+3,
progress);
}
// Thumbnail position

View File

@ -588,9 +588,9 @@ bool StatusBar::onProcessMessage(Message* msg)
for (ProgressList::iterator it = m_progress.begin(); it != m_progress.end(); ++it) {
Progress* progress = *it;
draw_progress_bar(doublebuffer,
x, y1, x+width-1, y2,
progress->getPos());
theme->drawProgressBar(doublebuffer,
x, y1, x+width-1, y2,
progress->getPos());
x -= width+4;
}