add download progress, improbable cloud browser, lock touch when pencil is down on iOS

This commit is contained in:
2018-01-04 00:02:28 +00:00
parent 01370642a1
commit 5feb3acb1d
10 changed files with 120 additions and 37 deletions

View File

@@ -63,7 +63,15 @@ void App::initLog()
LogRemote::I.file_init();
}
void App::download(std::string filename)
int progress_callback(void *clientp, curl_off_t dltotal,
curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
{
std::function<void(float)> progress = *(std::function<void(float)>*)clientp;
progress((float)dlnow / (float)dltotal);
return 0;
}
void App::download(std::string filename, std::function<void(float)> progress)
{
CURL *curl = curl_easy_init();
if (curl)
@@ -74,6 +82,9 @@ void App::download(std::string filename)
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_write);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &progress);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
auto err = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
@@ -213,6 +224,11 @@ void App::async_update()
#endif
}
void App::async_redraw()
{
redraw = true;
}
void App::async_end()
{
#if __OSX__