• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revisão29204 (tree)
Hora2021-05-06 04:38:13
Autorstefankueng

Mensagem de Log

adjust the colors of the autocomplete popup for dark mode

Mudança Sumário

Diff

--- trunk/src/Utils/MiscUI/SciEdit.cpp (revision 29203)
+++ trunk/src/Utils/MiscUI/SciEdit.cpp (revision 29204)
@@ -27,6 +27,7 @@
2727 #include "OnOutOfScope.h"
2828 #include "LoadIconEx.h"
2929 #include "Theme.h"
30+#include "DarkModeHelper.h"
3031
3132 void CSciEditContextMenuInterface::InsertMenuItems(CMenu&, int&) { return; }
3233 bool CSciEditContextMenuInterface::HandleMenuItemClick(int, CSciEdit*) { return false; }
@@ -782,6 +783,7 @@
782783 Call(SCI_AUTOCSETTYPESEPARATOR, static_cast<WPARAM>(m_typeSeparator));
783784 Call(SCI_AUTOCSETDROPRESTOFWORD, 1);
784785 Call(SCI_AUTOCSHOW, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(StringForControl(suggestions))));
786+ SetWindowStylesForAutocompletionPopup();
785787 }
786788
787789 void CSciEdit::DoAutoCompletion(Sci_Position nMinPrefixLength)
@@ -881,6 +883,7 @@
881883 Call(SCI_AUTOCSETTYPESEPARATOR, static_cast<WPARAM>(m_typeSeparator));
882884 auto sForControl = StringForControl(sAutoCompleteList);
883885 Call(SCI_AUTOCSHOW, StringForControl(word).GetLength(), reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sForControl)));
886+ SetWindowStylesForAutocompletionPopup();
884887 }
885888
886889 BOOL CSciEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
@@ -1053,6 +1056,11 @@
10531056 Call(SCI_STYLESETFORE, STYLE_DEFAULT, CTheme::darkTextColor);
10541057 Call(SCI_STYLESETBACK, STYLE_DEFAULT, CTheme::darkBkColor);
10551058 Call(SCI_SETCARETFORE, CTheme::darkTextColor);
1059+
1060+ Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST, RGB(187, 187, 187));
1061+ Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST_BACK, RGB(15, 15, 15));
1062+ Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST_SELECTED, RGB(187, 187, 187));
1063+ Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST_SELECTED_BACK, RGB(80, 80, 80));
10561064 }
10571065 else
10581066 {
@@ -1060,6 +1068,11 @@
10601068 Call(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT));
10611069 Call(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW));
10621070 Call(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT));
1071+
1072+ Call(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_LIST);
1073+ Call(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_LIST_BACK);
1074+ Call(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_LIST_SELECTED);
1075+ Call(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_LIST_SELECTED_BACK);
10631076 }
10641077 Call(SCI_SETSELFORE, TRUE, CTheme::Instance().GetThemeColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)));
10651078 Call(SCI_SETSELBACK, TRUE, CTheme::Instance().GetThemeColor(::GetSysColor(COLOR_HIGHLIGHT)));
@@ -1739,3 +1752,36 @@
17391752 m_bReadOnly = bReadOnly;
17401753 Call(SCI_SETREADONLY, m_bReadOnly);
17411754 }
1755+
1756+void CSciEdit::SetWindowStylesForAutocompletionPopup()
1757+{
1758+ if (CTheme::Instance().IsDarkTheme())
1759+ {
1760+ EnumThreadWindows(GetCurrentThreadId(), AdjustThemeProc, 0);
1761+ }
1762+}
1763+
1764+BOOL CSciEdit::AdjustThemeProc(HWND hwnd, LPARAM /*lParam*/)
1765+{
1766+ wchar_t szWndClassName[MAX_PATH] = {0};
1767+ GetClassName(hwnd, szWndClassName, _countof(szWndClassName));
1768+ if ((wcscmp(szWndClassName, L"ListBoxX") == 0) ||
1769+ (wcscmp(szWndClassName, WC_LISTBOX) == 0))
1770+ {
1771+ // in dark mode, the resizing border is visible at the top
1772+ // of the popup, and it's white and ugly.
1773+ // this removes the border, but that also means that the
1774+ // popup is not resizable anymore - which I think is not
1775+ // really necessary anyway.
1776+ auto dwCurStyle = static_cast<DWORD>(GetWindowLongPtr(hwnd, GWL_STYLE));
1777+ dwCurStyle &= ~WS_THICKFRAME;
1778+ dwCurStyle |= WS_BORDER;
1779+ SetWindowLongPtr(hwnd, GWL_STYLE, dwCurStyle);
1780+
1781+ DarkModeHelper::Instance().AllowDarkModeForWindow(hwnd, TRUE);
1782+ SetWindowTheme(hwnd, L"Explorer", nullptr);
1783+ EnumChildWindows(hwnd, AdjustThemeProc, 0);
1784+ }
1785+
1786+ return TRUE;
1787+}
--- trunk/src/Utils/MiscUI/SciEdit.h (revision 29203)
+++ trunk/src/Utils/MiscUI/SciEdit.h (revision 29204)
@@ -179,6 +179,9 @@
179179 std::string GetWordForSpellChecker(const CString& sWord) const;
180180 CString GetWordFromSpellChecker(const std::string& sWordA) const;
181181
182+ static void SetWindowStylesForAutocompletionPopup();
183+ static BOOL CALLBACK AdjustThemeProc(HWND hwnd, LPARAM lParam);
184+
182185 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
183186 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
184187 afx_msg void OnSysColorChange();
Show on old repository browser