skia: set package flags

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9344 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
mgaertner 2024-04-25 10:15:33 +00:00
parent ecc39afe00
commit b43dfb5c82
3 changed files with 89 additions and 28 deletions

View File

@ -21,6 +21,9 @@
</Item>
</Files>
<RequiredPkgs>
<Item>
<PackageName Value="IDEIntf"/>
</Item>
<Item>
<PackageName Value="Skia.LCL"/>
<DefaultFilename Value="../src/skia.lcl.lpk" Prefer="True"/>

View File

@ -8,7 +8,17 @@ unit SkiaLCLRegister;
interface
uses
LCL.Skia, classes;
LCL.Skia, classes, PropEdits, ObjInspStrConsts, FileUtil, Dialogs;
type
{ TSkSvgSourcePropertyEditor }
TSkSvgSourcePropertyEditor = class(TPropertyEditor)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
procedure Register;
@ -18,7 +28,36 @@ implementation
procedure Register;
begin
RegisterComponents('Skia', [TSkPaintBox]);
RegisterPropertyEditor(TypeInfo(TSkSvgSource), nil, '', TSkSvgSourcePropertyEditor);
RegisterComponents('Skia', [TSkPaintBox,TSkSvg]);
end;
{ TSkSvgSourcePropertyEditor }
function TSkSvgSourcePropertyEditor.GetAttributes: TPropertyAttributes;
begin
Result:=[paDialog,paRevertable];
end;
procedure TSkSvgSourcePropertyEditor.Edit;
var
Dlg: TOpenDialog;
ss: TStringStream;
begin
Dlg:=TOpenDialog.Create(nil);
ss:=nil;
try
Dlg.Filter:='Scalable Vector Grahics (*.svg)|*.svg|'+oisAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask;
Dlg.Options:=DefaultOpenDialogOptions+[ofFileMustExist];
Dlg.Title:=oisSelectAFile;
if not Dlg.Execute then exit;
ss:=TStringStream.Create('');
ss.LoadFromFile(Dlg.Filename);
SetStrValue(ss.AnsiDataString);
finally
ss.Free;
Dlg.Free;
end;
end;
end.

View File

@ -39,6 +39,7 @@ type
procedure SetOpacity(const AValue: Byte);
protected
FScaleFactor: Single;
class function GetControlClassDefaultSize: TSize; override;
procedure ChangeScale(Multiplier, Divider: Integer); override;
procedure Draw(const aCanvas: ISkCanvas; const aDest: TRectF; const aOpacity: Single); virtual;
procedure DeleteBuffers; virtual;
@ -59,24 +60,17 @@ type
{ TSkPaintBox }
TSkPaintBox = class(TSkCustomControl)
protected
class function GetControlClassDefaultSize: TSize; override;
public
constructor Create(AOwner: TComponent); override;
property DrawCacheKind;
published
property Align;
property Anchors;
property BorderSpacing;
property Color;
property Constraints;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property Hint;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
@ -149,7 +143,7 @@ type
property WrapMode: TSkSvgWrapMode read FWrapMode write SetWrapMode default DefaultWrapMode;
end;
{ TSkSvg }
{ TSkSvg - does not work yet }
TSkSvg = class(TSkCustomControl)
strict private
@ -163,8 +157,41 @@ type
destructor Destroy; override;
procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override;
published
property Align;
property Anchors;
property BorderSpacing;
property Constraints;
property DragCursor;
property DragMode;
property Enabled;
property Hint;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Svg: TSkSvgBrush read FSvg write SetSvg;
property Visible;
property OnChangeBounds;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDraw;
property OnEndDrag;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnMouseWheelHorz;
property OnMouseWheelLeft;
property OnMouseWheelRight;
property OnPaint;
property OnResize;
property OnStartDrag;
end;
TSkControlRenderBackend = (Default, Raster, HardwareAcceleration);
@ -406,6 +433,12 @@ begin
Invalidate;
end;
class function TSkCustomControl.GetControlClassDefaultSize: TSize;
begin
Result.CX := 50;
Result.CY := 50;
end;
procedure TSkCustomControl.ChangeScale(Multiplier, Divider: Integer);
begin
if Multiplier <> Divider then
@ -514,6 +547,8 @@ begin
FDrawCacheKind := TSkDrawCacheKind.Raster;
FOpacity := 255;
FScaleFactor := 1;
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);
end;
destructor TSkCustomControl.Destroy;
@ -524,8 +559,7 @@ end;
procedure TSkCustomControl.Redraw;
begin
FDrawCached := False;
Repaint;
Invalidate;
end;
procedure TSkCustomControl.Invalidate;
@ -534,22 +568,6 @@ begin
inherited Invalidate;
end;
{ TSkPaintBox }
class function TSkPaintBox.GetControlClassDefaultSize: TSize;
begin
Result.CX := 50;
Result.CY := 50;
end;
constructor TSkPaintBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csReplicatable];
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);
end;
{ TSkSvgBrush }
function TSkSvgBrush.GetDOM: ISkSVGDOM;
@ -602,6 +620,7 @@ begin
if FSource <> AValue then
begin
FSource := AValue;
writeln('TSkSvgBrush.SetSource ',length(FSource));
RecreateDOM;
DoChanged;
end;