Browse Source

text update editing

Unknown 6 years ago
parent
commit
4768c01061
2 changed files with 39 additions and 18 deletions
  1. 25 4
      lazpaintcontrols/lcvectororiginal.pas
  2. 14 14
      lazpaintcontrols/lcvectortextshapes.pas

+ 25 - 4
lazpaintcontrols/lcvectororiginal.pas

@@ -36,7 +36,7 @@ type
     FRenderIteration: integer; // increased at each BeginUpdate
     FOnChange: TShapeChangeEvent;
     FOnEditingChange: TShapeEditingChangeEvent;
-    FUpdateCount: integer;
+    FUpdateCount, FUpdateEditingCount: integer;
     FBoundsBeforeUpdate: TRectF;
     FPenFill, FBackFill, FOutlineFill: TVectorialFill;
     FPenWidth: single;
@@ -53,6 +53,8 @@ type
   protected
     procedure BeginUpdate;
     procedure EndUpdate;
+    procedure BeginEditingUpdate;
+    procedure EndEditingUpdate;
     procedure DoOnChange; virtual;
     function GetPenColor: TBGRAPixel; virtual;
     function GetPenWidth: single; virtual;
@@ -541,8 +543,9 @@ end;
 procedure TVectorShape.SetUsermode(AValue: TVectorShapeUsermode);
 begin
   if FUsermode=AValue then Exit;
+  BeginEditingUpdate;
   FUsermode:=AValue;
-  if Assigned(FOnEditingChange) then FOnEditingChange(self);
+  EndEditingUpdate;
 end;
 
 procedure TVectorShape.LoadFill(AStorage: TBGRACustomOriginalStorage;
@@ -751,19 +754,37 @@ begin
     FBoundsBeforeUpdate := GetRenderBounds(InfiniteRect, AffineMatrixIdentity);
     Inc(FRenderIteration);
   end;
-  FUpdateCount += 1;
+  inc(FUpdateCount);
 end;
 
 procedure TVectorShape.EndUpdate;
 begin
   if FUpdateCount > 0 then
   begin
-    FUpdateCount -= 1;
+    dec(FUpdateCount);
     if FUpdateCount = 0 then
       DoOnChange;
   end;
 end;
 
+procedure TVectorShape.BeginEditingUpdate;
+begin
+  inc(FUpdateEditingCount);
+end;
+
+procedure TVectorShape.EndEditingUpdate;
+begin
+  if FUpdateEditingCount > 0 then
+  begin
+    dec(FUpdateEditingCount);
+    if FUpdateEditingCount = 0 then
+    begin
+      if Assigned(FOnEditingChange) then
+        FOnEditingChange(self);
+    end;
+  end;
+end;
+
 procedure TVectorShape.DoOnChange;
 var
   boundsAfter: TRectF;

+ 14 - 14
lazpaintcontrols/lcvectortextshapes.pas

@@ -531,11 +531,11 @@ begin
   begin
     if (newPos <> FSelEnd) or (not AExtend and (FSelStart <> FSelEnd)) or (UserMode <> vsuEditText) then
     begin
-      BeginUpdate;
+      BeginEditingUpdate;
       FSelEnd:= newPos;
       if not AExtend or (UserMode <> vsuEditText) then FSelStart:= FSelEnd;
       UserMode := vsuEditText;
-      EndUpdate;
+      EndEditingUpdate;
     end;
   end;
 end;
@@ -1021,18 +1021,18 @@ begin
     tl := GetTextLayout;
     if (Key = skLeft) xor tl.ParagraphRightToLeft[tl.GetParagraphAt(FSelEnd)] then
     begin
-      BeginUpdate;
+      BeginEditingUpdate;
       if FSelEnd > 0 then
         Dec(FSelEnd, tl.IncludeNonSpacingCharsBefore(FSelEnd,1) );
       if not (ssShift in Shift) then FSelStart := FSelEnd;
-      EndUpdate;
+      EndEditingUpdate;
     end else
     begin
-      BeginUpdate;
+      BeginEditingUpdate;
       if FSelEnd < tl.CharCount then
         Inc(FSelEnd, tl.IncludeNonSpacingChars(FSelEnd,1) );
       if not (ssShift in Shift) then FSelStart := FSelEnd;
-      EndUpdate;
+      EndEditingUpdate;
     end;
     AHandled := true;
   end else
@@ -1045,17 +1045,17 @@ begin
       newPos := tl.FindTextBelow(FSelEnd);
     if (newPos <> -1) or (not (ssShift in Shift) and (FSelStart <> FSelEnd)) then
     begin
-      BeginUpdate;
+      BeginEditingUpdate;
       FSelEnd := newPos;
       if not (ssShift in Shift) then FSelStart := FSelEnd;
-      EndUpdate;
+      EndEditingUpdate;
     end;
     AHandled:= true;
   end else
   if Key = skHome then
   begin
     tl := GetTextLayout;
-    BeginUpdate;
+    BeginEditingUpdate;
     if ssCtrl in Shift then
       FSelEnd := 0
     else
@@ -1064,13 +1064,13 @@ begin
       FSelEnd := tl.ParagraphStartIndex[idxPara];
     end;
     if not (ssShift in Shift) then FSelStart := FSelEnd;
-    EndUpdate;
+    EndEditingUpdate;
     AHandled := true;
   end else
   if Key = skEnd then
   begin
     tl := GetTextLayout;
-    BeginUpdate;
+    BeginEditingUpdate;
     if ssCtrl in Shift then
       FSelEnd := tl.CharCount
     else
@@ -1079,7 +1079,7 @@ begin
       FSelEnd := tl.ParagraphEndIndexBeforeParagraphSeparator[idxPara];
     end;
     if not (ssShift in Shift) then FSelStart := FSelEnd;
-    EndUpdate;
+    EndEditingUpdate;
     AHandled := true;
   end else
   if Key = skReturn then
@@ -1127,10 +1127,10 @@ begin
   end else
   if (Key = skA) and (ssCtrl in Shift) then
   begin
-    BeginUpdate;
+    BeginEditingUpdate;
     FSelStart:= 0;
     FSelEnd:= GetTextLayout.CharCount;
-    EndUpdate;
+    EndEditingUpdate;
   end;
 end;