NSIS Menu Dark mode support

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7090 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2019-03-12 17:15:30 +00:00
parent 5eb8365481
commit 046353f7c5

View file

@ -23,21 +23,46 @@ Caption "$(^Name)"
!define PD "Docs" ; Local with WWW fallback (located at the same relative path)
!define WWW "http://nsis.sf.net"
!define CB_HEADER 0x755585
!define CB_HEADER '0x755585 0x222222'
!define UY_HEADER 28
!define CB_PAGE 0xffffff
!define CT_SECTION 0x666666
!define CB_SECTION ${CB_PAGE}
!define CT_PAGE '0x000000 0xaaaaaa'
!define CB_PAGE '0xffffff 0x111111'
!define CT_SECTION '0x666666 0xeeeeee'
!define CB_SECTION '${CB_PAGE}'
!define UY_SECTION 11 ; Height of a section
!define UY_SECTIONBPAD 2 ; Extra padding on the bottom of section headers
!define UY_TXT 9 ; Height of a normal item
!define UY_TXTBPAD 1 ; Extra padding on the bottom of normal items
!define UX_COLPAD 7 ; Spacing between columns
!define UY_ROW2 104 ; Absolute position of the 2nd row
!define CT_LINK 0x0c6e97 ; SYSCLR:HOTLIGHT
!define CT_LINK '0x0c6e97 0x0c6e97' ; SYSCLR:HOTLIGHT
!define /Math UX_PAGE 00 + ${UX_COLPAD}
!define /Math UY_PAGE ${UY_HEADER} + 20
!define UX ${UX_PAGE}
!define CB_FOOTERLINE '0xc4c4c4 0x333333'
!define CT_FOOTER '0xbbbbbb 0x444444'
Var UseLightTheme
Function .onGUIInit
ReadRegDWORD $UseLightTheme HKCU "Software\NSIS" "UseLightTheme"
StrCmp $UseLightTheme "" 0 +2
ReadRegDWORD $UseLightTheme HKCU "Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" "AppsUseLightTheme"
StrCmp $UseLightTheme "" 0 +2
StrCpy $UseLightTheme 1 ; Default
StrCmp $UseLightTheme "0" 0 +2
System::Call 'USER32::SetProp(p$hWndParent,t"UseImmersiveDarkModeColors",i1)'
FunctionEnd
!define SetCtlColors "!insertmacro SetCtlColors "
!macro SetCtlColors hWnd ctlig ctdar cblig cbdar
StrCmp $UseLightTheme "0" 0 +3
SetCtlColors ${hWnd} "${ctdar}" ${cbdar}
Goto +2
SetCtlColors ${hWnd} "${ctlig}" ${cblig}
!macroend
Function PageLeave
System::Call 'USER32::GetFocus()p.r0'
@ -60,7 +85,7 @@ System::Call 'USER32::MoveWindow(pr0,i0,i0,ir3,ir4,i0)'
nsDialogs::Create ${IDC_CHILDRECT}
Pop $R9
SetCtlColors $R9 000000 ${CB_PAGE}
${SetCtlColors} $R9 ${CT_PAGE} ${CB_PAGE}
!macro StartColumn W
!define /ReDef UY ${UY_PAGE}
@ -77,7 +102,7 @@ SetCtlColors $R9 000000 ${CB_PAGE}
!define /ReDef /Math W ${W} + 4 ; Make it slightly wider
${NSD_CreateLabel} ${UX}u ${UY}u ${W}u ${UY_SECTION}u "${Txt}"
Pop $0
SetCtlColors $0 ${CT_SECTION} transparent
${SetCtlColors} $0 ${CT_SECTION} transparent transparent
SendMessage $0 ${WM_SETFONT} ${HF_HEADER} 1
!define /ReDef /Math UY ${UY} + ${UY_SECTION}
!define /ReDef /Math UY ${UY} + ${UY_SECTIONBPAD}
@ -102,11 +127,11 @@ CreateFont ${HF_HEADER} "Arial" ${UY_SECTION} 700
nsDialogs::CreateControl ${__NSD_Label_CLASS} ${__NSD_Label_STYLE} ${__NSD_Label_EXSTYLE} 33u 0 -33u ${UY_HEADER}u ""
Pop $0
SetCtlColors $0 0xffffff ${CB_HEADER}
${SetCtlColors} $0 0xffffff 0xffffff ${CB_HEADER}
nsDialogs::CreateControl ${__NSD_Icon_CLASS} ${__NSD_Icon_STYLE}|${SS_CENTERIMAGE}|${SS_CENTER} ${__NSD_Icon_EXSTYLE} 0 0 33u ${UY_HEADER}u ""
Pop $0
SetCtlColors $0 "" ${CB_HEADER}
${SetCtlColors} $0 "" "" ${CB_HEADER}
${NSD_SetIconFromInstaller} $0 $1
CreateFont $1 "Trebuchet MS" 17
@ -133,7 +158,7 @@ SendMessage $0 ${WM_SETFONT} $1 1
!define /ReDef UY_MULTILINE 42
!insertmacro CreateControl Label "Many more examples, tutorials, plug-ins and NSIS-releted software are available at the online Developer Center." ${UX_W} ${UY_MULTILINE}
Pop $0
SetCtlColors $0 00000000 ${CB_PAGE}
${SetCtlColors} $0 ${CT_PAGE} ${CB_PAGE}
!insertmacro StartColumn 80
@ -183,11 +208,11 @@ Call AdjustLinkPair
; --- Footer ---
${NSD_CreateLabel} 0 -22u 100% 1 ""
Pop $0
SetCtlColors $0 000000 0xc4c4c4
${SetCtlColors} $0 000000 000000 ${CB_FOOTERLINE}
nsDialogs::CreateControl ${__NSD_Label_CLASS} ${__NSD_Label_STYLE}|${SS_CENTERIMAGE}|${SS_NOTIFY} ${__NSD_Label_EXSTYLE} -110u -20u 100% 20u "nsis.sourceforge.net"
Pop $0
SetCtlColors $0 0xbbbbbb transparent
${SetCtlColors} $0 ${CT_FOOTER} transparent transparent
SendMessage $0 ${WM_SETFONT} ${HF_HEADER} 1
nsDialogs::SetUserData $0 "http://nsis.sourceforge.net"
${NSD_OnClick} $0 OnLinkClick
@ -245,7 +270,7 @@ FunctionEnd
Function ConfigureLink
Pop $1 ; HWND
${NSD_OnClick} $1 OnLinkClick
SetCtlColors $1 ${CT_LINK} ${CB_PAGE}
${SetCtlColors} $1 ${CT_LINK} ${CB_PAGE}
${NSD_GetText} $1 $4
Push $4
Call SplitPipe
@ -270,7 +295,7 @@ FunctionEnd
Function AdjustLinkPair
Pop $2 ; Label
SetCtlColors $2 00000000 ${CB_PAGE}
${SetCtlColors} $2 ${CT_PAGE} ${CB_PAGE}
Call ConfigureLink
FunctionEnd