diff --git a/Source/forms/simba.aca.pas b/Source/forms/simba.aca.pas index 02be1e0c3..f3bad830c 100644 --- a/Source/forms/simba.aca.pas +++ b/Source/forms/simba.aca.pas @@ -217,7 +217,7 @@ procedure TSimbaACAForm.ButtonUpdateImageClick(Sender: TObject); begin if (not FWindow.IsValid()) then FWindow := GetDesktopWindow(); - FImageBox.SetBackground(FWindow); + FImageBox.SetBackgroundFromWindow(FWindow); end; procedure TSimbaACAForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); @@ -406,7 +406,7 @@ procedure TSimbaACAForm.ButtonLoadImageClick(Sender: TObject); try InitialDir := Application.Location; if Execute() then - FImageBox.SetBackground(FileName); + FImageBox.SetBackgroundFromFile(FileName); finally Free(); end; @@ -455,7 +455,7 @@ constructor TSimbaACAForm.Create(Window: TWindowHandle); FImageBox.OnMouseDown := @ClientImageMouseDown; FImageBox.OnMouseMove := @ClientImageMouseMove; FImageBox.OnPaintArea := @DoPaintArea; - FImageBox.SetBackground(FWindow); + FImageBox.SetBackgroundFromWindow(FWindow); FImageZoom := TSimbaImageBoxZoom.Create(Self); FImageZoom.Parent := PanelTop; diff --git a/Source/forms/simba.dtmeditor.pas b/Source/forms/simba.dtmeditor.pas index cd8d003cb..2d6a025c8 100644 --- a/Source/forms/simba.dtmeditor.pas +++ b/Source/forms/simba.dtmeditor.pas @@ -227,7 +227,7 @@ procedure TSimbaDTMEditorForm.ButtonUpdateImageClick(Sender: TObject); begin if (not FWindow.IsValid()) then FWindow := GetDesktopWindow(); - FImageBox.SetBackground(FWindow); + FImageBox.SetBackgroundFromWindow(FWindow); DrawDTM(); end; @@ -502,7 +502,7 @@ procedure TSimbaDTMEditorForm.MenuItemLoadImageClick(Sender: TObject); if Execute() then try - FImageBox.SetBackground(FileName); + FImageBox.SetBackgroundFromFile(FileName); except end; finally @@ -569,7 +569,7 @@ constructor TSimbaDTMEditorForm.Create(Window: TWindowHandle); FImageBox.OnMouseDown := @ClientImageMouseDown; FImageBox.OnMouseMove := @ClientImageMouseMove; FImageBox.OnMouseUp := @ClientImageMouseUp; - FImageBox.SetBackground(FWindow); + FImageBox.SetBackgroundFromWindow(FWindow); FImageZoom := TSimbaImageBoxZoom.Create(Self); FImageZoom.Parent := PanelTop; diff --git a/Source/forms/simba.main.lfm b/Source/forms/simba.main.lfm index 823c3f371..578391a80 100644 --- a/Source/forms/simba.main.lfm +++ b/Source/forms/simba.main.lfm @@ -4,8 +4,8 @@ object SimbaForm: TSimbaForm Top = 623 Width = 798 Caption = 'Simba' - ClientHeight = 539 - ClientWidth = 798 + ClientHeight = 0 + ClientWidth = 0 DesignTimePPI = 120 KeyPreview = True OnClose = FormClose @@ -16,9 +16,9 @@ object SimbaForm: TSimbaForm LCLVersion = '3.0.0.2' object DockPanel: TAnchorDockPanel Left = 0 - Height = 511 - Top = 28 - Width = 798 + Height = 0 + Top = 0 + Width = 0 Align = alClient BevelOuter = bvNone ParentFont = False @@ -26,9 +26,9 @@ object SimbaForm: TSimbaForm end object ToolBar: TToolBar Left = 0 - Height = 28 + Height = 504 Top = 0 - Width = 798 + Width = 0 AutoSize = True ButtonHeight = 28 ButtonWidth = 0 @@ -42,59 +42,59 @@ object SimbaForm: TSimbaForm TabOrder = 1 OnPaintButton = ToolBarPaintButton object ToolbarButtonRun: TToolButton - Left = 123 + Left = 0 Hint = 'Run Script (Alt + R)' - Top = 0 + Top = 196 Caption = '&Run' ImageIndex = 1 OnClick = MenuItemScriptStateClick end object ToolbarButtonPause: TToolButton - Left = 143 + Left = 0 Hint = 'Pause Script' - Top = 0 + Top = 224 Caption = '&Pause' Enabled = False ImageIndex = 2 OnClick = MenuItemScriptStateClick end object ToolbarButtonStop: TToolButton - Left = 163 + Left = 0 Hint = 'Stop Script (Alt + S)' - Top = 0 + Top = 252 Caption = '&Stop' Enabled = False ImageIndex = 3 OnClick = MenuItemScriptStateClick end object ToolbarButtonClearOutput: TToolButton - Left = 253 + Left = 0 Hint = 'Clear Output Box' - Top = 0 + Top = 420 Caption = 'Clear' ImageIndex = 13 OnClick = MenuClearOutputClick end object ToolbarButtonColorPicker: TToolButton - Left = 188 + Left = 0 Hint = 'Color Picker' - Top = 0 + Top = 308 Caption = 'ToolbarButtonColorPicker' ImageIndex = 11 OnClick = ToolbarButtonColorPickerClick end object ToolbarButtonTargetSelector: TToolButton - Left = 208 + Left = 0 Hint = 'Target Selector' - Top = 0 + Top = 336 Caption = 'ToolbarButtonTargetSelector' ImageIndex = 10 OnMouseDown = ToolbarButtonSelectTargetClick end object ToolbarButtonOpen: TToolButton - Left = 20 + Left = 0 Hint = 'Open Script (Ctrl + O)' - Top = 0 + Top = 28 Caption = '&Open' DropdownMenu = RecentFilesPopup ImageIndex = 6 @@ -104,40 +104,40 @@ object SimbaForm: TSimbaForm Style = tbsButtonDrop end object ToolbarButtonSave: TToolButton - Left = 53 + Left = 0 Hint = 'Save Script (Ctrl + S)' - Top = 0 + Top = 56 Caption = '&Save' ImageIndex = 8 OnClick = MenuSaveClick end object ToolbarButtonSaveAll: TToolButton - Left = 73 + Left = 0 Hint = 'Save All' - Top = 0 + Top = 84 Caption = 'Save All' ImageIndex = 9 OnClick = ToolbarButtonSaveAllClick end object ToolbarButtonCompile: TToolButton - Left = 98 + Left = 0 Hint = 'Compile Script (Alt + C)' - Top = 0 + Top = 140 ImageIndex = 0 OnClick = MenuItemScriptStateClick end object ToolbarButtonPackages: TToolButton - Left = 278 + Left = 0 Hint = 'Open Packages' - Top = 0 + Top = 476 Caption = 'ToolbarButtonPackages' ImageIndex = 14 OnClick = ToolbarButtonPackagesClick end object ToolButtonAreaSelector: TToolButton - Left = 228 + Left = 0 Hint = 'Area Selector' - Top = 0 + Top = 364 ImageIndex = 12 OnClick = ToolButtonAreaSelectorClick ShowCaption = False @@ -150,37 +150,37 @@ object SimbaForm: TSimbaForm OnClick = MenuNewClick end object ToolButton1: TToolButton - Left = 93 + Left = 0 Height = 28 - Top = 0 + Top = 112 Caption = 'ToolButton1' Style = tbsDivider end object ToolButton2: TToolButton - Left = 118 + Left = 0 Height = 28 - Top = 0 + Top = 168 Caption = 'ToolButton2' Style = tbsDivider end object ToolButton3: TToolButton - Left = 183 + Left = 0 Height = 28 - Top = 0 + Top = 280 Caption = 'ToolButton3' Style = tbsDivider end object ToolButton4: TToolButton - Left = 248 + Left = 0 Height = 28 - Top = 0 + Top = 392 Caption = 'ToolButton4' Style = tbsDivider end object ToolButton5: TToolButton - Left = 273 + Left = 0 Height = 28 - Top = 0 + Top = 448 Caption = 'ToolButton5' Style = tbsDivider end @@ -189,7 +189,7 @@ object SimbaForm: TSimbaForm Left = 0 Height = 0 Top = 0 - Width = 798 + Width = 0 Align = alTop AutoSize = True BevelOuter = bvNone diff --git a/Source/forms/simba.shapeboxform.pas b/Source/forms/simba.shapeboxform.pas index 175e00d64..68058e0a1 100644 --- a/Source/forms/simba.shapeboxform.pas +++ b/Source/forms/simba.shapeboxform.pas @@ -84,7 +84,7 @@ procedure TSimbaShapeBoxForm.MenuItemLoadImageClick(Sender: TObject); begin if OpenDialog.Execute() then begin - ShapeBox.SetBackground(OpenDialog.FileName); + ShapeBox.SetBackgroundFromFile(OpenDialog.FileName); HasBackground := True; end; diff --git a/Source/imagebox/simba.imagebox.pas b/Source/imagebox/simba.imagebox.pas index 731235651..82a628aa3 100644 --- a/Source/imagebox/simba.imagebox.pas +++ b/Source/imagebox/simba.imagebox.pas @@ -12,7 +12,7 @@ interface uses Classes, SysUtils, Forms, Controls, Graphics, GraphType, ComCtrls, LCLType, simba.mufasatypes, simba.image, simba.dtm, simba.imagebox_image, - simba.colormath; + simba.colormath, simba.target; type TSimbaImageBox_ScrollBox = class(TScrollBox) @@ -98,10 +98,11 @@ TSimbaImageBox = class(TWinControl) function FindColor(AColor: TColor; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TPointArray; function MatchColor(AColor: TColor; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TSingleMatrix; - procedure SetBackground(Data: PColorBGRA; AWidth, AHeight: Integer); overload; - procedure SetBackground(FileName: String); overload; - procedure SetBackground(Bitmap: TSimbaImage); overload; - procedure SetBackground(Window: TWindowHandle); overload; + procedure SetBackground(Image: TSimbaImage); + procedure SetBackgroundFromFile(FileName: String); + procedure SetBackgroundFromWindow(Window: TWindowHandle); + procedure SetBackgroundFromTarget(Target: TSimbaTarget; Bounds: TBox); overload; + procedure SetBackgroundFromTarget(Target: TSimbaTarget); overload; procedure Paint; @@ -427,8 +428,8 @@ procedure TSimbaImageBox.FontChanged(Sender: TObject); Canvas.Font.Size := Round(-GetFontData(Canvas.Font.Reference.Handle).Height * 72 / Canvas.Font.PixelsPerInch) + 6; FMousePanel.Width := Canvas.TextWidth('(1000, 1000)'); - FDimensionsPanel.Width := Canvas.TextWidth('1000x1000'); - FZoomPanel.Width := Canvas.TextWidth('100%'); + FDimensionsPanel.Width := Canvas.TextWidth('1000x1000'); + FZoomPanel.Width := Canvas.TextWidth('100%'); FStatusBar.Height := Round(Canvas.TextHeight('Taylor Swift') * 0.8); FStatusBar.Font := Self.Font; @@ -660,22 +661,17 @@ function TSimbaImageBox.MatchColor(AColor: TColor; ColorSpace: EColorSpace; Mult end; end; -procedure TSimbaImageBox.SetBackground(Data: PColorBGRA; AWidth, AHeight: Integer); -begin - LazImage_FromData(FBackground, Data, AWidth, AHeight); -end; - -procedure TSimbaImageBox.SetBackground(FileName: String); +procedure TSimbaImageBox.SetBackgroundFromFile(FileName: String); begin FBackground.LoadFromFile(FileName); end; -procedure TSimbaImageBox.SetBackground(Bitmap: TSimbaImage); +procedure TSimbaImageBox.SetBackground(Image: TSimbaImage); begin - SetBackground(Bitmap.Data, Bitmap.Width, Bitmap.Height); + LazImage_FromData(FBackground, Image.Data, Image.Width, Image.Height); end; -procedure TSimbaImageBox.SetBackground(Window: TWindowHandle); +procedure TSimbaImageBox.SetBackgroundFromWindow(Window: TWindowHandle); var Image: TSimbaImage; begin @@ -690,6 +686,23 @@ procedure TSimbaImageBox.SetBackground(Window: TWindowHandle); end; end; +procedure TSimbaImageBox.SetBackgroundFromTarget(Target: TSimbaTarget; Bounds: TBox); +var + Image: TSimbaImage; +begin + Image := Target.GetImage(Bounds); + try + SetBackground(Image); + finally + Image.Free(); + end; +end; + +procedure TSimbaImageBox.SetBackgroundFromTarget(Target: TSimbaTarget); +begin + SetBackgroundFromTarget(Target, TBox.Create(-1,-1,-1,-1)); +end; + constructor TSimbaImageBox.Create(AOwner: TComponent); begin inherited Create(AOwner); diff --git a/Source/script/imports/simba.import_imagebox.pas b/Source/script/imports/simba.import_imagebox.pas index ddc003dfd..fb35c78ce 100644 --- a/Source/script/imports/simba.import_imagebox.pas +++ b/Source/script/imports/simba.import_imagebox.pas @@ -14,7 +14,8 @@ implementation uses lptypes, ffi, - simba.imagebox, simba.imagebox_image, simba.image, simba.dtm, simba.colormath; + simba.imagebox, simba.imagebox_image, simba.image, simba.dtm, simba.colormath, + simba.target; type PComponent = ^TComponent; @@ -161,24 +162,29 @@ procedure _LapeSimbaImageBox_Paint(const Params: PParamArray); LAPE_WRAPPER_CALL PSimbaImageBox(Params^[0])^.Paint(); end; -procedure _LapeSimbaImageBox_SetBackground_Data(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeSimbaImageBox_SetBackground(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PSimbaImageBox(Params^[0])^.SetBackground(PPointer(Params^[1])^, PInteger(Params^[2])^, PInteger(Params^[3])^); + PSimbaImageBox(Params^[0])^.SetBackground(PSimbaImage(Params^[1])^); end; -procedure _LapeSimbaImageBox_SetBackground_FileName(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeSimbaImageBox_SetBackgroundFromFile(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PSimbaImageBox(Params^[0])^.SetBackground(PString(Params^[1])^); + PSimbaImageBox(Params^[0])^.SetBackgroundFromFile(PString(Params^[1])^); end; -procedure _LapeSimbaImageBox_SetBackground_Bitmap(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeSimbaImageBox_SetBackgroundFromWindow(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PSimbaImageBox(Params^[0])^.SetBackground(PSimbaImage(Params^[1])^); + PSimbaImageBox(Params^[0])^.SetBackgroundFromWindow(PWindowHandle(Params^[1])^); +end; + +procedure _LapeSimbaImageBox_SetBackgroundFromTarget1(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaImageBox(Params^[0])^.SetBackgroundFromTarget(PSimbaTarget(Params^[1])^, PBox(Params^[2])^); end; -procedure _LapeSimbaImageBox_SetBackground_Window(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeSimbaImageBox_SetBackgroundFromTarget2(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PSimbaImageBox(Params^[0])^.SetBackground(PWindowHandle(Params^[1])^); + PSimbaImageBox(Params^[0])^.SetBackgroundFromTarget(PSimbaTarget(Params^[1])^); end; procedure _LapeSimbaImageBox_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -270,53 +276,56 @@ procedure ImportSimbaImageBox(Compiler: TSimbaScript_Compiler); begin with Compiler do begin - addClass('TSimbaImageBoxBitmap'); - - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawLineGap(Start, Stop: TPoint; Gap: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawLineGap); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawLine(Start, Stop: TPoint; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawLine); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawCross(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCross); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawCrossArray(Centers: TPointArray; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCrossArray); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawCrossHair(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCrossHair); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawBox(Box: TBox; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawBox); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawBoxFilled(Box: TBox; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawBoxFilled); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawPoly(Poly: TPointArray; Connect: Boolean; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawPoly); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawPoint(P: TPoint; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawPoint); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawPoints(TPA: TPointArray; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawPoints); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawCircle(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCircle); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawCircleFilled(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCircleFilled); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawBoxTransparent(Box: TBox; Color: TColor; Transparency: Single);', @_LapeSimbaImageBoxBitmap_DrawBoxTransparent); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawEllipse(Center: TPoint; RadiusX, RadiusY: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawEllipse); - addGlobalFunc('procedure TSimbaImageBoxBitmap.DrawHeatmap(const Mat: TSingleMatrix);', @_LapeSimbaImageBoxBitmap_DrawHeatmap); - - addGlobalType('procedure(Sender: TObject; Bitmap: TSimbaImageBoxBitmap; Rect: TLazRect) of object', 'TSimbaImageBoxPaintAreaEvent', FFI_DEFAULT_ABI); - - addClass('TSimbaImageBox', 'TLazWinControl'); - - addClassVar('TSimbaImageBox', 'MousePoint', 'TPoint', @_LapeSimbaImageBox_MousePoint_Read); - addClassVar('TSimbaImageBox', 'Background', 'TLazBitmap', @_LapeSimbaImageBox_Background_Read); - addClassVar('TSimbaImageBox', 'Zoom', 'Single', @_LapeSimbaImageBox_Zoom_Read, @_LapeSimbaImageBox_Zoom_Write); - addClassVar('TSimbaImageBox', 'StatusBar', 'TLazStatusBar', @_LapeSimbaImageBox_StatusBar_Read); - addClassVar('TSimbaImageBox', 'StatusPanel', 'TLazStatusPanel', @_LapeSimbaImageBox_StatusPanel_Read); - addClassVar('TSimbaImageBox', 'OnMouseMove', 'TLazMouseMoveEvent', @_LapeSimbaImageBox_OnMouseMove_Read, @_LapeSimbaImageBox_OnMouseMove_Write); - addClassVar('TSimbaImageBox', 'OnMouseDown', 'TLazMouseEvent', @_LapeSimbaImageBox_OnMouseDown_Read, @_LapeSimbaImageBox_OnMouseDown_Write); - addClassVar('TSimbaImageBox', 'OnMouseUp', 'TLazMouseEvent', @_LapeSimbaImageBox_OnMouseUp_Read, @_LapeSimbaImageBox_OnMouseUp_Write); - addClassVar('TSimbaImageBox', 'OnMouseLeave', 'TLazNotifyEvent', @_LapeSimbaImageBox_OnMouseLeave_Read, @_LapeSimbaImageBox_OnMouseLeave_Write); - addClassVar('TSimbaImageBox', 'OnMouseEnter', 'TLazNotifyEvent', @_LapeSimbaImageBox_OnMouseEnter_Read, @_LapeSimbaImageBox_OnMouseEnter_Write); - addClassVar('TSimbaImageBox', 'OnDblClick', 'TLazNotifyEvent', @_LapeSimbaImageBox_OnDblClick_Read, @_LapeSimbaImageBox_OnDblClick_Write); - addClassVar('TSimbaImageBox', 'OnPaintArea', 'TSimbaImageBoxPaintAreaEvent', @_LapeSimbaImageBox_OnPaintArea_Read, @_LapeSimbaImageBox_OnPaintArea_Write); - - addGlobalFunc('function TSimbaImageBox.FindDTM(DTM: TDTM): TPointArray', @_LapeSimbaImageBox_FindDTM); - addGlobalFunc('function TSimbaImageBox.FindColor(Col: TColor; Tol: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TPointArray', @_LapeSimbaImageBox_FindColor); - addGlobalFunc('function TSimbaImageBox.MatchColor(Col: TColor; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TSingleMatrix', @_LapeSimbaImageBox_MatchColor); - - addGlobalFunc('procedure TSimbaImageBox.MoveTo(X, Y: Integer);', @_LapeSimbaImageBox_MoveTo); - addGlobalFunc('function TSimbaImageBox.IsVisible(X, Y: Integer): Boolean;', @_LapeSimbaImageBox_IsVisible); - addGlobalFunc('procedure TSimbaImageBox.Paint;', @_LapeSimbaImageBox_Paint); - addGlobalFunc('procedure TSimbaImageBox.SetBackground(Data: PColorBGRA; AWidth, AHeight: Integer); overload;', @_LapeSimbaImageBox_SetBackground_Data); - addGlobalFunc('procedure TSimbaImageBox.SetBackground(FileName: String); overload;', @_LapeSimbaImageBox_SetBackground_FileName); - addGlobalFunc('procedure TSimbaImageBox.SetBackground(Image: TImage); overload;', @_LapeSimbaImageBox_SetBackground_Bitmap); - addGlobalFunc('procedure TSimbaImageBox.SetBackground(Window: TWindowHandle); overload;', @_LapeSimbaImageBox_SetBackground_Window); - addClassConstructor('TSimbaImageBox', '(Owner: TLazComponent)', @_LapeSimbaImageBox_Create); + addClass('TImageBoxImage'); + + addGlobalFunc('procedure TImageBoxImage.DrawLineGap(Start, Stop: TPoint; Gap: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawLineGap); + addGlobalFunc('procedure TImageBoxImage.DrawLine(Start, Stop: TPoint; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawLine); + addGlobalFunc('procedure TImageBoxImage.DrawCross(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCross); + addGlobalFunc('procedure TImageBoxImage.DrawCrossArray(Centers: TPointArray; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCrossArray); + addGlobalFunc('procedure TImageBoxImage.DrawCrossHair(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCrossHair); + addGlobalFunc('procedure TImageBoxImage.DrawBox(Box: TBox; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawBox); + addGlobalFunc('procedure TImageBoxImage.DrawBoxFilled(Box: TBox; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawBoxFilled); + addGlobalFunc('procedure TImageBoxImage.DrawPoly(Poly: TPointArray; Connect: Boolean; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawPoly); + addGlobalFunc('procedure TImageBoxImage.DrawPoint(P: TPoint; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawPoint); + addGlobalFunc('procedure TImageBoxImage.DrawPoints(TPA: TPointArray; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawPoints); + addGlobalFunc('procedure TImageBoxImage.DrawCircle(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCircle); + addGlobalFunc('procedure TImageBoxImage.DrawCircleFilled(Center: TPoint; Radius: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawCircleFilled); + addGlobalFunc('procedure TImageBoxImage.DrawBoxTransparent(Box: TBox; Color: TColor; Transparency: Single);', @_LapeSimbaImageBoxBitmap_DrawBoxTransparent); + addGlobalFunc('procedure TImageBoxImage.DrawEllipse(Center: TPoint; RadiusX, RadiusY: Integer; Color: TColor);', @_LapeSimbaImageBoxBitmap_DrawEllipse); + addGlobalFunc('procedure TImageBoxImage.DrawHeatmap(const Mat: TSingleMatrix);', @_LapeSimbaImageBoxBitmap_DrawHeatmap); + + addGlobalType('procedure(Sender: TObject; Bitmap: TImageBoxImage; Rect: TLazRect) of object', 'TImageBoxPaintAreaEvent', FFI_DEFAULT_ABI); + + addClass('TImageBox', 'TLazWinControl'); + + addClassVar('TImageBox', 'MousePoint', 'TPoint', @_LapeSimbaImageBox_MousePoint_Read); + addClassVar('TImageBox', 'Background', 'TLazBitmap', @_LapeSimbaImageBox_Background_Read); + addClassVar('TImageBox', 'Zoom', 'Single', @_LapeSimbaImageBox_Zoom_Read, @_LapeSimbaImageBox_Zoom_Write); + addClassVar('TImageBox', 'StatusBar', 'TLazStatusBar', @_LapeSimbaImageBox_StatusBar_Read); + addClassVar('TImageBox', 'StatusPanel', 'TLazStatusPanel', @_LapeSimbaImageBox_StatusPanel_Read); + addClassVar('TImageBox', 'OnMouseMove', 'TLazMouseMoveEvent', @_LapeSimbaImageBox_OnMouseMove_Read, @_LapeSimbaImageBox_OnMouseMove_Write); + addClassVar('TImageBox', 'OnMouseDown', 'TLazMouseEvent', @_LapeSimbaImageBox_OnMouseDown_Read, @_LapeSimbaImageBox_OnMouseDown_Write); + addClassVar('TImageBox', 'OnMouseUp', 'TLazMouseEvent', @_LapeSimbaImageBox_OnMouseUp_Read, @_LapeSimbaImageBox_OnMouseUp_Write); + addClassVar('TImageBox', 'OnMouseLeave', 'TLazNotifyEvent', @_LapeSimbaImageBox_OnMouseLeave_Read, @_LapeSimbaImageBox_OnMouseLeave_Write); + addClassVar('TImageBox', 'OnMouseEnter', 'TLazNotifyEvent', @_LapeSimbaImageBox_OnMouseEnter_Read, @_LapeSimbaImageBox_OnMouseEnter_Write); + addClassVar('TImageBox', 'OnDblClick', 'TLazNotifyEvent', @_LapeSimbaImageBox_OnDblClick_Read, @_LapeSimbaImageBox_OnDblClick_Write); + addClassVar('TImageBox', 'OnPaintArea', 'TImageBoxPaintAreaEvent', @_LapeSimbaImageBox_OnPaintArea_Read, @_LapeSimbaImageBox_OnPaintArea_Write); + + addGlobalFunc('function TImageBox.FindDTM(DTM: TDTM): TPointArray', @_LapeSimbaImageBox_FindDTM); + addGlobalFunc('function TImageBox.FindColor(Col: TColor; Tol: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TPointArray', @_LapeSimbaImageBox_FindColor); + addGlobalFunc('function TImageBox.MatchColor(Col: TColor; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TSingleMatrix', @_LapeSimbaImageBox_MatchColor); + + addGlobalFunc('procedure TImageBox.MoveTo(X, Y: Integer);', @_LapeSimbaImageBox_MoveTo); + addGlobalFunc('function TImageBox.IsVisible(X, Y: Integer): Boolean;', @_LapeSimbaImageBox_IsVisible); + addGlobalFunc('procedure TImageBox.Paint;', @_LapeSimbaImageBox_Paint); + + addGlobalFunc('procedure TImageBox.SetBackground(Image: TImage)', @_LapeSimbaImageBox_SetBackground); + addGlobalFunc('procedure TImageBox.SetBackgroundFromFile(FileName: String)', @_LapeSimbaImageBox_SetBackgroundFromFile); + addGlobalFunc('procedure TImageBox.SetBackgroundFromWindow(Window: TWindowHandle)', @_LapeSimbaImageBox_SetBackgroundFromWindow); + addGlobalFunc('procedure TImageBox.SetBackgroundFromTarget(Target: TTarget; Bounds: TBox); overload', @_LapeSimbaImageBox_SetBackgroundFromTarget1); + addGlobalFunc('procedure TImageBox.SetBackgroundFromTarget(Target: TTarget); overload', @_LapeSimbaImageBox_SetBackgroundFromTarget2); + + addClassConstructor('TImageBox', '(Owner: TLazComponent)', @_LapeSimbaImageBox_Create); end; end; diff --git a/Source/script/imports/simba.import_shapebox.pas b/Source/script/imports/simba.import_shapebox.pas index 2ce944cdc..86625681a 100644 --- a/Source/script/imports/simba.import_shapebox.pas +++ b/Source/script/imports/simba.import_shapebox.pas @@ -170,7 +170,7 @@ procedure ImportSimbaShapeBox(Compiler: TSimbaScript_Compiler); begin with Compiler do begin - addClass('TSimbaShapeBox', 'TSimbaImageBox'); + addClass('TShapeBox', 'TImageBox'); addGlobalType([ 'record', @@ -190,40 +190,40 @@ procedure ImportSimbaShapeBox(Compiler: TSimbaScript_Compiler); 'end;' ], 'TShapeBoxShape'); - addClassConstructor('TSimbaShapeBox', '(Owner: TLazComponent)', @_LapeSimbaShapeBox_Create); + addClassConstructor('TShapeBox', '(Owner: TLazComponent)', @_LapeSimbaShapeBox_Create); - addGlobalFunc('function TSimbaShapeBox.GetShape(Index: Integer): TShapeBoxShape', @_LapeSimbaShapeBox_GetShape); - addGlobalFunc('function TSimbaShapeBox.ShapeCount: Integer', @_LapeSimbaShapeBox_GetShapeCount); - addGlobalFunc('function TSimbaShapeBox.ShapeIndex: Integer', @_LapeSimbaShapeBox_GetShapeIndex); + addGlobalFunc('function TShapeBox.GetShape(Index: Integer): TShapeBoxShape', @_LapeSimbaShapeBox_GetShape); + addGlobalFunc('function TShapeBox.ShapeCount: Integer', @_LapeSimbaShapeBox_GetShapeCount); + addGlobalFunc('function TShapeBox.ShapeIndex: Integer', @_LapeSimbaShapeBox_GetShapeIndex); - addClassVar('TSimbaShapeBox', 'UserDataSize', 'Integer', @_LapeSimbaShapeBox_UserDataSize_Read, @_LapeSimbaShapeBox_UserDataSize_Write); - addClassVar('TSimbaShapeBox', 'QueryNameOnNew', 'Boolean', @_LapeSimbaShapeBox_QueryNameOnNew_Read, @_LapeSimbaShapeBox_QueryNameOnNew_Write); + addClassVar('TShapeBox', 'UserDataSize', 'Integer', @_LapeSimbaShapeBox_UserDataSize_Read, @_LapeSimbaShapeBox_UserDataSize_Write); + addClassVar('TShapeBox', 'QueryNameOnNew', 'Boolean', @_LapeSimbaShapeBox_QueryNameOnNew_Read, @_LapeSimbaShapeBox_QueryNameOnNew_Write); - addGlobalFunc('procedure TSimbaShapeBox.DeleteShape(Index: Integer);', @_LapeSimbaShapeBox_DeleteShape); - addGlobalFunc('procedure TSimbaShapeBox.DeleteAllShapes;', @_LapeSimbaShapeBox_DeleteAllShapes); + addGlobalFunc('procedure TShapeBox.DeleteShape(Index: Integer);', @_LapeSimbaShapeBox_DeleteShape); + addGlobalFunc('procedure TShapeBox.DeleteAllShapes;', @_LapeSimbaShapeBox_DeleteAllShapes); - addGlobalFunc('procedure TSimbaShapeBox.SaveToFile(FileName: String);', @_LapeSimbaShapeBox_SaveToFile); - addGlobalFunc('procedure TSimbaShapeBox.LoadFromFile(FileName: String);', @_LapeSimbaShapeBox_LoadFromFile); + addGlobalFunc('procedure TShapeBox.SaveToFile(FileName: String);', @_LapeSimbaShapeBox_SaveToFile); + addGlobalFunc('procedure TShapeBox.LoadFromFile(FileName: String);', @_LapeSimbaShapeBox_LoadFromFile); - addGlobalFunc('function TSimbaShapeBox.PointButton: TLazButton;', @_LapeSimbaShapeBox_PointButton); - addGlobalFunc('function TSimbaShapeBox.BoxButton: TLazButton;', @_LapeSimbaShapeBox_BoxButton); - addGlobalFunc('function TSimbaShapeBox.PolyButton: TLazButton;', @_LapeSimbaShapeBox_PolyButton); - addGlobalFunc('function TSimbaShapeBox.PathButton: TLazButton;', @_LapeSimbaShapeBox_PathButton); - addGlobalFunc('function TSimbaShapeBox.PrintButton: TLazButton;', @_LapeSimbaShapeBox_PrintButton); - addGlobalFunc('function TSimbaShapeBox.NameButton: TLazButton;', @_LapeSimbaShapeBox_NameButton); - addGlobalFunc('function TSimbaShapeBox.DeleteButton: TLazButton;', @_LapeSimbaShapeBox_DeleteButton); - addGlobalFunc('function TSimbaShapeBox.DeleteAllButton: TLazButton;', @_LapeSimbaShapeBox_DeleteAllButton); + addGlobalFunc('function TShapeBox.PointButton: TLazButton;', @_LapeSimbaShapeBox_PointButton); + addGlobalFunc('function TShapeBox.BoxButton: TLazButton;', @_LapeSimbaShapeBox_BoxButton); + addGlobalFunc('function TShapeBox.PolyButton: TLazButton;', @_LapeSimbaShapeBox_PolyButton); + addGlobalFunc('function TShapeBox.PathButton: TLazButton;', @_LapeSimbaShapeBox_PathButton); + addGlobalFunc('function TShapeBox.PrintButton: TLazButton;', @_LapeSimbaShapeBox_PrintButton); + addGlobalFunc('function TShapeBox.NameButton: TLazButton;', @_LapeSimbaShapeBox_NameButton); + addGlobalFunc('function TShapeBox.DeleteButton: TLazButton;', @_LapeSimbaShapeBox_DeleteButton); + addGlobalFunc('function TShapeBox.DeleteAllButton: TLazButton;', @_LapeSimbaShapeBox_DeleteAllButton); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddPoint(Point: TPoint; AName: String = ""); overload', @_LapeSimbaShapeBox_ManualAddPoint1); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddPoint(Point: TPoint; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddPoint2); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddBox(Box: TBox; AName: String = "");', @_LapeSimbaShapeBox_ManualAddBox1); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddBox(Point: TBox; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddBox2); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddPoly(Poly: TPointArray; AName: String = "");', @_LapeSimbaShapeBox_ManualAddPoly1); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddPoly(Point: TPointArray; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddPoly2); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddPath(Path: TPointArray; AName: String = "");', @_LapeSimbaShapeBox_ManualAddPath1); - addGlobalFunc('procedure TSimbaShapeBox.ManualAddPath(Point: TPointArray; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddPath2); + addGlobalFunc('procedure TShapeBox.ManualAddPoint(Point: TPoint; AName: String = ""); overload', @_LapeSimbaShapeBox_ManualAddPoint1); + addGlobalFunc('procedure TShapeBox.ManualAddPoint(Point: TPoint; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddPoint2); + addGlobalFunc('procedure TShapeBox.ManualAddBox(Box: TBox; AName: String = "");', @_LapeSimbaShapeBox_ManualAddBox1); + addGlobalFunc('procedure TShapeBox.ManualAddBox(Point: TBox; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddBox2); + addGlobalFunc('procedure TShapeBox.ManualAddPoly(Poly: TPointArray; AName: String = "");', @_LapeSimbaShapeBox_ManualAddPoly1); + addGlobalFunc('procedure TShapeBox.ManualAddPoly(Point: TPointArray; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddPoly2); + addGlobalFunc('procedure TShapeBox.ManualAddPath(Path: TPointArray; AName: String = "");', @_LapeSimbaShapeBox_ManualAddPath1); + addGlobalFunc('procedure TShapeBox.ManualAddPath(Point: TPointArray; AName: String; constref UserData); overload; ', @_LapeSimbaShapeBox_ManualAddPath2); - addGlobalFunc('function TSimbaShapeBox.Panel: TLazPanel;', @_LapeSimbaShapeBox_Panel); + addGlobalFunc('function TShapeBox.Panel: TLazPanel;', @_LapeSimbaShapeBox_Panel); end; end; diff --git a/Source/script/simba.script_imports.pas b/Source/script/simba.script_imports.pas index 9767e5d49..9905adb1a 100644 --- a/Source/script/simba.script_imports.pas +++ b/Source/script/simba.script_imports.pas @@ -68,8 +68,6 @@ procedure AddSimbaImports(Compiler: TSimbaScript_Compiler); ImportDTM(Compiler); ImportMatchTemplate(Compiler); ImportJSON(Compiler); - ImportSimbaImageBox(Compiler); - ImportSimbaShapeBox(Compiler); ImportTiming(Compiler); ImportTPA(Compiler); @@ -93,6 +91,9 @@ procedure AddSimbaImports(Compiler: TSimbaScript_Compiler); ImportDialogs(Compiler); ImportThreading(Compiler); ImportPointBuffer(Compiler); + + ImportSimbaImageBox(Compiler); + ImportSimbaShapeBox(Compiler); end; end. diff --git a/Source/simba.env.pas b/Source/simba.env.pas index 5ca12c540..897a23262 100644 --- a/Source/simba.env.pas +++ b/Source/simba.env.pas @@ -75,7 +75,7 @@ function FindFile(var FileName: string; Ext: String; const SearchPaths: array of function FindInclude(var FileName: String; ExtraSearchDirs: TStringArray): Boolean; begin Result := FindFile(FileName, '', ExtraSearchDirs + [SimbaEnv.IncludesPath, SimbaEnv.SimbaPath]); - if (not Result) and (TSimbaPath.PathExtractExt(FileName) = '') then + if (not Result) and (TSimbaPath.PathExtractExt(FileName) <> '.simba') then Result := FindFile(FileName, '.simba', ExtraSearchDirs + [SimbaEnv.IncludesPath, SimbaEnv.SimbaPath]); end;