2
0
Эх сурвалжийг харах

outline width at generic shape level

Unknown 6 жил өмнө
parent
commit
04a683cb7b

+ 27 - 2
lazpaintcontrols/lcvectororiginal.pas

@@ -11,6 +11,7 @@ uses
 const
   InfiniteRect : TRect = (Left: -MaxLongInt; Top: -MaxLongInt; Right: MaxLongInt; Bottom: MaxLongInt);
   EmptyTextureId = 0;
+  DefaultShapeOutlineWidth = 2;
 
 type
   TVectorOriginal = class;
@@ -40,6 +41,7 @@ type
     FBoundsBeforeUpdate: TRectF;
     FPenFill, FBackFill, FOutlineFill: TVectorialFill;
     FPenWidth: single;
+    FOutlineWidth: single;
     FStroker: TBGRAPenStroker;
     FUsermode: TVectorShapeUsermode;
     FContainer: TVectorOriginal;
@@ -50,6 +52,7 @@ type
     function GetFill(var AFillVariable: TVectorialFill): TVectorialFill;
     procedure SetFill(var AFillVariable: TVectorialFill; AValue: TVectorialFill);
     procedure SetId(AValue: integer);
+    procedure SetOutlineWidth(AValue: single);
   protected
     procedure BeginUpdate;
     procedure EndUpdate;
@@ -121,6 +124,7 @@ type
     property OutlineFill: TVectorialFill read GetOutlineFill write SetOutlineFill;
     property PenWidth: single read GetPenWidth write SetPenWidth;
     property PenStyle: TBGRAPenStyle read GetPenStyle write SetPenStyle;
+    property OutlineWidth: single read FOutlineWidth write SetOutlineWidth;
     property JoinStyle: TPenJoinStyle read GetJoinStyle write SetJoinStyle;
     property Usermode: TVectorShapeUsermode read FUsermode write SetUsermode;
     property Container: TVectorOriginal read FContainer write SetContainer;
@@ -727,6 +731,15 @@ begin
   FId:=AValue;
 end;
 
+procedure TVectorShape.SetOutlineWidth(AValue: single);
+begin
+  if AValue < 0 then AValue := 0;
+  if FOutlineWidth=AValue then Exit;
+  BeginUpdate;
+  FOutlineWidth:=AValue;
+  EndUpdate;
+end;
+
 procedure TVectorShape.SetOutlineFill(AValue: TVectorialFill);
 begin
   SetFill(FOutlineFill, AValue);
@@ -955,6 +968,7 @@ begin
   FContainer := AContainer;
   FPenFill := nil;
   FPenWidth := 1;
+  FOutlineWidth := 2;
   FStroker := nil;
   FOnChange := nil;
   FOnEditingChange := nil;
@@ -1015,7 +1029,11 @@ begin
       else JoinStyle := pjsMiter;
       end;
     if vsfBackFill in f then LoadFill(AStorage, 'back', FBackFill);
-    if vsfOutlineFill in f then LoadFill(AStorage, 'outline', FOutlineFill);
+    if vsfOutlineFill in f then
+    begin
+      LoadFill(AStorage, 'outline', FOutlineFill);
+      OutlineWidth := AStorage.FloatDef['outline-width', 2];
+    end;
     EndUpdate;
   end;
 end;
@@ -1037,7 +1055,14 @@ begin
     else AStorage.RawString['join-style'] := 'miter';
     end;
   if vsfBackFill in f then SaveFill(AStorage, 'back', FBackFill);
-  if vsfOutlineFill in f then SaveFill(AStorage, 'outline', FOutlineFill);
+  if vsfOutlineFill in f then
+  begin
+    SaveFill(AStorage, 'outline', FOutlineFill);
+    if OutlineFill.FillType <> vftNone then
+      AStorage.Float['outline-width'] := FOutlineWidth
+    else
+      AStorage.RemoveAttribute('outline-width');
+  end;
 end;
 
 procedure TVectorShape.MouseMove(Shift: TShiftState; X, Y: single; var

+ 0 - 20
lazpaintcontrols/lcvectortextshapes.pas

@@ -18,7 +18,6 @@ type
     FFontEmHeight: single;
     FFontName: string;
     FFontStyle: TFontStyles;
-    FOutlineWidth: single;
     FText: string;
     FSelStart,FSelEnd: integer;
     FMouseSelecting: boolean;
@@ -30,7 +29,6 @@ type
     procedure SetFontName(AValue: string);
     procedure SetFontStyle(AValue: TFontStyles);
     procedure SetBidiParagraphAlignment(AValue: TBidiTextAlignment);
-    procedure SetOutlineWidth(AValue: single);
     procedure SetParagraphAlignment(AValue: TAlignment);
     procedure SetText(AValue: string);
     procedure SetVertAlign(AValue: TTextLayout);
@@ -89,7 +87,6 @@ type
     property BidiParagraphAlignment: TBidiTextAlignment read GetBidiParagraphAlignment write SetBidiParagraphAlignment;
     property ParagraphAlignment: TAlignment read GetParagraphAlignment write SetParagraphAlignment;
     property VerticalAlignment: TTextLayout read FVertAlign write SetVertAlign;
-    property OutlineWidth: single read FOutlineWidth write SetOutlineWidth;
   end;
 
 function FontStyleToStr(AStyle: TFontStyles): string;
@@ -249,15 +246,6 @@ begin
   if needUpdate then EndUpdate;
 end;
 
-procedure TTextShape.SetOutlineWidth(AValue: single);
-begin
-  if AValue < 0 then AValue := 0;
-  if FOutlineWidth=AValue then Exit;
-  BeginUpdate;
-  FOutlineWidth:=AValue;
-  EndUpdate;
-end;
-
 procedure TTextShape.SetParagraphAlignment(AValue: TAlignment);
 var
   tl: TBidiTextLayout;
@@ -554,7 +542,6 @@ begin
   FSelStart := 0;
   FSelEnd := 0;
   FGlobalMatrix := AffineMatrixIdentity;
-  FOutlineWidth := 2;
 end;
 
 procedure TTextShape.QuickDefine(const APoint1, APoint2: TPointF);
@@ -614,8 +601,6 @@ begin
   end else
     SetDefaultFont;
 
-  OutlineWidth := AStorage.FloatDef['outline-width', 2];
-
   tl := GetTextLayout;
   paraAlignList := TStringList.Create;
   paraAlignList.DelimitedText:= AStorage.RawString['paragraph-align'];
@@ -649,11 +634,6 @@ begin
   font.RawString['style'] := FontStyleToStr(FontStyle);
   font.Free;
 
-  if OutlineFill.FillType <> vftNone then
-    AStorage.Float['outline-width'] := FOutlineWidth
-  else
-    AStorage.RemoveAttribute('outline-width');
-
   tl := GetTextLayout;
   paraAlignList := TStringList.Create;
   for i := 0 to tl.ParagraphCount-1 do