Browse Source

Add VCL Styles support to the progress bar in the status bar (which didn't support dark mode before).

Martijn Laan 2 months ago
parent
commit
082c6080fb
1 changed files with 19 additions and 1 deletions
  1. 19 1
      Projects/Src/IDE.MainForm.pas

+ 19 - 1
Projects/Src/IDE.MainForm.pas

@@ -7234,7 +7234,25 @@ begin
       if FCompiling and (FProgressMax > 0) then begin
         var R := Rect;
         InflateRect(R, -2, -2);
-        if FProgressThemeData = 0 then begin
+        var LStyle := StyleServices(Self);
+        if not LStyle.Enabled or LStyle.IsSystemStyle then
+          LStyle := nil;
+        if LStyle <> nil then begin
+          { See Vcl.ComCtrl's TProgressBarStyleHook.Paint, .PaintFrame, and .PaintBar }
+          var Details: TThemedElementDetails;
+          Details.Element := teProgress;
+          if LStyle.HasTransparentParts(Details) then
+            LStyle.DrawParentBackground(Handle, Canvas.Handle, Details, False, @R);
+          Details := LStyle.GetElementDetails(tpBar);
+          LStyle.DrawElement(Canvas.Handle, Details, R);
+          InflateRect(R, -1, -1);
+          const W = R.Width;
+          const Pos = Round(W * (FProgress / FProgressMax));
+          var FillR := R;
+          FillR.Right := FillR.Left + Pos;
+          Details := LStyle.GetElementDetails(tpChunk);
+          LStyle.DrawElement(Canvas.Handle, Details, FillR);
+        end else if FProgressThemeData = 0 then begin
           { Border }
           Canvas.Pen.Color := clBtnShadow;
           Canvas.Brush.Style := bsClear;