Skip to content

Commit

Permalink
New class method TAQ.HasActiveActors and their usage in an example
Browse files Browse the repository at this point in the history
  • Loading branch information
WladiD committed Apr 30, 2019
1 parent cb54f19 commit fdc4a88
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 207 deletions.
4 changes: 3 additions & 1 deletion AQPControlAnimations.pas
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ function TAQPControlAnimations.BoundsAnimation(
OC: TControl absolute O;
begin
Result := True;
if not (O is TControl) then
if not ((O is TControl) and
((NewLeft <> OC.Left) or (NewTop <> OC.Top) or
(NewWidth <> OC.Width) or (NewHeight <> OC.Height))) then
Exit;

PrevLeft := OC.Left;
Expand Down
28 changes: 28 additions & 0 deletions AnyiQuack.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ TTimerThread = class;
emInOut, emInOutMirrored, emInOutCombined,
emOutIn, emOutInMirrored, emOutInCombined);
TActorRole = (arTimer, arInterval, arDelay, arAnimation);
TActorRoles = set of TActorRole;

TObjectArray = TArray<TObject>;
TEaseArray = array of TEaseType;
Expand Down Expand Up @@ -247,6 +248,8 @@ TAQ = class sealed (TAQBase)
class function Take(Objects: TObjectList): TAQ; overload;
class function Take<T: class>(Objects: TObjectList<T>): TAQ; overload;

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

class function GetUniqueID: Integer;

class function Ease(EaseType: TEaseType;
Expand Down Expand Up @@ -2549,6 +2552,31 @@ class function TAQ.Take<T>(Objects: TObjectList<T>): TAQ;
Result.Add(Objects[cc]);
end;

// Determines, whether there are active actors (running animation, delay...) for AObject in general
// or optional for the actor with the specified ID
class function TAQ.HasActiveActors(CheckActors: TActorRoles; AObject: TObject; ID: Integer): Boolean;
var
Found: Boolean;
begin
Found := False;
FActiveIntervalAQs.Each(
function(AQ: TAQ; O: TObject): Boolean
var
OAQ: TAQ absolute O;
CheckActor: TActorRole;
begin
for CheckActor in CheckActors do
begin
Found := OAQ.Contains(AObject) and OAQ.HasActors(CheckActor, ID);
if Found then
Break;
end;

Result := not Found;
end);
Result := Found;
end;

function TAQ.TimerActorsChain(ID: Integer; IncludeOrphans: Boolean): TAQ;
begin
if SupervisorLock(Result, aqmTimerActorsChain) then
Expand Down
Loading

0 comments on commit fdc4a88

Please sign in to comment.