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

Added the Preview functionality

Lulu 2 жил өмнө
parent
commit
2d742ef065

+ 16 - 6
lazpaint/dialog/filter/upixelate.lfm

@@ -1,6 +1,6 @@
 object FPixelate: TFPixelate
   Left = 607
-  Height = 125
+  Height = 144
   Top = 313
   Width = 179
   AutoSize = True
@@ -13,12 +13,12 @@ object FPixelate: TFPixelate
   ChildSizing.VerticalSpacing = 8
   ChildSizing.Layout = cclLeftToRightThenTopToBottom
   ChildSizing.ControlsPerLine = 1
-  ClientHeight = 125
+  ClientHeight = 144
   ClientWidth = 179
   OnCreate = FormCreate
   OnShow = FormShow
   Position = poOwnerFormCenter
-  LCLVersion = '1.6.0.4'
+  LCLVersion = '2.2.4.0'
   object Panel1: TPanel
     Left = 8
     Height = 23
@@ -35,13 +35,13 @@ object FPixelate: TFPixelate
       Left = 0
       Height = 23
       Top = 0
-      Width = 52
+      Width = 53
       Caption = 'Pixel size :'
       Layout = tlCenter
       ParentColor = False
     end
     object SpinEdit_PixelSize: TSpinEdit
-      Left = 60
+      Left = 61
       Height = 23
       Top = 0
       Width = 65
@@ -85,10 +85,20 @@ object FPixelate: TFPixelate
       TabOrder = 0
     end
   end
+  object CheckBox_Preview: TCheckBox
+    Left = 8
+    Height = 19
+    Top = 70
+    Width = 152
+    Checked = True
+    OnChange = CheckBox_PreviewChange
+    State = cbChecked
+    TabOrder = 3
+  end
   object Panel3: TPanel
     Left = 8
     Height = 25
-    Top = 70
+    Top = 97
     Width = 152
     BevelOuter = bvNone
     ChildSizing.HorizontalSpacing = 8

+ 20 - 2
lazpaint/dialog/filter/upixelate.pas

@@ -17,6 +17,7 @@ type
   TFPixelate = class(TForm)
     Button_Cancel: TButton;
     Button_OK: TButton;
+    CheckBox_Preview: TCheckBox;
     ComboBox_Quality: TComboBox;
     Label_Quality: TLabel;
     Label_PixelSize: TLabel;
@@ -25,6 +26,7 @@ type
     Panel3: TPanel;
     SpinEdit_PixelSize: TSpinEdit;
     procedure Button_OKClick(Sender: TObject);
+    procedure CheckBox_PreviewChange(Sender: TObject);
     procedure ComboBox_QualityChange(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure FormShow(Sender: TObject);
@@ -97,6 +99,8 @@ procedure TFPixelate.Button_OKClick(Sender: TObject);
 var
   qualityStr: TCaption;
 begin
+  if not CheckBox_Preview.Checked then PreviewNeeded;
+
   FFilterConnector.ValidateAction;
   FFilterConnector.LazPaintInstance.Config.SetDefaultPixelateSize(SpinEdit_PixelSize.Value);
   qualityStr := ComboBox_Quality.Text;
@@ -109,9 +113,19 @@ begin
   ModalResult := mrOK;
 end;
 
+procedure TFPixelate.CheckBox_PreviewChange(Sender: TObject);
+begin
+  if FInitializing then exit;
+  if CheckBox_Preview.Checked then
+    PreviewNeeded
+  else
+   FFilterConnector.RestoreBackup;
+end;
+
 procedure TFPixelate.ComboBox_QualityChange(Sender: TObject);
 begin
-  if not FInitializing then PreviewNeeded;
+  if not FInitializing and
+    CheckBox_Preview.Checked then PreviewNeeded;
 end;
 
 procedure TFPixelate.FormShow(Sender: TObject);
@@ -123,7 +137,8 @@ end;
 
 procedure TFPixelate.SpinEdit_PixelSizeChange(Sender: TObject);
 begin
-  if not FInitializing then PreviewNeeded;
+  if not FInitializing and
+    CheckBox_Preview.Checked then PreviewNeeded;
 end;
 
 function TFPixelate.ComputeFilteredLayer: TBGRABitmap;
@@ -155,6 +170,9 @@ begin
     qualityStr := '';
 
   ComboBox_Quality.ItemIndex := ComboBox_Quality.Items.IndexOf(qualityStr);
+
+  CheckBox_Preview.Checked := True;
+  CheckBox_Preview.Caption := rsPreview;
   FInitializing := false;
 end;