{***********************************************}
{   TeeChart Expand Animation Editor            }
{   Copyright (c) 2000-2020 by Steema Software  }
{***********************************************}
unit TeeExpandAnimationEdit;
{$I TeeDefs.inc}

interface

uses {$IFNDEF LINUX}
     Windows, Messages,
     {$ENDIF}
     SysUtils, Classes,

     Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, Buttons,

     TeEngine, TeeProcs, TeeAnimations, TeCanvas, TeeCustomShapeEditor, TeePenDlg;

type
  TExpandAnimationEdit = class(TForm)
    Label2: TLabel;
    Label3: TLabel;
    CBTarget: TComboFlat;
    CBTrigger: TComboFlat;
    Label1: TLabel;
    ESizeBy: TEdit;
    UDSizeBy: TUpDown;
    procedure ESizeByChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CBTriggerChange(Sender: TObject);
    procedure CBTargetChange(Sender: TObject);
  private
    Animation : TCustomExpandAnimation;

    procedure RefreshControls(AAnimation: TCustomExpandAnimation);
  public
    { Public declarations }
  end;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

procedure TExpandAnimationEdit.ESizeByChange(Sender: TObject);
begin
  if Assigned(Animation) then
     Animation.SizeBy:=UDSizeBy.Position;
end;

procedure TExpandAnimationEdit.RefreshControls(AAnimation: TCustomExpandAnimation);
begin
  CBTarget.ItemIndex:=Ord(Animation.Target);
  CBTrigger.ItemIndex:=Ord(Animation.Trigger);
  UDSizeBy.Position:=Animation.SizeBy;
end;

procedure TExpandAnimationEdit.FormShow(Sender: TObject);
begin
  Animation:=TCustomExpandAnimation(Tag);

  if Assigned(Animation) then
     RefreshControls(Animation);
end;

procedure TExpandAnimationEdit.CBTriggerChange(Sender: TObject);
begin
  if Assigned(Animation) then
     Animation.Trigger:=TAnimationTrigger(CBTrigger.ItemIndex);
end;

procedure TExpandAnimationEdit.CBTargetChange(Sender: TObject);
begin
  if Assigned(Animation) then
     Animation.Target:=TChartClickedPartStyle(CBTarget.ItemIndex);
end;

initialization
  RegisterClass(TExpandAnimationEdit);
end.
