From b29d38e6aa55b98ff139c7a83a8670fac6caab83 Mon Sep 17 00:00:00 2001 From: cfillion Date: Mon, 4 Nov 2024 09:49:38 -0500 Subject: [PATCH] repair setting the gradient end color on Windows (red/blue swapped since 2.14) [t=295534] Regression from 5b4b764f7d9a273ff51f2ce1d73cec2b95bd5069 --- Color/Color.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Color/Color.cpp b/Color/Color.cpp index 662ea0767..ad7793eb5 100644 --- a/Color/Color.cpp +++ b/Color/Color.cpp @@ -162,6 +162,15 @@ INT_PTR WINAPI doColorDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_COMMAND: { wParam = LOWORD(wParam); + + COLORREF *color; + switch(wParam) + { + case IDC_COLOR1: color = &g_crGradStart; break; + case IDC_COLOR2: color = &g_crGradEnd; break; + default: color = nullptr; break; + } + switch(wParam) { case IDC_COLOR1: @@ -176,22 +185,12 @@ INT_PTR WINAPI doColorDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) cc.lpCustColors = g_custColors; cc.Flags = CC_FULLOPEN | CC_RGBINIT; - if (wParam == IDC_COLOR1) - { - cc.rgbResult = SWS_ColorToNative(g_crGradStart); - if (ChooseColor(&cc)) - { - g_crGradStart = SWS_ColorFromNative(cc.rgbResult) & 0xFFFFFF; - PersistColors(); - RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); - } - } - else if (wParam == IDC_COLOR2) + if (color) { - cc.rgbResult = g_crGradEnd; + cc.rgbResult = SWS_ColorToNative(*color); if (ChooseColor(&cc)) { - g_crGradEnd = cc.rgbResult; + *color = SWS_ColorFromNative(cc.rgbResult) & 0xFFFFFF; PersistColors(); RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); } @@ -200,13 +199,11 @@ INT_PTR WINAPI doColorDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) PersistColors(); #elif !defined(__APPLE__) COLORREF cc = 0; - if (wParam == IDC_COLOR1) cc = SWS_ColorToNative(g_crGradStart); - if (wParam == IDC_COLOR2) cc = SWS_ColorToNative(g_crGradEnd); + if (color) cc = SWS_ColorToNative(*color); if (SWELL_ChooseColor(hwndDlg,&cc,16,g_custColors)) { - if (wParam == IDC_COLOR1) g_crGradStart = SWS_ColorFromNative(cc); - if (wParam == IDC_COLOR2) g_crGradEnd = SWS_ColorFromNative(cc); + if (color) *color = SWS_ColorFromNative(cc); PersistColors(); InvalidateRect(hwndDlg,NULL,FALSE); }