371 lines
9.7 KiB
Diff
371 lines
9.7 KiB
Diff
Index: gifanim.pas
|
|
===================================================================
|
|
--- gifanim.pas (revision none)
|
|
+++ gifanim.pas (working copy)
|
|
@@ -26,7 +26,7 @@
|
|
|
|
uses
|
|
Classes, LCLProc, Lresources, SysUtils, Controls, Graphics, ExtCtrls,
|
|
- IntfGraphics, FPimage, Contnrs, GraphType, dialogs;
|
|
+ IntfGraphics, FPimage, Contnrs, GraphType, dialogs, types;
|
|
|
|
const
|
|
|
|
@@ -193,7 +193,7 @@
|
|
procedure DoAutoSize; override;
|
|
procedure DoStartAnim;
|
|
procedure DoStopAnim;
|
|
- class function GetControlClassDefaultSize: TPoint; override;
|
|
+ class function GetControlClassDefaultSize: TSize; override;
|
|
procedure GifChanged;
|
|
procedure LoadFromFile(const Filename: string); virtual;
|
|
procedure Paint; override;
|
|
@@ -203,6 +203,8 @@
|
|
{ Public declarations }
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
+ procedure NextFrame;
|
|
+ procedure PriorFrame;
|
|
property Empty: boolean Read FEmpty;
|
|
property GifBitmaps: TGifList Read FGifBitmaps;
|
|
property GifIndex: integer Read FCurrentImage;
|
|
@@ -237,28 +239,9 @@
|
|
|
|
implementation
|
|
|
|
-uses LazIDEIntf, propedits;
|
|
-Type
|
|
- TGifFileNamePropertyEditor=class(TFileNamePropertyEditor)
|
|
- protected
|
|
- function GetFilter: String; override;
|
|
- function GetInitialDirectory: string; override;
|
|
- end;
|
|
-function TGifFileNamePropertyEditor.GetFilter: String;
|
|
-begin
|
|
- Result := 'GIF|*.gif';
|
|
-end;
|
|
-
|
|
-function TGifFileNamePropertyEditor.GetInitialDirectory: string;
|
|
-begin
|
|
- Result:= ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
|
|
-end;
|
|
-
|
|
procedure Register;
|
|
begin
|
|
RegisterComponents('Wile64', [TGifAnim]);
|
|
- RegisterPropertyEditor(TypeInfo(String),
|
|
- TGifAnim, 'FileName', TGifFileNamePropertyEditor);
|
|
end;
|
|
|
|
{ TGifAnim }
|
|
@@ -268,7 +251,7 @@
|
|
inherited Create(AOwner);
|
|
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks];
|
|
AutoSize := True;
|
|
- SetInitialBounds(0, 0, GetControlClassDefaultSize.X, GetControlClassDefaultSize.Y);
|
|
+ SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY);
|
|
FEmpty := True;
|
|
FCurrentImage := 0;
|
|
CurrentView := TBitmap.Create;
|
|
@@ -295,6 +278,59 @@
|
|
CurrentView.Free;
|
|
end;
|
|
|
|
+procedure TGifAnim.NextFrame;
|
|
+begin
|
|
+ if (not FEmpty) and Visible and (not FAnimate) then
|
|
+ begin
|
|
+ if FCurrentImage >= GifBitmaps.Count - 1 then
|
|
+ FCurrentImage := 0
|
|
+ else
|
|
+ Inc(FCurrentImage);
|
|
+ if Assigned(FOnFrameChanged) then
|
|
+ FOnFrameChanged(Self);
|
|
+ Repaint;
|
|
+ end;
|
|
+end;
|
|
+
|
|
+procedure TGifAnim.PriorFrame;
|
|
+var
|
|
+ DesiredImage: Integer;
|
|
+begin
|
|
+ if (not FEmpty) and Visible and (not FAnimate) then
|
|
+ begin
|
|
+ if FCurrentImage = 0 then
|
|
+ DesiredImage:= GifBitmaps.Count - 1
|
|
+ else
|
|
+ DesiredImage:= FCurrentImage - 1;
|
|
+ // For proper display repaint image from first frame to desired frame
|
|
+ FCurrentImage:= 0;
|
|
+ while FCurrentImage < DesiredImage do
|
|
+ begin
|
|
+ with GifBitmaps.Items[FCurrentImage] do
|
|
+ begin
|
|
+ BufferImg.Canvas.Brush.Color := (Self.Color);
|
|
+ if FCurrentImage = 0 then
|
|
+ BufferImg.Canvas.FillRect(Rect(0, 0, Width, Height));
|
|
+ if Delay <> 0 then
|
|
+ FWait.Interval := Delay * 10;
|
|
+ BufferImg.Canvas.Draw(PosX, PosY, Bitmap);
|
|
+ case Method of
|
|
+ //0 : Not specified...
|
|
+ //1 : No change Background
|
|
+ 2: BufferImg.Canvas.FillRect(
|
|
+ Rect(PosX, PosY, Bitmap.Width + PosX, Bitmap.Height + PosY));
|
|
+
|
|
+ 3: BufferImg.Canvas.FillRect(Rect(0, 0, Width, Height));
|
|
+ end;
|
|
+ end;
|
|
+ Inc(FCurrentImage);
|
|
+ end;
|
|
+ if Assigned(FOnFrameChanged) then
|
|
+ FOnFrameChanged(Self);
|
|
+ Repaint;
|
|
+ end;
|
|
+end;
|
|
+
|
|
function TGifAnim.LoadFromLazarusResource(const ResName: String): boolean;
|
|
var
|
|
GifLoader: TGifLoader;
|
|
@@ -340,12 +376,13 @@
|
|
begin
|
|
if (not Empty) and Visible then
|
|
begin
|
|
- if FCurrentImage > GifBitmaps.Count - 1 then
|
|
- FCurrentImage := 0;
|
|
- if assigned(FOnFrameChanged) then
|
|
- FOnFrameChanged(self);
|
|
- Paint;
|
|
- Inc(FCurrentImage);
|
|
+ if FCurrentImage >= GifBitmaps.Count - 1 then
|
|
+ FCurrentImage := 0
|
|
+ else
|
|
+ Inc(FCurrentImage);
|
|
+ if Assigned(FOnFrameChanged) then
|
|
+ FOnFrameChanged(Self);
|
|
+ Repaint;
|
|
end;
|
|
end;
|
|
|
|
@@ -365,27 +402,12 @@
|
|
end;
|
|
|
|
procedure TGifAnim.SetFileName(const AValue: string);
|
|
-var
|
|
- fn: string;
|
|
begin
|
|
-
|
|
- if (FFileName = AValue) then
|
|
- exit;
|
|
+ if (FFileName = AValue) then Exit;
|
|
FFileName := AValue;
|
|
ResetImage;
|
|
- if (FFileName = '') then exit;
|
|
- if (csDesigning in ComponentState) then
|
|
- begin
|
|
- fn:= ExtractFileName(AValue);
|
|
- FFileName:= ExtractFilePath(AValue);
|
|
- FFileName:= ExtractRelativepath(ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile) ,FFileName);
|
|
- FFileName:=FFileName+fn;
|
|
- LoadFromFile(FFileName+fn);
|
|
- end
|
|
- else begin
|
|
- FFileName := AValue;
|
|
- LoadFromFile(FFileName);
|
|
- end;
|
|
+ if (FFileName = '') then Exit;
|
|
+ LoadFromFile(FFileName);
|
|
if not Empty then
|
|
GifChanged;
|
|
end;
|
|
@@ -441,10 +463,10 @@
|
|
end;
|
|
end;
|
|
|
|
-class function TGifAnim.GetControlClassDefaultSize: TPoint;
|
|
+class function TGifAnim.GetControlClassDefaultSize: TSize;
|
|
begin
|
|
- Result.X := 90;
|
|
- Result.Y := 90;
|
|
+ Result.CX := 90;
|
|
+ Result.CY := 90;
|
|
end;
|
|
|
|
procedure TGifAnim.GifChanged;
|
|
Index: gifanimdsgn.pas
|
|
===================================================================
|
|
--- gifanimdsgn.pas (revision 0)
|
|
+++ gifanimdsgn.pas (revision 0)
|
|
@@ -0,0 +1,41 @@
|
|
+unit GifAnimDsgn;
|
|
+
|
|
+{$mode objfpc}{$H+}
|
|
+
|
|
+interface
|
|
+
|
|
+uses
|
|
+ LazIDEIntf, PropEdits;
|
|
+
|
|
+Type
|
|
+ TGifFileNamePropertyEditor = class(TFileNamePropertyEditor)
|
|
+ protected
|
|
+ function GetFilter: String; override;
|
|
+ function GetInitialDirectory: string; override;
|
|
+ end;
|
|
+
|
|
+procedure Register;
|
|
+
|
|
+implementation
|
|
+
|
|
+uses
|
|
+ SysUtils, GifAnim;
|
|
+
|
|
+function TGifFileNamePropertyEditor.GetFilter: String;
|
|
+begin
|
|
+ Result := 'GIF|*.gif';
|
|
+end;
|
|
+
|
|
+function TGifFileNamePropertyEditor.GetInitialDirectory: string;
|
|
+begin
|
|
+ Result:= ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
|
|
+end;
|
|
+
|
|
+procedure Register;
|
|
+begin
|
|
+ RegisterPropertyEditor(TypeInfo(String), TGifAnim,
|
|
+ 'FileName', TGifFileNamePropertyEditor);
|
|
+end;
|
|
+
|
|
+end.
|
|
+
|
|
Index: pkg_gifanim.lpk
|
|
===================================================================
|
|
--- pkg_gifanim.lpk (revision none)
|
|
+++ pkg_gifanim.lpk (working copy)
|
|
@@ -1,15 +1,21 @@
|
|
-<?xml version="1.0"?>
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
<CONFIG>
|
|
- <Package Version="3">
|
|
+ <Package Version="4">
|
|
<PathDelim Value="\"/>
|
|
<Name Value="pkg_gifanim"/>
|
|
+ <AddToProjectUsesSection Value="True"/>
|
|
<Author Value="Laurent Jacques"/>
|
|
<CompilerOptions>
|
|
- <Version Value="8"/>
|
|
+ <Version Value="11"/>
|
|
<PathDelim Value="\"/>
|
|
<SearchPaths>
|
|
- <OtherUnitFiles Value="$(LazarusDir)\ide\"/>
|
|
+ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
|
</SearchPaths>
|
|
+ <Linking>
|
|
+ <Debugging>
|
|
+ <DebugInfoType Value="dsDwarf2Set"/>
|
|
+ </Debugging>
|
|
+ </Linking>
|
|
<Other>
|
|
<CompilerPath Value="$(CompPath)"/>
|
|
</Other>
|
|
@@ -33,15 +39,16 @@
|
|
<Type Value="RunAndDesignTime"/>
|
|
<RequiredPkgs Count="2">
|
|
<Item1>
|
|
- <PackageName Value="FCL"/>
|
|
+ <PackageName Value="LCL"/>
|
|
<MinVersion Major="1" Valid="True"/>
|
|
</Item1>
|
|
<Item2>
|
|
- <PackageName Value="IDEIntf"/>
|
|
+ <PackageName Value="FCL"/>
|
|
+ <MinVersion Major="1" Valid="True"/>
|
|
</Item2>
|
|
</RequiredPkgs>
|
|
<UsageOptions>
|
|
- <UnitPath Value="$(PkgOutDir)\"/>
|
|
+ <UnitPath Value="$(PkgOutDir)"/>
|
|
</UsageOptions>
|
|
<PublishOptions>
|
|
<Version Value="2"/>
|
|
Index: pkg_gifanim_dsgn.lpk
|
|
===================================================================
|
|
--- pkg_gifanim_dsgn.lpk (revision 0)
|
|
+++ pkg_gifanim_dsgn.lpk (revision 0)
|
|
@@ -0,0 +1,49 @@
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
+<CONFIG>
|
|
+ <Package Version="4">
|
|
+ <PathDelim Value="\"/>
|
|
+ <Name Value="pkg_gifanim_dsgn"/>
|
|
+ <CompilerOptions>
|
|
+ <Version Value="11"/>
|
|
+ <PathDelim Value="\"/>
|
|
+ <SearchPaths>
|
|
+ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
|
+ </SearchPaths>
|
|
+ <Linking>
|
|
+ <Debugging>
|
|
+ <DebugInfoType Value="dsDwarf2Set"/>
|
|
+ </Debugging>
|
|
+ </Linking>
|
|
+ <Other>
|
|
+ <CompilerMessages>
|
|
+ <MsgFileName Value=""/>
|
|
+ </CompilerMessages>
|
|
+ <CompilerPath Value="$(CompPath)"/>
|
|
+ </Other>
|
|
+ </CompilerOptions>
|
|
+ <License Value="GPL"/>
|
|
+ <Version Major="1" Minor="4"/>
|
|
+ <Files Count="1">
|
|
+ <Item1>
|
|
+ <Filename Value="gifanimdsgn.pas"/>
|
|
+ <HasRegisterProc Value="True"/>
|
|
+ <UnitName Value="GifAnimDsgn"/>
|
|
+ </Item1>
|
|
+ </Files>
|
|
+ <Type Value="DesignTime"/>
|
|
+ <RequiredPkgs Count="2">
|
|
+ <Item1>
|
|
+ <PackageName Value="IDEIntf"/>
|
|
+ </Item1>
|
|
+ <Item2>
|
|
+ <PackageName Value="pkg_gifanim"/>
|
|
+ </Item2>
|
|
+ </RequiredPkgs>
|
|
+ <UsageOptions>
|
|
+ <UnitPath Value="$(PkgOutDir)"/>
|
|
+ </UsageOptions>
|
|
+ <PublishOptions>
|
|
+ <Version Value="2"/>
|
|
+ </PublishOptions>
|
|
+ </Package>
|
|
+</CONFIG>
|
|
Index: pkg_gifanim_dsgn.pas
|
|
===================================================================
|
|
--- pkg_gifanim_dsgn.pas (revision 0)
|
|
+++ pkg_gifanim_dsgn.pas (revision 0)
|
|
@@ -0,0 +1,21 @@
|
|
+{ This file was automatically created by Lazarus. Do not edit!
|
|
+ This source is only used to compile and install the package.
|
|
+ }
|
|
+
|
|
+unit pkg_gifanim_dsgn;
|
|
+
|
|
+interface
|
|
+
|
|
+uses
|
|
+ GifAnimDsgn, LazarusPackageIntf;
|
|
+
|
|
+implementation
|
|
+
|
|
+procedure Register;
|
|
+begin
|
|
+ RegisterUnit('GifAnimDsgn', @GifAnimDsgn.Register);
|
|
+end;
|
|
+
|
|
+initialization
|
|
+ RegisterPackage('pkg_gifanim_dsgn', @Register);
|
|
+end.
|