Parcourir la source

fix colorize layout

johann il y a 5 ans
Parent
commit
6a6b2b51f1
2 fichiers modifiés avec 93 ajouts et 79 suppressions
  1. 67 54
      lazpaint/dialog/color/ucolorize.lfm
  2. 26 25
      lazpaint/dialog/color/ucolorize.pas

+ 67 - 54
lazpaint/dialog/color/ucolorize.lfm

@@ -1,37 +1,37 @@
 object FColorize: TFColorize
   Left = 476
-  Height = 140
+  Height = 174
   Top = 173
   Width = 489
   BorderIcons = [biSystemMenu]
   BorderStyle = bsDialog
   Caption = 'Colorize'
-  ClientHeight = 140
+  ClientHeight = 174
   ClientWidth = 489
   Font.Height = -12
   OnCreate = FormCreate
   OnShow = FormShow
   Position = poOwnerFormCenter
-  LCLVersion = '1.0.10.0'
+  LCLVersion = '2.0.2.0'
   object Label_Hue: TLabel
     Left = 8
-    Height = 16
+    Height = 15
     Top = 10
-    Width = 23
+    Width = 24
     Caption = 'Hue'
     ParentColor = False
   end
   object Label_Colorness: TLabel
     Left = 8
-    Height = 16
+    Height = 15
     Top = 48
-    Width = 53
+    Width = 57
     Caption = 'Colorness'
     ParentColor = False
   end
   object TrackBar_Hue: TTrackBar
     Left = 69
-    Height = 30
+    Height = 38
     Top = 8
     Width = 328
     OnChange = TrackBar_Change
@@ -40,7 +40,7 @@ object FColorize: TFColorize
   end
   object TrackBar_Saturation: TTrackBar
     Left = 69
-    Height = 30
+    Height = 38
     Top = 44
     Width = 328
     OnChange = TrackBar_Change
@@ -50,7 +50,7 @@ object FColorize: TFColorize
   object Button_OK: TButton
     Left = 173
     Height = 22
-    Top = 109
+    Top = 143
     Width = 59
     Anchors = [akLeft, akBottom]
     Caption = 'OK'
@@ -62,7 +62,7 @@ object FColorize: TFColorize
   object Button_Cancel: TButton
     Left = 237
     Height = 22
-    Top = 109
+    Top = 143
     Width = 72
     Anchors = [akLeft, akBottom]
     Cancel = True
@@ -72,11 +72,10 @@ object FColorize: TFColorize
   end
   object FloatSpinEdit_Hue: TFloatSpinEdit
     Left = 408
-    Height = 23
+    Height = 27
     Top = 7
     Width = 72
     DecimalPlaces = 1
-    Increment = 1
     MaxValue = 360
     MinValue = 0
     OnChange = FloatSpinEdit_HueChange
@@ -85,11 +84,10 @@ object FColorize: TFColorize
   end
   object FloatSpinEdit_Saturation: TFloatSpinEdit
     Left = 408
-    Height = 23
+    Height = 27
     Top = 43
     Width = 72
     DecimalPlaces = 3
-    Increment = 1
     MaxValue = 1
     MinValue = 0
     OnChange = FloatSpinEdit_SaturationChange
@@ -98,53 +96,68 @@ object FColorize: TFColorize
   end
   object CheckBox_GSBA: TCheckBox
     Left = 8
-    Height = 19
+    Height = 23
     Top = 80
-    Width = 168
+    Width = 197
     Caption = 'Corrected hue and lightness'
     OnChange = CheckBox_GSBAChange
     TabOrder = 6
   end
-  object Label_Preset: TLabel
-    Left = 184
-    Height = 16
-    Top = 83
-    Width = 80
-    Alignment = taRightJustify
-    AutoSize = False
-    Caption = 'Preset'
-    ParentColor = False
-  end
-  object Combo_Preset: TComboBox
-    Left = 272
-    Height = 23
-    Top = 80
-    Width = 154
-    ItemHeight = 15
-    OnChange = Combo_PresetChange
-    Style = csDropDownList
+  object Panel1: TPanel
+    Left = 8
+    Height = 32
+    Top = 104
+    Width = 474
+    Anchors = [akTop, akLeft, akRight]
+    BevelOuter = bvNone
+    ChildSizing.Layout = cclTopToBottomThenLeftToRight
+    ClientHeight = 32
+    ClientWidth = 474
     TabOrder = 7
-  end
-  object ToolBar8: TToolBar
-    Left = 432
-    Height = 24
-    Top = 80
-    Width = 48
-    Align = alNone
-    EdgeBorders = []
-    Images = FMain.ImageList1
-    TabOrder = 8
-    object ToolButton23: TToolButton
-      Left = 1
-      Top = 0
-      ImageIndex = 81
-      OnClick = ToolButton23Click
+    object Label_Preset: TLabel
+      Left = 0
+      Height = 15
+      Top = 7
+      Width = 37
+      AutoSize = False
+      BorderSpacing.Right = 6
+      BorderSpacing.CellAlignVertical = ccaCenter
+      Caption = 'Preset'
+      ParentColor = False
     end
-    object ToolButton1: TToolButton
-      Left = 24
+    object Combo_Preset: TComboBox
+      Left = 43
+      Height = 29
       Top = 0
-      ImageIndex = 39
-      OnClick = ToolButton1Click
+      Width = 100
+      BorderSpacing.Right = 6
+      BorderSpacing.CellAlignVertical = ccaCenter
+      ItemHeight = 0
+      OnChange = Combo_PresetChange
+      Style = csDropDownList
+      TabOrder = 0
+    end
+    object ToolBar_AddRemove: TToolBar
+      Left = 149
+      Height = 22
+      Top = 3
+      Width = 47
+      Align = alNone
+      BorderSpacing.CellAlignVertical = ccaCenter
+      EdgeBorders = []
+      TabOrder = 1
+      object ToolButton_Add: TToolButton
+        Left = 1
+        Top = 0
+        ImageIndex = 81
+        OnClick = ToolButton_AddClick
+      end
+      object ToolButton_Remove: TToolButton
+        Left = 24
+        Top = 0
+        ImageIndex = 39
+        OnClick = ToolButton_RemoveClick
+      end
     end
   end
 end

+ 26 - 25
lazpaint/dialog/color/ucolorize.pas

@@ -6,7 +6,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
-  StdCtrls, ComCtrls, Spin, BGRABitmap, LCScaleDPI, lazpainttype,
+  StdCtrls, ComCtrls, Spin, ExtCtrls, BGRABitmap, LCScaleDPI, lazpainttype,
   ufilterconnector, uscripting;
 
 type
@@ -20,12 +20,13 @@ type
     Combo_Preset: TComboBox;
     FloatSpinEdit_Hue: TFloatSpinEdit;
     FloatSpinEdit_Saturation: TFloatSpinEdit;
-    Label_Preset: TLabel;
     Label_Hue: TLabel;
     Label_Colorness: TLabel;
-    ToolBar8: TToolBar;
-    ToolButton1: TToolButton;
-    ToolButton23: TToolButton;
+    Label_Preset: TLabel;
+    Panel1: TPanel;
+    ToolBar_AddRemove: TToolBar;
+    ToolButton_Remove: TToolButton;
+    ToolButton_Add: TToolButton;
     TrackBar_Hue: TTrackBar;
     TrackBar_Saturation: TTrackBar;
     procedure Button_OKClick(Sender: TObject);
@@ -35,8 +36,8 @@ type
     procedure FloatSpinEdit_SaturationChange(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure FormShow(Sender: TObject);
-    procedure ToolButton1Click(Sender: TObject);
-    procedure ToolButton23Click(Sender: TObject);
+    procedure ToolButton_RemoveClick(Sender: TObject);
+    procedure ToolButton_AddClick(Sender: TObject);
     procedure TrackBar_Change(Sender: TObject);
   private
     { private declarations }
@@ -45,15 +46,14 @@ type
     FFilterConnector: TFilterConnector;
     FUpdatingSpinEdit,FInComboPreset: boolean;
     FSelectedPresetName: string;
-    procedure AdjustLabels(ALabel1, ALabel2: TLabel; ATrack1, ATrack2: TTrackBar
-      );
+    procedure AdjustLabels(ALabel1, ALabel2: TLabel; ATrack1, ATrack2: TTrackBar);
     function GetChosenHue: Word;
-    function GetChosenHueF: double;
+    function GetChosenHueDegF: double;
     function GetChosenSatF: double;
     function GetChosenSaturation: Word;
     procedure OnTryStopAction({%H-}sender: TFilterConnector);
     procedure SetChosenHue(AValue: Word);
-    procedure SetChosenHueF(AValue: double);
+    procedure SetChosenHueDegF(AValue: double);
     procedure SetChosenSatF(AValue: double);
     procedure SetChosenSaturation(AValue: Word);
     procedure UpdateSpinEdit;
@@ -66,7 +66,7 @@ type
     procedure ApplyChosenColor;
     property ChosenHue: Word read GetChosenHue write SetChosenHue;
     property ChosenSaturation: Word read GetChosenSaturation write SetChosenSaturation;
-    property ChosenHueF: double read GetChosenHueF write SetChosenHueF;
+    property ChosenHueDegF: double read GetChosenHueDegF write SetChosenHueDegF;
     property ChosenSatF: double read GetChosenSatF write SetChosenSatF;
   end;
 
@@ -98,8 +98,8 @@ procedure TFColorize.Button_OKClick(Sender: TObject);
 begin
   ApplyChosenColor;
   FFilterConnector.ValidateAction;
-  FFilterConnector.Parameters.Floats['Hue'] := FloatSpinEdit_Hue.Value;
-  FFilterConnector.Parameters.Floats['Saturation'] := FloatSpinEdit_Saturation.Value;
+  FFilterConnector.Parameters.Floats['Hue'] := ChosenHueDegF;
+  FFilterConnector.Parameters.Floats['Saturation'] := ChosenSatF;
   FFilterConnector.Parameters.Booleans['Correction'] := CheckBox_GSBA.Checked;
 end;
 
@@ -127,7 +127,7 @@ procedure TFColorize.FloatSpinEdit_HueChange(Sender: TObject);
 begin
   if FUpdatingSpinEdit then exit;
   FUpdatingSpinEdit := true;
-  ChosenHueF := FloatSpinEdit_Hue.Value;
+  ChosenHueDegF := FloatSpinEdit_Hue.Value;
   Combo_Preset.ItemIndex := -1;
   FUpdatingSpinEdit := false;
 end;
@@ -163,9 +163,10 @@ begin
   ApplyChosenColor;
   Top := FInstance.MainFormBounds.Top;
   UpdateComboPreset(FInstance.Config.IndexOfColorizePreset(FSelectedPresetName));
+  ToolBar_AddRemove.Images := FInstance.Icons[DoScaleX(16, OriginalDPI)];
 end;
 
-procedure TFColorize.ToolButton1Click(Sender: TObject);
+procedure TFColorize.ToolButton_RemoveClick(Sender: TObject);
 begin
   if Combo_Preset.ItemIndex <> -1 then
   begin
@@ -174,13 +175,13 @@ begin
   end;
 end;
 
-procedure TFColorize.ToolButton23Click(Sender: TObject);
+procedure TFColorize.ToolButton_AddClick(Sender: TObject);
 var s: string; idx: integer;
 begin
   s := Trim(InputBox(rsColors,rsPresetName,''));
   if s <> '' then
   begin
-    idx := FInstance.Config.AddColorizePreset(s,GetChosenHueF,GetChosenSatF,CheckBox_GSBA.Checked);
+    idx := FInstance.Config.AddColorizePreset(s,ChosenHueDegF,ChosenSatF,CheckBox_GSBA.Checked);
     UpdateComboPreset(idx);
   end;
 end;
@@ -205,7 +206,7 @@ begin
   result := round(TrackBar_Hue.Position/TrackBar_Hue.Max*65535);
 end;
 
-function TFColorize.GetChosenHueF: double;
+function TFColorize.GetChosenHueDegF: double;
 begin
   result := round(ChosenHue/65536*3600)/10;
 end;
@@ -225,7 +226,7 @@ begin
   TrackBar_Hue.Position := round(AValue/65535*TrackBar_Hue.Max);
 end;
 
-procedure TFColorize.SetChosenHueF(AValue: double);
+procedure TFColorize.SetChosenHueDegF(AValue: double);
 begin
   ChosenHue:= round(AValue*65536/360) and 65535;
 end;
@@ -244,7 +245,7 @@ procedure TFColorize.UpdateSpinEdit;
 begin
   if FUpdatingSpinEdit then exit;
   FUpdatingSpinEdit:= true;
-  FloatSpinEdit_Hue.Value := ChosenHueF;
+  FloatSpinEdit_Hue.Value := ChosenHueDegF;
   FloatSpinEdit_Saturation.Value := ChosenSatF;
   FloatSpinEdit_Hue.Update;
   FloatSpinEdit_Saturation.Update;
@@ -257,7 +258,7 @@ begin
   OldInitialized := FInitialized;
   FInitialized := false;
   if AParams.IsDefined('Hue') then
-    ChosenHueF := AParams.Floats['Hue'];
+    ChosenHueDegF := AParams.Floats['Hue'];
   if AParams.IsDefined('Saturation') then
     ChosenSatF := AParams.Floats['Saturation'];
   if AParams.IsDefined('Correction') then
@@ -314,9 +315,9 @@ begin
     if AParameters.Booleans['Validate'] then
     begin
       if AParameters.IsDefined('Hue') then h := AParameters.Floats['Hue']
-      else h := FloatSpinEdit_Hue.Value;
+      else h := ChosenHueDegF;
       if AParameters.IsDefined('Saturation') then s := AParameters.Floats['Saturation']
-      else s := FloatSpinEdit_Saturation.Value;
+      else s := ChosenSatF;
       if AParameters.IsDefined('Correction') then corr := AParameters.Booleans['Correction']
       else corr := AInstance.Config.DefaultUseGSBA;
       Colorize(FFilterConnector, h, s, corr);
@@ -355,7 +356,7 @@ end;
 
 procedure TFColorize.ApplyChosenColor;
 begin
-  Colorize(FFilterConnector,ChosenHueF,ChosenSatF,CheckBox_GSBA.Checked);
+  Colorize(FFilterConnector, ChosenHueDegF, ChosenSatF, CheckBox_GSBA.Checked);
 end;
 
 {$R *.lfm}