SpartaDockedFormEditor: Prevent showing of undocked forms (short flicker) after creating new forms. Issue #32207. Patch by Balázs Székely

git-svn-id: trunk@58299 -
This commit is contained in:
michl 2018-06-17 22:55:12 +00:00
parent 19f92d6a42
commit a027232dda
4 changed files with 58 additions and 5 deletions

View File

@ -570,6 +570,7 @@ type
function GetTabDisplayState: TTabDisplayState; virtual; abstract; function GetTabDisplayState: TTabDisplayState; virtual; abstract;
function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract; function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract;
public public
function AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; virtual; abstract;
procedure ToggleFormUnit; virtual; abstract; procedure ToggleFormUnit; virtual; abstract;
procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract;

View File

@ -21,7 +21,7 @@ uses
{$IFDEF USE_GENERICS_COLLECTIONS} {$IFDEF USE_GENERICS_COLLECTIONS}
Generics.Collections, Generics.Defaults, Generics.Collections, Generics.Defaults,
{$ELSE} {$ELSE}
ghashmap, sparta_HashUtils, gvector, ghashmap, sparta_HashUtils, gvector, contnrs,
{$ENDIF} {$ENDIF}
// LCL // LCL
LCLIntf, LCLType, LMessages, ComCtrls, Controls, Forms, ExtCtrls, Graphics, LCLIntf, LCLType, LMessages, ComCtrls, Controls, Forms, ExtCtrls, Graphics,
@ -121,10 +121,16 @@ type
{ TDTXTabMaster } { TDTXTabMaster }
TDTXTabMaster = class(TIDETabMaster) TDTXTabMaster = class(TIDETabMaster)
private
FAutoSizeFormList: TObjectList;
protected protected
function GetTabDisplayState: TTabDisplayState; override; function GetTabDisplayState: TTabDisplayState; override;
function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; override; function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; override;
public public
constructor Create;
destructor Destroy; override;
function AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; override;
procedure EnableAutoSizing(AForm: TCustomForm);
procedure ToggleFormUnit; override; procedure ToggleFormUnit; override;
procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); override; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); override;
@ -787,6 +793,36 @@ begin
end; end;
end; end;
constructor TDTXTabMaster.Create;
begin
FAutoSizeFormList := TObjectList.Create(False);
end;
destructor TDTXTabMaster.Destroy;
begin
FAutoSizeFormList.Free;
inherited Destroy;
end;
function TDTXTabMaster.AutoSizeInShowDesigner(AForm: TCustomForm): Boolean;
begin
FAutoSizeFormList.Add(AForm);
Result := True;
end;
procedure TDTXTabMaster.EnableAutoSizing(AForm: TCustomForm);
var
AIndex: Integer;
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
begin
FAutoSizeFormList.Delete(AIndex);
AForm.EnableAutoSizing;
end;
end;
procedure TDTXTabMaster.ToggleFormUnit; procedure TDTXTabMaster.ToggleFormUnit;
begin begin
case TabDisplayState of case TabDisplayState of
@ -816,6 +852,8 @@ end;
procedure TDTXTabMaster.ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer); procedure TDTXTabMaster.ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer);
var var
LPageCtrl: TModulePageControl; LPageCtrl: TModulePageControl;
Designer: TIDesigner;
Form: TCustomForm;
begin begin
if ASourceEditor = nil then if ASourceEditor = nil then
Exit; Exit;
@ -1439,6 +1477,8 @@ begin
end; end;
LSourceWndData.ActiveDesignFormData := LFormData; LSourceWndData.ActiveDesignFormData := LFormData;
// enable autosizing after creating a new form, see issue #32207
TDTXTabMaster(IDETabMaster).EnableAutoSizing(LFormData.Form.Form);
// to handle windows with different size // to handle windows with different size
LPageCtrl.BoundToDesignTabSheet; LPageCtrl.BoundToDesignTabSheet;
end; end;

View File

@ -3551,10 +3551,13 @@ begin
AForm.WindowState := wsMinimized; AForm.WindowState := wsMinimized;
exit; exit;
end; end;
if IDETabMaster = nil then
begin
// do not call 'AForm.Show', because it will set Visible to true // do not call 'AForm.Show', because it will set Visible to true
AForm.BringToFront; AForm.BringToFront;
LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL); LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
end; end;
end;
procedure TMainIDE.DoViewAnchorEditor(State: TIWGetFormState); procedure TMainIDE.DoViewAnchorEditor(State: TIWGetFormState);
begin begin

View File

@ -2077,6 +2077,7 @@ var
Src: String; Src: String;
i: Integer; i: Integer;
LFindDesignerBaseClassByName: Boolean = True; LFindDesignerBaseClassByName: Boolean = True;
PreventAutoSize: Boolean;
begin begin
//debugln('TLazSourceFileManager.NewFile A NewFilename=',NewFilename); //debugln('TLazSourceFileManager.NewFile A NewFilename=',NewFilename);
// empty NewFilename is ok, it will be auto generated // empty NewFilename is ok, it will be auto generated
@ -2291,8 +2292,16 @@ begin
DisableAutoSize); DisableAutoSize);
if DisableAutoSize and (NewUnitInfo.Component<>nil) if DisableAutoSize and (NewUnitInfo.Component<>nil)
and (NewUnitInfo.Component is TControl) then and (NewUnitInfo.Component is TControl) then
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);
if not PreventAutoSize then
TControl(NewUnitInfo.Component).EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF}; TControl(NewUnitInfo.Component).EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF};
end; end;
end;
if Result<>mrOk then if Result<>mrOk then
begin begin
debugln(['TLazSourceFileManager.NewFile create designer form failed ',NewUnitInfo.Filename]); debugln(['TLazSourceFileManager.NewFile create designer form failed ',NewUnitInfo.Filename]);