LCL: delay autosizing when form is minimized

git-svn-id: trunk@33145 -
This commit is contained in:
mattias 2011-10-29 07:28:02 +00:00
parent 6f369dbff1
commit 2cd66811f0
5 changed files with 37 additions and 13 deletions

View File

@ -1302,7 +1302,7 @@ type
procedure AdjustSize; virtual;// smart calling DoAutoSize procedure AdjustSize; virtual;// smart calling DoAutoSize
function AutoSizePhases: TControlAutoSizePhases; virtual; function AutoSizePhases: TControlAutoSizePhases; virtual;
function AutoSizeDelayed: boolean; virtual; function AutoSizeDelayed: boolean; virtual;
function AutoSizeCheckParent: Boolean; virtual; function AutoSizeDelayedHandle: Boolean; virtual;
procedure AnchorToNeighbour(Side: TAnchorKind; Space: integer; procedure AnchorToNeighbour(Side: TAnchorKind; Space: integer;
Sibling: TControl); Sibling: TControl);
procedure AnchorParallel(Side: TAnchorKind; Space: integer; procedure AnchorParallel(Side: TAnchorKind; Space: integer;
@ -1954,7 +1954,7 @@ type
// size, position, bounds // size, position, bounds
function AutoSizePhases: TControlAutoSizePhases; override; function AutoSizePhases: TControlAutoSizePhases; override;
function AutoSizeDelayed: boolean; override; function AutoSizeDelayed: boolean; override;
function AutoSizeCheckParent: Boolean; override; function AutoSizeDelayedHandle: Boolean; override;
procedure BeginUpdateBounds; // disable SetBounds procedure BeginUpdateBounds; // disable SetBounds
procedure EndUpdateBounds; // enable SetBounds procedure EndUpdateBounds; // enable SetBounds
procedure LockRealizeBounds; // disable sending bounds to widgetset procedure LockRealizeBounds; // disable sending bounds to widgetset

View File

@ -594,7 +594,7 @@ type
procedure IntfHelp(AComponent: TComponent); procedure IntfHelp(AComponent: TComponent);
function IsShortcut(var Message: TLMKey): boolean; virtual; function IsShortcut(var Message: TLMKey): boolean; virtual;
procedure MakeFullyVisible(AMonitor: TMonitor = nil; UseWorkarea: Boolean = False); procedure MakeFullyVisible(AMonitor: TMonitor = nil; UseWorkarea: Boolean = False);
function AutoSizeCheckParent: Boolean; override; function AutoSizeDelayedHandle: Boolean; override;
procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer; procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer;
Raw: boolean = false; Raw: boolean = false;
WithThemeSpace: boolean = true); override; WithThemeSpace: boolean = true); override;

View File

@ -2585,8 +2585,8 @@ begin
// no autosize for invisible controls // no autosize for invisible controls
or (not IsControlVisible) or (not IsControlVisible)
// if there is no parent, then this control is not visible // if there is no parent, then this control is not visible
// (TCustomForm will override this) // (TWinControl and TCustomForm override this)
or not AutoSizeCheckParent or AutoSizeDelayedHandle
// if there is a parent, ask it // if there is a parent, ask it
or ((Parent<>nil) and Parent.AutoSizeDelayed); or ((Parent<>nil) and Parent.AutoSizeDelayed);
{$IFDEF VerboseCanAutoSize} {$IFDEF VerboseCanAutoSize}
@ -2597,16 +2597,22 @@ begin
else if csDestroying in ComponentState then debugln('csDestroying') else if csDestroying in ComponentState then debugln('csDestroying')
else if cfLoading in FControlFlags then debugln('cfLoading') else if cfLoading in FControlFlags then debugln('cfLoading')
else if not IsControlVisible then debugln('not IsControlVisible') else if not IsControlVisible then debugln('not IsControlVisible')
else if not AutoSizeCheckParent then debugln('not AutoSizeCheckParent') else if AutoSizeDelayedHandle then debugln('AutoSizeDelayedHandle')
else if ((Parent<>nil) and Parent.AutoSizeDelayed) then debugln('Parent.AutoSizeDelayed') else if ((Parent<>nil) and Parent.AutoSizeDelayed) then debugln('Parent.AutoSizeDelayed')
else debugln('?'); else debugln('?');
end; end;
{$ENDIF} {$ENDIF}
end; end;
function TControl.AutoSizeCheckParent: Boolean; {------------------------------------------------------------------------------
TControl AutoSizeDelayedHandle
Returns true if AutoSize should be skipped / delayed because of its handle.
A TControl does not have a handle, so it needs a parent.
------------------------------------------------------------------------------}
function TControl.AutoSizeDelayedHandle: Boolean;
begin begin
Result := Parent <> nil; Result := Parent = nil;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -2128,9 +2128,21 @@ begin
//DebugLn(['TCustomForm.ShowOnTop ',Name,':',ClassName,' ',Visible,' ',HandleAllocated,' ',csDesigning in ComponentState]); //DebugLn(['TCustomForm.ShowOnTop ',Name,':',ClassName,' ',Visible,' ',HandleAllocated,' ',csDesigning in ComponentState]);
end; end;
function TCustomForm.AutoSizeCheckParent: Boolean; {------------------------------------------------------------------------------
TCustomForm AutoSizeDelayedHandle
Returns true if AutoSize should be skipped / delayed because of its handle.
------------------------------------------------------------------------------}
function TCustomForm.AutoSizeDelayedHandle: Boolean;
begin begin
Result := True; if WindowState=wsMinimized then
exit(true);
if (Parent<>nil) or (ParentWindow<>0) then
// this form is inlined / embedded it works like a normal TWinControl
Result:=inherited AutoSizeDelayedHandle
else
// this form is on a screen => no delay
Result:=false;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}

View File

@ -2387,9 +2387,15 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function TWinControl.AutoSizeCheckParent: Boolean; {------------------------------------------------------------------------------
TWinControl AutoSizeDelayedHandle
Returns true if AutoSize should be skipped / delayed because of its handle.
A TWinControl needs a parent handle.
------------------------------------------------------------------------------}
function TWinControl.AutoSizeDelayedHandle: Boolean;
begin begin
Result := (Parent <> nil) or (ParentWindow <> 0); Result := (Parent = nil) and (ParentWindow = 0);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------