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

[ui] fix flickering of Status and Info fields

* Closes #634
This commit is contained in:
Pete Batard 2016-02-23 11:21:36 +00:00
parent 3a266d92a7
commit 0e65b1c920
5 changed files with 56 additions and 14 deletions

View file

@ -1,6 +1,6 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Message-Digest algorithms (sha1sum, md5sum) * Message-Digest algorithms (md5sum, sha1sum, sha256sum)
* Copyright © 1998-2001 Free Software Foundation, Inc. * Copyright © 1998-2001 Free Software Foundation, Inc.
* Copyright © 2004 g10 Code GmbH * Copyright © 2004 g10 Code GmbH
* Copyright © 2006-2012 Brad Conte <brad@bradconte.com> * Copyright © 2006-2012 Brad Conte <brad@bradconte.com>

View file

@ -307,8 +307,6 @@ static void print_extracted_file(char* psz_fullpath, int64_t i_file_length)
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, TRUE, FALSE)); safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, TRUE, FALSE));
uprintf("Extracting: %s\n", psz_fullpath); uprintf("Extracting: %s\n", psz_fullpath);
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, FALSE, FALSE)); safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, FALSE, FALSE));
// TODO: I don't think we need both of these...
SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, psz_fullpath);
PrintStatus(0, MSG_000, psz_fullpath); // MSG_000 is "%s" PrintStatus(0, MSG_000, psz_fullpath); // MSG_000 is "%s"
// ISO9660 cannot handle backslashes // ISO9660 cannot handle backslashes
for (i=0; i<nul_pos; i++) for (i=0; i<nul_pos; i++)

View file

@ -418,17 +418,59 @@ char* lmprintf(uint32_t msg_id, ...)
#define MSG_INFO 1 #define MSG_INFO 1
#define MSG_LOW_PRI 0 #define MSG_LOW_PRI 0
#define MSG_HIGH_PRI 1 #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 szMessage[2][2][MSG_LEN] = { {"", ""}, {"", ""} };
char* szStatusMessage = szMessage[MSG_STATUS][MSG_HIGH_PRI]; char* szStatusMessage = szMessage[MSG_STATUS][MSG_HIGH_PRI];
static BOOL bStatusTimerArmed = FALSE; static BOOL bStatusTimerArmed = FALSE, bOutputTimerArmed[2] = { FALSE, FALSE };
static char *output_msg[2];
static uint64_t last_msg_time[2] = { 0, 0 };
static void __inline OutputMessage(BOOL info, char* msg) static void PrintInfoMessage(char* msg) {
{
if (info)
SetWindowTextU(hInfo, msg); SetWindowTextU(hInfo, msg);
else }
static void PrintStatusMessage(char* msg) {
SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, msg); SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, msg);
} }
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
* 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)
{
int i = (idEvent == TID_OUTPUT_INFO)? 0 : 1;
KillTimer(hMainDialog, idEvent);
bOutputTimerArmed[i] = FALSE;
PrintMessage[i](output_msg[i]);
last_msg_time[i] = GetTickCount64();
}
static void OutputMessage(BOOL info, char* msg)
{
uint64_t delta;
int i = info ? 0 : 1;
if (bOutputTimerArmed[i]) {
// Already have a delayed message going - just change that message to latest
output_msg[i] = msg;
} else {
// Find if we need to arm a timer
delta = GetTickCount64() - last_msg_time[i];
if (delta < MSG_DELAY) {
// 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);
bOutputTimerArmed[i] = TRUE;
} else {
PrintMessage[i](msg);
last_msg_time[i] = GetTickCount64();
}
}
}
static void CALLBACK PrintMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) static void CALLBACK PrintMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{ {

View file

@ -168,6 +168,8 @@ typedef struct {
enum timer_type { enum timer_type {
TID_MESSAGE_INFO = 0x1000, TID_MESSAGE_INFO = 0x1000,
TID_MESSAGE_STATUS, TID_MESSAGE_STATUS,
TID_OUTPUT_INFO,
TID_OUTPUT_STATUS,
TID_BADBLOCKS_UPDATE, TID_BADBLOCKS_UPDATE,
TID_APP_TIMER, TID_APP_TIMER,
TID_BLOCKING_TIMER, TID_BLOCKING_TIMER,

View file

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