From ce6f326b146a771599d01795be05e162429a1f2d Mon Sep 17 00:00:00 2001 From: michl Date: Tue, 19 Jun 2018 07:53:06 +0000 Subject: [PATCH] SpartaDockedFormEditor: Prevent showing of undocked new created frames (short flicker) and more generally code for revision 58299 #a027232dda. git-svn-id: trunk@58321 - --- components/ideintf/lazideintf.pas | 2 +- .../source/sparta_mainide.pas | 40 ++++++++++++------- ide/sourcefilemanager.pas | 6 +-- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/components/ideintf/lazideintf.pas b/components/ideintf/lazideintf.pas index 0fa0c44263..4645e272da 100644 --- a/components/ideintf/lazideintf.pas +++ b/components/ideintf/lazideintf.pas @@ -570,7 +570,7 @@ type function GetTabDisplayState: TTabDisplayState; virtual; abstract; function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract; public - function AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; virtual; abstract; + function AutoSizeInShowDesigner(AControl: TControl): Boolean; virtual; abstract; procedure ToggleFormUnit; virtual; abstract; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract; diff --git a/components/sparta/dockedformeditor/source/sparta_mainide.pas b/components/sparta/dockedformeditor/source/sparta_mainide.pas index 2c0becae82..b196e961f5 100644 --- a/components/sparta/dockedformeditor/source/sparta_mainide.pas +++ b/components/sparta/dockedformeditor/source/sparta_mainide.pas @@ -122,15 +122,15 @@ type TDTXTabMaster = class(TIDETabMaster) private - FAutoSizeFormList: TObjectList; + FAutoSizeControlList: TObjectList; protected function GetTabDisplayState: TTabDisplayState; override; function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; override; public constructor Create; destructor Destroy; override; - function AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; override; - procedure EnableAutoSizing(AForm: TCustomForm); + function AutoSizeInShowDesigner(AControl: TControl): Boolean; override; + procedure EnableAutoSizing(AControl: TControl); procedure ToggleFormUnit; override; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); override; @@ -795,31 +795,42 @@ end; constructor TDTXTabMaster.Create; begin - FAutoSizeFormList := TObjectList.Create(False); + FAutoSizeControlList := TObjectList.Create(False); end; destructor TDTXTabMaster.Destroy; begin - FAutoSizeFormList.Free; + FAutoSizeControlList.Free; inherited Destroy; end; -function TDTXTabMaster.AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; +function TDTXTabMaster.AutoSizeInShowDesigner(AControl: TControl): Boolean; begin - FAutoSizeFormList.Add(AForm); + FAutoSizeControlList.Add(AControl); Result := True; end; -procedure TDTXTabMaster.EnableAutoSizing(AForm: TCustomForm); +procedure TDTXTabMaster.EnableAutoSizing(AControl: TControl); var AIndex: Integer; + AutoSizeControl: TControl; begin - AIndex := FAutoSizeFormList.IndexOf(AForm); - if Assigned(AForm) and (AIndex >= 0) and IsFormDesign(AForm) - and (not (AForm is TNonControlProxyDesignerForm)) and (not (AForm is TFrameProxyDesignerForm)) then + if not Assigned(AControl) then Exit; + AutoSizeControl := nil; + + if AControl is TNonFormProxyDesignerForm then begin - FAutoSizeFormList.Delete(AIndex); - AForm.EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF}; + if (TNonFormProxyDesignerForm(AControl).LookupRoot is TControl) then + AutoSizeControl := TControl(TNonFormProxyDesignerForm(AControl).LookupRoot); + end + else + AutoSizeControl := AControl; + + AIndex := FAutoSizeControlList.IndexOf(AutoSizeControl); + if (AIndex >= 0) then + begin + FAutoSizeControlList.Delete(AIndex); + AutoSizeControl.EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF}; end; end; @@ -880,8 +891,7 @@ end; { TDTXComponentsMaster } -function TDTXComponentsMaster.DrawNonVisualComponents(ALookupRoot: TComponent - ): Boolean; +function TDTXComponentsMaster.DrawNonVisualComponents(ALookupRoot: TComponent): Boolean; var LFormData: TDesignFormData; LPageCtrl: TModulePageControl; diff --git a/ide/sourcefilemanager.pas b/ide/sourcefilemanager.pas index 8e8313fe64..895581f6f1 100644 --- a/ide/sourcefilemanager.pas +++ b/ide/sourcefilemanager.pas @@ -2295,9 +2295,9 @@ begin begin // disable autosizing for docked form editor forms, see issue #32207 PreventAutoSize := (IDETabMaster <> nil) - and (NewUnitInfo.Component is TCustomForm) - and (IsFormDesign(NewUnitInfo.Component as TCustomForm)) - and IDETabMaster.AutoSizeInShowDesigner(NewUnitInfo.Component as TCustomForm); + and ((NewUnitInfo.Component is TCustomForm) + or (NewUnitInfo.Component is TCustomFrame)) + and IDETabMaster.AutoSizeInShowDesigner(TControl(NewUnitInfo.Component)); if not PreventAutoSize then TControl(NewUnitInfo.Component).EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF}; end;