1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ui] improve progress bar refresh

* Closes #699
This commit is contained in:
Pete Batard 2016-03-10 16:13:16 +00:00
parent a10a207790
commit b82462bb7d
6 changed files with 21 additions and 17 deletions

View file

@ -873,7 +873,7 @@ DWORD WINAPI SumThread(void* param)
read_size[0] = 1; // Don't trigger the first loop break
for (rb = 0; ;rb += read_size[_bufnum]) {
// Update the progress and check for cancel
if (_GetTickCount64() > LastRefresh + 25) {
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*rb) / (1.0f*img_report.projected_size);
PrintInfo(0, MSG_271, format_percent);

View file

@ -612,7 +612,7 @@ static BOOL FormatFAT32(DWORD DriveIndex)
format_percent = 0.0f;
for (i=0; i<(SystemAreaSize+BurstSize-1); i+=BurstSize) {
if (_GetTickCount64() > LastRefresh + 25) {
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*i)/(1.0f*(SystemAreaSize+BurstSize));
PrintInfo(0, MSG_217, format_percent);
@ -1449,7 +1449,7 @@ static DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
static void update_progress(const uint64_t processed_bytes)
{
if (_GetTickCount64() > LastRefresh + 25) {
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*processed_bytes)/(1.0f*img_report.projected_size);
PrintInfo(0, MSG_261, format_percent);
@ -1497,7 +1497,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
// will be as fast, if not faster, than whatever async scheme you can come up with.
rSize = BufSize;
for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) {
if (_GetTickCount64() > LastRefresh + 25) {
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb) / (1.0f*target_size);
PrintInfo(0, hSourceImage?MSG_261:MSG_286, format_percent);
@ -2043,7 +2043,7 @@ DWORD WINAPI SaveImageThread(void* param)
}
if (rSize == 0)
break;
if (_GetTickCount64() > LastRefresh + 25) {
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb)/(1.0f*SelectedDrive.DiskSize);
PrintInfo(0, MSG_261, format_percent);

View file

@ -418,8 +418,6 @@ char* lmprintf(uint32_t msg_id, ...)
#define MSG_INFO 1
#define MSG_LOW_PRI 0
#define MSG_HIGH_PRI 1
// Minimum delay between Info and Status message refreshes, in ms
#define MSG_DELAY 50
char szMessage[2][2][MSG_LEN] = { {"", ""}, {"", ""} };
char* szStatusMessage = szMessage[MSG_STATUS][MSG_HIGH_PRI];
static BOOL bStatusTimerArmed = FALSE, bOutputTimerArmed[2] = { FALSE, FALSE };
@ -436,7 +434,7 @@ typedef void PRINT_FUNCTION(char*);
PRINT_FUNCTION *PrintMessage[2] = { PrintInfoMessage, PrintStatusMessage };
/*
* The following timer call is used, along with MSG_DELAY, to prevent obnoxious flicker
* The following timer call is used, along with MAX_REFRESH, to prevent obnoxious flicker
* on the Info and Status fields due to messages being updated too quickly.
*/
static void CALLBACK OutputMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
@ -460,10 +458,10 @@ static void OutputMessage(BOOL info, char* msg)
} else {
// Find if we need to arm a timer
delta = _GetTickCount64() - last_msg_time[i];
if (delta < MSG_DELAY) {
if (delta < (2 * MAX_REFRESH)) {
// Not enough time has elapsed since our last output => arm a timer
output_msg[i] = msg;
SetTimer(hMainDialog, TID_OUTPUT_INFO + i, (UINT)(MSG_DELAY - delta), OutputMessageTimeout);
SetTimer(hMainDialog, TID_OUTPUT_INFO + i, (UINT)((2 * MAX_REFRESH) - delta), OutputMessageTimeout);
bOutputTimerArmed[i] = TRUE;
} else {
PrintMessage[i](msg);

View file

@ -763,6 +763,7 @@ static void InitProgress(BOOL bOnlyFormat)
void UpdateProgress(int op, float percent)
{
int pos;
static uint64_t LastRefresh = 0;
if ((op < 0) || (op >= OP_MAX)) {
duprintf("UpdateProgress: invalid op %d\n", op);
@ -794,8 +795,12 @@ void UpdateProgress(int op, float percent)
pos = MAX_PROGRESS;
}
SendMessage(hProgress, PBM_SETPOS, (WPARAM)pos, 0);
SetTaskbarProgressValue(pos, MAX_PROGRESS);
// Reduce the refresh rate, to avoid weird effects on the sliding part of progress bar
if (_GetTickCount64() > LastRefresh + (2 * MAX_REFRESH)) {
LastRefresh = _GetTickCount64();
SendMessage(hProgress, PBM_SETPOS, (WPARAM)pos, 0);
SetTaskbarProgressValue(pos, MAX_PROGRESS);
}
}
/*

View file

@ -55,6 +55,7 @@
#define MAX_CLUSTER_SIZES 18
#define MAX_PROGRESS (0xFFFF-1) // leave room for 1 more for insta-progress workaround
#define MAX_LOG_SIZE 0x7FFFFFFE
#define MAX_REFRESH 25 // How long we should wait to refresh UI elements (in ms)
#define MAX_GUID_STRING_LENGTH 40
#define MAX_GPT_PARTITIONS 128
#define MAX_SECTORS_TO_CLEAR 128 // nb sectors to zap when clearing the MBR/GPT (must be >34)

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.8.881"
CAPTION "Rufus 2.8.882"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -320,8 +320,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,8,881,0
PRODUCTVERSION 2,8,881,0
FILEVERSION 2,8,882,0
PRODUCTVERSION 2,8,882,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -338,13 +338,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.8.881"
VALUE "FileVersion", "2.8.882"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.8.881"
VALUE "ProductVersion", "2.8.882"
END
END
BLOCK "VarFileInfo"