Prechádzať zdrojové kódy

disable keyboard input for hidden updown

Johann ELSASS 1 rok pred
rodič
commit
138ba100c4

+ 5 - 0
lazpaint/maintoolbar.inc

@@ -7,6 +7,7 @@ procedure TFMain.CreateToolbarElements;
       lbl: TLabel; pnl: TPanel; mouseMove: TMouseMoveEvent; mouseClick: TNotifyEvent; AIsTarget: boolean);
   begin
     vf.PopupMenu := nil;
+    vf.AllowKeyInput:= false;
     vf.VerticalPadding:= DoScaleY(6, OriginalDPI);
     vf.OnChooseColor :=  @VectorialFill_ChooseColor;
     vf.OnTextureClick := @VectorialFill_TextureClick;
@@ -821,12 +822,15 @@ begin
   VectorialFill_Pen.Height := min(VectorialFill_Pen.ToolIconSize + VectorialFill_Pen.VerticalPadding,
                                Panel_SwapColor.ClientHeight - VectorialFill_Pen.Top - 1);
   VectorialFill_Pen.Tag := 0;
+  VectorialFill_Pen.AllowKeyInput:= false;
   VectorialFill_Back.Height := min(VectorialFill_Back.ToolIconSize + VectorialFill_Back.VerticalPadding,
                                Panel_SwapColor.ClientHeight - VectorialFill_Back.Top - 1);
   VectorialFill_Back.Tag := 0;
+  VectorialFill_Back.AllowKeyInput:= false;
   VectorialFill_Outline.Height := min(VectorialFill_Outline.ToolIconSize + VectorialFill_Outline.VerticalPadding,
                                   Panel_SwapColor.ClientHeight - VectorialFill_Outline.Top - 1);
   VectorialFill_Outline.Tag := 0;
+  VectorialFill_Outline.AllowKeyInput:= false;
   Panel_PenFill.Height := Panel_SwapColor.Height;
   Panel_BackFill.Height := Panel_SwapColor.Height;
   Panel_OutlineFill.Height := Panel_SwapColor.Height;
@@ -1612,6 +1616,7 @@ begin
   AFillControl.Height := AFillControl.PreferredSize.cy;
   APanel.Height := AFillControl.Top + AFillControl.Height + DoScaleY(3, OriginalDPI);
   AFillControl.Tag := 1;
+  AFillControl.AllowKeyInput:= true;
   HideFill(3000, true);
 end;
 

+ 13 - 0
lazpaintcontrols/lcvectorialfillcontrol.pas

@@ -24,6 +24,7 @@ type
   TLCVectorialFillControl = class(TWinControl)
   private
     function GetAllowedFillTypes: TVectorialFillTypes;
+    function GetAllowKeyInput: boolean;
     function GetAverageColor: TBGRAPixel;
     function GetCanAdjustToShape: boolean;
     function GetCanEditGradTexPoints: boolean;
@@ -51,6 +52,7 @@ type
     procedure InterfaceMouseUp(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
     procedure SetAllowedFillTypes(AValue: TVectorialFillTypes);
+    procedure SetAllowKeyInput(AValue: boolean);
     procedure SetCanAdjustToShape(AValue: boolean);
     procedure SetCanEditGradTexPoints(AValue: boolean);
     procedure SetEditingGradTexPoints(AValue: boolean);
@@ -112,6 +114,7 @@ type
     property TextureOpacity: byte read GetTexOpacity write SetTextureOpacity;
     property CanAdjustToShape: boolean read GetCanAdjustToShape write SetCanAdjustToShape;
     property PreferredSize: TSize read GetPreferredSizeAsSize;
+    property AllowKeyInput: boolean read GetAllowKeyInput write SetAllowKeyInput;
   published
     property AutoSize;
     property Align;
@@ -167,6 +170,11 @@ begin
   result := FInterface.AllowedFillTypes;
 end;
 
+function TLCVectorialFillControl.GetAllowKeyInput: boolean;
+begin
+  result := FInterface.AllowKeyInput;
+end;
+
 function TLCVectorialFillControl.GetAverageColor: TBGRAPixel;
 begin
   result := FInterface.AverageColor;
@@ -293,6 +301,11 @@ begin
   FInterface.AllowedFillTypes:= AValue;
 end;
 
+procedure TLCVectorialFillControl.SetAllowKeyInput(AValue: boolean);
+begin
+  FInterface.AllowKeyInput := AValue;
+end;
+
 procedure TLCVectorialFillControl.SetCanAdjustToShape(AValue: boolean);
 begin
   FInterface.CanAdjustToShape := AValue;

+ 22 - 0
lazpaintcontrols/lcvectorialfillinterface.pas

@@ -25,6 +25,7 @@ type
 
   TVectorialFillInterface = class(TComponent)
   private
+    FAllowKeyInput: boolean;
     FCanEditGradTexPoints: boolean;
     FIsTarget: boolean;
     FOnMouseDown: TMouseEvent;
@@ -36,6 +37,7 @@ type
     function GetEditingGradTexPoints: boolean;
     procedure Preview_MouseUp(Sender: TObject; Button: TMouseButton;
       {%H-}Shift: TShiftState; X, {%H-}Y: Integer);
+    procedure SetAllowKeyInput(AValue: boolean);
     procedure SetCanEditGradTexPoints(AValue: boolean);
     procedure SetEditingGradTexPoints(AValue: boolean);
     procedure SetIsTarget(AValue: boolean);
@@ -216,6 +218,7 @@ type
     property VerticalPadding: integer read FVerticalPadding write SetVerticalPadding;
     property PreferredSize: TSize read GetPreferredSize;
     property AllowedFillTypes: TVectorialFillTypes read FAllowedFillTypes write SetAllowedFillTypes;
+    property AllowKeyInput: boolean read FAllowKeyInput write SetAllowKeyInput;
   end;
 
 implementation
@@ -675,6 +678,7 @@ begin
   FUpDownSolidAlpha.Increment:= 15;
   FUpDownSolidAlpha.OnChange:=@UpDownSolidAlphaChange;
   FUpDownSolidAlpha.Hint := rsOpacity;
+  FUpDownSolidAlpha.Enabled:= FAllowKeyInput;
   AddToolbarControl(FToolbar, FUpDownSolidAlpha);
   AttachMouseEvent(FUpDownSolidAlpha);
 end;
@@ -707,6 +711,7 @@ begin
   FUpDownStartAlpha.Increment:= 15;
   FUpDownStartAlpha.OnChange:=@UpDownStartAlphaChange;
   FUpDownStartAlpha.Hint := rsStartOpacity;
+  FUpDownStartAlpha.Enabled:= FAllowKeyInput;
   AddToolbarControl(FToolbar, FUpDownStartAlpha);
   AttachMouseEvent(FUpDownStartAlpha);
   FButtonSwapColor := AddToolbarButton(FToolbar, rsSwapColors, 23, @ButtonSwapColorClick);
@@ -725,6 +730,7 @@ begin
   FUpDownEndAlpha.Increment:= 15;
   FUpDownEndAlpha.OnChange:=@UpDownEndAlphaChange;
   FUpDownEndAlpha.Hint := rsEndOpacity;
+  FUpDownEndAlpha.Enabled:= FAllowKeyInput;
   AddToolbarControl(FToolbar, FUpDownEndAlpha);
   AttachMouseEvent(FUpDownEndAlpha);
 
@@ -767,6 +773,7 @@ begin
   FUpDownTexAlpha.Increment:= 15;
   FUpDownTexAlpha.OnChange:=@UpDownTexAlphaChange;
   FUpDownTexAlpha.Hint := rsOpacity;
+  FUpDownTexAlpha.Enabled:= FAllowKeyInput;
   AddToolbarControl(FToolbar, FUpDownTexAlpha);
   AttachMouseEvent(FUpDownTexAlpha);
   FButtonLoadTexture := AddToolbarButton(FToolbar, rsLoadTexture+'...', 22, @ButtonLoadTextureClick);
@@ -819,6 +826,7 @@ var
 begin
   FContainer := nil;
 
+  FAllowKeyInput:= true;
   FAllowedFillTypes := [vftNone, vftSolid, vftGradient, vftTexture];
   FFillType:= vftSolid;
   FSolidColor:= BGRAWhite;
@@ -1146,6 +1154,20 @@ begin
   end;
 end;
 
+procedure TVectorialFillInterface.SetAllowKeyInput(AValue: boolean);
+begin
+  if FAllowKeyInput=AValue then Exit;
+  FAllowKeyInput:=AValue;
+  if Assigned(FUpDownStartAlpha) then
+    FUpDownStartAlpha.Enabled:= AValue;
+  if Assigned(FUpDownEndAlpha) then
+    FUpDownEndAlpha.Enabled:= AValue;
+  if Assigned(FUpDownSolidAlpha) then
+    FUpDownSolidAlpha.Enabled:= AValue;
+  if Assigned(FUpDownTexAlpha) then
+    FUpDownTexAlpha.Enabled:= AValue;
+end;
+
 procedure TVectorialFillInterface.EditGradTextPointsClick(Sender: TObject);
 begin
   if Assigned(FOnEditGradTexPoints) then FOnEditGradTexPoints(self);