Browse Source

Merge pull request #54 from bgrabitmap/dev-bgracontrols

Dev bgracontrols
lainz 6 years ago
parent
commit
9222296832

+ 2 - 0
bccombobox.pas

@@ -164,6 +164,8 @@ begin
     FListBox.SetBounds(FDropDownBorderSize,FDropDownBorderSize,
     FListBox.SetBounds(FDropDownBorderSize,FDropDownBorderSize,
       FForm.ClientWidth-2*FDropDownBorderSize,
       FForm.ClientWidth-2*FDropDownBorderSize,
       FForm.ClientHeight-2*FDropDownBorderSize);
       FForm.ClientHeight-2*FDropDownBorderSize);
+    if FForm.Top + FForm.Height > Screen.Height then
+      FForm.Top := FForm.Top - FForm.Height - Self.Height;
     FForm.Visible := True;
     FForm.Visible := True;
     if FListBox.CanSetFocus then
     if FListBox.CanSetFocus then
       FListBox.SetFocus;
       FListBox.SetFocus;

+ 2 - 2
bcimagebutton.pas

@@ -46,7 +46,7 @@ interface
 
 
 uses
 uses
   Classes, SysUtils, Forms, Controls, Graphics,
   Classes, SysUtils, Forms, Controls, Graphics,
-  {$IFDEF FPC}LCLType, LResources, LMessages,{$ENDIF} ExtCtrls,
+  {$IFDEF FPC}{$ifdef Windows}Windows,{$endif}LCLType, LResources, LMessages,{$ENDIF} ExtCtrls,
   Types,
   Types,
   {$IFNDEF FPC}Windows, Messages, BGRAGraphics, GraphType, FPImage, {$ENDIF}
   {$IFNDEF FPC}Windows, Messages, BGRAGraphics, GraphType, FPImage, {$ENDIF}
   { BGRAControls }
   { BGRAControls }
@@ -1390,7 +1390,7 @@ end;
 
 
 procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string);
 procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string);
 begin
 begin
-  LoadFromBitmapResource(Resource, RT_RCDATA);
+  LoadFromBitmapResource(Resource, {$ifdef Windows}Windows.{$endif}RT_RCDATA);
 end;
 end;
 
 
 procedure TBCCustomImageButton.LoadFromBitmapFile;
 procedure TBCCustomImageButton.LoadFromBitmapFile;

+ 1 - 1
bgracontrols.lpk

@@ -28,7 +28,7 @@
     </CompilerOptions>
     </CompilerOptions>
     <Description Value="BGRA Controls is a set of graphical UI elements that you can use with Lazarus LCL applications."/>
     <Description Value="BGRA Controls is a set of graphical UI elements that you can use with Lazarus LCL applications."/>
     <License Value="Modified LGPL"/>
     <License Value="Modified LGPL"/>
-    <Version Major="6" Minor="5"/>
+    <Version Major="6" Minor="6"/>
     <Files Count="56">
     <Files Count="56">
       <Item1>
       <Item1>
         <Filename Value="bcbasectrls.pas"/>
         <Filename Value="bcbasectrls.pas"/>

+ 1 - 1
bgracontrolsinfo.pas

@@ -8,7 +8,7 @@ uses
   Classes, SysUtils;
   Classes, SysUtils;
 
 
 const
 const
-  BGRAControlsVersion = 6050000;
+  BGRAControlsVersion = 6060000;
 
 
   function BGRAControlsVersionStr: string;
   function BGRAControlsVersionStr: string;
 
 

+ 1 - 1
bgrapascalscriptcomponent.lpk

@@ -11,7 +11,7 @@
         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
       </SearchPaths>
       </SearchPaths>
     </CompilerOptions>
     </CompilerOptions>
-    <Version Major="6" Minor="5"/>
+    <Version Major="6" Minor="6"/>
     <Files Count="3">
     <Files Count="3">
       <Item1>
       <Item1>
         <Filename Value="bgrapascalscript.pas"/>
         <Filename Value="bgrapascalscript.pas"/>

+ 35 - 0
bgraspriteanimation.pas

@@ -121,6 +121,8 @@ type
     procedure GifImageToSprite(Gif: TBGRAAnimatedGif);//FreeMan35 added
     procedure GifImageToSprite(Gif: TBGRAAnimatedGif);//FreeMan35 added
     procedure LoadFromResourceName(Instance: THandle; const ResName: string); overload;
     procedure LoadFromResourceName(Instance: THandle; const ResName: string); overload;
     procedure LoadFromBitmapResource(const Resource: string); overload;
     procedure LoadFromBitmapResource(const Resource: string); overload;
+    procedure LoadFromBGRABitmap(const BGRA: TBGRABitmap);
+    procedure SpriteToAnimatedGif(Filename: string);
     //FreeMan35 added
     //FreeMan35 added
     procedure AnimatedGifToSprite(Filename: string);
     procedure AnimatedGifToSprite(Filename: string);
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
@@ -574,6 +576,39 @@ begin
   LoadFromResourceName(HInstance, Resource);
   LoadFromResourceName(HInstance, Resource);
 end;
 end;
 
 
+procedure TBGRASpriteAnimation.LoadFromBGRABitmap(const BGRA: TBGRABitmap);
+begin
+  FSprite.Width := BGRA.Width;
+  FSprite.Height := BGRA.Height;
+  BGRA.Draw(FSprite.Canvas, 0, 0, False);
+end;
+
+procedure TBGRASpriteAnimation.SpriteToAnimatedGif(Filename: string);
+var
+  i: integer;
+  gif : TBGRAAnimatedGif;
+  TempSpriteWidth: Integer;
+  TempSpritePosition: Integer;
+  TempSpriteBGRA, TempSprite: TBGRABitmap;
+begin
+  gif := TBGRAAnimatedGif.Create;
+  gif.LoopCount := High(Word);
+  TempSpriteBGRA := TBGRABitmap.Create(FSprite);
+  TempSpriteWidth := TempSpriteBGRA.Width div FSpriteCount;
+  gif.SetSize(TempSpriteWidth, TempSpriteBGRA.Height);
+  for i:=0 to FSpriteCount-1 do
+  begin
+    TempSpritePosition := -TempSpriteWidth * i;
+    TempSprite := TBGRABitmap.Create(TempSpriteWidth, TempSpriteBGRA.Height);
+    TempSprite.BlendImage(TempSpritePosition, 0, TempSpriteBGRA, boLinearBlend);
+    gif.AddFullFrame(TempSprite, FAnimSpeed);
+    TempSprite.Free;
+  end;
+  TempSpriteBGRA.Free;
+  gif.SaveToFile(Filename);
+  gif.Free;
+end;
+
 procedure TBGRASpriteAnimation.AnimatedGifToSprite(Filename: string);
 procedure TBGRASpriteAnimation.AnimatedGifToSprite(Filename: string);
 var
 var
   TempGif: TBGRAAnimatedGif;
   TempGif: TBGRAAnimatedGif;

+ 31 - 30
test/test_bccontrols/test_bcimagebutton/unit1.lfm

@@ -1,20 +1,20 @@
 object Form1: TForm1
 object Form1: TForm1
   Left = 214
   Left = 214
-  Height = 302
+  Height = 403
   Top = 122
   Top = 122
-  Width = 248
+  Width = 331
   Caption = 'Form1'
   Caption = 'Form1'
-  ClientHeight = 302
-  ClientWidth = 248
+  ClientHeight = 403
+  ClientWidth = 331
   Color = clWhite
   Color = clWhite
-  DesignTimePPI = 72
   OnCreate = FormCreate
   OnCreate = FormCreate
-  LCLVersion = '1.9.0.0'
+  LCLVersion = '2.0.4.0'
   object BCImageButton1: TBCImageButton
   object BCImageButton1: TBCImageButton
-    Left = 24
-    Height = 41
-    Top = 12
-    Width = 206
+    Left = 32
+    Height = 55
+    Top = 16
+    Width = 275
+    AlphaTest = False
     Anchors = [akTop, akLeft, akRight]
     Anchors = [akTop, akLeft, akRight]
     Animation = False
     Animation = False
     BitmapFile = 'sample_1.png'
     BitmapFile = 'sample_1.png'
@@ -29,10 +29,11 @@ object Form1: TForm1
     ParentFont = False
     ParentFont = False
   end
   end
   object BCImageButton2: TBCImageButton
   object BCImageButton2: TBCImageButton
-    Left = 24
-    Height = 41
-    Top = 59
-    Width = 206
+    Left = 32
+    Height = 55
+    Top = 79
+    Width = 275
+    AlphaTest = False
     Anchors = [akTop, akLeft, akRight]
     Anchors = [akTop, akLeft, akRight]
     BitmapFile = 'sample_2.png'
     BitmapFile = 'sample_2.png'
     BitmapOptions.Direction = sdVertical
     BitmapOptions.Direction = sdVertical
@@ -40,10 +41,10 @@ object Form1: TForm1
     ParentFont = False
     ParentFont = False
   end
   end
   object BCImageButton3: TBCImageButton
   object BCImageButton3: TBCImageButton
-    Left = 24
-    Height = 41
-    Top = 107
-    Width = 206
+    Left = 32
+    Height = 55
+    Top = 143
+    Width = 275
     Anchors = [akTop, akLeft, akRight]
     Anchors = [akTop, akLeft, akRight]
     BitmapFile = 'sample_3.png'
     BitmapFile = 'sample_3.png'
     BitmapOptions.AutoDetectRepeat = True
     BitmapOptions.AutoDetectRepeat = True
@@ -59,10 +60,10 @@ object Form1: TForm1
     ParentFont = False
     ParentFont = False
   end
   end
   object BCImageButton4: TBCImageButton
   object BCImageButton4: TBCImageButton
-    Left = 24
-    Height = 41
-    Top = 154
-    Width = 206
+    Left = 32
+    Height = 55
+    Top = 205
+    Width = 275
     Anchors = [akTop, akLeft, akRight]
     Anchors = [akTop, akLeft, akRight]
     BitmapFile = 'sample_4.png'
     BitmapFile = 'sample_4.png'
     BitmapOptions.AutoDetectRepeat = True
     BitmapOptions.AutoDetectRepeat = True
@@ -76,10 +77,10 @@ object Form1: TForm1
     ParentFont = False
     ParentFont = False
   end
   end
   object BCImageButton5: TBCImageButton
   object BCImageButton5: TBCImageButton
-    Left = 24
-    Height = 41
-    Top = 202
-    Width = 206
+    Left = 32
+    Height = 55
+    Top = 269
+    Width = 275
     Anchors = [akTop, akLeft, akRight]
     Anchors = [akTop, akLeft, akRight]
     BitmapFile = 'sample_5.png'
     BitmapFile = 'sample_5.png'
     BitmapOptions.AutoDetectRepeat = True
     BitmapOptions.AutoDetectRepeat = True
@@ -92,10 +93,10 @@ object Form1: TForm1
     ParentFont = False
     ParentFont = False
   end
   end
   object BCImageButton6: TBCImageButton
   object BCImageButton6: TBCImageButton
-    Left = 24
-    Height = 41
-    Top = 250
-    Width = 206
+    Left = 32
+    Height = 55
+    Top = 333
+    Width = 275
     Anchors = [akTop, akLeft, akRight]
     Anchors = [akTop, akLeft, akRight]
     Animation = False
     Animation = False
     BitmapOptions.Direction = sdVertical
     BitmapOptions.Direction = sdVertical

+ 71 - 1
test/test_bcimagebutton_alpha/test.lpi

@@ -19,8 +19,78 @@
         <Resource_2 FileName="title_bath3.gif" Type="RCDATA" ResourceName="TITLE_BATH3"/>
         <Resource_2 FileName="title_bath3.gif" Type="RCDATA" ResourceName="TITLE_BATH3"/>
       </Resources>
       </Resources>
     </General>
     </General>
-    <BuildModes Count="1">
+    <BuildModes Count="3">
       <Item1 Name="Default" Default="True"/>
       <Item1 Name="Default" Default="True"/>
+      <Item2 Name="Debug">
+        <CompilerOptions>
+          <Version Value="11"/>
+          <PathDelim Value="\"/>
+          <Target>
+            <Filename Value="test"/>
+          </Target>
+          <SearchPaths>
+            <IncludeFiles Value="$(ProjOutDir)"/>
+            <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+          </SearchPaths>
+          <Parsing>
+            <SyntaxOptions>
+              <IncludeAssertionCode Value="True"/>
+            </SyntaxOptions>
+          </Parsing>
+          <CodeGeneration>
+            <Checks>
+              <IOChecks Value="True"/>
+              <RangeChecks Value="True"/>
+              <OverflowChecks Value="True"/>
+              <StackChecks Value="True"/>
+            </Checks>
+            <VerifyObjMethodCallValidity Value="True"/>
+          </CodeGeneration>
+          <Linking>
+            <Debugging>
+              <DebugInfoType Value="dsDwarf2Set"/>
+              <UseHeaptrc Value="True"/>
+              <TrashVariables Value="True"/>
+              <UseExternalDbgSyms Value="True"/>
+            </Debugging>
+            <Options>
+              <Win32>
+                <GraphicApplication Value="True"/>
+              </Win32>
+            </Options>
+          </Linking>
+        </CompilerOptions>
+      </Item2>
+      <Item3 Name="Release">
+        <CompilerOptions>
+          <Version Value="11"/>
+          <PathDelim Value="\"/>
+          <Target>
+            <Filename Value="test"/>
+          </Target>
+          <SearchPaths>
+            <IncludeFiles Value="$(ProjOutDir)"/>
+            <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+          </SearchPaths>
+          <CodeGeneration>
+            <SmartLinkUnit Value="True"/>
+            <Optimizations>
+              <OptimizationLevel Value="3"/>
+            </Optimizations>
+          </CodeGeneration>
+          <Linking>
+            <Debugging>
+              <GenerateDebugInfo Value="False"/>
+            </Debugging>
+            <LinkSmart Value="True"/>
+            <Options>
+              <Win32>
+                <GraphicApplication Value="True"/>
+              </Win32>
+            </Options>
+          </Linking>
+        </CompilerOptions>
+      </Item3>
     </BuildModes>
     </BuildModes>
     <PublishOptions>
     <PublishOptions>
       <Version Value="2"/>
       <Version Value="2"/>

+ 2 - 2
update_bgracontrols_force.json

@@ -8,13 +8,13 @@
       "ForceNotify" : true,
       "ForceNotify" : true,
       "InternalVersion" : 25,
       "InternalVersion" : 25,
       "Name" : "bgracontrols.lpk",
       "Name" : "bgracontrols.lpk",
-      "Version" : "6.5.0.0"
+      "Version" : "6.6.0.0"
     },
     },
     {
     {
       "ForceNotify" : false,
       "ForceNotify" : false,
       "InternalVersion" : 1,
       "InternalVersion" : 1,
       "Name" : "bgrapascalscriptcomponent.lpk",
       "Name" : "bgrapascalscriptcomponent.lpk",
-      "Version" : "6.5.0.0"
+      "Version" : "6.6.0.0"
     }
     }
   ]
   ]
 }
 }