-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
unit BCMaterialProgressBarMarquee; | ||
|
||
{$mode delphi} | ||
|
||
interface | ||
|
||
uses | ||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, BGRAGraphicControl, | ||
ExtCtrls, BGRABitmap, BGRABitmapTypes; | ||
|
||
type | ||
|
||
{ TBCMaterialProgressBarMarquee } | ||
|
||
TBCMaterialProgressBarMarquee = class(TBGRAGraphicControl) | ||
private | ||
FBarColor: TColor; | ||
progressbasr_cx, progressbar_cw: integer; | ||
progressbar_x, progressbar_w: integer; | ||
progressbar_increase: boolean; | ||
FTimer: TTimer; | ||
procedure SetBarColor(AValue: TColor); | ||
procedure TimerOnTimer(Sender: TObject); | ||
protected | ||
|
||
public | ||
procedure DiscardBitmap; | ||
procedure RedrawBitmapContent; override; | ||
constructor Create(AOwner: TComponent); override; | ||
published | ||
property BarColor: TColor read FBarColor write SetBarColor; | ||
property Visible; | ||
end; | ||
|
||
procedure Register; | ||
|
||
implementation | ||
|
||
procedure Register; | ||
begin | ||
RegisterComponents('BGRA Controls', [TBCMaterialProgressBarMarquee]); | ||
end; | ||
|
||
{ TBCMaterialProgressBarMarquee } | ||
|
||
procedure TBCMaterialProgressBarMarquee.TimerOnTimer(Sender: TObject); | ||
begin | ||
if progressbar_increase then | ||
begin | ||
progressbar_w := progressbar_w + progressbar_cw; | ||
if (progressbar_w >= Width - 5) then | ||
begin | ||
progressbar_increase := False; | ||
end; | ||
end | ||
else | ||
begin | ||
progressbar_w := progressbar_w - progressbar_cw; | ||
if (progressbar_w <= progressbar_cw) then | ||
begin | ||
progressbar_increase := True; | ||
end; | ||
end; | ||
progressbar_x := progressbar_x + progressbasr_cx; | ||
if (progressbar_x >= Width) then | ||
progressbar_x := -progressbar_w; | ||
DiscardBitmap; | ||
end; | ||
|
||
procedure TBCMaterialProgressBarMarquee.SetBarColor(AValue: TColor); | ||
begin | ||
if FBarColor = AValue then | ||
Exit; | ||
FBarColor := AValue; | ||
DiscardBitmap; | ||
end; | ||
|
||
procedure TBCMaterialProgressBarMarquee.DiscardBitmap; | ||
begin | ||
inherited DiscardBitmap; | ||
progressbar_cw := Width div 50; | ||
progressbasr_cx := progressbar_cw * 2; | ||
end; | ||
|
||
procedure TBCMaterialProgressBarMarquee.RedrawBitmapContent; | ||
begin | ||
Bitmap.Fill(Color); | ||
Bitmap.Rectangle(Rect(progressbar_x, 0, progressbar_x + progressbar_w, Bitmap.Height), | ||
BarColor, BarColor); | ||
end; | ||
|
||
constructor TBCMaterialProgressBarMarquee.Create(AOwner: TComponent); | ||
begin | ||
inherited Create(AOwner); | ||
progressbar_w := Width; | ||
progressbar_x := -progressbar_w; | ||
progressbar_increase := False; | ||
FTimer := TTimer.Create(Self); | ||
FTimer.Interval := 15; | ||
FTimer.OnTimer := TimerOnTimer; | ||
FTimer.Enabled := True; | ||
Color := clWhite; | ||
BarColor := $00E2A366; | ||
end; | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters