Add progress bar to downloading images
This commit is contained in:
parent
5c9fc917ac
commit
2a213028c0
1 changed files with 24 additions and 4 deletions
|
|
@ -438,16 +438,16 @@ void DrawingProgram::drag_drop_update() {
|
|||
else if(!droppedItem.isFile && is_valid_http_url(droppedItem.droppedData)) {
|
||||
auto img(std::make_shared<DrawImage>());
|
||||
img->coords = world.drawData.cam.c;
|
||||
Vector2f imDim = Vector2f{100.0f, 100.0f};
|
||||
img->d.p1 = droppedItem.pos - imDim;
|
||||
img->d.p2 = droppedItem.pos + imDim;
|
||||
img->d.imageID = {0, 0};
|
||||
img->commit_update(*this);
|
||||
uint64_t placement = components.client_list().size();
|
||||
auto objAdd = components.client_insert(placement, img);
|
||||
img->client_send_place(*this);
|
||||
add_undo_place_component(objAdd);
|
||||
droppedDownloadingFiles.emplace_back(objAdd, world.main.window.size.cast<float>(), FileDownloader::download_data_from_url(droppedItem.droppedData));
|
||||
Vector2f imDim = Vector2f{100.0f, 100.0f};
|
||||
img->d.p1 = droppedItem.pos - imDim;
|
||||
img->d.p2 = droppedItem.pos + imDim;
|
||||
img->d.imageID = {0, 0};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -707,6 +707,26 @@ void DrawingProgram::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if(!drawData.main->takingScreenshot) {
|
||||
for(auto& droppedDownFile : droppedDownloadingFiles) {
|
||||
if(droppedDownFile.comp->obj->collabListInfo.lock()) {
|
||||
canvas->save();
|
||||
auto img = std::static_pointer_cast<DrawImage>(droppedDownFile.comp->obj);
|
||||
img->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 = (img->d.p1 + img->d.p2) * 0.5f;
|
||||
|
||||
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, droppedDownFile.downData->progress * 360.0f, false, p);
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
canvas->clear(SkColor4f{0.0f, 0.0f, 0.0f, 0.0f});
|
||||
compCache.refresh_all_draw_cache(drawData);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue