Jelajahi Sumber

Added again commit changes from e855c85d36eed7ae9011c4973a4af6afcfa83cdb

lainz 7 tahun lalu
induk
melakukan
a0ff20c22f
3 mengubah file dengan 85 tambahan dan 17 penghapusan
  1. 66 4
      bcimagebutton.pas
  2. 12 12
      bgracontrols.pas
  3. 7 1
      bgraspriteanimation.pas

+ 66 - 4
bcimagebutton.pas

@@ -82,6 +82,7 @@ type
     procedure DoMouseUp; virtual;
     procedure DoMouseUp; virtual;
     procedure DoMouseEnter; virtual;
     procedure DoMouseEnter; virtual;
     procedure DoMouseLeave; virtual;
     procedure DoMouseLeave; virtual;
+    procedure DoMouseMove(x, y: integer); virtual;
   protected
   protected
     procedure Click; override;
     procedure Click; override;
     procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
     procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
@@ -89,6 +90,7 @@ type
     procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
     procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
     procedure MouseEnter; override;
     procedure MouseEnter; override;
     procedure MouseLeave; override;
     procedure MouseLeave; override;
+    procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
   public
   public
     property ModalResult: TModalResult
     property ModalResult: TModalResult
       read FModalResult write FModalResult default mrNone;
       read FModalResult write FModalResult default mrNone;
@@ -238,6 +240,8 @@ type
   TBCCustomImageButton = class(TBCGraphicButton)
   TBCCustomImageButton = class(TBCGraphicButton)
   private
   private
     { Private declarations }
     { Private declarations }
+    FAlphaTest: boolean;
+    FAlphaTestValue: byte;
     {$IFDEF INDEBUG}
     {$IFDEF INDEBUG}
     FDrawCount: integer;
     FDrawCount: integer;
     FRenderCount: integer;
     FRenderCount: integer;
@@ -253,6 +257,9 @@ type
     FBitmapFile: string;
     FBitmapFile: string;
     FTextVisible: boolean;
     FTextVisible: boolean;
     FToggle: boolean;
     FToggle: boolean;
+    FMouse: TPoint;
+    procedure SetFAlphaTest(AValue: boolean);
+    procedure SetFAlphaTestValue(AValue: byte);
     procedure SetFAnimation(AValue: boolean);
     procedure SetFAnimation(AValue: boolean);
     procedure SetFBitmapFile(AValue: string);
     procedure SetFBitmapFile(AValue: string);
     procedure SetFBitmapOptions(AValue: TBCImageButtonSliceScalingOptions);
     procedure SetFBitmapOptions(AValue: TBCImageButtonSliceScalingOptions);
@@ -276,9 +283,13 @@ type
     procedure DoMouseUp; override;
     procedure DoMouseUp; override;
     procedure DoMouseEnter; override;
     procedure DoMouseEnter; override;
     procedure DoMouseLeave; override;
     procedure DoMouseLeave; override;
+    procedure DoMouseMove(x, y: integer); override;
     procedure Click; override;
     procedure Click; override;
   public
   public
     { Public declarations }
     { Public declarations }
+    property AlphaTest: boolean read FAlphaTest write SetFAlphaTest default True;
+    property AlphaTestValue: byte
+      read FAlphaTestValue write SetFAlphaTestValue default 255;
     property Toggle: boolean read FToggle write SetFToggle default False;
     property Toggle: boolean read FToggle write SetFToggle default False;
     property Pressed: boolean read FPressed write SetFPressed default False;
     property Pressed: boolean read FPressed write SetFPressed default False;
     //property State: TBCGraphicButtonState read FState;
     //property State: TBCGraphicButtonState read FState;
@@ -290,8 +301,8 @@ type
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
     { It loads the 'BitmapFile' }
     { It loads the 'BitmapFile' }
-    procedure LoadFromBitmapResource(Resource: string; ResourceType: PChar); overload;
-    procedure LoadFromBitmapResource(Resource: string); overload;
+    procedure LoadFromBitmapResource(const Resource: string; ResourceType: PChar); overload;
+    procedure LoadFromBitmapResource(const Resource: string); overload;
     procedure LoadFromBitmapFile;
     procedure LoadFromBitmapFile;
     procedure Assign(Source: TPersistent); override;
     procedure Assign(Source: TPersistent); override;
     { Streaming }
     { Streaming }
@@ -308,6 +319,8 @@ type
 
 
   TBCImageButton = class(TBCCustomImageButton)
   TBCImageButton = class(TBCCustomImageButton)
   published
   published
+    property AlphaTest;
+    property AlphaTestValue;
     property Action;
     property Action;
     property Align;
     property Align;
     property Anchors;
     property Anchors;
@@ -868,6 +881,11 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TBCGraphicButton.DoMouseMove(x, y: integer);
+begin
+  inherited;
+end;
+
 procedure TBCGraphicButton.Click;
 procedure TBCGraphicButton.Click;
 begin
 begin
   DoClick;
   DoClick;
@@ -901,12 +919,22 @@ begin
   DoMouseLeave;
   DoMouseLeave;
 end;
 end;
 
 
+procedure TBCGraphicButton.MouseMove(Shift: TShiftState; X, Y: Integer);
+begin
+  inherited MouseMove(Shift, X, Y);
+  DoMouseMove(X, Y);
+end;
+
 { TBCCustomImageButton }
 { TBCCustomImageButton }
 
 
 procedure TBCCustomImageButton.Fade(Sender: TObject);
 procedure TBCCustomImageButton.Fade(Sender: TObject);
 begin
 begin
   if FFade.Mode <> fmSuspended then
   if FFade.Mode <> fmSuspended then
     Invalidate;
     Invalidate;
+
+  if csDesigning in ComponentState then
+    Exit;
+  FTimer.Enabled := FAnimation;
 end;
 end;
 
 
 procedure TBCCustomImageButton.SetFPressed(AValue: boolean);
 procedure TBCCustomImageButton.SetFPressed(AValue: boolean);
@@ -942,6 +970,20 @@ begin
   FBitmapOptions := AValue;
   FBitmapOptions := AValue;
 end;
 end;
 
 
+procedure TBCCustomImageButton.SetFAlphaTest(AValue: boolean);
+begin
+  if FAlphaTest = AValue then
+      Exit;
+    FAlphaTest := AValue;
+end;
+
+procedure TBCCustomImageButton.SetFAlphaTestValue(AValue: byte);
+begin
+  if FAlphaTestValue = AValue then
+      Exit;
+    FAlphaTestValue := AValue;
+end;
+
 procedure TBCCustomImageButton.SetFAnimation(AValue: boolean);
 procedure TBCCustomImageButton.SetFAnimation(AValue: boolean);
 begin
 begin
   if FAnimation = AValue then
   if FAnimation = AValue then
@@ -1181,6 +1223,9 @@ end;
 
 
 procedure TBCCustomImageButton.DoMouseDown;
 procedure TBCCustomImageButton.DoMouseDown;
 begin
 begin
+  if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
+    Exit;
+
   FFade.Mode := fmFadeOut;
   FFade.Mode := fmFadeOut;
 
 
   if Animation then
   if Animation then
@@ -1195,6 +1240,9 @@ procedure TBCCustomImageButton.DoMouseUp;
 var
 var
   Ctrl: TControl;
   Ctrl: TControl;
 begin
 begin
+  if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
+    Exit;
+
   FFade.Mode := fmFadeIn;
   FFade.Mode := fmFadeIn;
 
 
   if Animation then
   if Animation then
@@ -1236,8 +1284,20 @@ begin
   inherited DoMouseLeave;
   inherited DoMouseLeave;
 end;
 end;
 
 
+procedure TBCCustomImageButton.DoMouseMove(x, y: integer);
+begin
+  FMouse := Point(X, Y);
+  if FAlphaTest then
+    if FBGRANormal.GetPixel(X, Y).alpha >= FAlphaTestValue then
+      DoMouseEnter
+    else
+      DoMouseLeave;
+end;
+
 procedure TBCCustomImageButton.Click;
 procedure TBCCustomImageButton.Click;
 begin
 begin
+  if FAlphaTest and (FBGRANormal.GetPixel(FMouse.X, FMouse.Y).alpha < FAlphaTestValue) then
+    Exit;
   inherited Click;
   inherited Click;
   if (Toggle) then
   if (Toggle) then
   begin
   begin
@@ -1273,6 +1333,8 @@ begin
     FBitmapOptions.Bitmap.SetPixel(0,2,BGRA(0,0,255,255));
     FBitmapOptions.Bitmap.SetPixel(0,2,BGRA(0,0,255,255));
     FBitmapOptions.Bitmap.SetPixel(0,3,BGRA(100,100,100,255));}
     FBitmapOptions.Bitmap.SetPixel(0,3,BGRA(100,100,100,255));}
 
 
+    FAlphaTest := True;
+    FAlphaTestValue := 255;
     FFade.Step := 15;
     FFade.Step := 15;
     FFade.Mode := fmFadeOut;
     FFade.Mode := fmFadeOut;
     FTimer := TTimer.Create(Self);
     FTimer := TTimer.Create(Self);
@@ -1312,7 +1374,7 @@ begin
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
-procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string;
+procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string;
   ResourceType: PChar);
   ResourceType: PChar);
 var
 var
   res: TResourceStream;
   res: TResourceStream;
@@ -1326,7 +1388,7 @@ begin
   res.Free;
   res.Free;
 end;
 end;
 
 
-procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string);
+procedure TBCCustomImageButton.LoadFromBitmapResource(const Resource: string);
 begin
 begin
   LoadFromBitmapResource(Resource, RT_RCDATA);
   LoadFromBitmapResource(Resource, RT_RCDATA);
 end;
 end;

+ 12 - 12
bgracontrols.pas

@@ -8,15 +8,15 @@ unit bgracontrols;
 interface
 interface
 
 
 uses
 uses
- BCButton, BCButtonFocus, BCEffect, bcfilters, BCGameGrid, BCImageButton, 
- BCLabel, BCListBox, BCMaterialDesignButton, BCPanel, BCRadialProgressBar, 
- BCRTTI, BCSamples, BCStylesForm, BCSVGButton, BCSVGViewer, BCToolBar, 
- BCTrackbarUpdown, BGRACustomDrawn, BGRAFlashProgressBar, BGRAGraphicControl, 
- BGRAImageList, BGRAImageManipulation, BGRAKnob, BGRAResizeSpeedButton, 
- BGRAShape, BGRASpeedButton, BGRASpriteAnimation, BGRAVirtualScreen, 
- ColorSpeedButton, DTAnalogClock, dtthemedclock, MaterialColors, BCMDButton, 
- BCMDButtonFocus, DTAnalogCommon, DTAnalogGauge, dtthemedgauge, 
- LazarusPackageIntf;
+  BCButton, BCButtonFocus, BCEffect, bcfilters, BCGameGrid, BCImageButton, 
+  BCLabel, BCListBox, BCMaterialDesignButton, BCMDButton, BCMDButtonFocus, 
+  BCPanel, BCRadialProgressBar, BCRTTI, BCSamples, BCStylesForm, BCSVGButton, 
+  BCSVGViewer, BCToolBar, BCTrackbarUpdown, BGRACustomDrawn, 
+  BGRAFlashProgressBar, BGRAGraphicControl, BGRAImageList, 
+  BGRAImageManipulation, BGRAKnob, BGRAResizeSpeedButton, BGRAShape, 
+  BGRASpeedButton, BGRASpriteAnimation, BGRAVirtualScreen, ColorSpeedButton, 
+  DTAnalogClock, DTAnalogCommon, DTAnalogGauge, dtthemedclock, dtthemedgauge, 
+  MaterialColors, LazarusPackageIntf;
 
 
 implementation
 implementation
 
 
@@ -29,6 +29,8 @@ begin
   RegisterUnit('BCLabel', @BCLabel.Register);
   RegisterUnit('BCLabel', @BCLabel.Register);
   RegisterUnit('BCListBox', @BCListBox.Register);
   RegisterUnit('BCListBox', @BCListBox.Register);
   RegisterUnit('BCMaterialDesignButton', @BCMaterialDesignButton.Register);
   RegisterUnit('BCMaterialDesignButton', @BCMaterialDesignButton.Register);
+  RegisterUnit('BCMDButton', @BCMDButton.Register);
+  RegisterUnit('BCMDButtonFocus', @BCMDButtonFocus.Register);
   RegisterUnit('BCPanel', @BCPanel.Register);
   RegisterUnit('BCPanel', @BCPanel.Register);
   RegisterUnit('BCRadialProgressBar', @BCRadialProgressBar.Register);
   RegisterUnit('BCRadialProgressBar', @BCRadialProgressBar.Register);
   RegisterUnit('BCSVGButton', @BCSVGButton.Register);
   RegisterUnit('BCSVGButton', @BCSVGButton.Register);
@@ -47,10 +49,8 @@ begin
   RegisterUnit('BGRAVirtualScreen', @BGRAVirtualScreen.Register);
   RegisterUnit('BGRAVirtualScreen', @BGRAVirtualScreen.Register);
   RegisterUnit('ColorSpeedButton', @ColorSpeedButton.Register);
   RegisterUnit('ColorSpeedButton', @ColorSpeedButton.Register);
   RegisterUnit('DTAnalogClock', @DTAnalogClock.Register);
   RegisterUnit('DTAnalogClock', @DTAnalogClock.Register);
-  RegisterUnit('dtthemedclock', @dtthemedclock.Register);
-  RegisterUnit('BCMDButton', @BCMDButton.Register);
-  RegisterUnit('BCMDButtonFocus', @BCMDButtonFocus.Register);
   RegisterUnit('DTAnalogGauge', @DTAnalogGauge.Register);
   RegisterUnit('DTAnalogGauge', @DTAnalogGauge.Register);
+  RegisterUnit('dtthemedclock', @dtthemedclock.Register);
   RegisterUnit('dtthemedgauge', @dtthemedgauge.Register);
   RegisterUnit('dtthemedgauge', @dtthemedgauge.Register);
 end;
 end;
 
 

+ 7 - 1
bgraspriteanimation.pas

@@ -119,7 +119,8 @@ type
   public
   public
     { Public declarations }
     { Public declarations }
     procedure GifImageToSprite(Gif: TBGRAAnimatedGif);//FreeMan35 added
     procedure GifImageToSprite(Gif: TBGRAAnimatedGif);//FreeMan35 added
-    procedure LoadFromResourceName(Instance: THandle; const ResName: string);
+    procedure LoadFromResourceName(Instance: THandle; const ResName: string); overload;
+    procedure LoadFromBitmapResource(const Resource: string); overload;
     //FreeMan35 added
     //FreeMan35 added
     procedure AnimatedGifToSprite(Filename: string);
     procedure AnimatedGifToSprite(Filename: string);
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
@@ -568,6 +569,11 @@ begin
   TempGif.Free;
   TempGif.Free;
 end;
 end;
 
 
+procedure TBGRASpriteAnimation.LoadFromBitmapResource(const Resource: string);
+begin
+  LoadFromResourceName(HInstance, Resource);
+end;
+
 procedure TBGRASpriteAnimation.AnimatedGifToSprite(Filename: string);
 procedure TBGRASpriteAnimation.AnimatedGifToSprite(Filename: string);
 var
 var
   TempGif: TBGRAAnimatedGif;
   TempGif: TBGRAAnimatedGif;