Make sure progress bar is centered on image

This commit is contained in:
Yousef Khadadeh 2025-10-10 14:45:33 +03:00
parent 2aab3e9e60
commit d633e549bc

View file

@ -59,18 +59,22 @@ void DrawImage::update_from_delayed_ptr(const std::shared_ptr<DrawComponent>& de
void DrawImage::draw_download_progress_bar(SkCanvas* canvas, const DrawData& drawData, float progress) {
if(progress == 0.0f)
return;
canvas->save();
canvas_do_calculated_transform(canvas);
SkPaint p;
p.setStroke(true);
p.setStrokeWidth(10.0f);
p.setStrokeCap(SkPaint::kRound_Cap);
p.setColor4f(drawData.main->toolbar.io->theme->fillColor5);
Vector2f center = (d.p1 + d.p2) * 0.5f;
calculate_draw_transform(drawData);
if(drawSetupData.shouldDraw) {
canvas->save();
canvas_do_calculated_transform(canvas);
SkPaint p;
p.setStroke(true);
p.setStrokeWidth(10.0f);
p.setStrokeCap(SkPaint::kRound_Cap);
p.setColor4f(drawData.main->toolbar.io->theme->fillColor5);
Vector2f center = convert_vec2<Vector2f>(imRect.center());
const float DOWNLOAD_ARC_RADIUS = 50.0f;
canvas->drawArc(SkRect::MakeLTRB(center.x() - DOWNLOAD_ARC_RADIUS, center.y() - DOWNLOAD_ARC_RADIUS, center.x() + DOWNLOAD_ARC_RADIUS, center.y() + DOWNLOAD_ARC_RADIUS), 0.0f, progress * 360.0f, false, p);
canvas->restore();
const float DOWNLOAD_ARC_RADIUS = 50.0f;
canvas->drawArc(SkRect::MakeLTRB(center.x() - DOWNLOAD_ARC_RADIUS, center.y() - DOWNLOAD_ARC_RADIUS, center.x() + DOWNLOAD_ARC_RADIUS, center.y() + DOWNLOAD_ARC_RADIUS), 0.0f, progress * 360.0f, false, p);
canvas->restore();
drawSetupData.shouldDraw = false;
}
}
void DrawImage::draw(SkCanvas* canvas, const DrawData& drawData) {