Selaa lähdekoodia

late load dialogs

johann 5 vuotta sitten
vanhempi
commit
d113982d1d
2 muutettua tiedostoa jossa 88 lisäystä ja 38 poistoa
  1. 16 16
      lazpaint/lazpaintdialogs.inc
  2. 72 22
      lazpaint/lazpaintinstance.pas

+ 16 - 16
lazpaint/lazpaintdialogs.inc

@@ -21,9 +21,9 @@ begin
   FormsNeeded;
   topmostInfo := HideTopmost;
   try
-    FCanvasSize.repeatImage := False;
-    if FCanvasSize.ShowModal = mrOk then
-      Image.Assign(FCanvasSize.canvasSizeResult, true, True);
+    FormCanvasSize.repeatImage := False;
+    if FormCanvasSize.ShowModal = mrOk then
+      Image.Assign(FormCanvasSize.canvasSizeResult, true, True);
   except
     on ex:Exception do
       ShowError('ShowCanvasSizeDlg',ex.Message);
@@ -37,9 +37,9 @@ begin
   FormsNeeded;
   topmostInfo := HideTopmost;
   try
-    FCanvasSize.repeatImage := True;
-    if FCanvasSize.ShowModal = mrOk then
-      image.Assign(FCanvasSize.canvasSizeResult,true,True);
+    FormCanvasSize.repeatImage := True;
+    if FormCanvasSize.ShowModal = mrOk then
+      image.Assign(FormCanvasSize.canvasSizeResult,true,True);
   except
     on ex:Exception do
       ShowError('ShowRepeatImageDlg',ex.Message);
@@ -239,7 +239,7 @@ begin
   oldSelectionNormal := ShowSelectionNormal;
   ShowSelectionNormal := true;
   try
-    case FColorIntensity.ShowModal(self,ciIntensity,AParameters) of
+    case FormColorIntensity.ShowModal(self,ciIntensity,AParameters) of
     mrOK: result := srOk;
     else result := srCancelledByUser;
     end;
@@ -247,7 +247,7 @@ begin
     on ex:Exception do
     begin
       result := srException;
-      ShowError(FColorIntensity.Caption, ex.Message);
+      ShowError(FormColorIntensity.Caption, ex.Message);
     end;
   end;
   ShowSelectionNormal := oldSelectionNormal;
@@ -269,7 +269,7 @@ begin
   oldSelectionNormal := ShowSelectionNormal;
   ShowSelectionNormal := true;
   try
-    case FColorIntensity.ShowModal(self,ciLightness,AParameters) of
+    case FormColorIntensity.ShowModal(self,ciLightness,AParameters) of
     mrOk: result := srOk;
     else result := srCancelledByUser;
     end;
@@ -277,7 +277,7 @@ begin
     on ex:Exception do
     begin
       result := srException;
-      ShowError(FColorIntensity.Caption,ex.Message);
+      ShowError(FormColorIntensity.Caption,ex.Message);
     end;
   end;
   ShowSelectionNormal := oldSelectionNormal;
@@ -298,7 +298,7 @@ begin
   oldSelectionNormal := ShowSelectionNormal;
   ShowSelectionNormal := true;
   try
-    case FShiftColors.ShowModal(self,AParameters) of
+    case FormShiftColors.ShowModal(self,AParameters) of
     mrOk: result := srOk;
     else result := srCancelledByUser;
     end;
@@ -306,7 +306,7 @@ begin
     on ex:Exception do
     begin
       result := srException;
-      ShowError(FShiftColors.Caption,ex.Message);
+      ShowError(FormShiftColors.Caption,ex.Message);
     end;
   end;
   ShowSelectionNormal := oldSelectionNormal;
@@ -327,7 +327,7 @@ begin
   oldSelectionNormal := ShowSelectionNormal;
   ShowSelectionNormal := true;
   try
-    case FColorize.ShowModal(self,AParameters) of
+    case FormColorize.ShowModal(self,AParameters) of
     mrOk: result := srOk;
     else result := srCancelledByUser;
     end;
@@ -335,7 +335,7 @@ begin
     on ex:Exception do
     begin
       result := srException;
-      ShowError(FColorize.Caption, ex.Message);
+      ShowError(FormColorize.Caption, ex.Message);
     end;
   end;
   ShowSelectionNormal := oldSelectionNormal;
@@ -356,7 +356,7 @@ begin
   oldSelectionNormal := ShowSelectionNormal;
   ShowSelectionNormal := true;
   try
-    case FColorCurves.ShowModal(self,AParameters) of
+    case FormAdjustCurves.ShowModal(self,AParameters) of
     mrOk: result := srOk;
     else result := srCancelledByUser;
     end;
@@ -401,7 +401,7 @@ begin
   top := self.HideTopmost;
   oldSelectionNormal := ShowSelectionNormal;
   ShowSelectionNormal := true;
-  result := FCustomBlur.ShowDlg(AFilterConnector);
+  result := FormCustomBlur.ShowDlg(AFilterConnector);
   ShowSelectionNormal := oldSelectionNormal;
   self.ShowTopmost(top);
 end;

+ 72 - 22
lazpaint/lazpaintinstance.pas

@@ -29,6 +29,12 @@ type
   private
     FScriptName: String;
 
+    function GetFormAdjustCurves: TFAdjustCurves;
+    function GetFormCanvasSize: TFCanvasSize;
+    function GetFormColorIntensity: TFColorIntensity;
+    function GetFormColorize: TFColorize;
+    function GetFormCustomBlur: TFCustomBlur;
+    function GetFormShiftColors: TFShiftColors;
     function GetInitialized: boolean;
     function GetMainFormVisible: boolean;
     procedure OnImageActionProgress({%H-}ASender: TObject; AProgressPercent: integer);
@@ -68,12 +74,12 @@ type
     FImageList: TFImageList;
     FChooseColor: TFChooseColor;
     FLayerStack: TFLayerStack;
-    FCanvasSize: TFCanvasSize;
-    FColorIntensity: TFColorIntensity;
-    FShiftColors: TFShiftColors;
-    FColorize: TFColorize;
-    FColorCurves: TFAdjustCurves;
-    FCustomBlur: TFCustomBlur;
+    FFormCanvasSize: TFCanvasSize;
+    FFormColorIntensity: TFColorIntensity;
+    FFormShiftColors: TFShiftColors;
+    FFormColorize: TFColorize;
+    FFormAdjustCurves: TFAdjustCurves;
+    FFormCustomBlur: TFCustomBlur;
     FLoadingLayers: TFLoading;
     FTopMostInfo: TTopMostInfo;
     FGridVisible: boolean;
@@ -158,6 +164,12 @@ type
     procedure ApplyTheme(ADarkTheme: boolean); override;
     procedure UpdateLayerControlVisibility;
     procedure UpdateChooseColorControlVisibility;
+    property FormCanvasSize: TFCanvasSize read GetFormCanvasSize;
+    property FormColorIntensity: TFColorIntensity read GetFormColorIntensity;
+    property FormShiftColors: TFShiftColors read GetFormShiftColors;
+    property FormColorize: TFColorize read GetFormColorize;
+    property FormAdjustCurves: TFAdjustCurves read GetFormAdjustCurves;
+    property FormCustomBlur: TFCustomBlur read GetFormCustomBlur;
 
   public
     constructor Create; override;
@@ -428,16 +440,6 @@ begin
   FChooseColor.LazPaintInstance := self;
   FChooseColor.DarkTheme:= Config.GetDarkTheme;
 
-  Application.CreateForm(TFCanvasSize, FCanvasSize);
-  FCanvasSize.LazPaintInstance := self;
-  Application.CreateForm(TFColorIntensity, FColorIntensity);
-  Application.CreateForm(TFShiftColors, FShiftColors);
-  Application.CreateForm(TFColorize, FColorize);
-  Application.CreateForm(TFAdjustCurves, FColorCurves);
-  Application.CreateForm(TFCustomBlur, FCustomBlur);
-  FCustomBlur.LazPaintInstance := self;
-
-
   FInFormsNeeded := false;
 end;
 
@@ -660,6 +662,54 @@ begin
   result := Assigned(FMain) and FMain.Initialized;
 end;
 
+function TLazPaintInstance.GetFormCanvasSize: TFCanvasSize;
+begin
+  if FFormCanvasSize = nil then
+  begin
+    Application.CreateForm(TFCanvasSize, FFormCanvasSize);
+    FFormCanvasSize.LazPaintInstance := self;
+  end;
+  result := FFormCanvasSize;
+end;
+
+function TLazPaintInstance.GetFormAdjustCurves: TFAdjustCurves;
+begin
+  if FFormAdjustCurves = nil then
+    Application.CreateForm(TFAdjustCurves, FFormAdjustCurves);
+  result := FFormAdjustCurves;
+end;
+
+function TLazPaintInstance.GetFormColorIntensity: TFColorIntensity;
+begin
+  if FFormColorIntensity = nil then
+    Application.CreateForm(TFColorIntensity, FFormColorIntensity);
+  result := FFormColorIntensity;
+end;
+
+function TLazPaintInstance.GetFormColorize: TFColorize;
+begin
+  if FFormColorize = nil then
+    Application.CreateForm(TFColorize, FFormColorize);
+  result := FFormColorize;
+end;
+
+function TLazPaintInstance.GetFormCustomBlur: TFCustomBlur;
+begin
+  if FFormCustomBlur = nil then
+  begin
+    Application.CreateForm(TFCustomBlur, FFormCustomBlur);
+    FFormCustomBlur.LazPaintInstance := self;
+  end;
+  result := FFormCustomBlur;
+end;
+
+function TLazPaintInstance.GetFormShiftColors: TFShiftColors;
+begin
+  if FFormShiftColors = nil then
+    Application.CreateForm(TFShiftColors, FFormShiftColors);
+  result := FFormShiftColors;
+end;
+
 procedure TLazPaintInstance.PythonScriptCommand(ASender: TObject; ACommand,
   AParam: UTF8String; out AResult: UTF8String);
 var
@@ -1339,12 +1389,12 @@ begin
   if FLoadingLayers <> nil then FreeAndNil(FLoadingLayers);
 
   FreeAndNil(FLayerStack);
-  FreeAndNil(FCustomBlur);
-  FreeAndNil(FColorize);
-  FreeAndNil(FColorCurves);
-  FreeAndNil(FShiftColors);
-  FreeAndNil(FColorIntensity);
-  FreeAndNil(FCanvasSize);
+  FreeAndNil(FFormCustomBlur);
+  FreeAndNil(FFormColorize);
+  FreeAndNil(FFormAdjustCurves);
+  FreeAndNil(FFormShiftColors);
+  FreeAndNil(FFormColorIntensity);
+  FreeAndNil(FFormCanvasSize);
   FreeAndNil(FChooseColor);
   FreeAndNil(FFormToolbox);
   FreeAndNil(FToolManager);