瀏覽代碼

create fill control into package along with LC... units

Unknown 6 年之前
父節點
當前提交
04c3829166

+ 0 - 0
vectoredit/fillimages.lrs → lazpaintcontrols/fillimages.lrs


+ 0 - 0
vectoredit/fillimages.lst → lazpaintcontrols/fillimages.lst


+ 0 - 0
vectoredit/fillimages24.png → lazpaintcontrols/fillimages24.png


+ 65 - 0
lazpaintcontrols/lazpaintcontrols.lpk

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <Package Version="4">
+    <Name Value="lazpaintcontrols"/>
+    <Type Value="RunAndDesignTime"/>
+    <CompilerOptions>
+      <Version Value="11"/>
+      <SearchPaths>
+        <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
+      </SearchPaths>
+    </CompilerOptions>
+    <Version Minor="1"/>
+    <Files Count="7">
+      <Item1>
+        <Filename Value="lctoolbars.pas"/>
+        <UnitName Value="LCToolbars"/>
+      </Item1>
+      <Item2>
+        <Filename Value="lcvectorialfill.pas"/>
+        <UnitName Value="LCVectorialFill"/>
+      </Item2>
+      <Item3>
+        <Filename Value="lcvectorialfillinterface.pas"/>
+        <UnitName Value="LCVectorialFillInterface"/>
+      </Item3>
+      <Item4>
+        <Filename Value="lcvectororiginal.pas"/>
+        <UnitName Value="LCVectorOriginal"/>
+      </Item4>
+      <Item5>
+        <Filename Value="lcvectorpolyshapes.pas"/>
+        <UnitName Value="LCVectorPolyShapes"/>
+      </Item5>
+      <Item6>
+        <Filename Value="lcvectorshapes.pas"/>
+        <UnitName Value="LCVectorShapes"/>
+      </Item6>
+      <Item7>
+        <Filename Value="lcvectorialfillcontrol.pas"/>
+        <HasRegisterProc Value="True"/>
+        <UnitName Value="LCVectorialFillControl"/>
+      </Item7>
+    </Files>
+    <RequiredPkgs Count="4">
+      <Item1>
+        <PackageName Value="bgracontrols"/>
+      </Item1>
+      <Item2>
+        <PackageName Value="BGRABitmapPack"/>
+      </Item2>
+      <Item3>
+        <PackageName Value="LCL"/>
+      </Item3>
+      <Item4>
+        <PackageName Value="FCL"/>
+      </Item4>
+    </RequiredPkgs>
+    <UsageOptions>
+      <UnitPath Value="$(PkgOutDir)"/>
+    </UsageOptions>
+    <PublishOptions>
+      <Version Value="2"/>
+    </PublishOptions>
+  </Package>
+</CONFIG>

+ 23 - 0
lazpaintcontrols/lazpaintcontrols.pas

@@ -0,0 +1,23 @@
+{ This file was automatically created by Lazarus. Do not edit!
+  This source is only used to compile and install the package.
+ }
+
+unit lazpaintcontrols;
+
+interface
+
+uses
+  LCToolbars, LCVectorialFill, LCVectorialFillInterface, LCVectorOriginal, 
+  LCVectorPolyShapes, LCVectorShapes, LCVectorialFillControl, 
+  LazarusPackageIntf;
+
+implementation
+
+procedure Register;
+begin
+  RegisterUnit('LCVectorialFillControl', @LCVectorialFillControl.Register);
+end;
+
+initialization
+  RegisterPackage('lazpaintcontrols', @Register);
+end.

+ 0 - 0
vectoredit/lctoolbars.pas → lazpaintcontrols/lctoolbars.pas


+ 2 - 2
vectoredit/lcvectorialfill.pas → lazpaintcontrols/lcvectorialfill.pas

@@ -42,8 +42,8 @@ type
       ANewCoord: TPointF; AShift: TShiftState);
     procedure TextureMoveYAxis({%H-}ASender: TObject; {%H-}APrevCoord,
       ANewCoord: TPointF; AShift: TShiftState);
-    procedure TextureStartMove(ASender: TObject; AIndex: integer;
-      AShift: TShiftState);
+    procedure TextureStartMove({%H-}ASender: TObject; {%H-}AIndex: integer;
+      {%H-}AShift: TShiftState);
   public
     constructor Create;
     procedure Clear;

+ 272 - 0
lazpaintcontrols/lcvectorialfillcontrol.pas

@@ -0,0 +1,272 @@
+unit LCVectorialFillControl;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, Controls, LCVectorialFillInterface,
+  LCVectorialFill, BGRABitmap, BGRABitmapTypes, BGRAGradientScanner;
+
+type
+  { TLCVectorialFillControl }
+
+  TLCVectorialFillControl = class(TWinControl)
+  private
+    function GetCanAdjustToShape: boolean;
+    function GetFillType: TVectorialFillType;
+    function GetGradEndColor: TBGRAPixel;
+    function GetGradInterp: TBGRAColorInterpolation;
+    function GetGradRepetition: TBGRAGradientRepetition;
+    function GetGradStartColor: TBGRAPixel;
+    function GetGradType: TGradientType;
+    function GetSolidColor: TBGRAPixel;
+    function GetTexOpacity: byte;
+    function GetTexRepetition: TTextureRepetition;
+    function GetTexture: TBGRABitmap;
+    function GetToolIconSize: integer;
+    procedure SetCanAdjustToShape(AValue: boolean);
+    procedure SetFillType(AValue: TVectorialFillType);
+    procedure SetGradEndColor(AValue: TBGRAPixel);
+    procedure SetGradientType(AValue: TGradientType);
+    procedure SetGradInterpolation(AValue: TBGRAColorInterpolation);
+    procedure SetGradRepetition(AValue: TBGRAGradientRepetition);
+    procedure SetGradStartColor(AValue: TBGRAPixel);
+    procedure SetSolidColor(AValue: TBGRAPixel);
+    procedure SetTexture(AValue: TBGRABitmap);
+    procedure SetTextureOpacity(AValue: byte);
+    procedure SetTextureRepetition(AValue: TTextureRepetition);
+    procedure SetToolIconSize(AValue: integer);
+  protected
+    FInterface: TVectorialFillInterface;
+    FOnAdjustToShape: TNotifyEvent;
+    FOnFillChange: TNotifyEvent;
+    FOnFillTypeChange: TNotifyEvent;
+    FOnTextureChange: TNotifyEvent;
+    procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
+      {%H-}WithThemeSpace: Boolean); override;
+    procedure DoOnAdjustToShape(Sender: TObject);
+    procedure DoOnFillChange(Sender: TObject);
+    procedure DoOnFillTypeChange(Sender: TObject);
+    procedure DoOnTextureChange(Sender: TObject);
+    procedure DoOnResize; override;
+  public
+    constructor Create(TheOwner: TComponent); override;
+    destructor Destroy; override;
+    property FillType: TVectorialFillType read GetFillType write SetFillType;
+    property SolidColor: TBGRAPixel read GetSolidColor write SetSolidColor;
+    property GradientType: TGradientType read GetGradType write SetGradientType;
+    property GradStartColor: TBGRAPixel read GetGradStartColor write SetGradStartColor;
+    property GradEndColor: TBGRAPixel read GetGradEndColor write SetGradEndColor;
+    property GradRepetition: TBGRAGradientRepetition read GetGradRepetition write SetGradRepetition;
+    property GradInterpolation: TBGRAColorInterpolation read GetGradInterp write SetGradInterpolation;
+    property Texture: TBGRABitmap read GetTexture write SetTexture;
+    property TextureRepetition: TTextureRepetition read GetTexRepetition write SetTextureRepetition;
+    property TextureOpacity: byte read GetTexOpacity write SetTextureOpacity;
+    property CanAdjustToShape: boolean read GetCanAdjustToShape write SetCanAdjustToShape;
+    property OnFillChange: TNotifyEvent read FOnFillChange write FOnFillChange;
+    property OnTextureChange: TNotifyEvent read FOnTextureChange write FOnTextureChange;
+    property OnAdjustToShape: TNotifyEvent read FOnAdjustToShape write FOnAdjustToShape;
+    property OnFillTypeChange: TNotifyEvent read FOnFillTypeChange write FOnFillTypeChange;
+  published
+    property AutoSize;
+    property Align;
+    property Enabled;
+    property Visible;
+    property ToolIconSize: integer read GetToolIconSize write SetToolIconSize;
+  end;
+
+procedure Register;
+
+implementation
+
+uses Types;
+
+procedure Register;
+begin
+  RegisterComponents('Lazpaint Controls', [TLCVectorialFillControl]);
+end;
+
+{ TLCVectorialFillControl }
+
+function TLCVectorialFillControl.GetCanAdjustToShape: boolean;
+begin
+  result := FInterface.CanAdjustToShape;
+end;
+
+function TLCVectorialFillControl.GetFillType: TVectorialFillType;
+begin
+  result := FInterface.FillType;
+end;
+
+function TLCVectorialFillControl.GetGradEndColor: TBGRAPixel;
+begin
+  result := FInterface.GradEndColor;
+end;
+
+function TLCVectorialFillControl.GetGradInterp: TBGRAColorInterpolation;
+begin
+  result := FInterface.GradInterpolation;
+end;
+
+function TLCVectorialFillControl.GetGradRepetition: TBGRAGradientRepetition;
+begin
+  result := FInterface.GradRepetition;
+end;
+
+function TLCVectorialFillControl.GetGradStartColor: TBGRAPixel;
+begin
+  result := FInterface.GradStartColor;
+end;
+
+function TLCVectorialFillControl.GetGradType: TGradientType;
+begin
+  result := FInterface.GradientType;
+end;
+
+function TLCVectorialFillControl.GetSolidColor: TBGRAPixel;
+begin
+  result := FInterface.SolidColor;
+end;
+
+function TLCVectorialFillControl.GetTexOpacity: byte;
+begin
+  result := FInterface.TextureOpacity;
+end;
+
+function TLCVectorialFillControl.GetTexRepetition: TTextureRepetition;
+begin
+  result := FInterface.TextureRepetition;
+end;
+
+function TLCVectorialFillControl.GetTexture: TBGRABitmap;
+begin
+  result := FInterface.Texture;
+end;
+
+function TLCVectorialFillControl.GetToolIconSize: integer;
+begin
+  result := FInterface.ImageListSize.cy;
+end;
+
+procedure TLCVectorialFillControl.SetCanAdjustToShape(AValue: boolean);
+begin
+  FInterface.CanAdjustToShape := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetFillType(AValue: TVectorialFillType);
+begin
+  FInterface.FillType := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetGradEndColor(AValue: TBGRAPixel);
+begin
+  FInterface.GradEndColor := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetGradientType(AValue: TGradientType);
+begin
+  FInterface.GradientType := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetGradInterpolation(
+  AValue: TBGRAColorInterpolation);
+begin
+  FInterface.GradInterpolation := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetGradRepetition(
+  AValue: TBGRAGradientRepetition);
+begin
+  FInterface.GradRepetition := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetGradStartColor(AValue: TBGRAPixel);
+begin
+  FInterface.GradStartColor := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetSolidColor(AValue: TBGRAPixel);
+begin
+  FInterface.SolidColor := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetTexture(AValue: TBGRABitmap);
+begin
+  FInterface.Texture := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetTextureOpacity(AValue: byte);
+begin
+  FInterface.TextureOpacity := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetTextureRepetition(
+  AValue: TTextureRepetition);
+begin
+  FInterface.TextureRepetition := AValue;
+end;
+
+procedure TLCVectorialFillControl.SetToolIconSize(AValue: integer);
+begin
+  FInterface.ImageListSize := Size(AValue,AValue);
+end;
+
+procedure TLCVectorialFillControl.CalculatePreferredSize(var PreferredWidth,
+  PreferredHeight: integer; WithThemeSpace: Boolean);
+begin
+  with FInterface.PreferredSize do
+  begin
+    PreferredWidth := cx;
+    PreferredHeight := cy;
+  end;
+end;
+
+procedure TLCVectorialFillControl.DoOnAdjustToShape(Sender: TObject);
+begin
+  if Assigned(FOnAdjustToShape) then FOnAdjustToShape(self);
+end;
+
+procedure TLCVectorialFillControl.DoOnFillChange(Sender: TObject);
+begin
+  if Assigned(FOnFillChange) then FOnFillChange(self);
+end;
+
+procedure TLCVectorialFillControl.DoOnFillTypeChange(Sender: TObject);
+begin
+  InvalidatePreferredSize;
+  AdjustSize;
+  if Assigned(FOnFillTypeChange) then FOnFillTypeChange(self);
+end;
+
+procedure TLCVectorialFillControl.DoOnTextureChange(Sender: TObject);
+begin
+  if Assigned(FOnTextureChange) then FOnTextureChange(self);
+end;
+
+procedure TLCVectorialFillControl.DoOnResize;
+begin
+  inherited DoOnResize;
+  FInterface.LoadImageList;
+  FInterface.ContainerSizeChanged;
+end;
+
+constructor TLCVectorialFillControl.Create(TheOwner: TComponent);
+begin
+  inherited Create(TheOwner);
+  FInterface := TVectorialFillInterface.Create(nil, 16,16);
+  FInterface.OnFillChange:=@DoOnFillChange;
+  FInterface.OnTextureChange:=@DoOnTextureChange;
+  FInterface.OnAdjustToShape:=@DoOnAdjustToShape;
+  FInterface.OnFillTypeChange:=@DoOnFillTypeChange;
+  FInterface.Container := self;
+end;
+
+destructor TLCVectorialFillControl.Destroy;
+begin
+  FreeAndNil(FInterface);
+  inherited Destroy;
+end;
+
+end.
+

+ 39 - 25
vectoredit/lcvectorialfillinterface.pas → lazpaintcontrols/lcvectorialfillinterface.pas

@@ -6,7 +6,7 @@ interface
 
 uses
   Classes, SysUtils, Types,
-  Controls, StdCtrls, ComCtrls, Menus, Dialogs, ExtDlgs, ExtCtrls,
+  Controls, ComCtrls, Menus, Dialogs, ExtDlgs, ExtCtrls,
   BGRAImageList, BCTrackbarUpdown,
   BGRABitmap, BGRABitmapTypes, LCVectorialFill,
   BGRAGradientScanner, Graphics, BGRAGraphics;
@@ -65,6 +65,8 @@ type
 
     FToolbar: TToolBar;
     FImageList: TBGRAImageList;
+    FImageListLoaded: boolean;
+    FImageListSize: TSize;
 
     procedure AdjustToShapeClick(Sender: TObject);
     procedure ButtonFillChange(Sender: TObject);
@@ -75,7 +77,6 @@ type
     procedure ButtonLoadTextureClick(Sender: TObject);
     procedure ButtonSwapColorClick(Sender: TObject);
     procedure ButtonTexRepeatClick(Sender: TObject);
-    procedure LoadImageList(AImageListWidth,AImageListHeight: integer);
     procedure Changed;
     procedure OnClickBackGradType(ASender: TObject);
     procedure OnClickBackTexRepeat(ASender: TObject);
@@ -91,6 +92,7 @@ type
     procedure SetGradStartColor(AValue: TBGRAPixel);
     procedure SetGradRepetition(AValue: TBGRAGradientRepetition);
     procedure SetGradInterpolation(AValue: TBGRAColorInterpolation);
+    procedure SetImageListSize(AValue: TSize);
     procedure SetTexture(AValue: TBGRABitmap);
     procedure SetTextureRepetition(AValue: TTextureRepetition);
     procedure SetTextureOpacity(AValue: byte);
@@ -122,7 +124,8 @@ type
     constructor Create(AOwner: TComponent; AImageListWidth,AImageListHeight: Integer);
     destructor Destroy; override;
     procedure LoadTexture;
-    procedure AdjustControlSize;
+    procedure LoadImageList;
+    procedure ContainerSizeChanged;
     function GetTextureThumbnail(AWidth, AHeight: integer; ABackColor: TColor): TBitmap;
     property FillType: TVectorialFillType read FFillType write SetFillType;
     property SolidColor: TBGRAPixel read FSolidColor write SetSolidColor;
@@ -134,37 +137,50 @@ type
     property Texture: TBGRABitmap read FTexture write SetTexture;
     property TextureRepetition: TTextureRepetition read FTexRepetition write SetTextureRepetition;
     property TextureOpacity: byte read FTexOpacity write SetTextureOpacity;
+    property CanAdjustToShape: boolean read FCanAdjustToShape write SetCanAdjustToShape;
     property OnFillChange: TNotifyEvent read FOnFillChange write FOnFillChange;
     property OnTextureChange: TNotifyEvent read FOnTextureChange write FOnTextureChange;
     property OnAdjustToShape: TNotifyEvent read FOnAdjustToShape write FOnAdjustToShape;
-    property CanAdjustToShape: boolean read FCanAdjustToShape write SetCanAdjustToShape;
     property OnFillTypeChange: TNotifyEvent read FOnFillTypeChange write FOnFillTypeChange;
     property Container: TWinControl read FContainer write SetContainer;
+    property ImageListSize: TSize read FImageListSize write SetImageListSize;
     property PreferredSize: TSize read GetPreferredSize;
   end;
 
 implementation
 
-uses LCToolbars, Toolwin, BGRAThumbnail, LResources;
+uses LCToolbars, Toolwin, BGRAThumbnail, LResources,
+  LCVectorOriginal, LCVectorShapes, LCVectorPolyShapes;
 
 { TVectorialFillInterface }
 
-procedure TVectorialFillInterface.LoadImageList(AImageListWidth,
-  AImageListHeight: integer);
+procedure TVectorialFillInterface.LoadImageList;
 var
   i: Integer;
   lst: TStringList;
 begin
   if FImageList = nil then FImageList := TBGRAImageList.Create(self);
+  if FImageListLoaded and (FImageList.Width=FImageListSize.cx) and (FImageList.Height=FImageListSize.cy) then exit;
   FImageList.Clear;
-  FImageList.Width := AImageListWidth;
-  FImageList.Height := AImageListHeight;
+  FImageList.Width := FImageListSize.cx;
+  FImageList.Height := FImageListSize.cy;
 
   lst := TStringList.Create;
   lst.CommaText := GetResourceString('fillimages.lst');
   for i := 0 to lst.Count-1 do
     LoadToolbarImage(FImageList, i, lst[i]);
   lst.Free;
+
+  FImageListLoaded := true;
+  if Assigned(FToolbar) then
+  begin
+    SetToolbarImages(FToolbar, FImageList);
+    for i := 0 to FToolbar.ControlCount-1 do
+      if FToolbar.Controls[i] is TBCTrackbarUpdown then
+        FToolbar.Controls[i].Width := FToolbar.ButtonWidth*2
+      else if FToolbar.Controls[i] is TShape then
+        FToolbar.Controls[i].Width := FToolbar.ButtonWidth;
+  end;
 end;
 
 procedure TVectorialFillInterface.Changed;
@@ -229,17 +245,10 @@ begin
   end;
 end;
 
-procedure TVectorialFillInterface.AdjustControlSize;
+procedure TVectorialFillInterface.ContainerSizeChanged;
 begin
-  with PreferredSize do
-  begin
-    if Assigned(Container) then
-    begin
-      Container.Width := cx;
-      Container.Height := cy;
-    end;
-    FToolbar.Height := cy;
-  end;
+  FToolbar.Align:= alTop;
+  FToolbar.Height := FContainer.Height;
 end;
 
 procedure TVectorialFillInterface.SetFillType(AValue: TVectorialFillType);
@@ -311,8 +320,6 @@ begin
                            FButtonLoadTexture,FTexturePreview]);
     end;
   end;
-
-  AdjustControlSize;
 end;
 
 procedure TVectorialFillInterface.UpdateShapeSolidColor;
@@ -567,8 +574,9 @@ begin
   FTexOpacity:= 255;
   FCanAdjustToShape:= true;
 
-  FImageList := nil;
-  LoadImageList(AImageListWidth,AImageListHeight);
+  FImageList := TBGRAImageList.Create(self);
+  FImageListLoaded:= false;
+  FImageListSize := Size(AImageListWidth,AImageListHeight);
 
   FOpenPictureDlg := TOpenPictureDialog.Create(self);
   FColorDlg:= TColorDialog.Create(self);
@@ -700,8 +708,7 @@ begin
   if Assigned(FContainer) then
   begin
     FContainer.InsertControl(FToolBar);
-    FToolbar.Align:= alTop;
-    FToolbar.Height := FContainer.Height;
+    ContainerSizeChanged;
   end;
 end;
 
@@ -718,6 +725,13 @@ begin
     FButtonAdjustToTexture.Enabled := AValue;
 end;
 
+procedure TVectorialFillInterface.SetImageListSize(AValue: TSize);
+begin
+  if (FImageListSize.cx=AValue.cx) and (FImageListSize.cy=AValue.cy) then Exit;
+  FImageListSize:=AValue;
+  if FImageListLoaded then LoadImageList;
+end;
+
 procedure TVectorialFillInterface.AdjustToShapeClick(Sender: TObject);
 begin
   if Assigned(FOnAdjustToShape) then FOnAdjustToShape(self);

+ 0 - 0
vectoredit/lcvectororiginal.pas → lazpaintcontrols/lcvectororiginal.pas


+ 0 - 0
vectoredit/lcvectorpolyshapes.pas → lazpaintcontrols/lcvectorpolyshapes.pas


+ 1 - 0
vectoredit/lcvectorshapes.pas → lazpaintcontrols/lcvectorshapes.pas

@@ -98,6 +98,7 @@ type
     procedure SetShapeAltitudePercent(AValue: single);
     procedure SetShapeKind(AValue: TPhongShapeKind);
     function BackVisible: boolean;
+  protected
     function AllowShearTransform: boolean; override;
   public
     constructor Create(AContainer: TVectorOriginal); override;

+ 7 - 22
vectoredit/createresource.lpi

@@ -27,37 +27,22 @@
         <FormatVersion Value="1"/>
       </local>
     </RunParams>
-    <RequiredPackages Count="2">
+    <RequiredPackages Count="3">
       <Item1>
-        <PackageName Value="BGRABitmapPack"/>
+        <PackageName Value="lazpaintcontrols"/>
       </Item1>
       <Item2>
-        <PackageName Value="LCL"/>
+        <PackageName Value="BGRABitmapPack"/>
       </Item2>
+      <Item3>
+        <PackageName Value="LCL"/>
+      </Item3>
     </RequiredPackages>
-    <Units Count="5">
+    <Units Count="1">
       <Unit0>
         <Filename Value="createresource.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit0>
-      <Unit1>
-        <Filename Value="lcvectorialfill.pas"/>
-        <IsPartOfProject Value="True"/>
-      </Unit1>
-      <Unit2>
-        <Filename Value="lcvectororiginal.pas"/>
-        <IsPartOfProject Value="True"/>
-        <UnitName Value="LCVectorOriginal"/>
-      </Unit2>
-      <Unit3>
-        <Filename Value="lcvectorpolyshapes.pas"/>
-        <IsPartOfProject Value="True"/>
-      </Unit3>
-      <Unit4>
-        <Filename Value="lcvectorshapes.pas"/>
-        <IsPartOfProject Value="True"/>
-        <UnitName Value="LCVectorShapes"/>
-      </Unit4>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 8 - 6
vectoredit/createresource.pas

@@ -20,7 +20,6 @@ const
 
 procedure MakeResource(AVectorImagesPath: string; AListFile: string; AResourceFile: string; ACombinedImage: string);
 var
-  path: String;
   search: TSearchRec;
   res: TMultiFileContainer;
   fs: TFileStreamUTF8;
@@ -30,13 +29,16 @@ var
   mem: TMemoryStreamUTF8;
   combineList: TStringListUTF8;
 begin
-  path := StringReplace(AVectorImagesPath,'/',PathDelim,[rfReplaceAll]);
-  if FindFirstUTF8(path+'*.lzp', faAnyFile, search)=0 then
+  AVectorImagesPath := StringReplace(AVectorImagesPath,'/',PathDelim,[rfReplaceAll]);
+  AListFile := StringReplace(AListFile,'/',PathDelim,[rfReplaceAll]);
+  AResourceFile := StringReplace(AResourceFile,'/',PathDelim,[rfReplaceAll]);
+  ACombinedImage := StringReplace(ACombinedImage,'/',PathDelim,[rfReplaceAll]);
+  if FindFirstUTF8(AVectorImagesPath+'*.lzp', faAnyFile, search)=0 then
   begin
     res := TLazResourceContainer.Create;
     writeln('Adding files to resource...');
     repeat
-      fs := TFileStreamUTF8.Create(path+search.name, fmOpenRead);
+      fs := TFileStreamUTF8.Create(AVectorImagesPath+search.name, fmOpenRead);
       res.Add(EntryFilename(search.name), fs, false, false);
       fs.Free;
       writeln(search.Name);
@@ -54,7 +56,7 @@ begin
     end;
     for i := combineList.Count-1 downto 0 do
       if combineList[i]='' then combineList.Delete(i);
-    res.RawStringByFilename[AListFile] := combineList.CommaText;
+    res.RawStringByFilename[ExtractFilename(AListFile)] := combineList.CommaText;
 
     res.SaveToFile(AResourceFile);
     writeln('Done Resource');
@@ -89,6 +91,6 @@ end;
 
 begin
   MakeResource('../lazpaint/buttons/vector/', 'vectorimages.lst', 'vectorimages.lrs', 'vectorimages'+inttostr(imgHeight)+'.png');
-  MakeResource('../lazpaint/buttons/vector/fill/', 'fillimages.lst', 'fillimages.lrs', 'fillimages'+inttostr(imgHeight)+'.png');
+  MakeResource('../lazpaint/buttons/vector/fill/', '../lazpaintcontrols/fillimages.lst', '../lazpaintcontrols/fillimages.lrs', '../lazpaintcontrols/fillimages'+inttostr(imgHeight)+'.png');
 end.
 

+ 15 - 17
vectoredit/umain.lfm

@@ -1,7 +1,7 @@
 object Form1: TForm1
-  Left = 616
+  Left = 608
   Height = 622
-  Top = 92
+  Top = 0
   Width = 981
   Caption = 'Vector Edit'
   ClientHeight = 622
@@ -895,7 +895,7 @@ object Form1: TForm1
         Left = 285
         Height = 60
         Top = 0
-        Width = 70
+        Width = 151
         Background.Color = clBtnFace
         Background.ColorOpacity = 255
         Background.Gradient1.StartColor = clWhite
@@ -952,16 +952,6 @@ object Form1: TForm1
         Rounding.RoundY = 1
         Rounding.RoundOptions = []
         TabOrder = 2
-        object PanelBackFillIntf: TPanel
-          Left = 32
-          Height = 58
-          Top = 1
-          Width = 22
-          Align = alLeft
-          BevelOuter = bvNone
-          TabOrder = 0
-          OnResize = PanelBackFillIntfResize
-        end
         object PanelBackFillHead: TPanel
           Left = 1
           Height = 58
@@ -971,8 +961,7 @@ object Form1: TForm1
           BevelOuter = bvNone
           ClientHeight = 58
           ClientWidth = 31
-          TabOrder = 1
-          OnResize = PanelBackFillIntfResize
+          TabOrder = 0
           object LBack: TLabel
             Left = 0
             Height = 28
@@ -1014,9 +1003,18 @@ object Form1: TForm1
             end
           end
         end
+        object BackFillControl: TLCVectorialFillControl
+          Left = 32
+          Height = 58
+          Top = 1
+          Width = 117
+          AutoSize = True
+          Align = alLeft
+          ToolIconSize = 24
+        end
       end
       object PanelShape: TBCPanel
-        Left = 355
+        Left = 436
         Height = 60
         Top = 0
         Width = 122
@@ -1136,7 +1134,7 @@ object Form1: TForm1
         end
       end
       object PanelExtendedStyle: TBCPanel
-        Left = 477
+        Left = 558
         Height = 60
         Top = 0
         Width = 162

+ 51 - 58
vectoredit/umain.pas

@@ -11,7 +11,7 @@ uses
   BCTrackbarUpdown, BCPanel, BCButton, BGRAVirtualScreen, BGRAImageList,
   BGRABitmap, BGRABitmapTypes, BGRAGraphics, BGRALazPaint, BGRALayerOriginal,
   BGRATransform, BGRAGradientScanner, LCVectorOriginal, LCVectorialFill,
-  LCVectorShapes, LCVectorPolyShapes, LCVectorialFillInterface;
+  LCVectorShapes, LCVectorPolyShapes, LCVectorialFillControl;
 
 const
   ToolIconSize = 36;
@@ -42,8 +42,8 @@ type
   TForm1 = class(TForm)
     ButtonMoveBackFillPoints: TToolButton;
     LBack: TLabel;
+    BackFillControl: TLCVectorialFillControl;
     PanelBackFillHead: TPanel;
-    PanelBackFillIntf: TPanel;
     ShapeSendToBack: TAction;
     ShapeBringToFront: TAction;
     ShapeMoveDown: TAction;
@@ -121,7 +121,7 @@ type
     procedure FileOpenExecute(Sender: TObject);
     procedure FileSaveAsExecute(Sender: TObject);
     procedure FileSaveExecute(Sender: TObject);
-    procedure PanelBackFillIntfResize(Sender: TObject);
+    procedure BackFillControlResize(Sender: TObject);
     procedure PanelFileResize(Sender: TObject);
     procedure PanelShapeResize(Sender: TObject);
    procedure ShapeBringToFrontExecute(Sender: TObject);
@@ -151,7 +151,6 @@ type
     FPenWidth: single;
     FPenStyle: TBGRAPenStyle;
     FPenJoinStyle: TPenJoinStyle;
-    FBackFillIntf: TVectorialFillInterface;
     FFlattened: TBGRABitmap;
     FLastEditorBounds: TRect;
     FUpdatingFromShape: boolean;
@@ -322,7 +321,7 @@ begin
   img.OnOriginalEditingChange:= @OnEditingChange;
   img.OnOriginalChange:= @OnOriginalChange;
 
-  zoom := AffineMatrixScale(20,20);
+  zoom := AffineMatrixScale(1,1);
   FPenStyleMenu := TPopupMenu.Create(nil);
   item:= TMenuItem.Create(FPenStyleMenu); item.Caption := PenStyleToStr[psClear];
   item.OnClick := @OnClickPenStyle;       item.Tag := ord(psClear);
@@ -334,11 +333,11 @@ begin
     FPenStyleMenu.Items.Add(item);
   end;
 
-  FBackFillIntf := TVectorialFillInterface.Create(nil, ActionIconSize,ActionIconSize);
-  FBackFillIntf.SolidColor := CSSDodgerBlue;
-  FBackFillIntf.OnFillChange:=@RequestBackFillUpdate;
-  FBackFillIntf.OnAdjustToShape:=@RequestBackFillAdjustToShape;
-  FBackFillIntf.Container := PanelBackFillIntf;
+  BackFillControl.ToolIconSize:= ActionIconSize;
+  BackFillControl.SolidColor := CSSDodgerBlue;
+  BackFillControl.OnFillChange:= @RequestBackFillUpdate;
+  BackFillControl.OnAdjustToShape:= @RequestBackFillAdjustToShape;
+  BackFillControl.OnResize:= @BackFillControlResize;
 
   FSplineStyleMenu := TPopupMenu.Create(nil);
   for ss := low(TSplineStyle) to high(TSplineStyle) do
@@ -560,14 +559,9 @@ begin
   end;
 end;
 
-procedure TForm1.PanelBackFillIntfResize(Sender: TObject);
+procedure TForm1.BackFillControlResize(Sender: TObject);
 begin
-  with FBackFillIntf.PreferredSize do
-  begin
-    PanelBackFillIntf.Width := cx;
-    PanelBackFillIntf.Height := cy;
-  end;
-  PanelBackFill.Width := PanelBackFillIntf.Left+PanelBackFillIntf.Width+1;
+  PanelBackFill.ClientWidth := PanelBackFillHead.Width+BackFillControl.Width+2;
 end;
 
 procedure TForm1.PanelFileResize(Sender: TObject);
@@ -686,7 +680,6 @@ end;
 procedure TForm1.FormDestroy(Sender: TObject);
 begin
   RemoveExtendedStyleControls;
-  FBackFillIntf.Free;
   img.Free;
   FFlattened.Free;
   FPenStyleMenu.Free;
@@ -783,7 +776,7 @@ begin
     else UpdateToolbarFromShape(nil);
 
     if currentTool in [ptPolyline, ptCurve] then
-      FBackFillIntf.FillType := vftNone;
+      BackFillControl.FillType := vftNone;
   end;
 
   UpdateShapeUserMode;
@@ -1185,23 +1178,23 @@ begin
 
     if vsfBackFill in f then
     begin
-      FBackFillIntf.FillType := AShape.BackFill.FillType;
-      case FBackFillIntf.FillType of
+      BackFillControl.FillType := AShape.BackFill.FillType;
+      case BackFillControl.FillType of
         vftTexture:
           begin
             texSource := AShape.BackFill.Texture;
-            if Assigned(texSource) then FBackFillIntf.Texture := texSource;
-            FBackFillIntf.TextureOpacity:= AShape.BackFill.TextureOpacity;
-            FBackFillIntf.TextureRepetition:= AShape.BackFill.TextureRepetition;
+            if Assigned(texSource) then BackFillControl.Texture := texSource;
+            BackFillControl.TextureOpacity:= AShape.BackFill.TextureOpacity;
+            BackFillControl.TextureRepetition:= AShape.BackFill.TextureRepetition;
           end;
-        vftSolid: FBackFillIntf.SolidColor := AShape.BackFill.SolidColor;
+        vftSolid: BackFillControl.SolidColor := AShape.BackFill.SolidColor;
         vftGradient:
           begin
-            FBackFillIntf.GradStartColor := AShape.BackFill.Gradient.StartColor;
-            FBackFillIntf.GradEndColor := AShape.BackFill.Gradient.EndColor;
-            FBackFillIntf.GradientType:= AShape.BackFill.Gradient.GradientType;
-            FBackFillIntf.GradRepetition:= AShape.BackFill.Gradient.Repetition;
-            FBackFillIntf.GradInterpolation := AShape.BackFill.Gradient.ColorInterpolation;
+            BackFillControl.GradStartColor := AShape.BackFill.Gradient.StartColor;
+            BackFillControl.GradEndColor := AShape.BackFill.Gradient.EndColor;
+            BackFillControl.GradientType:= AShape.BackFill.Gradient.GradientType;
+            BackFillControl.GradRepetition:= AShape.BackFill.Gradient.Repetition;
+            BackFillControl.GradInterpolation := AShape.BackFill.Gradient.ColorInterpolation;
           end;
       end;
     end;
@@ -1341,7 +1334,7 @@ begin
   if not IsCreateShapeTool(currentTool) then
     raise exception.Create('No shape type selected');
   result := PaintToolClass[currentTool].Create(vectorOriginal);
-  if (result is TCustomPolypointShape) and (FBackFillIntf.FillType = vftGradient) then FBackFillIntf.FillType := vftSolid;
+  if (result is TCustomPolypointShape) and (BackFillControl.FillType = vftGradient) then BackFillControl.FillType := vftSolid;
   result.PenColor := penColor;
   result.PenWidth := penWidth;
   result.PenStyle := penStyle;
@@ -1373,26 +1366,26 @@ var
   rF: TRectF;
   sx,sy: single;
 begin
-  if FBackFillIntf.FillType = vftSolid then
-    result := TVectorialFill.CreateAsSolid(FBackFillIntf.SolidColor)
-  else if (FBackFillIntf.FillType = vftTexture) and Assigned(FBackFillIntf.Texture) then
+  if BackFillControl.FillType = vftSolid then
+    result := TVectorialFill.CreateAsSolid(BackFillControl.SolidColor)
+  else if (BackFillControl.FillType = vftTexture) and Assigned(BackFillControl.Texture) then
   begin
     rF := AShape.GetRenderBounds(InfiniteRect,AffineMatrixIdentity,[rboAssumeBackFill]);
-    if not (FBackFillIntf.TextureRepetition in [trRepeatX,trRepeatBoth]) and (rF.Width <> 0) and (FBackFillIntf.Texture.Width > 0) then
-      sx:= rF.Width/FBackFillIntf.Texture.Width else sx:= 1;
-    if not (FBackFillIntf.TextureRepetition in [trRepeatY,trRepeatBoth]) and (rF.Height <> 0) and (FBackFillIntf.Texture.Height > 0) then
-      sy:= rF.Height/FBackFillIntf.Texture.Height else sy:= 1;
+    if not (BackFillControl.TextureRepetition in [trRepeatX,trRepeatBoth]) and (rF.Width <> 0) and (BackFillControl.Texture.Width > 0) then
+      sx:= rF.Width/BackFillControl.Texture.Width else sx:= 1;
+    if not (BackFillControl.TextureRepetition in [trRepeatY,trRepeatBoth]) and (rF.Height <> 0) and (BackFillControl.Texture.Height > 0) then
+      sy:= rF.Height/BackFillControl.Texture.Height else sy:= 1;
 
-    result := TVectorialFill.CreateAsTexture(FBackFillIntf.Texture,
+    result := TVectorialFill.CreateAsTexture(BackFillControl.Texture,
                  AffineMatrixTranslation(rF.TopLeft.x,rF.TopLeft.y)*
                  AffineMatrixScale(sx,sy),
-                 FBackFillIntf.TextureOpacity, FBackFillIntf.TextureRepetition);
+                 BackFillControl.TextureOpacity, BackFillControl.TextureRepetition);
   end
-  else if FBackFillIntf.FillType = vftGradient then
+  else if BackFillControl.FillType = vftGradient then
   begin
     grad := TBGRALayerGradientOriginal.Create;
-    grad.StartColor := FBackFillIntf.GradStartColor;
-    grad.EndColor := FBackFillIntf.GradEndColor;
+    grad.StartColor := BackFillControl.GradStartColor;
+    grad.EndColor := BackFillControl.GradEndColor;
     if Assigned(AShape) then
     begin
       rF := AShape.GetRenderBounds(rect(0,0,img.Width,img.Height),vectorTransform,[rboAssumeBackFill]);
@@ -1400,9 +1393,9 @@ begin
     end
     else
       rF := rectF(0,0,img.Width,img.Height);
-    grad.GradientType:= FBackFillIntf.GradientType;
-    grad.Repetition := FBackFillIntf.GradRepetition;
-    grad.ColorInterpolation:= FBackFillIntf.GradInterpolation;
+    grad.GradientType:= BackFillControl.GradientType;
+    grad.Repetition := BackFillControl.GradRepetition;
+    grad.ColorInterpolation:= BackFillControl.GradInterpolation;
     if grad.GradientType = gtLinear then
     begin
       grad.Origin := rF.TopLeft;
@@ -1456,7 +1449,7 @@ procedure TForm1.UpdateBackToolFillPoints;
 var
   canEdit: Boolean;
 begin
-  canEdit := (FBackFillIntf.FillType in[vftGradient,vftTexture]) and
+  canEdit := (BackFillControl.FillType in[vftGradient,vftTexture]) and
     Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape);
   ButtonMoveBackFillPoints.Enabled := canEdit;
   if (currentTool = ptMoveBackFillPoint) and not canEdit then currentTool:= ptHand;
@@ -1469,21 +1462,21 @@ begin
   if Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape) and
     (vsfBackFill in vectorOriginal.SelectedShape.Fields) then
   begin
-    if (FBackFillIntf.FillType = vftTexture) and (FBackFillIntf.TextureOpacity = 0) then
+    if (BackFillControl.FillType = vftTexture) and (BackFillControl.TextureOpacity = 0) then
       vectorFill := nil else
-    if (FBackFillIntf.FillType = vftTexture) and (vectorOriginal.SelectedShape.BackFill.FillType = vftTexture) then
+    if (BackFillControl.FillType = vftTexture) and (vectorOriginal.SelectedShape.BackFill.FillType = vftTexture) then
     begin
-      vectorFill := TVectorialFill.CreateAsTexture(FBackFillIntf.Texture, vectorOriginal.SelectedShape.BackFill.TextureMatrix,
-                                                   FBackFillIntf.TextureOpacity, FBackFillIntf.TextureRepetition);
+      vectorFill := TVectorialFill.CreateAsTexture(BackFillControl.Texture, vectorOriginal.SelectedShape.BackFill.TextureMatrix,
+                                                   BackFillControl.TextureOpacity, BackFillControl.TextureRepetition);
     end
-    else if (FBackFillIntf.FillType = vftGradient) and (vectorOriginal.SelectedShape.BackFill.FillType = vftGradient) then
+    else if (BackFillControl.FillType = vftGradient) and (vectorOriginal.SelectedShape.BackFill.FillType = vftGradient) then
     begin
       vectorFill := vectorOriginal.SelectedShape.BackFill.Duplicate;
-      vectorFill.Gradient.StartColor := FBackFillIntf.GradStartColor;
-      vectorFill.Gradient.EndColor := FBackFillIntf.GradEndColor;
-      vectorFill.Gradient.GradientType := FBackFillIntf.GradientType;
-      vectorFill.Gradient.Repetition := FBackFillIntf.GradRepetition;
-      vectorFill.Gradient.ColorInterpolation:= FBackFillIntf.GradInterpolation;
+      vectorFill.Gradient.StartColor := BackFillControl.GradStartColor;
+      vectorFill.Gradient.EndColor := BackFillControl.GradEndColor;
+      vectorFill.Gradient.GradientType := BackFillControl.GradientType;
+      vectorFill.Gradient.Repetition := BackFillControl.GradRepetition;
+      vectorFill.Gradient.ColorInterpolation:= BackFillControl.GradInterpolation;
     end else
       vectorFill := CreateBackFill(vectorOriginal.SelectedShape);
 
@@ -1519,7 +1512,7 @@ begin
   EditCopy.Enabled := AShape <> nil;
   EditCut.Enabled := AShape <> nil;
   EditDelete.Enabled := AShape <> nil;
-  FBackFillIntf.CanAdjustToShape := AShape <> nil;
+  BackFillControl.CanAdjustToShape := AShape <> nil;
 end;
 
 procedure TForm1.RemoveShapeIfEmpty(AShape: TVectorShape);

+ 10 - 32
vectoredit/vectoredit.lpi

@@ -27,18 +27,21 @@
         <FormatVersion Value="1"/>
       </local>
     </RunParams>
-    <RequiredPackages Count="3">
+    <RequiredPackages Count="4">
       <Item1>
-        <PackageName Value="BGRABitmapPack"/>
+        <PackageName Value="lazpaintcontrols"/>
       </Item1>
       <Item2>
-        <PackageName Value="bgracontrols"/>
+        <PackageName Value="BGRABitmapPack"/>
       </Item2>
       <Item3>
-        <PackageName Value="LCL"/>
+        <PackageName Value="bgracontrols"/>
       </Item3>
+      <Item4>
+        <PackageName Value="LCL"/>
+      </Item4>
     </RequiredPackages>
-    <Units Count="9">
+    <Units Count="4">
       <Unit0>
         <Filename Value="vectoredit.lpr"/>
         <IsPartOfProject Value="True"/>
@@ -51,39 +54,14 @@
         <ResourceBaseClass Value="Form"/>
       </Unit1>
       <Unit2>
-        <Filename Value="lcvectororiginal.pas"/>
+        <Filename Value="uvectorclipboard.pas"/>
         <IsPartOfProject Value="True"/>
-        <UnitName Value="LCVectorOriginal"/>
       </Unit2>
       <Unit3>
-        <Filename Value="lcvectorialfill.pas"/>
-        <IsPartOfProject Value="True"/>
-        <UnitName Value="LCVectorialFill"/>
-      </Unit3>
-      <Unit4>
-        <Filename Value="lcvectorshapes.pas"/>
-        <IsPartOfProject Value="True"/>
-        <UnitName Value="LCVectorShapes"/>
-      </Unit4>
-      <Unit5>
-        <Filename Value="uvectorclipboard.pas"/>
-        <IsPartOfProject Value="True"/>
-      </Unit5>
-      <Unit6>
         <Filename Value="../lazpaint/uscaledpi.pas"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="UScaleDPI"/>
-      </Unit6>
-      <Unit7>
-        <Filename Value="lcvectorpolyshapes.pas"/>
-        <IsPartOfProject Value="True"/>
-        <UnitName Value="LCVectorPolyShapes"/>
-      </Unit7>
-      <Unit8>
-        <Filename Value="lctoolbars.pas"/>
-        <IsPartOfProject Value="True"/>
-        <UnitName Value="LCToolbars"/>
-      </Unit8>
+      </Unit3>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 1 - 3
vectoredit/vectoredit.lpr

@@ -8,10 +8,8 @@ uses
   {$ENDIF}{$ENDIF}
   Interfaces, // this includes the LCL widgetset
   Forms, umain, 
-  LCVectororiginal, LCVectorialFill, LCVectorshapes, LCVectorPolyShapes,
   uvectorclipboard,
-  LResources, LCToolbars
-  { you can add units after this };
+  LResources;
 
 {$R *.res}
 

二進制
vectoredit/vectorimages24.png