|
@@ -18,6 +18,8 @@
|
|
|
Deleted Unit BGRADrawerFlashProgressBar;
|
|
Deleted Unit BGRADrawerFlashProgressBar;
|
|
|
New Test with all Features
|
|
New Test with all Features
|
|
|
Added Timer Style
|
|
Added Timer Style
|
|
|
|
|
+ 2025-01 Added Marquee Bounce and Stepit Method,
|
|
|
|
|
+ TimerPlayPause works also for Marquee (useful for debugging)
|
|
|
***************************** END CONTRIBUTOR(S) *****************************}
|
|
***************************** END CONTRIBUTOR(S) *****************************}
|
|
|
unit BGRAFlashProgressBar;
|
|
unit BGRAFlashProgressBar;
|
|
|
|
|
|
|
@@ -78,7 +80,11 @@ type
|
|
|
xpos: integer;
|
|
xpos: integer;
|
|
|
internalTimer: TFPTimer;
|
|
internalTimer: TFPTimer;
|
|
|
marqueeLeft,
|
|
marqueeLeft,
|
|
|
- marqueeRight: Integer;
|
|
|
|
|
|
|
+ marqueeRight,
|
|
|
|
|
+ marqueeCount,
|
|
|
|
|
+ marqueeBCount: Integer;
|
|
|
|
|
+ marqueeWall,
|
|
|
|
|
+ marqueeBouncing: Boolean;
|
|
|
|
|
|
|
|
procedure SetBackgroundRandomize(AValue: boolean);
|
|
procedure SetBackgroundRandomize(AValue: boolean);
|
|
|
procedure SetBackgroundRandomizeMaxIntensity(AValue: word);
|
|
procedure SetBackgroundRandomizeMaxIntensity(AValue: word);
|
|
@@ -130,8 +136,14 @@ type
|
|
|
|
|
|
|
|
procedure Draw(ABitmap: TBGRABitmap);
|
|
procedure Draw(ABitmap: TBGRABitmap);
|
|
|
|
|
|
|
|
- //Timer Methods applies only if Style is pbstTimer
|
|
|
|
|
|
|
+ //Step It, if Style is pbstNormal then Inc/Dec Value,
|
|
|
|
|
+ // if pbstMarquee then do next Animation Step (AIncrement is ignored)
|
|
|
|
|
+ // if pbstTimer then Value is decremented of 100ms (AIncrement is ignored)
|
|
|
|
|
+ procedure StepIt(AIncrement: Double);
|
|
|
|
|
+
|
|
|
|
|
+ //Timer Restart applies only if Style is pbstTimer
|
|
|
procedure TimerReStart;
|
|
procedure TimerReStart;
|
|
|
|
|
+ //Timer Paly/Pause applies only if Style is pbstMarquee or pbstTimer
|
|
|
procedure TimerPlayPause;
|
|
procedure TimerPlayPause;
|
|
|
|
|
|
|
|
property XPosition: integer read xpos;
|
|
property XPosition: integer read xpos;
|
|
@@ -164,8 +176,6 @@ type
|
|
|
property MarqueeWidth: Word read FMarqueeWidth write SetMarqueeWidth default 0;
|
|
property MarqueeWidth: Word read FMarqueeWidth write SetMarqueeWidth default 0;
|
|
|
property MarqueeSpeed: TBGRAPBarMarqueeSpeed read FMarqueeSpeed write SetMarqueeSpeed default pbmsMedium;
|
|
property MarqueeSpeed: TBGRAPBarMarqueeSpeed read FMarqueeSpeed write SetMarqueeSpeed default pbmsMedium;
|
|
|
property MarqueeDirection: TBGRAPBarMarqueeDirection read FMarqueeDirection write SetMarqueeDirection default pbmdToRight;
|
|
property MarqueeDirection: TBGRAPBarMarqueeDirection read FMarqueeDirection write SetMarqueeDirection default pbmdToRight;
|
|
|
-
|
|
|
|
|
- { #todo 5 -oMaxM : I'm implementing this in the new year }
|
|
|
|
|
property MarqueeBounce: Word read FMarqueeBounce write SetMarqueeBounce;
|
|
property MarqueeBounce: Word read FMarqueeBounce write SetMarqueeBounce;
|
|
|
|
|
|
|
|
property TimerInterval: Cardinal read FTimerInterval write SetTimerInterval default 100;
|
|
property TimerInterval: Cardinal read FTimerInterval write SetTimerInterval default 100;
|
|
@@ -312,6 +322,7 @@ end;
|
|
|
|
|
|
|
|
procedure TBGRAFlashProgressBar.SetMarqueeBounce(AValue: Word);
|
|
procedure TBGRAFlashProgressBar.SetMarqueeBounce(AValue: Word);
|
|
|
begin
|
|
begin
|
|
|
|
|
+ marqueeBCount:= AValue;
|
|
|
if FMarqueeBounce=AValue then Exit;
|
|
if FMarqueeBounce=AValue then Exit;
|
|
|
FMarqueeBounce:=AValue;
|
|
FMarqueeBounce:=AValue;
|
|
|
|
|
|
|
@@ -395,9 +406,13 @@ begin
|
|
|
Case FStyle of
|
|
Case FStyle of
|
|
|
pbstMarquee: begin
|
|
pbstMarquee: begin
|
|
|
SetMarqueeSpeed(FMarqueeSpeed);
|
|
SetMarqueeSpeed(FMarqueeSpeed);
|
|
|
- marqueeLeft:= 0;
|
|
|
|
|
|
|
|
|
|
- if not(csLoading in ComponentState) and
|
|
|
|
|
|
|
+ if (FMarqueeDirection = pbmdToRight)
|
|
|
|
|
+ then marqueeLeft:= 2
|
|
|
|
|
+ else marqueeLeft:= -FMarqueeWidth;
|
|
|
|
|
+
|
|
|
|
|
+ if FTimerAutoRestart and
|
|
|
|
|
+ not(csLoading in ComponentState) and
|
|
|
not(csDesigning in ComponentState) then internalTimer.Enabled:= True;
|
|
not(csDesigning in ComponentState) then internalTimer.Enabled:= True;
|
|
|
end;
|
|
end;
|
|
|
pbstTimer: begin
|
|
pbstTimer: begin
|
|
@@ -455,12 +470,40 @@ procedure TBGRAFlashProgressBar.TimerOnTimer(Sender: TObject);
|
|
|
begin
|
|
begin
|
|
|
Case FStyle of
|
|
Case FStyle of
|
|
|
pbstMarquee: begin
|
|
pbstMarquee: begin
|
|
|
|
|
+ if (FMarqueeBounce > 0) then
|
|
|
|
|
+ begin
|
|
|
|
|
+ if marqueeBouncing then
|
|
|
|
|
+ begin
|
|
|
|
|
+ if (marqueeCount = 0) //we've reached the rebound wall
|
|
|
|
|
+ then begin
|
|
|
|
|
+ marqueeCount:= 3; //Set the bounce length (3*2pixels)
|
|
|
|
|
+
|
|
|
|
|
+ if (marqueeCurMode = pbmdToRight)
|
|
|
|
|
+ then marqueeCurMode:= pbmdToLeft
|
|
|
|
|
+ else marqueeCurMode:= pbmdToRight;
|
|
|
|
|
+
|
|
|
|
|
+ //decreases the rebound counter only if we are in the real wall
|
|
|
|
|
+ if marqueeWall then dec(marqueeBCount);
|
|
|
|
|
+
|
|
|
|
|
+ if (marqueeBCount > 0)
|
|
|
|
|
+ then marqueeBouncing:= True
|
|
|
|
|
+ else begin
|
|
|
|
|
+ //Stop Bouncing
|
|
|
|
|
+ if marqueeWall then marqueeBCount:= FMarqueeBounce;
|
|
|
|
|
+ marqueeBouncing:= False;
|
|
|
|
|
+ end;
|
|
|
|
|
+ end
|
|
|
|
|
+ else dec(marqueeCount);
|
|
|
|
|
+ end;
|
|
|
|
|
+ end;
|
|
|
|
|
+
|
|
|
|
|
+ //Move the bar 2 pixels
|
|
|
if (marqueeCurMode = pbmdToRight)
|
|
if (marqueeCurMode = pbmdToRight)
|
|
|
then inc(marqueeLeft, 2)
|
|
then inc(marqueeLeft, 2)
|
|
|
else dec(marqueeLeft, 2);
|
|
else dec(marqueeLeft, 2);
|
|
|
end;
|
|
end;
|
|
|
pbstTimer: begin
|
|
pbstTimer: begin
|
|
|
- //FValue:= TTime(, FTimerInterval);
|
|
|
|
|
|
|
+ { #note -oMaxM : If we had to be more precise we should keep the Start time and subtract the current time }
|
|
|
FValue:= IncMilliSecond(FValue, -internalTimer.Interval);
|
|
FValue:= IncMilliSecond(FValue, -internalTimer.Interval);
|
|
|
if (FValue <= 0)
|
|
if (FValue <= 0)
|
|
|
then begin
|
|
then begin
|
|
@@ -511,13 +554,19 @@ begin
|
|
|
inherited Loaded;
|
|
inherited Loaded;
|
|
|
|
|
|
|
|
Case FStyle of
|
|
Case FStyle of
|
|
|
- pbstMarquee: if not(csDesigning in ComponentState) then internalTimer.Enabled:= True;
|
|
|
|
|
|
|
+ pbstMarquee: begin
|
|
|
|
|
+ if (FMarqueeDirection = pbmdToRight)
|
|
|
|
|
+ then marqueeLeft:= 2
|
|
|
|
|
+ else marqueeLeft:= -FMarqueeWidth;
|
|
|
|
|
+
|
|
|
|
|
+ if FTimerAutoRestart and not(csDesigning in ComponentState) then internalTimer.Enabled:= True;
|
|
|
|
|
+ end;
|
|
|
pbstTimer: begin
|
|
pbstTimer: begin
|
|
|
- FValue:= FMaxValue;
|
|
|
|
|
- internalTimer.Interval:= FTimerInterval;
|
|
|
|
|
|
|
+ FValue:= FMaxValue;
|
|
|
|
|
+ internalTimer.Interval:= FTimerInterval;
|
|
|
|
|
|
|
|
- if FTimerAutoRestart and not(csDesigning in ComponentState) then internalTimer.Enabled:= True;
|
|
|
|
|
- end;
|
|
|
|
|
|
|
+ if FTimerAutoRestart and not(csDesigning in ComponentState) then internalTimer.Enabled:= True;
|
|
|
|
|
+ end;
|
|
|
else internalTimer.Enabled:= False;
|
|
else internalTimer.Enabled:= False;
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
@@ -573,6 +622,7 @@ begin
|
|
|
marqueeCurMode:= pbmdToRight;
|
|
marqueeCurMode:= pbmdToRight;
|
|
|
marqueeLeft:= 0;
|
|
marqueeLeft:= 0;
|
|
|
marqueeRight:= 0;
|
|
marqueeRight:= 0;
|
|
|
|
|
+ marqueeBouncing:= False;
|
|
|
|
|
|
|
|
//Timer
|
|
//Timer
|
|
|
FTimerInterval:= 100;
|
|
FTimerInterval:= 100;
|
|
@@ -791,26 +841,31 @@ begin
|
|
|
if (marqueeCurMode = pbmdToRight)
|
|
if (marqueeCurMode = pbmdToRight)
|
|
|
then begin
|
|
then begin
|
|
|
//check if the whole bar is out put it back to the beginning
|
|
//check if the whole bar is out put it back to the beginning
|
|
|
- if (marqueeLeft >= tx-2) then
|
|
|
|
|
- begin
|
|
|
|
|
- marqueeLeft:= 2;
|
|
|
|
|
- end;
|
|
|
|
|
|
|
+ if (marqueeLeft >= content.Right) then marqueeLeft:= content.Left;
|
|
|
|
|
|
|
|
//Calculate the Right
|
|
//Calculate the Right
|
|
|
marqueeRight:= marqueeLeft+(rMarqueeWidth-1);
|
|
marqueeRight:= marqueeLeft+(rMarqueeWidth-1);
|
|
|
|
|
|
|
|
//Check if part of the bar is out calculate the visible piece on the left
|
|
//Check if part of the bar is out calculate the visible piece on the left
|
|
|
marqueeOver:= 0;
|
|
marqueeOver:= 0;
|
|
|
- if (marqueeRight > tx-2) then
|
|
|
|
|
|
|
+ marqueeWall:= (marqueeRight >= content.Right-1);
|
|
|
|
|
+ if marqueeWall then
|
|
|
begin
|
|
begin
|
|
|
- marqueeOver:= marqueeRight-(tx-2);
|
|
|
|
|
|
|
+ if (FMarqueeBounce > 0)
|
|
|
|
|
+ then begin
|
|
|
|
|
+ //Put perfectly on the Right edge
|
|
|
|
|
+ marqueeRight:= content.Right-1;
|
|
|
|
|
+ marqueeLeft:= marqueeRight-(rMarqueeWidth-1);
|
|
|
|
|
+ marqueeBouncing:= True;
|
|
|
|
|
+ end
|
|
|
|
|
+ else marqueeOver:= marqueeRight-(content.Right-1);
|
|
|
end;
|
|
end;
|
|
|
end
|
|
end
|
|
|
else begin
|
|
else begin
|
|
|
//check if the whole bar is out put it back to the end
|
|
//check if the whole bar is out put it back to the end
|
|
|
- if (marqueeLeft <= -(rMarqueeWidth+2)) then
|
|
|
|
|
|
|
+ if (marqueeLeft <= -rMarqueeWidth) then //(rMarqueeWidth+2)) then
|
|
|
begin
|
|
begin
|
|
|
- marqueeLeft:= tx-2-rMarqueeWidth;
|
|
|
|
|
|
|
+ marqueeLeft:= content.Right-rMarqueeWidth;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
//Calculate the Right
|
|
//Calculate the Right
|
|
@@ -818,9 +873,17 @@ begin
|
|
|
|
|
|
|
|
//check if part of the bar is out then the visible piece on the left is equal to marqueeRight
|
|
//check if part of the bar is out then the visible piece on the left is equal to marqueeRight
|
|
|
marqueeOver:= 0;
|
|
marqueeOver:= 0;
|
|
|
- if (marqueeRight < rMarqueeWidth) then
|
|
|
|
|
|
|
+ marqueeWall:= (marqueeRight-1 <= rMarqueeWidth);
|
|
|
|
|
+ if marqueeWall then
|
|
|
begin
|
|
begin
|
|
|
- marqueeOver:= marqueeRight;
|
|
|
|
|
|
|
+ if (FMarqueeBounce > 0)
|
|
|
|
|
+ then begin
|
|
|
|
|
+ //Put perfectly on the Left edge
|
|
|
|
|
+ marqueeLeft:= content.Left;
|
|
|
|
|
+ marqueeRight:= marqueeLeft+(rMarqueeWidth-1);
|
|
|
|
|
+ marqueeBouncing:= True;
|
|
|
|
|
+ end
|
|
|
|
|
+ else marqueeOver:= marqueeRight;
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
@@ -835,15 +898,14 @@ begin
|
|
|
end
|
|
end
|
|
|
else begin
|
|
else begin
|
|
|
//Draw visible piece on the Left
|
|
//Draw visible piece on the Left
|
|
|
- DrawBar(rect(2, content.top, marqueeOver, content.bottom), FBarColor);
|
|
|
|
|
|
|
+ DrawBar(rect(content.Left, content.top, marqueeOver, content.bottom), FBarColor);
|
|
|
ABitmap.SetPixel(marqueeOver, content.top, BGRA(62, 62, 62));
|
|
ABitmap.SetPixel(marqueeOver, content.top, BGRA(62, 62, 62));
|
|
|
ABitmap.SetVertLine(marqueeOver, content.top + 1, content.bottom - 1, BGRA(40, 40, 40));
|
|
ABitmap.SetVertLine(marqueeOver, content.top + 1, content.bottom - 1, BGRA(40, 40, 40));
|
|
|
//Draw visible piece on the Right
|
|
//Draw visible piece on the Right
|
|
|
- DrawBar(rect(tx-2-(rMarqueeWidth+1-marqueeOver), content.top, tx-2, content.bottom), FBarColor);
|
|
|
|
|
- ABitmap.SetPixel(tx-2-(rMarqueeWidth+1-marqueeOver), content.top, BGRA(62, 62, 62));
|
|
|
|
|
- ABitmap.SetVertLine(tx-2-(rMarqueeWidth+1-marqueeOver), content.top + 1, content.bottom - 1, BGRA(40, 40, 40));
|
|
|
|
|
|
|
+ DrawBar(rect(content.Right-(rMarqueeWidth+1-marqueeOver), content.top, tx-2, content.bottom), FBarColor);
|
|
|
|
|
+ ABitmap.SetPixel(content.Right-(rMarqueeWidth+1-marqueeOver), content.top, BGRA(62, 62, 62));
|
|
|
|
|
+ ABitmap.SetVertLine(content.Right-(rMarqueeWidth+1-marqueeOver), content.top + 1, content.bottom - 1, BGRA(40, 40, 40));
|
|
|
end;
|
|
end;
|
|
|
-
|
|
|
|
|
end;
|
|
end;
|
|
|
pbstTimer: begin
|
|
pbstTimer: begin
|
|
|
if FMaxValue > FMinValue then
|
|
if FMaxValue > FMinValue then
|
|
@@ -873,6 +935,18 @@ begin
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+procedure TBGRAFlashProgressBar.StepIt(AIncrement: Double);
|
|
|
|
|
+begin
|
|
|
|
|
+ Case FStyle of
|
|
|
|
|
+ pbstMarquee,
|
|
|
|
|
+ pbstTimer: begin
|
|
|
|
|
+ internalTimer.Enabled:= False;
|
|
|
|
|
+ TimerOnTimer(nil);
|
|
|
|
|
+ end
|
|
|
|
|
+ else Value:= Value+AIncrement;
|
|
|
|
|
+ end;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
procedure TBGRAFlashProgressBar.TimerReStart;
|
|
procedure TBGRAFlashProgressBar.TimerReStart;
|
|
|
begin
|
|
begin
|
|
|
if (FStyle = pbstTimer) then
|
|
if (FStyle = pbstTimer) then
|
|
@@ -888,7 +962,7 @@ end;
|
|
|
|
|
|
|
|
procedure TBGRAFlashProgressBar.TimerPlayPause;
|
|
procedure TBGRAFlashProgressBar.TimerPlayPause;
|
|
|
begin
|
|
begin
|
|
|
- if (FStyle = pbstTimer) then
|
|
|
|
|
|
|
+ if (FStyle in [pbstMarquee, pbstTimer]) then
|
|
|
begin
|
|
begin
|
|
|
internalTimer.Enabled:= not(internalTimer.Enabled);
|
|
internalTimer.Enabled:= not(internalTimer.Enabled);
|
|
|
Invalidate;
|
|
Invalidate;
|