Make UDL generic dark mode possible via UI

Checkboxes "Transparent" of bg & fg color are added for each styler.
The bg color and/or fg color set in current Styler will be ignored and the dark/light theme's bg/fg color will be used, if the checkbox "Transparent" is checked.

To make generic UDL for all dark themes, user has to enable "Transparent" checkboxes for both bg and fg color in "Default Style", then set all the other styles with bg color transparent, or set both non-transparent, according the need of your token to be colorized.

Fix #10738
pull/10748/head
Don HO 2021-10-31 15:09:32 +01:00
parent 0fd8cecf8b
commit 32d5307edd
3 changed files with 52 additions and 17 deletions

View File

@ -1915,15 +1915,46 @@ INT_PTR CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
style._fgColor = dlg->_pFgColour->getColour();
style._bgColor = dlg->_pBgColour->getColour();
if (dlg->_pFgColour->isEnabled())
style._colorStyle |= COLORSTYLE_FOREGROUND;
else
style._colorStyle &= ~COLORSTYLE_FOREGROUND;
if (dlg->_pBgColour->isEnabled())
style._colorStyle |= COLORSTYLE_BACKGROUND;
else
style._colorStyle &= ~COLORSTYLE_BACKGROUND;
if (wParam == IDC_STYLER_CHECK_FG_TRANSPARENT || wParam == IDC_STYLER_CHECK_BG_TRANSPARENT)
{
if (wParam == IDC_STYLER_CHECK_FG_TRANSPARENT)
{
bool isTransparent = (BST_CHECKED == ::SendDlgItemMessage(hwnd, IDC_STYLER_CHECK_FG_TRANSPARENT, BM_GETCHECK, 0, 0));
dlg->_pFgColour->setEnabled(!isTransparent);
dlg->_pFgColour->redraw();
style._colorStyle &= ~COLORSTYLE_FOREGROUND;
}
if (wParam == IDC_STYLER_CHECK_BG_TRANSPARENT)
{
bool isTransparent = (BST_CHECKED == ::SendDlgItemMessage(hwnd, IDC_STYLER_CHECK_BG_TRANSPARENT, BM_GETCHECK, 0, 0));
dlg->_pBgColour->setEnabled(!isTransparent);
dlg->_pBgColour->redraw();
style._colorStyle &= ~COLORSTYLE_BACKGROUND;
}
}
else
{
if (dlg->_pFgColour->isEnabled())
{
style._colorStyle |= COLORSTYLE_FOREGROUND;
}
else
{
style._colorStyle &= ~COLORSTYLE_FOREGROUND;
}
::SendDlgItemMessage(hwnd, IDC_STYLER_CHECK_FG_TRANSPARENT, BM_SETCHECK, !dlg->_pFgColour->isEnabled(), 0);
if (dlg->_pBgColour->isEnabled())
{
style._colorStyle |= COLORSTYLE_BACKGROUND;
}
else
{
style._colorStyle &= ~COLORSTYLE_BACKGROUND;
}
::SendDlgItemMessage(hwnd, IDC_STYLER_CHECK_BG_TRANSPARENT, BM_SETCHECK, !dlg->_pBgColour->isEnabled(), 0);
}
style._fontStyle = FONTSTYLE_NONE;
if (BST_CHECKED == ::SendMessage(::GetDlgItem(hwnd, IDC_STYLER_CHECK_BOLD), BM_GETCHECK, 0, 0))
style._fontStyle |= FONTSTYLE_BOLD;

View File

@ -256,13 +256,15 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,100,280,50,14
PUSHBUTTON "Cancel",IDCANCEL,172,280,50,14
CONTROL "Bold",IDC_STYLER_CHECK_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,31,90,13
CONTROL "Italic",IDC_STYLER_CHECK_ITALIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,45,90,13
CONTROL "Underline",IDC_STYLER_CHECK_UNDERLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,59,90,13
COMBOBOX IDC_STYLER_COMBO_FONT_NAME,65,32,104,80,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_STYLER_COMBO_FONT_SIZE,65,53,104,77,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Foreground color:",IDC_STYLER_FG_STATIC,14,85,75,11
RTEXT "Background color:",IDC_STYLER_BG_STATIC,153,86,75,11
CONTROL "Bold",IDC_STYLER_CHECK_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,23,90,13
CONTROL "Italic",IDC_STYLER_CHECK_ITALIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,37,90,13
CONTROL "Underline",IDC_STYLER_CHECK_UNDERLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,51,90,13
COMBOBOX IDC_STYLER_COMBO_FONT_NAME,65,29,104,80,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_STYLER_COMBO_FONT_SIZE,65,49,104,77,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Foreground color:",IDC_STYLER_FG_STATIC,14,75,75,11
CONTROL "Transparent",IDC_STYLER_CHECK_FG_TRANSPARENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,92,78,13
RTEXT "Background color:",IDC_STYLER_BG_STATIC,153,75,75,11
CONTROL "Transparent",IDC_STYLER_CHECK_BG_TRANSPARENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,92,78,13
CONTROL "Delimiter 1",IDC_STYLER_CHECK_NESTING_DELIMITER1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,38,132,76,13
CONTROL "Delimiter 2",IDC_STYLER_CHECK_NESTING_DELIMITER2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,38,149,76,13
CONTROL "Delimiter 3",IDC_STYLER_CHECK_NESTING_DELIMITER3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,38,166,76,13
@ -284,8 +286,8 @@ BEGIN
CONTROL "Keyword 6",IDC_STYLER_CHECK_NESTING_KEYWORD6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,217,76,13
CONTROL "Keyword 7",IDC_STYLER_CHECK_NESTING_KEYWORD7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,234,76,13
CONTROL "Keyword 8",IDC_STYLER_CHECK_NESTING_KEYWORD8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,251,76,13
RTEXT "Name:",IDC_STYLER_NAME_STATIC,23,32,36,12
RTEXT "Size:",IDC_STYLER_SIZE_STATIC,22,53,36,12
RTEXT "Name:",IDC_STYLER_NAME_STATIC,26,30,36,12
RTEXT "Size:",IDC_STYLER_SIZE_STATIC,25,50,36,12
CONTROL "Operators 1",IDC_STYLER_CHECK_NESTING_OPERATORS1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,209,166,76,13
CONTROL "Operators 2",IDC_STYLER_CHECK_NESTING_OPERATORS2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,209,183,76,13
CONTROL "Numbers",IDC_STYLER_CHECK_NESTING_NUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,209,200,76,13

View File

@ -293,6 +293,8 @@
#define IDC_STYLER_STATIC_FONT_OPTIONS (IDD_STYLER_POPUP_DLG + 30)
#define IDC_STYLER_NAME_STATIC (IDD_STYLER_POPUP_DLG + 31)
#define IDC_STYLER_SIZE_STATIC (IDD_STYLER_POPUP_DLG + 32)
#define IDC_STYLER_CHECK_FG_TRANSPARENT (IDD_STYLER_POPUP_DLG + 33)
#define IDC_STYLER_CHECK_BG_TRANSPARENT (IDD_STYLER_POPUP_DLG + 34)
#define IDD_STRING_DLG 26000 //IDD_GLOBAL_USERDEFINE_DLG + 6000
#define IDC_STRING_STATIC (IDD_STRING_DLG + 1)