Просмотр исходного кода

Merge branch 'master' of https://github.com/bgrabitmap/bgracontrols

lainz 7 лет назад
Родитель
Сommit
7527df407a
3 измененных файлов с 57 добавлено и 15 удалено
  1. 2 2
      bctrackbarupdown.pas
  2. 53 11
      bgraflashprogressbar.pas
  3. 2 2
      bgravirtualscreen.pas

+ 2 - 2
bctrackbarupdown.pas

@@ -463,8 +463,8 @@ begin
     else
     begin
       s := ABitmap.TextSize(inSel);
-      ABitmap.FillRect(x,y+1,x+s.cx,y+s.cy,clHighlight,dmSet);
-      ABitmap.TextOut(x,y,inSel,clHighlightText);
+      ABitmap.FillRect(x,y+1,x+s.cx,y+s.cy,ColorToRGB(clHighlight),dmSet);
+      ABitmap.TextOut(x,y,inSel,ColorToRGB(clHighlightText));
       inc(x,s.cx);
     end;
     ABitmap.TextOut(x,y,afterSel,fgcolor);

+ 53 - 11
bgraflashprogressbar.pas

@@ -41,7 +41,7 @@ interface
 
 uses
   Classes, SysUtils, LResources, LMessages, Forms, Controls, Graphics,
-  Dialogs, BGRABitmap;
+  Dialogs, BGRABitmap, Math;
 
 type
 
@@ -51,12 +51,20 @@ type
 
   TBGRAFlashProgressBar = class(TGraphicControl)
   private
+    FBackgroundRandomize: boolean;
+    FBackgroundRandomizeMaxIntensity: word;
+    FBackgroundRandomizeMinIntensity: word;
+    FColor: TColor;
     FMaxValue: integer;
     FMinValue: integer;
     FValue:    integer;
     FBmp:      TBGRABitmap;
     FRandSeed: integer;
     FOnRedraw: TBGRAProgressBarRedrawEvent;
+    procedure SetFBackgroundRandomize(AValue: boolean);
+    procedure SetFBackgroundRandomizeMaxIntensity(AValue: word);
+    procedure SetFBackgroundRandomizeMinIntensity(AValue: word);
+    procedure SetFColor(AValue: TColor);
     procedure SetMaxValue(const AValue: integer);
     procedure SetMinValue(const AValue: integer);
     procedure SetValue(const AValue: integer);
@@ -95,6 +103,10 @@ type
     property OnMouseWheelDown;
     property OnRedraw: TBGRAProgressBarRedrawEvent read FOnredraw write FOnRedraw;
     property Color;
+    property BackgroundColor: TColor read FColor write SetFColor;
+    property BackgroundRandomizeMinIntensity: word read FBackgroundRandomizeMinIntensity write SetFBackgroundRandomizeMinIntensity;
+    property BackgroundRandomizeMaxIntensity: word read FBackgroundRandomizeMaxIntensity write SetFBackgroundRandomizeMaxIntensity;
+    property BackgroundRandomize: boolean read FBackgroundRandomize write SetFBackgroundRandomize;
   end;
 
 procedure Register;
@@ -150,6 +162,7 @@ var
   content: TRect;
   xpos, y, tx, ty: integer;
   grayValue: integer;
+  bgColor: TBGRAPixel;
 
   function ApplyLightness(c: TBGRAPixel; lightness: word): TBGRAPixel;
   begin
@@ -186,7 +199,7 @@ begin
   else
     FBmp.FillTransparent;
 
-  FBmp.Rectangle(0, 0, tx, ty, BGRA(255, 255, 255, 6), dmSet);
+  FBmp.Rectangle(0, 0, tx, ty, BGRA(255, 255, 255, 6), BackgroundColor, dmSet);
   if (tx > 2) and (ty > 2) then
     FBmp.Rectangle(1, 1, tx - 1, ty - 1, BGRA(29, 29, 29), dmSet);
 
@@ -194,17 +207,12 @@ begin
   begin
     content  := Rect(2, 2, tx - 2, ty - 2);
     randseed := FRandSeed;
+    if BackgroundRandomize then
     for y := content.Top to content.Bottom - 1 do
     begin
-      if y = content.Top then
-        grayValue := 33
-      else
-      if y = content.Top + 1 then
-        grayValue := 43
-      else
-        grayValue := 47 + random(50 - 47 + 1);
-      FBmp.SetHorizLine(content.Left, y, content.Right - 1, BGRA(
-        grayValue, grayValue, grayValue));
+      bgColor := BackgroundColor;
+      bgColor.Intensity := RandomRange(BackgroundRandomizeMinIntensity, BackgroundRandomizeMaxIntensity);
+      FBmp.HorizLine(content.Left, y, content.Right - 1, bgColor, dmSet);
     end;
     if tx >= 6 then
       FBmp.DrawVertLine(content.Right - 1, content.Top, content.Bottom - 1,
@@ -249,6 +257,10 @@ begin
   randomize;
   FRandSeed := randseed;
   Color := BGRA(102, 163, 226);
+  BackgroundColor := BGRA(47,47,47);
+  BackgroundRandomize := True;
+  BackgroundRandomizeMinIntensity := 4000;
+  BackgroundRandomizeMaxIntensity := 5000;
 end;
 
 destructor TBGRAFlashProgressBar.Destroy;
@@ -302,4 +314,34 @@ begin
   Invalidate;
 end;
 
+procedure TBGRAFlashProgressBar.SetFColor(AValue: TColor);
+begin
+  if FColor=AValue then Exit;
+  FColor:=AValue;
+  Invalidate;
+end;
+
+procedure TBGRAFlashProgressBar.SetFBackgroundRandomize(AValue: boolean);
+begin
+  if FBackgroundRandomize=AValue then Exit;
+  FBackgroundRandomize:=AValue;
+  Invalidate;
+end;
+
+procedure TBGRAFlashProgressBar.SetFBackgroundRandomizeMaxIntensity(AValue: word
+  );
+begin
+  if FBackgroundRandomizeMaxIntensity=AValue then Exit;
+  FBackgroundRandomizeMaxIntensity:=AValue;
+  Invalidate;
+end;
+
+procedure TBGRAFlashProgressBar.SetFBackgroundRandomizeMinIntensity(AValue: word
+  );
+begin
+  if FBackgroundRandomizeMinIntensity=AValue then Exit;
+  FBackgroundRandomizeMinIntensity:=AValue;
+  Invalidate;
+end;
+
 end.

+ 2 - 2
bgravirtualscreen.pas

@@ -227,14 +227,14 @@ begin
   // to avoid flickering in Windows running without themes (classic style)
   DoubleBuffered := ControlCount <> 0;
   {$ENDIF}
-  BGRASetSize(Width, Height);
+  BGRASetSize(ClientWidth, ClientHeight);
   FBGRA.Draw(Canvas, 0, 0);
 end;
 
 procedure TCustomBGRAVirtualScreen.Resize;
 begin
   inherited Resize;
-  if (FBGRA <> nil) and ((Width <> FBGRA.Width) or (Height <> FBGRA.Height)) then
+  if (FBGRA <> nil) and ((ClientWidth <> FBGRA.Width) or (ClientHeight <> FBGRA.Height)) then
     DiscardBitmap;
 end;