Преглед изворни кода

Added preview functionality for dialog Colorize

Lulu пре 2 година
родитељ
комит
3b0ca5e06b

+ 31 - 24
lazpaint/dialog/color/ucolorize.lfm

@@ -1,23 +1,23 @@
 object FColorize: TFColorize
   Left = 476
-  Height = 174
+  Height = 193
   Top = 173
   Width = 489
   BorderIcons = [biSystemMenu]
   BorderStyle = bsDialog
   Caption = 'Colorize'
-  ClientHeight = 174
+  ClientHeight = 193
   ClientWidth = 489
   Font.Height = -12
   OnCreate = FormCreate
   OnShow = FormShow
   Position = poOwnerFormCenter
-  LCLVersion = '2.0.2.0'
+  LCLVersion = '2.2.4.0'
   object Label_Hue: TLabel
     Left = 8
     Height = 15
     Top = 10
-    Width = 24
+    Width = 22
     Caption = 'Hue'
     ParentColor = False
   end
@@ -25,7 +25,7 @@ object FColorize: TFColorize
     Left = 8
     Height = 15
     Top = 48
-    Width = 57
+    Width = 52
     Caption = 'Colorness'
     ParentColor = False
   end
@@ -50,10 +50,10 @@ object FColorize: TFColorize
   object Button_OK: TButton
     Left = 173
     Height = 22
-    Top = 143
+    Top = 162
     Width = 59
     Anchors = [akLeft, akBottom]
-    Caption = 'OK'
+    Caption = 'rsOK'
     Default = True
     ModalResult = 1
     OnClick = Button_OKClick
@@ -62,43 +62,39 @@ object FColorize: TFColorize
   object Button_Cancel: TButton
     Left = 237
     Height = 22
-    Top = 143
+    Top = 162
     Width = 72
     Anchors = [akLeft, akBottom]
     Cancel = True
-    Caption = 'Cancel'
+    Caption = 'rsCancel'
     ModalResult = 2
     TabOrder = 3
   end
   object FloatSpinEdit_Hue: TFloatSpinEdit
     Left = 408
-    Height = 27
+    Height = 23
     Top = 7
     Width = 72
     DecimalPlaces = 1
     MaxValue = 360
-    MinValue = 0
     OnChange = FloatSpinEdit_HueChange
     TabOrder = 4
-    Value = 0
   end
   object FloatSpinEdit_Saturation: TFloatSpinEdit
     Left = 408
-    Height = 27
+    Height = 23
     Top = 43
     Width = 72
     DecimalPlaces = 3
     MaxValue = 1
-    MinValue = 0
     OnChange = FloatSpinEdit_SaturationChange
     TabOrder = 5
-    Value = 0
   end
   object CheckBox_GSBA: TCheckBox
     Left = 8
-    Height = 23
+    Height = 19
     Top = 80
-    Width = 197
+    Width = 168
     Caption = 'Corrected hue and lightness'
     OnChange = CheckBox_GSBAChange
     TabOrder = 6
@@ -117,8 +113,8 @@ object FColorize: TFColorize
     object Label_Preset: TLabel
       Left = 0
       Height = 15
-      Top = 7
-      Width = 37
+      Top = 4
+      Width = 32
       AutoSize = False
       BorderSpacing.Right = 6
       BorderSpacing.CellAlignVertical = ccaCenter
@@ -126,21 +122,21 @@ object FColorize: TFColorize
       ParentColor = False
     end
     object Combo_Preset: TComboBox
-      Left = 43
-      Height = 29
+      Left = 38
+      Height = 23
       Top = 0
       Width = 100
       BorderSpacing.Right = 6
       BorderSpacing.CellAlignVertical = ccaCenter
-      ItemHeight = 0
+      ItemHeight = 15
       OnChange = Combo_PresetChange
       Style = csDropDownList
       TabOrder = 0
     end
     object ToolBar_AddRemove: TToolBar
-      Left = 149
+      Left = 144
       Height = 22
-      Top = 3
+      Top = 0
       Width = 47
       Align = alNone
       BorderSpacing.CellAlignVertical = ccaCenter
@@ -160,4 +156,15 @@ object FColorize: TFColorize
       end
     end
   end
+  object CheckBox_Preview: TCheckBox
+    Left = 8
+    Height = 19
+    Top = 136
+    Width = 70
+    Caption = 'rsPreview'
+    Checked = True
+    OnChange = CheckBox_PreviewChange
+    State = cbChecked
+    TabOrder = 8
+  end
 end

+ 4 - 3
lazpaint/dialog/color/ucolorize.lrj

@@ -2,8 +2,9 @@
 {"hash":104240549,"name":"tfcolorize.caption","sourcebytes":[67,111,108,111,114,105,122,101],"value":"Colorize"},
 {"hash":20405,"name":"tfcolorize.label_hue.caption","sourcebytes":[72,117,101],"value":"Hue"},
 {"hash":57214659,"name":"tfcolorize.label_colorness.caption","sourcebytes":[67,111,108,111,114,110,101,115,115],"value":"Colorness"},
-{"hash":1339,"name":"tfcolorize.button_ok.caption","sourcebytes":[79,75],"value":"OK"},
-{"hash":77089212,"name":"tfcolorize.button_cancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"},
+{"hash":497723,"name":"tfcolorize.button_ok.caption","sourcebytes":[114,115,79,75],"value":"rsOK"},
+{"hash":127421996,"name":"tfcolorize.button_cancel.caption","sourcebytes":[114,115,67,97,110,99,101,108],"value":"rsCancel"},
 {"hash":72944099,"name":"tfcolorize.checkbox_gsba.caption","sourcebytes":[67,111,114,114,101,99,116,101,100,32,104,117,101,32,97,110,100,32,108,105,103,104,116,110,101,115,115],"value":"Corrected hue and lightness"},
-{"hash":91802052,"name":"tfcolorize.label_preset.caption","sourcebytes":[80,114,101,115,101,116],"value":"Preset"}
+{"hash":91802052,"name":"tfcolorize.label_preset.caption","sourcebytes":[80,114,101,115,101,116],"value":"Preset"},
+{"hash":126662215,"name":"tfcolorize.checkbox_preview.caption","sourcebytes":[114,115,80,114,101,118,105,101,119],"value":"rsPreview"}
 ]}

+ 21 - 0
lazpaint/dialog/color/ucolorize.pas

@@ -18,6 +18,7 @@ type
     Button_Cancel: TButton;
     Button_OK: TButton;
     CheckBox_GSBA: TCheckBox;
+    CheckBox_Preview: TCheckBox;
     Combo_Preset: TComboBox;
     FloatSpinEdit_Hue: TFloatSpinEdit;
     FloatSpinEdit_Saturation: TFloatSpinEdit;
@@ -32,6 +33,7 @@ type
     TrackBar_Saturation: TTrackBar;
     procedure Button_OKClick(Sender: TObject);
     procedure CheckBox_GSBAChange(Sender: TObject);
+    procedure CheckBox_PreviewChange(Sender: TObject);
     procedure Combo_PresetChange(Sender: TObject);
     procedure FloatSpinEdit_HueChange(Sender: TObject);
     procedure FloatSpinEdit_SaturationChange(Sender: TObject);
@@ -114,6 +116,15 @@ begin
   end;
 end;
 
+procedure TFColorize.CheckBox_PreviewChange(Sender: TObject);
+begin
+  if not FInitialized then exit;
+  if CheckBox_Preview.Checked then
+    ApplyChosenColor
+  else
+   FFilterConnector.RestoreBackup;
+end;
+
 procedure TFColorize.Combo_PresetChange(Sender: TObject);
 begin
   if FInComboPreset then exit;
@@ -266,6 +277,12 @@ begin
   if AParams.IsDefined('Correction') then
     CheckBox_GSBA.Checked := AParams.Booleans['Correction'];
   UpdateSpinEdit;
+
+  Button_OK.Caption := rsOK;
+  Button_Cancel.Caption := rsCancel;
+  CheckBox_Preview.Caption := rsPreview;
+  CheckBox_Preview.Checked := True;
+  CheckBox_Preview.Enabled := True;
   FInitialized := OldInitialized;
 end;
 
@@ -359,6 +376,10 @@ end;
 procedure TFColorize.ApplyChosenColor;
 begin
   Colorize(FFilterConnector, ChosenHueDegF, ChosenSatF, CheckBox_GSBA.Checked);
+
+  FInitialized := False;
+  CheckBox_Preview.Checked := True;
+  FInitialized := True;
 end;
 
 {$R *.lfm}