diff options
Diffstat (limited to 'c/main.cpp')
-rw-r--r-- | c/main.cpp | 53 |
1 files changed, 21 insertions, 32 deletions
@@ -178,8 +178,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case 0x02E0: /* WM_DPICHANGED */ { - LPRECT lpr; - lpr = (LPRECT)lParam; + LPRECT lpr = (LPRECT)lParam; g_iDPI = HIWORD(wParam); SetWindowPos(hWnd, NULL, lpr->left, lpr->top, @@ -212,6 +211,9 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case IDT_TIMER: { static int i = 0; + + /* Animate ellipsis in status bar while doing + * work in other thread. */ if (Pl("episode_data","thread_running","A",g_aThread)) { i = (i+1)%4; SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), @@ -258,28 +260,22 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_WATCHED: { - int iEpFocus; CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, g_bViewWatched? MF_UNCHECKED: MF_CHECKED); g_bViewWatched = !g_bViewWatched; - g_elv.Update(); Pl("cfg","set_view_watched","I",g_bViewWatched); - iEpFocus = ListView_GetNextItem(g_elv.HWnd(), -1, LVNI_FOCUSED); - if (iEpFocus == -1) break; - ListView_EnsureVisible(g_elv.HWnd(), iEpFocus, TRUE); + g_elv.Update(); + g_elv.EnsureFocusVisible(); break; } case IDM_VIEW_TV_ORIGINAL: { - int iEpFocus; CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, g_bViewTVOriginal? MF_UNCHECKED: MF_CHECKED); g_bViewTVOriginal = !g_bViewTVOriginal; - g_elv.Update(); Pl("cfg","set_view_tv_original","I",g_bViewTVOriginal); - iEpFocus = ListView_GetNextItem(g_elv.HWnd(), -1, LVNI_FOCUSED); - if (iEpFocus == -1) break; - ListView_EnsureVisible(g_elv.HWnd(), iEpFocus, TRUE); + g_elv.Update(); + g_elv.EnsureFocusVisible(); break; } case IDM_VIEW_OTHERS: /* Show/hide other screenwriters. */ @@ -290,27 +286,25 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) MF_CHECKED); g_szLimitScreenwriter[0] = 0; } else { - char *sz; - LVITEM lvi; iEpFocus = ListView_GetNextItem(g_elv.HWnd(), -1, LVNI_FOCUSED); if (iEpFocus == -1) break; + + LVITEM lvi; lvi.iItem = iEpFocus; lvi.mask = LVIF_PARAM; if (!ListView_GetItem(g_elv.HWnd(), &lvi)) break; - if (!Pl("episode_data","episode_datum","ISs", - lvi.lParam,"Screenwriter",&sz)) + + char *sz; + if (!Pl("episode_data","episode_datum","ISs",lvi.lParam,"Screenwriter",&sz)) break; strcpy_s(g_szLimitScreenwriter, sizeof(g_szLimitScreenwriter), sz); CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_UNCHECKED); } + Pl("cfg","set_limit_screenwriter","S",g_szLimitScreenwriter); g_elv.Update(); - Pl("cfg","set_limit_screenwriter","S", - g_szLimitScreenwriter); - iEpFocus = ListView_GetNextItem(g_elv.HWnd(), -1, LVNI_FOCUSED); - if (iEpFocus == -1) break; - ListView_EnsureVisible(g_elv.HWnd(), iEpFocus, TRUE); + g_elv.EnsureFocusVisible(); break; } case IDM_WATCH_LOCALLY: @@ -456,8 +450,7 @@ AboutDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) HWND CreateStatusBar(HWND hWndParent, HINSTANCE hInstance) { - HWND hWnd; - hWnd = CreateWindowEx( + HWND hWnd = CreateWindowEx( 0, STATUSCLASSNAME, (LPCTSTR) NULL, @@ -485,10 +478,7 @@ Attach() void SetupFonts() { - HMODULE hModule; - LOGFONT lf; - - hModule = LoadLibrary(TEXT("User32.dll")); + HMODULE hModule = LoadLibrary(TEXT("User32.dll")); if (hModule && GetProcAddress(hModule, "SystemParametersInfoW")) { NONCLIENTMETRICS m; m.cbSize = sizeof(NONCLIENTMETRICS); @@ -499,6 +489,8 @@ SetupFonts() } else g_hfNormal = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)); + + LOGFONT lf; GetObject(g_hfNormal, sizeof(LOGFONT), &lf); lf.lfWeight = FW_BOLD; g_fBold = CreateFontIndirect(&lf); @@ -537,11 +529,8 @@ UpdateLayout() SendMessage(g_dlv.HWnd(), WM_SETREDRAW, TRUE, 0); /* Resize status bar parts. */ - { - int aParts[] = {rc.right-Dpi(55), rc.right}; - SendMessage(g_hWndStatus, SB_SETPARTS, - (WPARAM)sizeof(aParts), (LPARAM)aParts); - } + int aParts[] = {rc.right-Dpi(55), rc.right}; + SendMessage(g_hWndStatus, SB_SETPARTS, (WPARAM)sizeof(aParts), (LPARAM)aParts); } /* Try to style application according to current Windows theme. */ |