Skip to content

Commit

Permalink
Merge branch 'feature/Win32-DarkMode-TabControl'
Browse files Browse the repository at this point in the history
  • Loading branch information
GerbilSoft committed Nov 19, 2023
2 parents 6f3afd6 + daaf162 commit 6155b1d
Show file tree
Hide file tree
Showing 18 changed files with 509 additions and 54 deletions.
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
GtkWidget.
* Windows: Dark Mode is now supported on Windows 10 1809 and later in the
installation program and rp-config.
* Note that tab controls are not properly themed yet, and RichEdit controls
have some minor glitches.
* Portions of the Dark Mode functionality were taken from:
* win32-darkmode: https://github.com/ysc3839/win32-darkmode [MIT license]
* TortoiseGit: https://gitlab.com/tortoisegit/tortoisegit/-/blob/HEAD/src/Utils/Theme.cpp [GPLv2]
* Notepad++: https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/src/WinControls [GPLv3]
* Due to Notepad++ using GPLv3, any Windows builds that use Dark Mode
will also be considered GPLv3.

* New parsers:
* Wim: Microsoft Windows Images, used by the Windows installer starting with
Expand Down
24 changes: 24 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,30 @@ Files:
Copyright: Copyright (c) 2017 rxi
License: MIT

Files:
src/libwin32darkmode/DarkMode.?pp
src/libwin32darkmode/ListViewUtil.?pp
Copyright: Copyright (c) 2019 Richard Yu
License: MIT

Files:
src/libwin32darkmode/IatHook.hpp
Copyright: Copyright (c) 2018 Stephen Eckels
License: MIT

Files:
src/libwin32darkmode/TGDarkMode.cpp
Copyright:
Copyright (C) 2020, 2023 - TortoiseGit
Copyright (C) 2020-2021 - TortoiseSVN
License: GPL-2+

Files:
src/libwin32darkmode/NppDarkMode.cpp
Copyright:
Copyright (C)2021 Don HO <[email protected]>
License: GPL-3+

License: BSD-2-clause
All rights reserved.
.
Expand Down
3 changes: 3 additions & 0 deletions src/libwin32darkmode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ SET(${PROJECT_NAME}_SRCS
DarkMode.cpp
DarkModeCtrl.cpp
ListViewUtil.cpp
NppDarkMode.cpp
TGDarkMode.cpp
)
SET(${PROJECT_NAME}_H
DarkMode.hpp
DarkModeCtrl.hpp
IatHook.hpp
ListViewUtil.hpp
NppDarkMode.hpp
TGDarkMode.hpp
)

Expand All @@ -36,6 +38,7 @@ INCLUDE(SetMSVCDebugPath)
SET_MSVC_DEBUG_PATH(${PROJECT_NAME})
# Exclude from ALL builds.
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE win32ui)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE gdiplus comctl32 uxtheme)

IF(RP_LIBROMDATA_IS_DLL AND MSVC)
Expand Down
11 changes: 10 additions & 1 deletion src/libwin32darkmode/DarkMode.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
// https://github.com/ysc3839/win32-darkmode
/**
* Undocumented Win32 APIs for Dark Mode functionality.
*
* Based on ysc3839's win32-darkmode example application:
* https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/DarkMode.h
* Copyright (c) 2019 Richard Yu
* SPDX-License-Identifier: MIT
*
* See LICENSE.ysc3839 for more information.
*/

#include "libwin32common/RpWin32_sdk.h"
#include <tchar.h>
Expand Down
11 changes: 10 additions & 1 deletion src/libwin32darkmode/DarkMode.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
// https://github.com/ysc3839/win32-darkmode
/**
* Undocumented Win32 APIs for Dark Mode functionality.
*
* Based on ysc3839's win32-darkmode example application:
* https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/DarkMode.h
* Copyright (c) 2019 Richard Yu
* SPDX-License-Identifier: MIT
*
* See LICENSE.ysc3839 for more information.
*/
#pragma once

// for HTHEME
Expand Down
22 changes: 22 additions & 0 deletions src/libwin32darkmode/DarkModeCtrl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** DarkMode control helpers **/
#include "DarkModeCtrl.hpp"
#include "DarkMode.hpp"
#include "NppDarkMode.hpp" // Notepad++ dark mode subclasses
#include "TGDarkMode.hpp" // TortoiseGit dark mode subclasses

#include <richedit.h>
Expand Down Expand Up @@ -148,6 +149,27 @@ void DarkMode_InitEdit(HWND hWnd)
SendMessage(hWnd, WM_THEMECHANGED, 0, 0);
}

/**
* Initialize dark mode for a Tab control.
* @param hWnd Tab control handle
*/
void DarkMode_InitTabControl(HWND hWnd)
{
if (unlikely(!g_darkModeSupported))
return;

// Windows doesn't have a built-in dark mode theme for Tab controls,
// so don't bother calling SetWindowTheme().
_AllowDarkModeForWindow(hWnd, true);

// Set the Tab control subclass.
// NOTE: hbrBkgnd creation is handled by NppDarkMode_TabControlSubclassProc().
SetWindowSubclass(hWnd, NppDarkMode_TabControlSubclassProc, NppDarkMode_SubclassID, reinterpret_cast<DWORD_PTR>(&hbrBkgnd));

// WM_THEMECHANGED will set TCS_OWNERDRAWFIXED if Dark Mode is enabled.
SendMessage(hWnd, WM_THEMECHANGED, 0, 0);
}

/**
* Initialize dark mode for a RichEdit control.
* @param hWnd RichEdit control handle
Expand Down
2 changes: 2 additions & 0 deletions src/libwin32darkmode/DarkModeCtrl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void DarkMode_InitButton(HWND hWnd);
void DarkMode_InitComboBox(HWND hWnd);
void DarkMode_InitComboBoxEx(HWND hWnd);
void DarkMode_InitEdit(HWND hWnd);
void DarkMode_InitTabControl(HWND hWnd);
void DarkMode_InitRichEdit(HWND hWnd);

/** Same as above, but with GetDlgItem wrappers **/
Expand All @@ -42,6 +43,7 @@ DARKMODE_GETDLGITEM_WRAPPER(Button)
DARKMODE_GETDLGITEM_WRAPPER(ComboBox)
DARKMODE_GETDLGITEM_WRAPPER(ComboBoxEx)
DARKMODE_GETDLGITEM_WRAPPER(Edit)
DARKMODE_GETDLGITEM_WRAPPER(TabControl)
DARKMODE_GETDLGITEM_WRAPPER(RichEdit)

#ifdef __cplusplus
Expand Down
16 changes: 10 additions & 6 deletions src/libwin32darkmode/IatHook.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// https://github.com/ysc3839/win32-darkmode

// This file contains code from
// https://github.com/stevemk14ebr/PolyHook_2_0/blob/master/sources/IatHook.cpp
// which is licensed under the MIT License.
// See PolyHook_2_0-LICENSE for more information.
/**
* Undocumented Win32 APIs for Dark Mode functionality.
*
* Based on ysc3839's win32-darkmode example application:
* https://github.com/stevemk14ebr/PolyHook_2_0/blob/master/sources/IatHook.cpp
* Copyright (c) 2018 Stephen Eckels
* SPDX-License-Identifier: MIT
*
* See LICENSE.PolyHook_2_0 for more information.
*/

#pragma once

Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 8 additions & 1 deletion src/libwin32darkmode/ListViewUtil.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// https://github.com/ysc3839/win32-darkmode
/**
* Undocumented Win32 APIs for Dark Mode functionality.
*
* Based on ysc3839's win32-darkmode example application:
* https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/ListViewUtil.h
* Copyright (c) 2019 Richard Yu
* SPDX-License-Identifier: MIT
*/

#include "libwin32common/RpWin32_sdk.h"
#include <commctrl.h> // SubclassProc()
Expand Down
9 changes: 8 additions & 1 deletion src/libwin32darkmode/ListViewUtil.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// https://github.com/ysc3839/win32-darkmode
/**
* Undocumented Win32 APIs for Dark Mode functionality.
*
* Based on ysc3839's win32-darkmode example application:
* https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/ListViewUtil.h
* Copyright (c) 2019 Richard Yu
* SPDX-License-Identifier: MIT
*/
#pragma once

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 6155b1d

Please sign in to comment.