20-01-2019, Saat: 01:35
Kendi mobil projem için geliştirdiğim özel bir buton. Sizde kendi projelerinizde değerlendirebilirsiniz.

Sample Link

Sample Link
unit NrCircleAnimationButton;
{---------------------------------------------
2019 Salih BAĞCI NrCircleAnimationButton.pas
----------------------------------------------}
interface
uses Fmx.Layouts,System.UITypes,FMX.Graphics,Fmx.Objects,FMX.Ani,System.Classes,FMX.Types,Types;
type
TNrCircleAnimationButton = class(TLayout)
strict private
FAnimationEnabled : Boolean;
FOpAnimationEnabled : Boolean;
FAnimationDuration : Single;
FOpAnimationDuration : Single;
FArcColor : TAlphaColor;
FImageBitmap : TBitmap;
FCaption : String;
FCaptionColor : TAlphaColor;
FBackGroundColor : TAlphaColor;
FBackGroundStrokeColor : TAlphaColor;
Arc : TArc;
ArcAnimation : TFloatAnimation;
OpAnimation : TFloatAnimation;
Image : TImage;
Text : TText;
Circle : TCircle;
procedure setAnimationEnabled(const Value: Boolean);
procedure setOpAnimationEnabled(const Value: Boolean);
procedure setAnimationDuration(const Value: Single);
procedure setOpAnimationDuration(const Value: Single);
procedure setArcColor(const Value: TAlphaColor);
procedure setImageBitmap(const Value: TBitmap);
procedure setCaption(const Value: String);
procedure setCaptionColor(const Value: TAlphaColor);
procedure setBackGroundColor(const Value: TAlphaColor);
procedure setBackGroundStrokeColor(const Value: TAlphaColor);
public
constructor Create(AOwner: TComponent;AWidth,AHeight:Single);
destructor Destroy; override;
published
property AnimationDuration: Single read FAnimationDuration write setAnimationDuration;
property OpAnimationDuration: Single read FOpAnimationDuration write setOpAnimationDuration;
property AnimationEnabled: Boolean read FAnimationEnabled write setAnimationEnabled;
property OpAnimationEnabled: Boolean read FOpAnimationEnabled write setOpAnimationEnabled;
property ArcColor: TAlphaColor read FArcColor write setArcColor;
property ImageBitmap:TBitmap read FImageBitmap write setImageBitmap;
property Caption:String read FCaption write setCaption;
property CaptionColor: TAlphaColor read FCaptionColor write setCaptionColor;
property BackGroundColor: TAlphaColor read FBackGroundColor write setBackGroundColor;
property BackGroundStrokeColor: TAlphaColor read FBackGroundStrokeColor write setBackGroundStrokeColor;
end;
implementation
{ TNrCircleAnimationButton }
constructor TNrCircleAnimationButton.Create(AOwner: TComponent;AWidth,AHeight:Single);
function RGB(R,G,B:Byte):TAlphaColor;
begin
TAlphaColorRec(Result).R := R;
TAlphaColorRec(Result).G := G;
TAlphaColorRec(Result).B := B;
TAlphaColorRec(Result).A := 255;
end;
begin
Inherited Create(AOwner);
Width := AWidth;
Height := AHeight;
//Create Object
Image := TImage.Create(Self);
Text := TText.Create(Self);
Circle := TCircle.Create(Self);
Arc := TArc.Create(Self);
ArcAnimation := TFloatAnimation.Create(Arc);
OpAnimation := TFloatAnimation.Create(Text);
//BeginUpdate
Image.BeginUpdate;
Arc.BeginUpdate;
Text.BeginUpdate;
Circle.BeginUpdate;
//Const Property
HitTest := True;
Arc.HitTest := False;
Image.HitTest := False;
Text.HitTest := False;
Circle.HitTest := False;
Image.Parent := Self;
Text.Parent := Self;
Arc.Parent := Self;
Circle.Parent := Self;
ArcAnimation.Parent := Arc;
OpAnimation.Parent := Text;
Arc.Align := TAlignLayout.Client;
Image.Align := TAlignLayout.Client;
Text.Align := TAlignLayout.Client;
Circle.Align := TAlignLayout.Client;
Image.Margins.Rect := RectF(15,15,15,15);
Text.Margins.Rect := RectF(5,5,5,5);
Text.Font.Size := AWidth / 4;
Text.TextSettings.Font.Style := [TFontStyle.fsBold];
Image.WrapMode := TImageWrapMode.Place;
ArcAnimation.Loop := True;
ArcAnimation.PropertyName := 'RotationAngle';
ArcAnimation.StartValue := 0;
ArcAnimation.StopValue := 360;
OpAnimation.Loop := True;
OpAnimation.PropertyName := 'Opacity';
OpAnimation.StartValue := 0.3;
OpAnimation.StopValue := 1;
Arc.Stroke.Thickness := AWidth / 10;
Arc.EndAngle := -90;
Circle.Stroke.Thickness := Arc.Stroke.Thickness;
Circle.SendToBack;
setAnimationDuration(1);
setOpAnimationDuration(4);
setCaption('');
setArcColor(RGB(51,51,51));
setCaptionColor(RGB(51,51,51));
setBackGroundColor(RGB(192,197,206));
setBackGroundStrokeColor(RGB(153,153,153));
//EndUpdate
Image.EndUpdate;
Arc.EndUpdate;
Text.EndUpdate;
Circle.EndUpdate;
end;
destructor TNrCircleAnimationButton.Destroy;
begin
setAnimationEnabled(False);
setOpAnimationEnabled(False);
ArcAnimation.Free;
OpAnimation.Free;
Arc.Free;
Text.Free;
Circle.Free;
Image.Free;
inherited;
end;
procedure TNrCircleAnimationButton.setAnimationDuration(const Value: Single);
begin
ArcAnimation.Duration := Value;
FAnimationDuration := Value;
end;
procedure TNrCircleAnimationButton.setAnimationEnabled(const Value: Boolean);
begin
ArcAnimation.Enabled := Value;
FAnimationEnabled := Value;
end;
procedure TNrCircleAnimationButton.setArcColor(const Value: TAlphaColor);
begin
Arc.Stroke.Color := Value;
FArcColor := Value;
end;
procedure TNrCircleAnimationButton.setBackGroundColor(const Value: TAlphaColor);
begin
Circle.Fill.Color := Value;
FBackGroundColor := Value;
end;
procedure TNrCircleAnimationButton.setBackGroundStrokeColor(const Value: TAlphaColor);
begin
Circle.Stroke.Color := Value;
FBackGroundStrokeColor := Value;
end;
procedure TNrCircleAnimationButton.setCaption(const Value: String);
begin
Text.BeginUpdate;
Text.Text := Value;
Text.EndUpdate;
end;
procedure TNrCircleAnimationButton.setCaptionColor(const Value: TAlphaColor);
begin
Text.TextSettings.FontColor := Value;
FCaptionColor := Value;
end;
procedure TNrCircleAnimationButton.setImageBitmap(const Value: TBitmap);
begin
FImageBitmap := Value;
Image.BeginUpdate;
Image.Bitmap.Assign(Value);
Image.EndUpdate;
end;
procedure TNrCircleAnimationButton.setOpAnimationDuration(const Value: Single);
begin
OpAnimation.Duration := Value;
FOpAnimationDuration := Value;
end;
procedure TNrCircleAnimationButton.setOpAnimationEnabled(const Value: Boolean);
begin
OpAnimation.Enabled := Value;
FOpAnimationEnabled := Value;
end;
end.
Yalnızım ama bir kente yürüyen ordu gibiyim, edebiyattan kaçınmalıyım..

