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) { void DrawImage::draw_download_progress_bar(SkCanvas* canvas, const DrawData& drawData, float progress) {
if(progress == 0.0f) if(progress == 0.0f)
return; return;
canvas->save(); calculate_draw_transform(drawData);
canvas_do_calculated_transform(canvas); if(drawSetupData.shouldDraw) {
SkPaint p; canvas->save();
p.setStroke(true); canvas_do_calculated_transform(canvas);
p.setStrokeWidth(10.0f); SkPaint p;
p.setStrokeCap(SkPaint::kRound_Cap); p.setStroke(true);
p.setColor4f(drawData.main->toolbar.io->theme->fillColor5); p.setStrokeWidth(10.0f);
Vector2f center = (d.p1 + d.p2) * 0.5f; 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; 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->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(); canvas->restore();
drawSetupData.shouldDraw = false;
}
} }
void DrawImage::draw(SkCanvas* canvas, const DrawData& drawData) { void DrawImage::draw(SkCanvas* canvas, const DrawData& drawData) {