Browse Source

vector fill type, drop down for gradient type

Unknown 6 years ago
parent
commit
33a5e18929
5 changed files with 216 additions and 425 deletions
  1. 13 258
      vectoredit/umain.lfm
  2. 126 96
      vectoredit/umain.pas
  3. 54 46
      vectoredit/uvectorialfill.pas
  4. 13 11
      vectoredit/uvectororiginal.pas
  5. 10 14
      vectoredit/uvectorshapes.pas

+ 13 - 258
vectoredit/umain.lfm

@@ -1,5 +1,5 @@
 object Form1: TForm1
-  Left = 464
+  Left = 463
   Height = 622
   Top = 0
   Width = 981
@@ -1973,7 +1973,6 @@ object Form1: TForm1
             Hint = 'No fill'
             Top = 0
             Caption = 'ToolButtonBackFillNone'
-            Grouped = True
             ImageIndex = 0
             OnClick = ToolButtonBackFillChange
             Style = tbsCheck
@@ -1984,60 +1983,17 @@ object Form1: TForm1
             Top = 0
             Caption = 'ToolButtonBackFillSolid'
             Down = True
-            Grouped = True
             ImageIndex = 1
             OnClick = ToolButtonBackFillChange
             Style = tbsCheck
           end
-          object ToolButtonBackFillLinear: TToolButton
-            Left = 80
-            Hint = 'Linear gradient'
-            Top = 0
-            Caption = 'ToolButtonBackFillLinear'
-            Grouped = True
-            ImageIndex = 2
-            OnClick = ToolButtonBackFillChange
-            Style = tbsCheck
-          end
-          object ToolButtonBackFillReflected: TToolButton
-            Left = 103
-            Hint = 'Reflected gradient'
-            Top = 0
-            Caption = 'ToolButtonBackFillReflected'
-            Grouped = True
-            ImageIndex = 3
-            OnClick = ToolButtonBackFillChange
-            Style = tbsCheck
-          end
-          object ToolButtonBackFillDiamond: TToolButton
-            Left = 126
-            Hint = 'Diamond gradient'
-            Top = 0
-            Caption = 'ToolButtonBackFillDiamond'
-            Grouped = True
-            ImageIndex = 4
-            OnClick = ToolButtonBackFillChange
-            Style = tbsCheck
-          end
-          object ToolButtonBackFillRadial: TToolButton
-            Left = 149
-            Hint = 'Radial gradient'
-            Top = 0
-            Caption = 'ToolButtonBackFillRadial'
-            Grouped = True
-            ImageIndex = 5
-            OnClick = ToolButtonBackFillChange
-            Style = tbsCheck
-          end
           object ToolButtonBackFillTexture: TToolButton
-            Left = 172
+            Left = 103
             Hint = 'Texture fill'
             Top = 0
             Caption = 'ToolButtonBackFillTexture'
-            Grouped = True
             ImageIndex = 6
             OnClick = ToolButtonBackFillChange
-            Style = tbsCheck
           end
           object ButtonMoveBackFillPoints: TToolButton
             Left = 3
@@ -2057,234 +2013,34 @@ object Form1: TForm1
             Caption = 'ToolButton2'
             Style = tbsSeparator
           end
+          object ToolButtonBackFillGrad: TToolButton
+            Left = 80
+            Top = 0
+            Caption = 'ToolButtonBackFillGrad'
+            ImageIndex = 2
+            OnClick = ToolButtonBackFillGradClick
+          end
         end
         object PanelBackFillTex: TPanel
           Left = 42
           Height = 27
           Top = 28
-          Width = 227
+          Width = 162
           BevelOuter = bvNone
           ClientHeight = 27
-          ClientWidth = 227
+          ClientWidth = 162
           TabOrder = 3
           Visible = False
           object BackImage: TImage
-            Left = 154
+            Left = 131
             Height = 25
             Hint = 'Texture preview'
             Top = 1
-            Width = 69
-            Anchors = [akTop, akLeft, akRight]
+            Width = 29
             ParentShowHint = False
             ShowHint = True
             Visible = False
           end
-          object ButtonBackNoTex: TBCButton
-            Left = 127
-            Height = 25
-            Hint = 'Discard texture'
-            Top = 1
-            Width = 25
-            StateClicked.Background.Color = clBlack
-            StateClicked.Background.ColorOpacity = 255
-            StateClicked.Background.Gradient1.StartColor = 16577765
-            StateClicked.Background.Gradient1.StartColorOpacity = 255
-            StateClicked.Background.Gradient1.DrawMode = dmSet
-            StateClicked.Background.Gradient1.EndColor = 16180676
-            StateClicked.Background.Gradient1.EndColorOpacity = 255
-            StateClicked.Background.Gradient1.ColorCorrection = True
-            StateClicked.Background.Gradient1.GradientType = gtLinear
-            StateClicked.Background.Gradient1.Point1XPercent = 0
-            StateClicked.Background.Gradient1.Point1YPercent = 0
-            StateClicked.Background.Gradient1.Point2XPercent = 0
-            StateClicked.Background.Gradient1.Point2YPercent = 100
-            StateClicked.Background.Gradient1.Sinus = False
-            StateClicked.Background.Gradient2.StartColor = 15716760
-            StateClicked.Background.Gradient2.StartColorOpacity = 255
-            StateClicked.Background.Gradient2.DrawMode = dmSet
-            StateClicked.Background.Gradient2.EndColor = 14398312
-            StateClicked.Background.Gradient2.EndColorOpacity = 255
-            StateClicked.Background.Gradient2.ColorCorrection = True
-            StateClicked.Background.Gradient2.GradientType = gtLinear
-            StateClicked.Background.Gradient2.Point1XPercent = 0
-            StateClicked.Background.Gradient2.Point1YPercent = 0
-            StateClicked.Background.Gradient2.Point2XPercent = 0
-            StateClicked.Background.Gradient2.Point2YPercent = 100
-            StateClicked.Background.Gradient2.Sinus = False
-            StateClicked.Background.Gradient1EndPercent = 55
-            StateClicked.Background.Style = bbsGradient
-            StateClicked.Border.Color = 9134636
-            StateClicked.Border.ColorOpacity = 255
-            StateClicked.Border.LightColor = clBlack
-            StateClicked.Border.LightOpacity = 100
-            StateClicked.Border.LightWidth = 1
-            StateClicked.Border.Style = bboSolid
-            StateClicked.Border.Width = 1
-            StateClicked.FontEx.Color = clBlack
-            StateClicked.FontEx.EndEllipsis = False
-            StateClicked.FontEx.FontQuality = fqSystemClearType
-            StateClicked.FontEx.Height = 0
-            StateClicked.FontEx.SingleLine = True
-            StateClicked.FontEx.Shadow = False
-            StateClicked.FontEx.ShadowColor = clBlack
-            StateClicked.FontEx.ShadowColorOpacity = 255
-            StateClicked.FontEx.ShadowRadius = 5
-            StateClicked.FontEx.ShadowOffsetX = 5
-            StateClicked.FontEx.ShadowOffsetY = 5
-            StateClicked.FontEx.Style = []
-            StateClicked.FontEx.TextAlignment = bcaCenter
-            StateClicked.FontEx.WordBreak = False
-            StateHover.Background.Color = clBlack
-            StateHover.Background.ColorOpacity = 255
-            StateHover.Background.Gradient1.StartColor = 16643818
-            StateHover.Background.Gradient1.StartColorOpacity = 255
-            StateHover.Background.Gradient1.DrawMode = dmSet
-            StateHover.Background.Gradient1.EndColor = 16576729
-            StateHover.Background.Gradient1.EndColorOpacity = 255
-            StateHover.Background.Gradient1.ColorCorrection = True
-            StateHover.Background.Gradient1.GradientType = gtLinear
-            StateHover.Background.Gradient1.Point1XPercent = 0
-            StateHover.Background.Gradient1.Point1YPercent = 0
-            StateHover.Background.Gradient1.Point2XPercent = 0
-            StateHover.Background.Gradient1.Point2YPercent = 100
-            StateHover.Background.Gradient1.Sinus = False
-            StateHover.Background.Gradient2.StartColor = 16639678
-            StateHover.Background.Gradient2.StartColorOpacity = 255
-            StateHover.Background.Gradient2.DrawMode = dmSet
-            StateHover.Background.Gradient2.EndColor = 16112039
-            StateHover.Background.Gradient2.EndColorOpacity = 255
-            StateHover.Background.Gradient2.ColorCorrection = True
-            StateHover.Background.Gradient2.GradientType = gtLinear
-            StateHover.Background.Gradient2.Point1XPercent = 0
-            StateHover.Background.Gradient2.Point1YPercent = 0
-            StateHover.Background.Gradient2.Point2XPercent = 0
-            StateHover.Background.Gradient2.Point2YPercent = 100
-            StateHover.Background.Gradient2.Sinus = False
-            StateHover.Background.Gradient1EndPercent = 50
-            StateHover.Background.Style = bbsGradient
-            StateHover.Border.Color = 11632444
-            StateHover.Border.ColorOpacity = 255
-            StateHover.Border.LightColor = clWhite
-            StateHover.Border.LightOpacity = 200
-            StateHover.Border.LightWidth = 1
-            StateHover.Border.Style = bboSolid
-            StateHover.Border.Width = 1
-            StateHover.FontEx.Color = clBlack
-            StateHover.FontEx.EndEllipsis = False
-            StateHover.FontEx.FontQuality = fqSystemClearType
-            StateHover.FontEx.Height = 0
-            StateHover.FontEx.SingleLine = True
-            StateHover.FontEx.Shadow = False
-            StateHover.FontEx.ShadowColor = clBlack
-            StateHover.FontEx.ShadowColorOpacity = 255
-            StateHover.FontEx.ShadowRadius = 5
-            StateHover.FontEx.ShadowOffsetX = 5
-            StateHover.FontEx.ShadowOffsetY = 5
-            StateHover.FontEx.Style = []
-            StateHover.FontEx.TextAlignment = bcaCenter
-            StateHover.FontEx.WordBreak = False
-            StateNormal.Background.Color = clBlack
-            StateNormal.Background.ColorOpacity = 255
-            StateNormal.Background.Gradient1.StartColor = 15921906
-            StateNormal.Background.Gradient1.StartColorOpacity = 255
-            StateNormal.Background.Gradient1.DrawMode = dmSet
-            StateNormal.Background.Gradient1.EndColor = 15461355
-            StateNormal.Background.Gradient1.EndColorOpacity = 255
-            StateNormal.Background.Gradient1.ColorCorrection = True
-            StateNormal.Background.Gradient1.GradientType = gtLinear
-            StateNormal.Background.Gradient1.Point1XPercent = 0
-            StateNormal.Background.Gradient1.Point1YPercent = 0
-            StateNormal.Background.Gradient1.Point2XPercent = 0
-            StateNormal.Background.Gradient1.Point2YPercent = 100
-            StateNormal.Background.Gradient1.Sinus = False
-            StateNormal.Background.Gradient2.StartColor = 14540253
-            StateNormal.Background.Gradient2.StartColorOpacity = 255
-            StateNormal.Background.Gradient2.DrawMode = dmSet
-            StateNormal.Background.Gradient2.EndColor = 13619151
-            StateNormal.Background.Gradient2.EndColorOpacity = 255
-            StateNormal.Background.Gradient2.ColorCorrection = True
-            StateNormal.Background.Gradient2.GradientType = gtLinear
-            StateNormal.Background.Gradient2.Point1XPercent = 0
-            StateNormal.Background.Gradient2.Point1YPercent = 0
-            StateNormal.Background.Gradient2.Point2XPercent = 0
-            StateNormal.Background.Gradient2.Point2YPercent = 100
-            StateNormal.Background.Gradient2.Sinus = False
-            StateNormal.Background.Gradient1EndPercent = 50
-            StateNormal.Background.Style = bbsGradient
-            StateNormal.Border.Color = 7368816
-            StateNormal.Border.ColorOpacity = 255
-            StateNormal.Border.LightColor = clWhite
-            StateNormal.Border.LightOpacity = 200
-            StateNormal.Border.LightWidth = 1
-            StateNormal.Border.Style = bboSolid
-            StateNormal.Border.Width = 1
-            StateNormal.FontEx.Color = clBlack
-            StateNormal.FontEx.EndEllipsis = False
-            StateNormal.FontEx.FontQuality = fqSystemClearType
-            StateNormal.FontEx.Height = 0
-            StateNormal.FontEx.SingleLine = True
-            StateNormal.FontEx.Shadow = False
-            StateNormal.FontEx.ShadowColor = clBlack
-            StateNormal.FontEx.ShadowColorOpacity = 255
-            StateNormal.FontEx.ShadowRadius = 5
-            StateNormal.FontEx.ShadowOffsetX = 5
-            StateNormal.FontEx.ShadowOffsetY = 5
-            StateNormal.FontEx.Style = []
-            StateNormal.FontEx.TextAlignment = bcaCenter
-            StateNormal.FontEx.WordBreak = False
-            Color = clNone
-            DropDownWidth = 16
-            DropDownArrowSize = 8
-            GlobalOpacity = 255
-            Glyph.Data = {
-              36040000424D3604000000000000360000002800000010000000100000000100
-              2000000000000004000064000000640000000000000000000000000000002222
-              0D00383800001D1D291114141D0D25253C000000000000000000000000000000
-              000000004E000000450900003A140000000100000800000000002A2A1E001F1F
-              A100252568331A1A95BB19197DA31313311D19194E0000000000000000000D0D
-              8300060671102020A9902222AAC509096A47FFFFFF0000000E00252580002828
-              64321717A4CE0505DBFF0C0CC7FE191981AF1111321D1717520010107F000909
-              6A102020A8983636CFFC4444DFFF2C2CB9DD07076C476767FF0042422D091C1C
-              98B10404E4FF0000E7FF0000DAFF0D0DC0FE191983AF0E0E331C0E0E690F1F1F
-              A3982C2CC4FC3838D1FF4747E0FF5252ECFF2626B3C40000381454540A032121
-              90870A0AD2FC0000E7FF0000D9FF0101CBFF0F0FB7FE191987B41D1D97A62222
-              B9FB2828C2FF3737D0FF4848E1FF4848E2FD2020B69000003007303067003838
-              510D202093920B0BCCFB0000DAFF0000C9FF0101B8FF1010AFFF1717AFFF1919
-              B2FF2828C0FF3838D1FF3D3DD7FC2121B5980000781004048D00000000002C2C
-              6C003333580D1F1F96920C0CC6FB0000CBFF0000B6FF0000A3FF0808A1FF1818
-              B0FF2929C2FF3333CDFC2020B0980000751006068A0000000000000000000000
-              0000292972002F2F5D0C2020969A0D0DBFFF0606C0FF0A0AB8FF0F0FB7FF1A1A
-              BBFF2929C3FF1D1DA4A601016E0F090984000000000000000000000000000000
-              00002323630025254A0F1D1D919F1C1CC5FF2C2CD6FF3131D9FF3030D9FF3030
-              D5FF3030CBFF1A1A96B401013C1C070763000000000000000000000000002626
-              5F00292948101C1C8F982525C8FC4B4BDEFF5757E0FF4A4AD8FF4A4AD8FF5656
-              E0FF5252DDFF3E3ED0FE1B1B99AF0000421D050568000000000029295A002C2C
-              43101B1B8C982E2ECCFC6B6BE6FF7D7DE6FF6868DFFF2C2CBFFE2F2FBFFE6A6A
-              DFFF7C7CE6FF7474E6FF4E4ED9FE1B1B9EAF0000431C03036A00494909041E1E
-              8B8C3737D1FD8C8CEEFFA2A2EDFF8888E8FF3535C4FC1A1A989F1D1DA29A4040
-              C7FA8C8CE7FFA1A1EDFF9797EEFF5E5EE1FF1C1CA0A300001C0C43432F091B1B
-              9BAF5353E5FFC0C0F5FFA8A8F0FF3D3DCBFC1919969819195C0F10107E0C1E1E
-              AA925050D0FBAFAFEFFFC2C2F4FF7E7EEFFF2727BDBA00004310252581002929
-              6F2D2020A9C96161E3FF4646CFFC191994981C1C58101E1E6D00121291000A0A
-              800D1E1EAF926060D8FB8383EAFF3333C7CE080898321919C1004D4D37001818
-              94002727752D1B1B9FAF1B1B938B202056112020680000000000000000000E0E
-              95000606870E2020B4872525BCB20C0C95321C1CD30000003A00000000005252
-              1F0097970000333349092E2E44052F2F4F000000000000000000000000000000
-              000000008000000077050000780A000000000000340000000000
-            }
-            InnerMargin = 0
-            OnClick = ButtonBackNoTexClick
-            ParentColor = False
-            Rounding.RoundX = 3
-            Rounding.RoundY = 3
-            Rounding.RoundOptions = []
-            RoundingDropDown.RoundX = 1
-            RoundingDropDown.RoundY = 1
-            RoundingDropDown.RoundOptions = []
-            ShowHint = True
-            TextApplyGlobalOpacity = False
-            MemoryUsage = bmuHigh
-          end
           object ButtonBackLoadTex: TBCButton
             Left = 104
             Height = 25
@@ -2608,7 +2364,6 @@ object Form1: TForm1
             TabOrder = 0
             TabStop = True
             UseDockManager = False
-            Visible = False
           end
           object ButtonBackTexRepeat: TBCButton
             Left = 27

+ 126 - 96
vectoredit/umain.pas

@@ -17,6 +17,7 @@ const
   ActionIconSize = 24;
   EditorPointSize = 7;
   PenStyleToStr : array[TPenStyle] of string = ('─────', '─ ─ ─ ─', '···············', '─ · ─ · ─', '─ ·· ─ ·· ╴', 'InsideFrame', 'Pattern', 'Clear');
+  GradTypeToStr : array[TGradientType] of string = ('Linear','Reflected','Diamond','Radial');
   GradRepetitionToStr : array[TBGRAGradientRepetition] of string = ('Pad', 'Repeat', 'Reflect', 'Sine');
   ColorInterpToStr : array[TBGRAColorInterpolation] of string = ('sRGB', 'RGB', 'HSL CW', 'HSL CCW', 'Corr. HSL CW', 'Corr. HSL CCW');
   TextureRepetitionToStr: array[TTextureRepetition] of string = ('No repetition', 'Repeat X', 'Repeat Y', 'Repeat both');
@@ -46,6 +47,7 @@ type
     ShapeBringToFront: TAction;
     ShapeMoveDown: TAction;
     ShapeMoveUp: TAction;
+    ToolButtonBackFillGrad: TToolButton;
     VectorImageList24: TBGRAImageList;
     ActionList: TActionList;
     BackImage: TImage;
@@ -61,7 +63,6 @@ type
     ButtonBackGradInterp: TBCButton;
     ButtonBackGradRepetion: TBCButton;
     ButtonBackLoadTex: TBCButton;
-    ButtonBackNoTex: TBCButton;
     ButtonBackSwapGradColor: TBCButton;
     ButtonBackTexAdjust: TBCButton;
     ButtonBackTexRepeat: TBCButton;
@@ -102,11 +103,7 @@ type
     ToolButton7: TToolButton;
     ToolButton8: TToolButton;
     ToolButton9: TToolButton;
-    ToolButtonBackFillDiamond: TToolButton;
-    ToolButtonBackFillLinear: TToolButton;
     ToolButtonBackFillNone: TToolButton;
-    ToolButtonBackFillRadial: TToolButton;
-    ToolButtonBackFillReflected: TToolButton;
     ToolButtonBackFillSolid: TToolButton;
     ToolButtonBackFillTexture: TToolButton;
     ToolButtonJoinBevel: TToolButton;
@@ -159,6 +156,7 @@ type
     procedure ShapeMoveDownExecute(Sender: TObject);
     procedure ShapeMoveUpExecute(Sender: TObject);
     procedure ShapeSendToBackExecute(Sender: TObject);
+    procedure ToolButtonBackFillGradClick(Sender: TObject);
     procedure ToolButtonJoinClick(Sender: TObject);
     procedure UpDownBackGradAlphaChange(Sender: TObject; AByUser: boolean);
     procedure UpDownBackTexAlphaChange(Sender: TObject; AByUser: boolean);
@@ -171,7 +169,6 @@ type
       Shift: TShiftState; X, Y: Integer);
     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
     procedure ButtonBackLoadTexClick(Sender: TObject);
-    procedure ButtonBackNoTexClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure FormKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
@@ -188,6 +185,9 @@ type
   private
     FPenColor, FBackColor: TBGRAPixel;
     FBackGradStartColor, FBackGradEndColor: TBGRAPixel;
+    FBackFillType: TVectorialFillType;
+    FBackGradType: TGradientType;
+    FBackGradTypeMenu: TPopupMenu;
     FBackGradRepetition: TBGRAGradientRepetition;
     FBackGradRepetitionMenu: TPopupMenu;
     FBackGradInterp: TBGRAColorInterpolation;
@@ -224,6 +224,7 @@ type
     function GetZoomFactor: single;
     procedure ImageChange(ARectF: TRectF);
     procedure LoadVectorImages;
+    procedure OnClickBackGradType(ASender: TObject);
     procedure OnClickSplineStyleItem(ASender: TObject);
     procedure OnEditingChange({%H-}ASender: TObject; AOriginal: TBGRALayerCustomOriginal);
     procedure OnOriginalChange({%H-}ASender: TObject; AOriginal: TBGRALayerCustomOriginal);
@@ -235,10 +236,12 @@ type
     procedure OnClickBackGradInterp(ASender: TObject);
     procedure PhongShapeKindClick(Sender: TObject);
     procedure SetBackColor(AValue: TBGRAPixel);
+    procedure SetBackFillType(AValue: TVectorialFillType);
     procedure SetBackGradEndColor(AValue: TBGRAPixel);
     procedure SetBackGradInterp(AValue: TBGRAColorInterpolation);
     procedure SetBackGradRepetition(AValue: TBGRAGradientRepetition);
     procedure SetBackGradStartColor(AValue: TBGRAPixel);
+    procedure SetBackGradType(AValue: TGradientType);
     procedure SetBackTexRepetition(AValue: TTextureRepetition);
     procedure SetBackTexture(AValue: TBGRABitmap);
     procedure SetCurrentTool(AValue: TPaintTool);
@@ -263,7 +266,6 @@ type
     procedure UpdateShapeBackFill;
     procedure UpdateShapeUserMode;
     procedure UpdateShapeActions(AShape: TVectorShape);
-    function ToolButtonBackFillGradDown: boolean;
     procedure OnClickBackTexRepeat(ASender: TObject);
     procedure RemoveShapeIfEmpty(AShape: TVectorShape);
     procedure DoLoadTex;
@@ -291,6 +293,8 @@ type
     property backColor: TBGRAPixel read FBackColor write SetBackColor;
     property backGradStartColor: TBGRAPixel read FBackGradStartColor write SetBackGradStartColor;
     property backGradEndColor: TBGRAPixel read FBackGradEndColor write SetBackGradEndColor;
+    property backFillType: TVectorialFillType read FBackFillType write SetBackFillType;
+    property backGradType: TGradientType read FBackGradType write SetBackGradType;
     property backGradRepetition: TBGRAGradientRepetition read FBackGradRepetition write SetBackGradRepetition;
     property backGradInterp: TBGRAColorInterpolation read FBackGradInterp write SetBackGradInterp;
     property backTexture: TBGRABitmap read GetBackTexture write SetBackTexture;
@@ -451,6 +455,12 @@ begin
   SetToolbarImages(ToolBarEdit, vectorImageList);
 end;
 
+procedure TForm1.OnClickBackGradType(ASender: TObject);
+begin
+  backGradType := TGradientType((ASender as TMenuItem).Tag);
+  if backFillType <> vftGradient then backFillType:= vftGradient;
+end;
+
 { TForm1 }
 
 procedure TForm1.FormCreate(Sender: TObject);
@@ -463,6 +473,7 @@ var
   ss: TSplineStyle;
   toolImageList: TBGRAImageList;
   i: Integer;
+  gt: TGradientType;
 begin
   baseCaption:= Caption;
   if ToolIconSize <> ToolImageList48.Width then
@@ -499,6 +510,16 @@ begin
     FPenStyleMenu.Items.Add(item);
   end;
 
+  FBackGradTypeMenu := TPopupMenu.Create(nil);
+  FBackGradTypeMenu.Images := FillImageList16;
+  for gt := low(TGradientType) to high(TGradientType) do
+  begin
+    item := TMenuItem.Create(FBackGradTypeMenu); item.Caption := GradTypeToStr[gt];
+    item.OnClick:=@OnClickBackGradType;          item.Tag := ord(gt);
+    item.ImageIndex:= 2+ord(gt);
+    FBackGradTypeMenu.Items.Add(item);
+  end;
+
   FBackGradRepetitionMenu := TPopupMenu.Create(nil);
   FBackGradRepetitionMenu.Images := FillImageList16;
   for gr := low(TBGRAGradientRepetition) to high(TBGRAGradientRepetition) do
@@ -549,6 +570,7 @@ begin
   joinStyle:= pjsBevel;
   currentTool:= ptHand;
   splineStyle:= ssEasyBezier;
+  FBackFillType:= vftSolid;
   FBackGradRepetition:= grPad;
   FBackGradInterp:= ciLinearRGB;
   FBackTexRepetition:= trRepeatBoth;
@@ -579,16 +601,6 @@ begin
   DoLoadTex;
 end;
 
-procedure TForm1.ButtonBackNoTexClick(Sender: TObject);
-begin
-  backTexture := nil;
-  if ToolButtonBackFillTexture.Down then
-  begin
-    ToolButtonBackFillNone.Down := true;
-    UpdateBackComponentsVisibility;
-  end;
-end;
-
 procedure TForm1.BGRAVirtualScreen1MouseDown(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
 var
@@ -670,6 +682,14 @@ begin
   end;
 end;
 
+procedure TForm1.ToolButtonBackFillGradClick(Sender: TObject);
+begin
+  if Assigned(FBackGradTypeMenu) then
+    with ToolButtonBackFillGrad.ClientToScreen(Point(0,ToolButtonBackFillGrad.Height)) do
+      FBackGradTypeMenu.PopUp(X,Y);
+  ToolButtonBackFillGrad.Down := FBackFillType = vftGradient;
+end;
+
 procedure TForm1.ToolButtonJoinClick(Sender: TObject);
 begin
   if (Sender as TToolButton).Down then
@@ -867,13 +887,13 @@ begin
       FBackGradEndColor.alpha := (Sender as TBCTrackbarUpdown).Value
     else
       FBackGradStartColor.alpha := (Sender as TBCTrackbarUpdown).Value;
-    if ToolButtonBackFillGradDown then UpdateShapeBackFill;
+    if backFillType = vftGradient then UpdateShapeBackFill;
   end;
 end;
 
 procedure TForm1.UpDownBackTexAlphaChange(Sender: TObject; AByUser: boolean);
 begin
-  if AByUser and ToolButtonBackFillTexture.Down then UpdateShapeBackFill;
+  if AByUser and (backFillType = vftTexture) then UpdateShapeBackFill;
 end;
 
 procedure TForm1.BGRAVirtualScreen1MouseMove(Sender: TObject;
@@ -905,7 +925,7 @@ begin
   begin
     prevRF := newShape.GetRenderBounds(InfiniteRect, vectorTransform);
     newShape.QuickDefine(newStartPoint,ptF);
-    if (vsfBackFill in newShape.Fields) and newShape.BackFill.IsGradient or newShape.BackFill.IsTexture then
+    if (vsfBackFill in newShape.Fields) and (newShape.BackFill.FillType in [vftGradient, vftTexture]) then
     begin
       vectorFill := CreateBackFill(newShape);
       newShape.BackFill := vectorFill;
@@ -965,6 +985,7 @@ begin
   FFlattened.Free;
   FBackTexture.FreeReference;
   FPenStyleMenu.Free;
+  FBackGradTypeMenu.Free;
   FBackGradRepetitionMenu.Free;
   FBackGradInterpMenu.Free;
   FBackTexRepetitionMenu.Free;
@@ -1028,8 +1049,7 @@ procedure TForm1.ToolButtonBackFillChange(Sender: TObject);
 begin
   if FUpdatingFromShape then exit;
 
-  if (Sender = ToolButtonBackFillTexture) and ToolButtonBackFillTexture.Down
-    and (backTexture = nil) then
+  if (Sender = ToolButtonBackFillTexture) and (backTexture = nil) then
   begin
     DoLoadTex;
     exit;
@@ -1037,8 +1057,22 @@ begin
 
   if (Sender as TToolButton).Down then
   begin
-    UpdateShapeBackFill;
-    UpdateBackComponentsVisibility;
+    if Sender = ToolButtonBackFillNone then backFillType := vftNone;
+    if Sender = ToolButtonBackFillSolid then backFillType := vftSolid;
+    if Sender = ToolButtonBackFillGrad then backFillType := vftGradient;
+    if Sender = ToolButtonBackFillTexture then backFillType := vftTexture;
+  end else
+  begin
+    if not ToolButtonBackFillNone.Down and
+       not ToolButtonBackFillSolid.Down and
+       not ToolButtonBackFillGrad.Down and
+       not ToolButtonBackFillTexture.Down then
+    begin
+      ToolButtonBackFillNone.Down := (backFillType = vftNone);
+      ToolButtonBackFillSolid.Down := (backFillType = vftSolid);
+      ToolButtonBackFillGrad.Down := (backFillType = vftGradient);
+      ToolButtonBackFillTexture.Down := (backFillType = vftTexture);
+    end;
   end;
 end;
 
@@ -1092,7 +1126,7 @@ begin
     else UpdateToolbarFromShape(nil);
 
     if currentTool in [ptPolyline, ptCurve] then
-      ToolButtonBackFillNone.Down := true;
+      backFillType := vftNone;
   end;
 
   UpdateShapeUserMode;
@@ -1106,7 +1140,7 @@ begin
   if AByUser then
   begin
     FBackColor:= ColorToBGRA(ShapeBackColor.Brush.Color, UpDownBackAlpha.Value);
-    if ToolButtonBackFillSolid.Down then UpdateShapeBackFill;
+    if backFillType = vftSolid then UpdateShapeBackFill;
   end;
 end;
 
@@ -1269,17 +1303,29 @@ begin
   FBackColor := AValue;
   ShapeBackColor.Brush.Color := AValue.ToColor;
   UpDownBackAlpha.Value := AValue.alpha;
-  if not FUpdatingFromShape and ToolButtonBackFillSolid.Down then
+  if not FUpdatingFromShape and (backFillType = vftSolid) then
     UpdateShapeBackFill;
 end;
 
+procedure TForm1.SetBackFillType(AValue: TVectorialFillType);
+begin
+  if FBackFillType=AValue then Exit;
+  FBackFillType:=AValue;
+  ToolButtonBackFillNone.Down := (FBackFillType = vftNone);
+  ToolButtonBackFillSolid.Down := (FBackFillType = vftSolid);
+  ToolButtonBackFillGrad.Down := (FBackFillType = vftGradient);
+  ToolButtonBackFillTexture.Down := (FBackFillType = vftTexture);
+  if not FUpdatingFromShape then UpdateShapeBackFill;
+  UpdateBackComponentsVisibility;
+end;
+
 procedure TForm1.SetBackGradEndColor(AValue: TBGRAPixel);
 begin
   FBackGradEndColor := AValue;
   UpDownBackEndAlpha.Value := AValue.alpha;
   AValue.alpha := 255;
   ShapeBackEndColor.Brush.Color := AValue.ToColor;
-  if not FUpdatingFromShape and ToolButtonBackFillGradDown then
+  if not FUpdatingFromShape and (backFillType = vftGradient) then
     UpdateShapeBackFill;
 end;
 
@@ -1298,7 +1344,7 @@ begin
   FillImageList16.Draw(glyph.Canvas,0,0,11+ord(FBackGradInterp));
   ButtonBackGradInterp.Glyph.Assign(glyph);
   glyph.Free;
-  if not FUpdatingFromShape and ToolButtonBackFillGradDown then
+  if not FUpdatingFromShape and (backFillType = vftGradient) then
     UpdateShapeBackFill;
 end;
 
@@ -1317,7 +1363,7 @@ begin
   FillImageList16.Draw(glyph.Canvas,0,0,7+ord(FBackGradRepetition));
   ButtonBackGradRepetion.Glyph.Assign(glyph);
   glyph.Free;
-  if not FUpdatingFromShape and ToolButtonBackFillGradDown then
+  if not FUpdatingFromShape and (backFillType = vftGradient) then
     UpdateShapeBackFill;
 end;
 
@@ -1327,13 +1373,22 @@ begin
   UpDownBackStartAlpha.Value := AValue.alpha;
   AValue.alpha := 255;
   ShapeBackStartColor.Brush.Color := AValue.ToColor;
-  if not FUpdatingFromShape and ToolButtonBackFillGradDown then
+  if not FUpdatingFromShape and (backFillType = vftGradient) then
+    UpdateShapeBackFill;
+end;
+
+procedure TForm1.SetBackGradType(AValue: TGradientType);
+begin
+  if FBackGradType=AValue then Exit;
+  FBackGradType:=AValue;
+  ToolButtonBackFillGrad.ImageIndex := 2+ord(FBackGradType);
+  if not FUpdatingFromShape and (backFillType = vftGradient) then
     UpdateShapeBackFill;
 end;
 
 procedure TForm1.SetBackTexRepetition(AValue: TTextureRepetition);
 var
-  glyph: Graphics.TBitmap;
+  glyph: TBitmap;
 begin
   if FBackTexRepetition=AValue then Exit;
   FBackTexRepetition:=AValue;
@@ -1346,7 +1401,7 @@ begin
   FillImageList16.Draw(glyph.Canvas,0,0,17+ord(FBackTexRepetition));
   ButtonBackTexRepeat.Glyph.Assign(glyph);
   glyph.Free;
-  if not FUpdatingFromShape and ToolButtonBackFillTexture.Down then
+  if not FUpdatingFromShape and (backFillType = vftTexture) then
     UpdateShapeBackFill;
 end;
 
@@ -1385,7 +1440,7 @@ begin
     BackImage.Visible := false;
   end;
 
-  if not FUpdatingFromShape and ToolButtonBackFillTexture.Down then
+  if not FUpdatingFromShape and (backFillType = vftTexture) then
     UpdateShapeBackFill;
 end;
 
@@ -1628,33 +1683,25 @@ begin
 
     if vsfBackFill in f then
     begin
-      if AShape.BackFill.IsTexture then
-      begin
-        texSource := AShape.BackFill.Texture;
-        if Assigned(texSource) then backTexture := texSource;
-        UpDownBackTexAlpha.Value := AShape.BackFill.TextureOpacity;
-        backTextureRepetition:= AShape.BackFill.TextureRepetition;
-        ToolButtonBackFillTexture.Down := true;
-      end else
-      if AShape.BackFill.IsSolid and (AShape.BackFill.SolidColor.alpha <> 0) then
-      begin
-        backColor := AShape.BackFill.SolidColor;
-        ToolButtonBackFillSolid.Down := true;
-      end else
-      if AShape.BackFill.IsGradient then
-      begin
-        backGradStartColor := AShape.BackFill.Gradient.StartColor;
-        backGradEndColor := AShape.BackFill.Gradient.EndColor;
-        case AShape.BackFill.Gradient.GradientType of
-          gtReflected: ToolButtonBackFillReflected.Down := true;
-          gtDiamond: ToolButtonBackFillDiamond.Down := true;
-          gtRadial: ToolButtonBackFillRadial.Down := true;
-        else{gtLinear} ToolButtonBackFillLinear.Down := true;
-        end;
-        backGradRepetition:= AShape.BackFill.Gradient.Repetition;
-        backGradInterp := AShape.BackFill.Gradient.ColorInterpolation;
-      end else
-        ToolButtonBackFillNone.Down := true;
+      backFillType:= AShape.BackFill.FillType;
+      case backFillType of
+        vftTexture:
+          begin
+            texSource := AShape.BackFill.Texture;
+            if Assigned(texSource) then backTexture := texSource;
+            UpDownBackTexAlpha.Value := AShape.BackFill.TextureOpacity;
+            backTextureRepetition:= AShape.BackFill.TextureRepetition;
+          end;
+        vftSolid: backColor := AShape.BackFill.SolidColor;
+        vftGradient:
+          begin
+            backGradStartColor := AShape.BackFill.Gradient.StartColor;
+            backGradEndColor := AShape.BackFill.Gradient.EndColor;
+            backGradType:= AShape.BackFill.Gradient.GradientType;
+            backGradRepetition:= AShape.BackFill.Gradient.Repetition;
+            backGradInterp := AShape.BackFill.Gradient.ColorInterpolation;
+          end;
+      end;
       UpdateBackComponentsVisibility;
     end;
 
@@ -1793,8 +1840,7 @@ begin
   if not IsCreateShapeTool(currentTool) then
     raise exception.Create('No shape type selected');
   result := PaintToolClass[currentTool].Create(vectorOriginal);
-  if (result is TCustomPolypointShape) and ToolButtonBackFillGradDown then
-    ToolButtonBackFillSolid.Down := true;
+  if (result is TCustomPolypointShape) and (backFillType = vftGradient) then backFillType := vftSolid;
   result.PenColor := penColor;
   result.PenWidth := penWidth;
   result.PenStyle := penStyle;
@@ -1826,9 +1872,9 @@ var
   rF: TRectF;
   sx,sy: single;
 begin
-  if ToolButtonBackFillSolid.Down then
+  if backFillType = vftSolid then
     result := TVectorialFill.CreateAsSolid(FBackColor)
-  else if ToolButtonBackFillTexture.Down and Assigned(backTexture) then
+  else if (backFillType = vftTexture) and Assigned(backTexture) then
   begin
     rF := AShape.GetRenderBounds(InfiniteRect,AffineMatrixIdentity,[rboAssumeBackFill]);
     if not (FBackTexRepetition in [trRepeatX,trRepeatBoth]) and (rF.Width <> 0) and (backTexture.Width > 0) then
@@ -1841,7 +1887,7 @@ begin
                  AffineMatrixScale(sx,sy),
                  UpDownBackTexAlpha.Value, FBackTexRepetition);
   end
-  else if ToolButtonBackFillGradDown then
+  else if backFillType = vftGradient then
   begin
     grad := TBGRALayerGradientOriginal.Create;
     grad.StartColor := FBackGradStartColor;
@@ -1853,10 +1899,7 @@ begin
     end
     else
       rF := rectF(0,0,img.Width,img.Height);
-    if ToolButtonBackFillLinear.Down then grad.GradientType:= gtLinear;
-    if ToolButtonBackFillReflected.Down then grad.GradientType:= gtReflected;
-    if ToolButtonBackFillDiamond.Down then grad.GradientType:= gtDiamond;
-    if ToolButtonBackFillRadial.Down then grad.GradientType:= gtRadial;
+    grad.GradientType:= FBackGradType;
     grad.Repetition := FBackGradRepetition;
     grad.ColorInterpolation:= FBackGradInterp;
     if grad.GradientType = gtLinear then
@@ -1912,16 +1955,16 @@ procedure TForm1.UpdateBackComponentsVisibility;
 var
   canEdit: Boolean;
 begin
-  ShapeBackColor.Visible := ToolButtonBackFillSolid.Down;
-  UpDownBackAlpha.Visible := ToolButtonBackFillSolid.Down;
-  PanelBackFillGrad.Visible:= ToolButtonBackFillGradDown;
-  PanelBackFillTex.Visible := ToolButtonBackFillTexture.Down;
-  UpDownBackTexAlpha.Visible := ToolButtonBackFillTexture.Down;
-  canEdit := (ToolButtonBackFillGradDown or ToolButtonBackFillTexture.Down) and
+  ShapeBackColor.Visible := backFillType = vftSolid;
+  UpDownBackAlpha.Visible := backFillType = vftSolid;
+  PanelBackFillGrad.Visible:= backFillType = vftGradient;
+  PanelBackFillTex.Visible := backFillType = vftTexture;
+  canEdit := (backFillType in[vftGradient,vftTexture]) and
     Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape);
   ButtonMoveBackFillPoints.Enabled := canEdit;
   ButtonBackTexAdjust.Enabled := canEdit;
   if (currentTool = ptMoveBackFillPoint) and not canEdit then currentTool:= ptHand;
+  if backFillType <> vftTexture then backTexture := nil;
 end;
 
 procedure TForm1.UpdateShapeBackFill;
@@ -1931,22 +1974,19 @@ begin
   if Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape) and
     (vsfBackFill in vectorOriginal.SelectedShape.Fields) then
   begin
-    if ToolButtonBackFillTexture.Down and (UpDownBackTexAlpha.Value = 0) then
+    if (backFillType = vftTexture) and (UpDownBackTexAlpha.Value = 0) then
       vectorFill := nil else
-    if ToolButtonBackFillTexture.Down and vectorOriginal.SelectedShape.BackFill.IsTexture then
+    if (backFillType = vftTexture) and (vectorOriginal.SelectedShape.BackFill.FillType = vftTexture) then
     begin
       vectorFill := TVectorialFill.CreateAsTexture(FBackTexture, vectorOriginal.SelectedShape.BackFill.TextureMatrix,
                                                    UpDownBackTexAlpha.Value, FBackTexRepetition);
     end
-    else if ToolButtonBackFillGradDown and vectorOriginal.SelectedShape.BackFill.IsGradient then
+    else if (backFillType = vftGradient) and (vectorOriginal.SelectedShape.BackFill.FillType = vftGradient) then
     begin
       vectorFill := vectorOriginal.SelectedShape.BackFill.Duplicate;
       vectorFill.Gradient.StartColor := FBackGradStartColor;
       vectorFill.Gradient.EndColor := FBackGradEndColor;
-      if ToolButtonBackFillLinear.Down then vectorFill.Gradient.GradientType:= gtLinear;
-      if ToolButtonBackFillReflected.Down then vectorFill.Gradient.GradientType:= gtReflected;
-      if ToolButtonBackFillDiamond.Down then vectorFill.Gradient.GradientType:= gtDiamond;
-      if ToolButtonBackFillRadial.Down then vectorFill.Gradient.GradientType:= gtRadial;
+      vectorFill.Gradient.GradientType := FBackGradType;
       vectorFill.Gradient.Repetition := FBackGradRepetition;
       vectorFill.Gradient.ColorInterpolation:= FBackGradInterp;
     end else
@@ -1986,12 +2026,6 @@ begin
   EditDelete.Enabled := AShape <> nil;
 end;
 
-function TForm1.ToolButtonBackFillGradDown: boolean;
-begin
-  result := ToolButtonBackFillLinear.Down or ToolButtonBackFillReflected.Down or
-            ToolButtonBackFillDiamond.Down or ToolButtonBackFillRadial.Down;
-end;
-
 procedure TForm1.OnClickBackTexRepeat(ASender: TObject);
 begin
   backTextureRepetition := TTextureRepetition((ASender as TMenuItem).Tag);
@@ -2030,22 +2064,18 @@ begin
       newTex := TBGRABitmap.Create(OpenPictureDialog1.FileName, true);
       backTexture := newTex;
       newTex.FreeReference;
-      ToolButtonBackFillTexture.Down:= true;
-      UpdateBackComponentsVisibility;
+      backFillType:= vftTexture;
     except
       on ex: exception do
         ShowMessage(ex.Message);
     end;
   end;
-  if ToolButtonBackFillTexture.Down and (backTexture = nil) then
+  if (backFillType = vftTexture) and (backTexture = nil) then
   begin
     if Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape) then
       UpdateToolbarFromShape(vectorOriginal.SelectedShape)
     else
-    begin
-      ToolButtonBackFillNone.Down:= true;
-      ToolButtonBackFillChange(ToolButtonBackFillNone);
-    end;
+      backFillType:= vftNone;
   end;
 end;
 

+ 54 - 46
vectoredit/uvectorialfill.pas

@@ -10,6 +10,7 @@ uses
 
 type
   TTextureRepetition = (trNone, trRepeatX, trRepeatY, trRepeatBoth);
+  TVectorialFillType = (vftNone, vftSolid, vftGradient, vftTexture);
 
   { TVectorialFill }
 
@@ -26,9 +27,7 @@ type
     FOnChange: TNotifyEvent;
     procedure GradientChange({%H-}ASender: TObject; {%H-}ABounds: PRectF=nil);
     procedure Init; virtual;
-    function GetIsGradient: boolean;
-    function GetIsTexture: boolean;
-    function GetIsNone: boolean;
+    function GetFillType: TVectorialFillType;
     function GetIsEditable: boolean;
     procedure SetOnChange(AValue: TNotifyEvent);
     procedure SetTextureMatrix(AValue: TAffineMatrix);
@@ -59,15 +58,13 @@ type
     procedure ConfigureEditor(AEditor: TBGRAOriginalEditor);
     function CreateScanner(AMatrix: TAffineMatrix; ADraft: boolean): TBGRACustomScanner;
     function IsSlow(AMatrix: TAffineMatrix): boolean;
+    function IsFullyTransparent: boolean;
     procedure Transform(AMatrix: TAffineMatrix);
     function Duplicate: TVectorialFill; virtual;
     destructor Destroy; override;
     function Equals(Obj: TObject): boolean; override;
     procedure Assign(Obj: TObject);
-    property IsNone: boolean read GetIsNone;
-    property IsSolid: boolean read FIsSolid;
-    property IsTexture: boolean read GetIsTexture;
-    property IsGradient: boolean read GetIsGradient;
+    property FillType: TVectorialFillType read GetFillType;
     property IsEditable: boolean read GetIsEditable;
     property Gradient: TBGRALayerGradientOriginal read FGradient;
     property SolidColor: TBGRAPixel read FColor write SetSolid;
@@ -84,16 +81,6 @@ uses BGRAGradientScanner;
 
 { TVectorialFill }
 
-function TVectorialFill.GetIsGradient: boolean;
-begin
-  result:= Assigned(FGradient);
-end;
-
-function TVectorialFill.GetIsTexture: boolean;
-begin
-  result:= Assigned(FTexture);
-end;
-
 procedure TVectorialFill.SetOnChange(AValue: TNotifyEvent);
 begin
   if FOnChange=AValue then Exit;
@@ -102,7 +89,7 @@ end;
 
 procedure TVectorialFill.SetTextureMatrix(AValue: TAffineMatrix);
 begin
-  if not IsTexture then raise exception.Create('Not a texture fill');
+  if FillType <> vftTexture then raise exception.Create('Not a texture fill');
   if FTextureMatrix=AValue then Exit;
   FTextureMatrix:=AValue;
   Changed;
@@ -110,7 +97,7 @@ end;
 
 procedure TVectorialFill.SetTextureOpacity(AValue: byte);
 begin
-  if not IsTexture then raise exception.Create('Not a texture fill');
+  if FillType <> vftTexture then raise exception.Create('Not a texture fill');
   if FTextureOpacity=AValue then Exit;
   FTextureOpacity:=AValue;
   Changed;
@@ -221,24 +208,27 @@ begin
   FIsSolid := false;
 end;
 
-function TVectorialFill.GetIsNone: boolean;
-begin
-  result:= not IsSolid and not IsGradient and not IsTexture;
-end;
-
 function TVectorialFill.GetIsEditable: boolean;
 begin
-  result:= IsGradient or IsTexture;
+  result:= FillType in [vftGradient, vftTexture];
 end;
 
 procedure TVectorialFill.SetTextureRepetition(AValue: TTextureRepetition);
 begin
-  if not IsTexture then raise exception.Create('Not a texture fill');
+  if FillType <> vftTexture then raise exception.Create('Not a texture fill');
   if FTextureRepetition=AValue then Exit;
   FTextureRepetition:=AValue;
   Changed;
 end;
 
+function TVectorialFill.GetFillType: TVectorialFillType;
+begin
+  if FIsSolid then result:= vftSolid
+  else if Assigned(FGradient) then result := vftGradient
+  else if Assigned(FTexture) then result := vftTexture
+  else result := vftNone;
+end;
+
 procedure TVectorialFill.GradientChange(ASender: TObject; ABounds: PRectF=nil);
 begin
   Changed;
@@ -253,7 +243,7 @@ procedure TVectorialFill.Clear;
 var
   notify: Boolean;
 begin
-  notify := IsSolid or IsGradient or IsTexture;
+  notify := FillType <> vftNone;
   InternalClear;
   if notify then Changed;
 end;
@@ -280,7 +270,7 @@ end;
 
 procedure TVectorialFill.SetSolid(AColor: TBGRAPixel);
 begin
-  if IsSolid and (SolidColor = AColor) then exit;
+  if (FillType = vftSolid) and (SolidColor = AColor) then exit;
   InternalClear;
   if AColor.alpha = 0 then AColor := BGRAPixelTransparent;
   FColor := AColor;
@@ -311,8 +301,10 @@ end;
 
 procedure TVectorialFill.ConfigureEditor(AEditor: TBGRAOriginalEditor);
 begin
-  if IsGradient then Gradient.ConfigureEditor(AEditor) else
-  if IsTexture then ConfigureTextureEditor(AEditor);
+  case FillType of
+  vftGradient: Gradient.ConfigureEditor(AEditor);
+  vftTexture: ConfigureTextureEditor(AEditor);
+  end;
 end;
 
 function TVectorialFill.CreateScanner(AMatrix: TAffineMatrix; ADraft: boolean
@@ -356,13 +348,24 @@ begin
     result := false;
 end;
 
+function TVectorialFill.IsFullyTransparent: boolean;
+begin
+  case FillType of
+  vftNone: result := true;
+  vftSolid: result:= SolidColor.alpha = 0;
+  else result:= false;
+  end;
+end;
+
 procedure TVectorialFill.Transform(AMatrix: TAffineMatrix);
 begin
-  if IsGradient then Gradient.Transform(AMatrix)
-  else if IsTexture then
-  begin
-    FTextureMatrix := AMatrix*FTextureMatrix;
-    Changed;
+  case FillType of
+  vftGradient: Gradient.Transform(AMatrix);
+  vftTexture:
+    begin
+      FTextureMatrix := AMatrix*FTextureMatrix;
+      Changed;
+    end;
   end;
 end;
 
@@ -386,21 +389,24 @@ begin
     result := true
   else
   if Obj = nil then
-    result := IsNone
+    result := (FillType = vftNone)
   else
   if Obj is TVectorialFill then
   begin
     other := TVectorialFill(Obj);
     if Self = nil then
-      result := other.IsNone
+      result := (other.FillType = vftNone)
     else
     begin
-      if other.IsSolid then result := IsSolid and (other.SolidColor = SolidColor) else
-      if other.IsGradient then result := IsGradient and (other.Gradient.Equals(Gradient)) else
-      if other.IsTexture then result := IsTexture and (other.Texture = Texture) and
+      case other.FillType of
+      vftSolid: result := (FillType = vftSolid) and (other.SolidColor = SolidColor);
+      vftGradient: result := (FillType = vftGradient) and (other.Gradient.Equals(Gradient));
+      vftTexture: result := (FillType = vftTexture) and (other.Texture = Texture) and
                        (other.TextureMatrix = TextureMatrix) and (other.TextureOpacity = TextureOpacity)
-                       and (other.TextureRepetition = TextureRepetition) else
-        result := IsNone;
+                       and (other.TextureRepetition = TextureRepetition);
+      else
+        result := FillType = vftNone;
+      end;
     end;
   end else
     result:= false;
@@ -414,10 +420,12 @@ begin
   if Obj is TVectorialFill then
   begin
     other := TVectorialFill(Obj);
-    if other.IsSolid then SetSolid(other.SolidColor) else
-    if other.IsGradient then SetGradient(other.Gradient,false) else
-    if other.IsTexture then SetTexture(other.Texture,other.TextureMatrix,other.TextureOpacity,other.TextureRepetition) else
-      Clear;
+    case other.FillType of
+    vftSolid: SetSolid(other.SolidColor);
+    vftGradient: SetGradient(other.Gradient,false);
+    vftTexture: SetTexture(other.Texture,other.TextureMatrix,other.TextureOpacity,other.TextureRepetition);
+    else Clear;
+    end;
   end else
     raise exception.Create('Incompatible type');
 end;

+ 13 - 11
vectoredit/uvectororiginal.pas

@@ -544,27 +544,29 @@ procedure TVectorShape.SaveFill(AStorage: TBGRACustomOriginalStorage;
 var
   obj: TBGRACustomOriginalStorage;
   m: TAffineMatrix;
+  ft: TVectorialFillType;
 begin
   AStorage.RemoveObject(AObjectName+'-fill');
   AStorage.RemoveObject(AObjectName+'-color');
   if Assigned(AValue) then
   begin
-    if AValue.IsSolid then
+    ft := AValue.FillType;
+    if ft = vftSolid then
     begin
       AStorage.Color[AObjectName+'-color'] := AValue.SolidColor;
       exit;
     end else
-    if not AValue.IsTexture and not AValue.IsGradient then exit;
+    if not (ft in [vftTexture,vftGradient]) then exit;
 
     obj := AStorage.CreateObject(AObjectName+'-fill');
     try
-      if AValue.IsSolid then
+      if ft = vftSolid then
       begin
         obj.RawString['class'] := 'solid';
         obj.Color['color'] := AValue.SolidColor;
       end
       else
-      if AValue.IsTexture then
+      if ft = vftTexture then
       begin
         obj.RawString['class'] := 'texture';
         obj.Int['tex-id'] := Container.GetTextureId(AValue.Texture);
@@ -581,7 +583,7 @@ begin
           trRepeatBoth: obj.RemoveAttribute('repetition');
         end;
       end else
-      if AValue.IsGradient then
+      if ft = vftGradient then
       begin
         obj.RawString['class'] := 'gradient';
         AValue.Gradient.SaveToStorage(obj);
@@ -724,9 +726,9 @@ begin
   if FBackFill.Equals(AValue) then exit;
   BeginUpdate;
   freeTex := Assigned(FBackFill) and Assigned(FBackFill.Texture) and
-    not (Assigned(AValue) and AValue.IsTexture and (AValue.Texture = FBackFill.Texture));
+    not (Assigned(AValue) and (AValue.FillType = vftTexture) and (AValue.Texture = FBackFill.Texture));
   if AValue = nil then FreeAndNil(FBackFill) else
-  if AValue.IsTexture then
+  if AValue.FillType = vftTexture then
   begin
     if Assigned(Container) then
       sharedTex := Container.GetTexture(Container.AddTexture(AValue.Texture))
@@ -1073,7 +1075,7 @@ begin
   for i := 0 to FShapes.Count-1 do
   begin
     f:= FShapes[i].Fields;
-    if (vsfBackFill in f) and FShapes[i].BackFill.IsTexture then
+    if (vsfBackFill in f) and (FShapes[i].BackFill.FillType = vftTexture) then
     begin
       tex := FShapes[i].BackFill.Texture;
       inc(FTextures[IndexOfTexture(GetTextureId(tex))].Counter);
@@ -1102,7 +1104,7 @@ begin
       raise exception.Create('Container mismatch');
   end;
   result:= FShapes.Add(AShape);
-  if (vsfBackFill in AShape.Fields) and AShape.BackFill.IsTexture then AddTexture(AShape.BackFill.Texture);
+  if (vsfBackFill in AShape.Fields) and (AShape.BackFill.FillType = vftTexture) then AddTexture(AShape.BackFill.Texture);
   AShape.OnChange := @OnShapeChange;
   AShape.OnEditingChange := @OnShapeEditingChange;
   DiscardFrozenShapes;
@@ -1163,7 +1165,7 @@ begin
     end else
       prevMode := vsuEdit;
     if Assigned(AShape) and (prevMode = vsuEditBackFill) and (prevMode in AShape.Usermodes) and
-       AShape.BackFill.IsGradient then AShape.Usermode:= prevMode;
+       (AShape.BackFill.FillType in[vftGradient,vftTexture]) then AShape.Usermode:= prevMode;
     FSelectedShape := AShape;
     DiscardFrozenShapes;
     NotifyEditorChange;
@@ -1252,7 +1254,7 @@ begin
     else
     begin
       if (FSelectedShape.Usermode = vsuEditBackFill) and
-         (FSelectedShape.BackFill.IsGradient or FSelectedShape.BackFill.IsTexture) then
+         (FSelectedShape.BackFill.FillType in [vftGradient,vftTexture]) then
         FSelectedShape.BackFill.ConfigureEditor(AEditor)
       else
         FSelectedShape.ConfigureEditor(AEditor);

+ 10 - 14
vectoredit/uvectorshapes.pas

@@ -213,7 +213,7 @@ type
 
 implementation
 
-uses BGRAPen, BGRAGraphics, BGRAFillInfo, BGRAPath, math;
+uses BGRAPen, BGRAGraphics, BGRAFillInfo, BGRAPath, math, uvectorialfill;
 
 function MatrixForPixelCentered(const AMatrix: TAffineMatrix): TAffineMatrix;
 begin
@@ -541,8 +541,7 @@ end;
 
 function TRectShape.BackVisible: boolean;
 begin
-  result := BackFill.IsGradient or BackFill.IsTexture or
-            (BackFill.IsSolid and (BackFill.SolidColor.alpha <> 0));
+  result := not BackFill.IsFullyTransparent;
 end;
 
 function TRectShape.GetCornerPositition: single;
@@ -590,7 +589,7 @@ begin
   pts := GetAffineBox(AMatrix, true).AsPolygon;
   If BackVisible then
   begin
-    if BackFill.IsSolid then backScan := nil
+    if (BackFill.FillType = vftSolid) then backScan := nil
     else backScan := BackFill.CreateScanner(AMatrix, ADraft);
 
     if GetOrthoRect(AMatrix, orthoRect) then
@@ -702,8 +701,7 @@ end;
 
 function TEllipseShape.BackVisible: boolean;
 begin
-  result := BackFill.IsGradient or BackFill.IsTexture or
-            (BackFill.IsSolid and (BackFill.SolidColor.alpha <> 0));
+  result := not BackFill.IsFullyTransparent;
 end;
 
 function TEllipseShape.GetCornerPositition: single;
@@ -741,7 +739,7 @@ begin
     radius := (orthoRect.BottomRight-orthoRect.TopLeft)*0.5;
     If BackVisible then
     begin
-      if BackFill.IsSolid then backScan := nil
+      if BackFill.FillType = vftSolid then backScan := nil
       else backScan := BackFill.CreateScanner(AMatrix, ADraft);
 
       if ADraft then
@@ -789,7 +787,7 @@ begin
     pts := ComputeEllipse(m*FOrigin, m*FXAxis, m*FYAxis);
     If BackVisible then
     begin
-      if BackFill.IsSolid then backScan := nil
+      if BackFill.FillType = vftSolid then backScan := nil
       else backScan := BackFill.CreateScanner(AMatrix, ADraft);
 
       if ADraft then
@@ -1325,8 +1323,7 @@ end;
 
 function TPolylineShape.BackVisible: boolean;
 begin
-  result := BackFill.IsGradient or BackFill.IsTexture or
-            (BackFill.IsSolid and (BackFill.SolidColor.alpha <> 0));
+  result := not BackFill.IsFullyTransparent;
 end;
 
 class function TPolylineShape.Fields: TVectorShapeFields;
@@ -1344,7 +1341,7 @@ begin
   pts := GetCurve(AMatrix);
   if BackVisible then
   begin
-    if BackFill.IsSolid then backScan := nil
+    if BackFill.FillType = vftSolid then backScan := nil
     else backScan := BackFill.CreateScanner(AMatrix, ADraft);
 
     if ADraft then
@@ -1643,8 +1640,7 @@ end;
 
 function TPhongShape.BackVisible: boolean;
 begin
-  result := BackFill.IsGradient or BackFill.IsTexture or
-            (BackFill.IsSolid and (BackFill.SolidColor.alpha <> 0));
+  result := not BackFill.IsFullyTransparent;
 end;
 
 function TPhongShape.AllowShearTransform: boolean;
@@ -1841,7 +1837,7 @@ begin
        shader.LightPositionZ := round(h*3/2);
 
       raster := TBGRABitmap.Create(rectRaster.Width,rectRaster.Height);
-      if BackFill.IsSolid then
+      if BackFill.FillType = vftSolid then
         shader.Draw(raster,map,round(h),-rectRaster.Left,-rectRaster.Top,BackFill.SolidColor)
       else
       begin