Skip to content

Commit

Permalink
Merge pull request #14 from hatelamers/13-implement-full-dark-mode
Browse files Browse the repository at this point in the history
#13 added support for dark mode
  • Loading branch information
hatelamers authored Nov 23, 2024
2 parents 48201da + bb9a483 commit 17eb122
Show file tree
Hide file tree
Showing 21 changed files with 1,114 additions and 152 deletions.
13 changes: 7 additions & 6 deletions buildenv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

get_filename_component(WORKSPACE_ROOT ".." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(MAIN_TARGET_SOURCE_DIR "${WORKSPACE_ROOT}/src/app")
set(MAIN_TARGET_RESOURCE_DIR "${MAIN_TARGET_SOURCE_DIR}/res")

include("${CMAKE_CURRENT_LIST_DIR}/LocalBuild.cmake" OPTIONAL)

file(READ "${CMAKE_CURRENT_LIST_DIR}/buildnumber.txt" BUILD_NUMBER)
file(READ "${MAIN_TARGET_SOURCE_DIR}/buildnumber.txt" BUILD_NUMBER)
include("${CMAKE_CURRENT_LIST_DIR}/Product.cmake")
if(NOT ${BUILD_NUMBER})
set(BUILD_NUMBER 1)
Expand All @@ -35,12 +39,9 @@ set(CPACK_SINGLE_TARGET_SYSTEM ON)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/TargetArch.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/InstallSetup.cmake)

get_filename_component(WORKSPACE_ROOT ".." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(PRODUCT_LICENSE_FILE "${WORKSPACE_ROOT}/LICENSE")

set(MAIN_TARGET_NAME ${PROJECT_NAME})
set(MAIN_TARGET_SOURCE_DIR "${WORKSPACE_ROOT}/src/app")
set(MAIN_TARGET_RESOURCE_DIR "${MAIN_TARGET_SOURCE_DIR}/res")

configure_file("${MAIN_TARGET_SOURCE_DIR}/productmeta.h.in" "${MAIN_TARGET_SOURCE_DIR}/productmeta.h")
configure_file("${MAIN_TARGET_SOURCE_DIR}/app.manifest.in" "${MAIN_TARGET_RESOURCE_DIR}/app.manifest")
Expand All @@ -65,9 +66,9 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND}
-DBINARY_DIR=${CMAKE_BINARY_DIR}
-DSOURCE_DIR=${CMAKE_CURRENT_LIST_DIR}
-DMAIN_TARGET_SOURCE_DIR=${MAIN_TARGET_SOURCE_DIR}
-DTARGET_SOURCE_DIR=${MAIN_TARGET_SOURCE_DIR}
-DBUILD_TYPE=$<CONFIG>
-DMAIN_TARGET_NAME=${MAIN_TARGET_NAME}
-DTARGET_NAME=${MAIN_TARGET_NAME}
-P ${CMAKE_CURRENT_LIST_DIR}/cmake/PostBuild.cmake
COMMENT "Performing post-build tasks ($<CONFIG>)"
)
Expand Down
2 changes: 1 addition & 1 deletion buildenv/Product.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(PRODUCT_NAME WinPinMenu)
set(PRODUCT_VERSION ${PRODUCT_VERSION_MAJOR}.${PRODUCT_VERSION_MINOR}.${PRODUCT_VERSION_PATCH}.${BUILD_NUMBER})
set(PRODUCT_VENDOR "diVISION")
set(PRODUCT_DESCRIPTON "diVISION Pinnable Taskbar Menu For Windows")
set(PRODUCT_MAINTANER "dimamizou@users.sf.net")
set(PRODUCT_MAINTANER "dimamizou@jasics.net")
set(PRODUCT_HOMEPAGE_URL "https://github.com/hatelamers/WinPinMenu")
set(PROJECT_LICENSE "GNU/GPL")
set(PROJECT_LICENSE_URL "https://www.gnu.org/licenses/gpl-3.0.en.html")
Expand Down
1 change: 0 additions & 1 deletion buildenv/buildnumber.txt

This file was deleted.

14 changes: 7 additions & 7 deletions buildenv/cmake/PostBuild.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
if(NOT ${BUILD_TYPE} MATCHES Debug)
include("${SOURCE_DIR}/Product.cmake")
file(READ "${SOURCE_DIR}/buildnumber.txt" BUILD_NUMBER)
file(READ "${TARGET_SOURCE_DIR}/buildnumber.txt" BUILD_NUMBER)
if(NOT ${BUILD_NUMBER})
set(BUILD_NUMBER 1)
endif()

math(EXPR BUILD_NUMBER "${BUILD_NUMBER} + 1")
if(${CMAKE_VERSION} VERSION_LESS 3.18)
file(WRITE "${SOURCE_DIR}/buildnumber.txt" "${BUILD_NUMBER}")
file(WRITE "${TARGET_SOURCE_DIR}/buildnumber.txt" "${BUILD_NUMBER}")
else()
file(CONFIGURE OUTPUT "${SOURCE_DIR}/buildnumber.txt" CONTENT "${BUILD_NUMBER}")
file(CONFIGURE OUTPUT "${TARGET_SOURCE_DIR}/buildnumber.txt" CONTENT "${BUILD_NUMBER}")
endif()
file(REMOVE "${MAIN_TARGET_SOURCE_DIR}/productmeta.h")
configure_file("${MAIN_TARGET_SOURCE_DIR}/productmeta.h.in" "${MAIN_TARGET_SOURCE_DIR}/productmeta.h")
file(TOUCH_NOCREATE "${MAIN_TARGET_SOURCE_DIR}/${MAIN_TARGET_NAME}.rc")
file(REMOVE "${TARGET_SOURCE_DIR}/productmeta.h")
configure_file("${TARGET_SOURCE_DIR}/productmeta.h.in" "${TARGET_SOURCE_DIR}/productmeta.h")
file(TOUCH_NOCREATE "${TARGET_SOURCE_DIR}/${TARGET_NAME}.rc")

message(STATUS "Build number set to ${BUILD_NUMBER} in ${SOURCE_DIR}/buildnumber.txt")
message(STATUS "Build number set to ${BUILD_NUMBER} in ${TARGET_SOURCE_DIR}/buildnumber.txt")
endif()
45 changes: 33 additions & 12 deletions src/app/AboutDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
#include "stdafx.h"
#include "resource.h"
#include "productmeta.h"
#include "Draw.h"

#include "aboutdlg.h"

LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
uxTheme.AllowDarkModeForWindow(m_hWnd, true);
if (uxTheme.ShouldAppsUseDarkMode())
{
uxTheme.SwitchWindowDarkMode(m_hWnd, true);
}
SetThemeExtendedStyle(THEME_EX_THEMECLIENTEDGE);
//EnableThemeDialogTexture(ETDT_ENABLETAB);
ATLTRACE(_T(__FUNCTION__) _T("\n"));

DoDataExchange(FALSE);
//m_lnkLicense.SetHyperLinkExtendedStyle(HLINK_COMMANDBUTTON, HLINK_COMMANDBUTTON);
if (m_fvi.Open())
{
m_fvi.SetInfoDlgItemText(m_hWnd, IDC_TXT_PRODUCTNAME, SFI_PRODUCTNAME);
Expand All @@ -29,10 +23,6 @@ LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara
m_fvi.SetInfoDlgItemText(m_hWnd, IDC_TXT_FILEVERSION, SFI_FILEVERSION);
m_fvi.SetInfoDlgItemText(m_hWnd, IDC_TXT_COMPANYNAME, SFI_COMPANYNAME);

//LPTSTR lpValue(NULL);
//UINT uLen(0);
//if (m_fvi.GetStringFileInfo(SFI_LEGALTRADEMARKS, lpValue, &uLen))
// m_lnkLicense.SetToolTipText(lpValue);
}
m_lnkLicense.SetHyperLink(PRODUCT_LICENSE_URL);

Expand All @@ -41,11 +31,42 @@ LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara
#else
m_lnkRelNotes.ShowWindow(SW_HIDE);
#endif
m_clrLink = m_lnkLicense.m_clrLink;
m_clrVisited = m_lnkLicense.m_clrVisited;

UpdateColors();
return TRUE;
}

LRESULT CAboutDlg::OnThemeChange(UINT, WPARAM, LPARAM, BOOL& bHandled)
{
bHandled = FALSE;
UpdateColors();
return 0L;
}


LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
EndDialog(wID);
return 0;
}

void CAboutDlg::UpdateColors()
{
auto clrLink = m_clrLink;
auto clrVisited = m_clrVisited;
if (IsInDarkMode())
{
clrLink = HLS_TRANSFORM(clrLink, 35, 0);
clrVisited = HLS_TRANSFORM(clrVisited, 30, 0);
}
ApplyLinkColor(m_lnkLicense, clrLink, clrVisited);
ApplyLinkColor(m_lnkRelNotes, clrLink, clrVisited);
}

void CAboutDlg::ApplyLinkColor(CHyperLink& link, COLORREF clrLink, COLORREF clrVisited) const
{
link.m_clrLink = clrLink;
link.m_clrVisited = clrVisited;
}
14 changes: 12 additions & 2 deletions src/app/AboutDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
#pragma once
#include "FileVersionInfo.h"

class CAboutDlg;
using CUxAboutDialog = CUxModeWindow<CAboutDlg>;

class CAboutDlg
: public CDialogImpl<CAboutDlg>
, public CThemeImpl<CAboutDlg>
, public CUxAboutDialog
, public CWinDataExchange<CAboutDlg>
{
public:
enum { IDD = IDD_ABOUTBOX };

BEGIN_MSG_MAP(CAboutDlg)
MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChange)
CHAIN_MSG_MAP(CUxAboutDialog)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
COMMAND_ID_HANDLER(IDRETRY, OnCloseCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
CHAIN_MSG_MAP(CThemeImpl<CAboutDlg>)
END_MSG_MAP()

BEGIN_DDX_MAP(CAboutDlg)
Expand All @@ -33,9 +37,15 @@ class CAboutDlg
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnThemeChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

void UpdateColors();
void ApplyLinkColor(CHyperLink& link, COLORREF clrLink, COLORREF clrVisited) const;

private:
COLORREF m_clrLink{ 0 };
COLORREF m_clrVisited{ 0 };
CHyperLink m_lnkLicense;
CHyperLink m_lnkRelNotes;
CFileVersionInfo m_fvi;
Expand Down
Loading

0 comments on commit 17eb122

Please sign in to comment.