summaryrefslogtreecommitdiff
path: root/examples/gui/animation
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-05-30 13:32:06 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-05-30 13:32:06 +0000
commit7f33425aec78550975b32d8ab03d98e99b04cb81 (patch)
tree184f2cfa20591e7aa8f58dd0a72b590e1d7c766a /examples/gui/animation
parent9462d3a6b12c2f5d35ebc5035d2c2205edd8a8db (diff)
downloadfpGUI-7f33425aec78550975b32d8ab03d98e99b04cb81.tar.xz
* Created a new bitmap animation component called TfpgImgAnim.
* Created a Animation demo in the examples/gui/animation directory.
Diffstat (limited to 'examples/gui/animation')
-rw-r--r--examples/gui/animation/anim_test.lpi54
-rw-r--r--examples/gui/animation/anim_test.lpr185
-rw-r--r--examples/gui/animation/extrafpc.cfg5
-rw-r--r--examples/gui/animation/gears.bmpbin0 -> 78174 bytes
-rw-r--r--examples/gui/animation/gears.xcfbin0 -> 55488 bytes
-rw-r--r--examples/gui/animation/readme.txt15
-rw-r--r--examples/gui/animation/wanda.bmpbin0 -> 19062 bytes
7 files changed, 259 insertions, 0 deletions
diff --git a/examples/gui/animation/anim_test.lpi b/examples/gui/animation/anim_test.lpi
new file mode 100644
index 00000000..a6b8a8f6
--- /dev/null
+++ b/examples/gui/animation/anim_test.lpi
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="6"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=".elf"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpgui_package"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="anim_test.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="anim_test"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits
+"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/animation/anim_test.lpr b/examples/gui/animation/anim_test.lpr
new file mode 100644
index 00000000..10cf9286
--- /dev/null
+++ b/examples/gui/animation/anim_test.lpr
@@ -0,0 +1,185 @@
+program anim_test;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, SysUtils,
+ // fpGUI
+ fpgfx, gui_form, gfxbase, gui_button,
+ gui_label, gui_trackbar, gui_animation;
+
+type
+
+ TMainForm = class(TfpgForm)
+ private
+ procedure TrackbarChanged(Sender: TObject; APosition: integer);
+ procedure btnQuitClicked(Sender: TObject);
+ procedure btnStartClicked(Sender: TObject);
+ public
+ {@VFD_HEAD_BEGIN: MainForm}
+ btnQuit: TfpgButton;
+ btnStart: TfpgButton;
+ tbName1: TfpgTrackBar;
+ Anim1: TfpgImgAnim;
+ wanda: TfpgImgAnim;
+ lblName1: TfpgLabel;
+ lblName2: TfpgLabel;
+ lblName3: TfpgLabel;
+ {@VFD_HEAD_END: MainForm}
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TMainForm.TrackbarChanged(Sender: TObject; APosition: integer);
+begin
+ Anim1.Position := APosition;
+end;
+
+procedure TMainForm.btnQuitClicked(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.btnStartClicked(Sender: TObject);
+begin
+ if btnStart.Tag = 0 then
+ btnStart.Tag := 1
+ else
+ btnStart.Tag := 0;
+
+ case btnStart.Tag of
+ 0:
+ begin
+ btnStart.Text := 'Start';
+ Anim1.Enabled := False;
+ end;
+
+ 1:
+ begin
+ btnStart.Text := 'Stop';
+ Anim1.Enabled := True;
+ end;
+ end; { case }
+end;
+
+procedure TMainForm.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: MainForm}
+ Name := 'MainForm';
+ SetPosition(329, 251, 300, 250);
+ WindowTitle := 'Animation Demo';
+ Sizeable := False;
+ WindowPosition := wpScreenCenter;
+
+ btnQuit := TfpgButton.Create(self);
+ with btnQuit do
+ begin
+ Name := 'btnQuit';
+ SetPosition(212, 216, 80, 24);
+ Text := 'Quit';
+ FontDesc := '#Label1';
+ ImageName := '';
+ OnClick := @btnQuitClicked;
+ end;
+
+ btnStart := TfpgButton.Create(self);
+ with btnStart do
+ begin
+ Name := 'btnStart';
+ SetPosition(140, 12, 80, 24);
+ Text := 'Start';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 1;
+ OnClick := @btnStartClicked;
+ end;
+
+ tbName1 := TfpgTrackBar.Create(self);
+ with tbName1 do
+ begin
+ Name := 'tbName1';
+ SetPosition(154, 84, 100, 30);
+ Max := 3;
+ ShowPosition := True;
+ TabOrder := 2;
+ OnChange := @TrackbarChanged;
+ end;
+
+ Anim1 := TfpgImgAnim.Create(self);
+ with Anim1 do
+ begin
+ Name := 'Anim1';
+ SetPosition(16, 12, 110, 100);
+ ImageFileName := 'gears.bmp';
+ end;
+
+ wanda := TfpgImgAnim.Create(self);
+ with wanda do
+ begin
+ Name := 'wanda';
+ SetPosition(64, 156, 104, 40);
+ IsTransparent := False;
+ ImageFileName := 'wanda.bmp';
+ FrameCount := 8;
+ Interval := 300;
+ Enabled := True;
+ end;
+
+ lblName1 := TfpgLabel.Create(self);
+ with lblName1 do
+ begin
+ Name := 'lblName1';
+ SetPosition(140, 52, 152, 16);
+ FontDesc := '#Label2';
+ Text := 'Step through frames';
+ end;
+
+ lblName2 := TfpgLabel.Create(self);
+ with lblName2 do
+ begin
+ Name := 'lblName2';
+ SetPosition(56, 136, 192, 16);
+ FontDesc := '#Label2';
+ Text := 'Wanda the fish';
+ end;
+
+ lblName3 := TfpgLabel.Create(self);
+ with lblName3 do
+ begin
+ Name := 'lblName3';
+ SetPosition(140, 68, 152, 16);
+ FontDesc := '#Label1';
+ Text := '(stop the animation first)';
+ end;
+
+ {@VFD_BODY_END: MainForm}
+end;
+
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ try
+ frm.Show;
+ fpgApplication.Run;
+ finally
+ frm.Free;
+ end;
+end;
+
+begin
+ MainProc;
+end.
+
+
diff --git a/examples/gui/animation/extrafpc.cfg b/examples/gui/animation/extrafpc.cfg
new file mode 100644
index 00000000..073dc4b6
--- /dev/null
+++ b/examples/gui/animation/extrafpc.cfg
@@ -0,0 +1,5 @@
+-FUunits
+-Fu../../../lib
+-Xs
+-XX
+-CX
diff --git a/examples/gui/animation/gears.bmp b/examples/gui/animation/gears.bmp
new file mode 100644
index 00000000..f8e6717a
--- /dev/null
+++ b/examples/gui/animation/gears.bmp
Binary files differ
diff --git a/examples/gui/animation/gears.xcf b/examples/gui/animation/gears.xcf
new file mode 100644
index 00000000..ccc4210e
--- /dev/null
+++ b/examples/gui/animation/gears.xcf
Binary files differ
diff --git a/examples/gui/animation/readme.txt b/examples/gui/animation/readme.txt
new file mode 100644
index 00000000..0681eeea
--- /dev/null
+++ b/examples/gui/animation/readme.txt
@@ -0,0 +1,15 @@
+
+ To create an animation bitmap you need to place the different
+ frames in a horizontal layout. Each frame must be the same size.
+ I included the original gears.xcf file which can be edited with
+ 'The Gimp' imaging program.
+
+ This demo includes two animation examples.
+
+ gears.bmp - which contains 4 frames with transparency.
+ wanda.bmp - which contains 8 frames and no transparency.
+ Wanda the fish originates from the Gnome project.
+
+
+ Regards,
+ - Graeme -
diff --git a/examples/gui/animation/wanda.bmp b/examples/gui/animation/wanda.bmp
new file mode 100644
index 00000000..10a27e4e
--- /dev/null
+++ b/examples/gui/animation/wanda.bmp
Binary files differ