Skip to content
Waldemar Derr edited this page Oct 15, 2019 · 39 revisions
  TAQ = class sealed (TAQBase)
  public
    class function Managed: TAQ;
    class function Unmanaged: TAQ;

    class function Take(...): TAQ;

    class function HasActiveActors(...): Boolean;

    class function GetUniqueID: Integer;

    class function Ease(...): TEaseFunction;

    class function EaseReal(StartValue, EndValue, Progress: Real; EaseType: TEaseType;
      EaseModifier: TEaseModifier = emIn): Real; overload;
    class function EaseReal(StartValue, EndValue, Progress: Real;
      EaseFunction: TEaseFunction): Real; overload;

    class function EaseInteger(StartValue, EndValue: Integer; Progress: Real; EaseType: TEaseType;
      EaseModifier: TEaseModifier = emIn): Integer; overload;
    class function EaseInteger(StartValue, EndValue: Integer; Progress: Real;
      EaseFunction: TEaseFunction): Integer; overload;

    class function EaseColor(
      StartColor, EndColor: {$IFDEF FMX}TAlphaColor{$ELSE}TColor{$ENDIF}; Progress: Real; EaseType: TEaseType;
      EaseModifier: TEaseModifier = emIn): {$IFDEF FMX}TAlphaColor{$ELSE}TColor{$ENDIF}; overload;
    class function EaseColor(
      StartColor, EndColor: {$IFDEF FMX}TAlphaColor{$ELSE}TColor{$ENDIF}; Progress: Real;
      EaseFunction: TEaseFunction): {$IFDEF FMX}TAlphaColor{$ELSE}TColor{$ENDIF}; overload;

    class function EasePoint(StartPoint, EndPoint: TPoint; Progress: Real; EaseType: TEaseType;
      EaseModifier: TEaseModifier = emIn): TPoint; overload;
    class function EasePoint(StartPoint, EndPoint: TPoint; Progress: Real;
      EaseFunction: TEaseFunction): TPoint; overload;

    class function EaseRect(StartRect, EndRect: TRect; Progress: Real; EaseType: TEaseType;
      EaseModifier: TEaseModifier = emIn): TRect; overload;
    class function EaseRect(StartRect, EndRect: TRect; Progress: Real;
      EaseFunction: TEaseFunction): TRect; overload;

    class function EaseString(const StartString, EndString: String; Progress: Real; EaseType: TEaseType;
      EaseModifier: TEaseModifier = emIn): String; overload;
    class function EaseString(const StartString, EndString: String; Progress: Real;
      EaseFunction: TEaseFunction): String; overload;

  // Public instance related stuff
  public
    constructor Create; override;
    destructor Destroy; override;

    function Each(EachFunction: TEachFunction): TAQ; override;
    function EachInterval(Interval: Integer; Each: TEachFunction; ID: Integer = 0): TAQ;
    function EachTimer(Duration: Integer; Each: TEachFunction; LastEach: TEachFunction = nil;
      ID: Integer = 0): TAQ;
    function EachAnimation(Duration: Integer; Each: TEachFunction; LastEach: TEachFunction = nil;
      ID: Integer = 0): TAQ;
    function EachDelay(Delay: Integer; Each: TEachFunction; ID: Integer = 0): TAQ;
    function EachRepeat(Times: Integer; EachFunction: TEachFunction): TAQ;

    function NewChain: TAQ;
    function EndChain: TAQ;

    function Die: TAQ;

    function Append(AObject: TObject): TAQ; overload;
    function Append(const Objects: TObjectArray): TAQ; overload;
    function Append(Objects: TObjectList): TAQ; overload;
    function AppendAQ(AQ: TAQ): TAQ;

    function ChildrenAppend(Recurse: Boolean = False; ChildrenFiller: TEachFunction = nil): TAQ;
    function ChildrenChain(Recurse: Boolean = False; ChildrenFiller: TEachFunction = nil): TAQ;
    function ParentsAppend(Recurse: Boolean = False; ParentsFiller: TEachFunction = nil): TAQ;
    function ParentsChain(Recurse: Boolean = False; ParentsFiller: TEachFunction = nil): TAQ;

    function MultiplexChain: TAQ;
    function DemultiplexChain: TAQ;

    function AnimationActorsChain(ID: Integer = 0; IncludeOrphans: Boolean = False): TAQ;
    function IntervalActorsChain(ID: Integer = 0; IncludeOrphans: Boolean = False): TAQ;
    function TimerActorsChain(ID: Integer = 0; IncludeOrphans: Boolean = False): TAQ;
    function DelayActorsChain(ID: Integer = 0; IncludeOrphans: Boolean = False): TAQ;

    function FinishAnimations(ID: Integer = 0): TAQ;
    function CancelAnimations(ID: Integer = 0): TAQ;
    function FinishTimers(ID: Integer = 0): TAQ;
    function CancelTimers(ID: Integer = 0): TAQ;
    function CancelDelays(ID: Integer = 0): TAQ;
    function CancelIntervals(ID: Integer = 0): TAQ;

    function FilterChain(ByClass: TClass): TAQ; overload;
    function FilterChain(FilterEach: TEachFunction): TAQ; overload;

    function ExcludeChain(ByClass: TClass): TAQ; overload;
    function ExcludeChain(AObject: TObject): TAQ; overload;
    function ExcludeChain(const Objects: TObjectArray): TAQ; overload;
    function ExcludeChain(Objects: TObjectList): TAQ; overload;
    function ExcludeChain(AQ: TAQ): TAQ; overload;
    function ExcludeChain(ExcludeEach: TEachFunction): TAQ; overload;

    function IfThen(Condition: Boolean): TAQ;
    function IfElse: TAQ;
    function IfEnd: TAQ;

    function IfAll(EachFunction: TEachFunction): TAQ;
    function IfAny(EachFunction: TEachFunction): TAQ;

    function IfContains(AObject: TObject): TAQ;

    function IfContainsAny(ByClass: TClass): TAQ; overload;
    function IfContainsAny(const Objects: TObjectArray): TAQ; overload;
    function IfContainsAny(Objects: TObjectList): TAQ; overload;
    function IfContainsAny(AQ: TAQ): TAQ; overload;

    function IfContainsAll(ByClass: TClass): TAQ; overload;
    function IfContainsAll(const Objects: TObjectArray): TAQ; overload;
    function IfContainsAll(Objects: TObjectList): TAQ; overload;
    function IfContainsAll(AQ: TAQ): TAQ; overload;

    function SliceChain(StartIndex: Integer; Count: Integer = 0): TAQ;

    function DebugMessage(HeadMessage: String = ''; Caption: String = ''): TAQ;

    function Plugin: T;

    function Contains(AObject: TObject): Boolean;
    procedure Clean;

    property CurrentInterval: TInterval read FCurrentInterval;
  end;

TAQ.Managed

class function TAQ.Managed: TAQ;

Returns a managed TAQ instance

Managed means, that you don't need to worry about memory leaks ;-) There is a simple (but maybe powerful) garbage collector implementation. By requesting for a managed instance it looks primary in the garabage for an died TAQ instance and in case returning it.

TAQ.Unmanaged

class function TAQ.Unmanaged: TAQ;

Returns a unmanaged TAQ instance

It's just the opposite of TAQ.Managed and it is the same as TAQ.Create

TAQ.Take

class function TAQ.Take(AObject: TObject): TAQ;
class function TAQ.Take(const Objects: TObjectArray): TAQ;
class function TAQ.Take(Objects: TObjectList): TAQ;
class function TAQ.Take<T: class>(Objects: TObjectList<T>): TAQ;

Creates a new or recycle an existing managed TAQ instance

There are several overloaded versions of the method. Each of them creates or retake an matching TAQ instance from the garbage collector. The returned TAQ instance contains the passed object(s) and you can work with them.

TAQ.HasActiveActors

class function TAQ.HasActiveActors(CheckActors: TActorRoles; AObject: TObject; ID: Integer = 0): Boolean;

Determines, whether there are active actors for a specific object

Determines, whether there are active actors (running animation, delay...) for AObject in general or optional (if passed) for the actor with the specified ID.

Example

if not TAQ.HasActiveActors([arAnimation], MyButton, BoundsAnimationID) then
  Take(MyButton)
    .Plugin<TAQPControlAnimations>
    .BoundsAnimation(..., BoundsAnimationID);

TAQ.GetUniqueID

class function TAQ.GetUniqueID: Integer;

Returns a unique ID

The returned ID can be used to identify an animation, delay, timer, interval etc. It is recommended to save such IDs in class variables and fill them in an class constructor, see following example.

Example

TMyClass = class
private 
  class var MyAnimationID: Integer;
  class constructor Create;
end;

class constructor TMyClass.Create;
begin
  MyAnimationID := TAQ.GetUniqueID;
end;

TAQ.Ease

There are three overloaded versions of this method and each of them is a little bit special, so we list them separetly. The returned anonymous function of type TEaseFunction can be passed to the specific EaseX methods.

class function TAQ.Ease(EaseType: TEaseType;
  EaseModifier: TEaseModifier = emIn): TEaseFunction;

This method returns a TEaseFunction for the passed TEaseType, which can be optional modified with TEaseModifier

class function TAQ.Ease(const EaseTypes: array of TEaseType;
  EaseModifier: TEaseModifier = emIn): TEaseFunction;
class function TAQ.Ease(EaseFunction: TEaseFunction = nil;
  EaseModifier: TEaseModifier = emIn): TEaseFunction;
Clone this wiki locally