Forráskód Böngészése

highlight selected fill

Johann ELSASS 5 éve
szülő
commit
929ed2f3be

+ 6 - 0
lazpaint/lazpaintinstance.pas

@@ -1898,6 +1898,12 @@ procedure TLazPaintInstance.SetChooseColorTarget(const AValue: TColorTarget);
 begin
   if not Assigned(FChooseColor) then exit;
   FChooseColor.ColorTarget:= AValue;
+  if Assigned(FMain) then
+  begin
+    FMain.VectorialFill_Pen.IsTarget := AValue in [ctForeColorSolid..ctForeColorEndGrad];
+    FMain.VectorialFill_Back.IsTarget := AValue in [ctBackColorSolid..ctBackColorEndGrad];
+    FMain.VectorialFill_Outline.IsTarget := AValue in [ctOutlineColorSolid..ctOutlineColorEndGrad];
+  end;
   ColorToFChooseColor;
 end;
 

+ 8 - 4
lazpaint/maintoolbar.inc

@@ -2,7 +2,7 @@
 procedure TFMain.CreateToolbarElements;
 
   procedure InitVectorialFill(vf: TLCVectorialFillControl; grad: TBGRALayerGradientOriginal;
-      lbl: TLabel; pnl: TPanel; mouseMove: TMouseMoveEvent);
+      lbl: TLabel; pnl: TPanel; mouseMove: TMouseMoveEvent; AIsTarget: boolean);
   begin
     vf.PopupMenu := nil;
     vf.VerticalPadding:= DoScaleY(6, OriginalDPI);
@@ -26,6 +26,7 @@ procedure TFMain.CreateToolbarElements;
     pnl.PopupMenu := nil;
     pnl.OnMouseMove:= mouseMove;
     vf.OnMouseMove:= mouseMove;
+    vf.IsTarget:= AIsTarget;
   end;
 
 var
@@ -37,11 +38,14 @@ begin
   Panel_ToolbarBackground.PopupMenu := PopupToolbar;
   Perspective_Repeat.OnClick:=@Perspective_RepeatClick;
   Perspective_TwoPlanes.OnClick := @Perspective_TwoPlanesClick;
-  InitVectorialFill(VectorialFill_Pen, ToolManager.ForeLastGradient, Label_Pen, Panel_PenFill, @VectorialFill_ShowPenFill);
+  InitVectorialFill(VectorialFill_Pen, ToolManager.ForeLastGradient, Label_Pen, Panel_PenFill,
+    @VectorialFill_ShowPenFill, LazPaintInstance.ChooseColorTarget in[ctForeColorSolid..ctForeColorEndGrad]);
   VectorialFill_Pen.SolidColor := ToolManager.ForeColor;
-  InitVectorialFill(VectorialFill_Back, ToolManager.BackLastGradient, Label_Back, Panel_BackFill, @VectorialFill_ShowBackFill);
+  InitVectorialFill(VectorialFill_Back, ToolManager.BackLastGradient, Label_Back, Panel_BackFill,
+    @VectorialFill_ShowBackFill, LazPaintInstance.ChooseColorTarget in[ctBackColorSolid..ctBackColorEndGrad]);
   VectorialFill_Back.SolidColor := ToolManager.BackColor;
-  InitVectorialFill(VectorialFill_Outline, ToolManager.OutlineLastGradient, nil, Panel_OutlineFill, @VectorialFill_ShowOutlineFill);
+  InitVectorialFill(VectorialFill_Outline, ToolManager.OutlineLastGradient, nil, Panel_OutlineFill,
+    @VectorialFill_ShowOutlineFill, LazPaintInstance.ChooseColorTarget in[ctOutlineColorSolid..ctOutlineColorEndGrad]);
   VectorialFill_Outline.SolidColor := ToolManager.OutlineColor;
   Image_SwapColors.OnMouseDown := @Image_SwapColorsMouseDown;
   Tool_DrawShapeBorder.OnClick := @Tool_DrawShapeBorderClick;

+ 13 - 0
lazpaintcontrols/lcvectorialfillcontrol.pas

@@ -34,6 +34,7 @@ type
     function GetGradRepetition: TBGRAGradientRepetition;
     function GetGradStartColor: TBGRAPixel;
     function GetGradType: TGradientType;
+    function GetIsTarget: boolean;
     function GetPreferredSizeAsSize: TSize;
     function GetSolidColor: TBGRAPixel;
     function GetTexOpacity: byte;
@@ -59,6 +60,7 @@ type
     procedure SetGradInterpolation(AValue: TBGRAColorInterpolation);
     procedure SetGradRepetition(AValue: TBGRAGradientRepetition);
     procedure SetGradStartColor(AValue: TBGRAPixel);
+    procedure SetIsTarget(AValue: boolean);
     procedure SetOnChooseColor(AValue: TChooseColorEvent);
     procedure SetOnTextureClick(AValue: TNotifyEvent);
     procedure SetSolidColor(AValue: TBGRAPixel);
@@ -95,6 +97,7 @@ type
     procedure UpdateShapeFill(AShape: TVectorShape; ATarget: TLCFillTarget);
     procedure UpdateFillExceptGeometry(ATargetFill: TVectorialFill);
     property FillType: TVectorialFillType read GetFillType write SetFillType;
+    property IsTarget: boolean read GetIsTarget write SetIsTarget;
     property AverageColor: TBGRAPixel read GetAverageColor;
     property SolidColor: TBGRAPixel read GetSolidColor write SetSolidColor;
     property GradientType: TGradientType read GetGradType write SetGradientType;
@@ -211,6 +214,11 @@ begin
   result := FInterface.GradientType;
 end;
 
+function TLCVectorialFillControl.GetIsTarget: boolean;
+begin
+  result := FInterface.IsTarget;
+end;
+
 function TLCVectorialFillControl.GetPreferredSizeAsSize: TSize;
 begin
   result.cx:= Width;
@@ -329,6 +337,11 @@ begin
   FInterface.GradStartColor := AValue;
 end;
 
+procedure TLCVectorialFillControl.SetIsTarget(AValue: boolean);
+begin
+  FInterface.IsTarget := AValue;
+end;
+
 procedure TLCVectorialFillControl.SetOnChooseColor(AValue: TChooseColorEvent);
 begin
   if FOnChooseColor=AValue then Exit;

+ 17 - 1
lazpaintcontrols/lcvectorialfillinterface.pas

@@ -26,6 +26,7 @@ type
   TVectorialFillInterface = class(TComponent)
   private
     FCanEditGradTexPoints: boolean;
+    FIsTarget: boolean;
     FOnMouseDown: TMouseEvent;
     FOnMouseEnter: TNotifyEvent;
     FOnMouseLeave: TNotifyEvent;
@@ -37,6 +38,7 @@ type
       {%H-}Shift: TShiftState; X, {%H-}Y: Integer);
     procedure SetCanEditGradTexPoints(AValue: boolean);
     procedure SetEditingGradTexPoints(AValue: boolean);
+    procedure SetIsTarget(AValue: boolean);
     procedure SetVerticalPadding(AValue: integer);
     procedure ToolbarMouseDown(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
@@ -182,6 +184,7 @@ type
     function CreateShapeFill(AShape: TVectorShape): TVectorialFill;
     procedure UpdateShapeFill(AShape: TVectorShape; ATarget: TLCFillTarget);
     property FillType: TVectorialFillType read FFillType write SetFillType;
+    property IsTarget: boolean read FIsTarget write SetIsTarget;
     property SolidColor: TBGRAPixel read FSolidColor write SetSolidColor;
     property AverageColor: TBGRAPixel read GetAverageColor;
     property GradientType: TGradientType read FGradType write SetGradientType;
@@ -486,7 +489,13 @@ begin
         grad.Free;
       end;
   end;
-  bmp.Rectangle(bmp.ClipRect, BGRA(0,0,0,128), dmDrawWithTransparency);
+  if IsTarget then
+  begin
+    if bmp.GetPixel(bmp.Width/2,bmp.Height/2).Lightness > 20000 then
+      bmp.Rectangle(bmp.ClipRect, BGRABlack, dmDrawWithTransparency)
+      else bmp.Rectangle(bmp.ClipRect, CSSSilver, dmDrawWithTransparency);
+  end
+    else bmp.Rectangle(bmp.ClipRect, BGRA(0,0,0,128), dmDrawWithTransparency);
   bmpCopy := bmp.MakeBitmapCopy(clBtnFace);
   bmp.Free;
   FPreview.Picture.Assign(bmpCopy);
@@ -1152,6 +1161,13 @@ begin
     FButtonEditGradTexPoints.Down := AValue;
 end;
 
+procedure TVectorialFillInterface.SetIsTarget(AValue: boolean);
+begin
+  if FIsTarget=AValue then Exit;
+  FIsTarget:=AValue;
+  UpdatePreview;
+end;
+
 procedure TVectorialFillInterface.ToolbarMouseEnter(Sender: TObject);
 begin
   If Assigned(FOnMouseEnter) then FOnMouseEnter(self);