Browse Source

Dark theme for progress window (part of Issue 1696)

https://winscp.net/tracker/1696

Source commit: 47fcfc8dad350a518be9ccfd53ee9d07fb4943b7
Martin Prikryl 4 months ago
parent
commit
d3c47a0481

+ 7 - 0
source/forms/Progress.cpp

@@ -871,3 +871,10 @@ void __fastcall TProgressForm::MouseWheelHandler(TMessage & Message)
   TForm::MouseWheelHandler(Message);
 }
 //---------------------------------------------------------------------------
+void __fastcall TProgressForm::CreateWnd()
+{
+  TForm::CreateWnd();
+  ApplyColorMode(this);
+  Toolbar->Color = Color;
+}
+//---------------------------------------------------------------------------

+ 0 - 2
source/forms/Progress.dfm

@@ -221,7 +221,6 @@ object ProgressForm: TProgressForm
       Width = 302
       Height = 27
       AllowDrag = False
-      Color = clWindow
       object Toolbar: TTBXToolbar
         Left = 0
         Top = 0
@@ -232,7 +231,6 @@ object ProgressForm: TProgressForm
         ProcessShortCuts = True
         ShowHint = True
         TabOrder = 0
-        Color = clWindow
         object CancelItem: TTBXItem
           Caption = '&CancelX'
           ImageIndex = 0

+ 1 - 0
source/forms/Progress.h

@@ -136,6 +136,7 @@ protected:
   virtual void __fastcall Dispatch(void * Message);
   void __fastcall SetCancelLower(TCancelStatus ACancel);
   DYNAMIC void __fastcall MouseWheelHandler(TMessage & Message);
+  virtual void __fastcall CreateWnd();
 
   INTERFACE_HOOK;
 

+ 3 - 2
source/packages/my/PathLabel.pas

@@ -539,7 +539,7 @@ var
   HotTrackBottom: Integer;
   Separator, Buf, Buf2: string;
   Str: string;
-  HotTrackColor: TColor;
+  HotTrackColor, OrigColor: TColor;
   VirtualMask: string;
   IsEmptyMask: Boolean;
   IsVirtualMask: Boolean;
@@ -695,6 +695,7 @@ begin
       end;
     end;
 
+    OrigColor := Canvas.Font.Color;
     if (FDisplayHotTrack <> '') and (FDisplayHotTrack <> HotTrackMask) then
     begin
       Canvas.Font.Color := HotTrackColor;
@@ -713,7 +714,7 @@ begin
     if TrackingActive then
       Canvas.Font.Color := FColors[2 + Integer(FIsActive)]
     else
-      Canvas.Font.Color := clWindowText;
+      Canvas.Font.Color := OrigColor;
 
     if FDisplayHotTrack = HotTrackMask then
     begin

+ 19 - 12
source/windows/VCLCommon.cpp

@@ -1117,23 +1117,30 @@ void ApplyDarkModeOnControl(TControl * Control)
       PublicControl->Color = WindowColor;
     }
 
-    if (dynamic_cast<TForm *>(Control) != NULL)
+    bool IsForm = (dynamic_cast<TForm *>(Control) != NULL);
+    bool IsPanel = (dynamic_cast<TPanel *>(Control) != NULL);
+    if (IsForm || IsPanel)
     {
-      DebugAssert((PublicControl->Color == clBtnFace) || (PublicControl->Color == BtnFaceColor));
-      PublicControl->Color = BtnFaceColor;
-      PublicControl->Font->Color = GetWindowTextColor(PublicControl->Color);
-    }
-    else if (dynamic_cast<TPanel *>(Control) != NULL)
-    {
-      DebugAssert(!PublicControl->ParentColor);
-      if ((PublicControl->Color == clWindow) || (PublicControl->Color == WindowColor))
+      if (PublicControl->ParentColor)
       {
-        PublicControl->Color = WindowColor;
+        DebugAssert(IsPanel);
       }
       else
       {
-        DebugAssert((PublicControl->Color == clBtnFace) || (PublicControl->Color == BtnFaceColor));
-        PublicControl->Color = BtnFaceColor;
+        if ((PublicControl->Color == clWindow) || (PublicControl->Color == WindowColor))
+        {
+          PublicControl->Color = WindowColor;
+        }
+        else
+        {
+          DebugAssert((PublicControl->Color == clBtnFace) || (PublicControl->Color == BtnFaceColor));
+          PublicControl->Color = BtnFaceColor;
+        }
+      }
+
+      if (IsForm)
+      {
+        PublicControl->Font->Color = GetWindowTextColor(PublicControl->Color);
       }
     }
     else if (dynamic_cast<TTreeView *>(WinControl) != NULL)