diff --git a/ide/runparamsopts.lfm b/ide/runparamsopts.lfm index 3fbf12a3c8..c56e8f9d61 100644 --- a/ide/runparamsopts.lfm +++ b/ide/runparamsopts.lfm @@ -220,7 +220,6 @@ object RunParamsOptsDlg: TRunParamsOptsDlg Width = 149 Anchors = [akTop, akRight, akBottom] AutoSize = True - BorderSpacing.Left = 6 BorderSpacing.Top = 6 BorderSpacing.Right = 6 BorderSpacing.InnerBorder = 4 diff --git a/ide/runparamsopts.lrs b/ide/runparamsopts.lrs index 0c288fe506..6a6fb527e1 100644 --- a/ide/runparamsopts.lrs +++ b/ide/runparamsopts.lrs @@ -72,54 +72,53 @@ LazarusResources.Add('TRunParamsOptsDlg','FORMDATA',[ +'orkingDirectoryGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorS' +'ideBottom.Control'#7#24'WorkingDirectoryComboBox'#21'AnchorSideBottom.Side' +#7#9'asrBottom'#4'Left'#3'E'#1#6'Height'#2#27#3'Top'#2#6#5'Width'#3#149#0#7 - +'Anchors'#11#5'akTop'#7'akRight'#8'akBottom'#0#8'AutoSize'#9#18'BorderSpacin' - +'g.Left'#2#6#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#25'Border' - +'Spacing.InnerBorder'#2#4#7'Caption'#6#19'WorkingDirectoryBtn'#7'OnClick'#7 - +#24'WorkingDirectoryBtnClick'#8'TabOrder'#2#0#0#0#9'TComboBox'#24'WorkingDir' - +'ectoryComboBox'#22'AnchorSideLeft.Control'#7#24'WorkingDirectoryGroupBox'#21 - +'AnchorSideTop.Control'#7#24'WorkingDirectoryGroupBox'#23'AnchorSideRight.Co' - +'ntrol'#7#19'WorkingDirectoryBtn'#4'Left'#2#6#6'Height'#2#27#3'Top'#2#6#5'Wi' - +'dth'#3'9'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#16'AutoCompleteTe' - +'xt'#11#22'cbactEndOfLineComplete'#20'cbactSearchAscending'#0#20'BorderSpaci' - +'ng.Around'#2#6#9'MaxLength'#2#0#8'TabOrder'#2#1#4'Text'#6#24'WorkingDirecto' - +'ryComboBox'#0#0#0#0#5'TPage'#11'EnvVarsPage'#7'Caption'#6#11'EnvVarsPage'#11 - +'ClientWidth'#3#240#1#12'ClientHeight'#3#168#1#0#9'TCheckBox'#30'IncludeSyst' - +'emVariablesCheckBox'#4'Left'#2#6#6'Height'#2#22#3'Top'#3#140#1#5'Width'#3 - +#228#1#5'Align'#7#8'alBottom'#20'BorderSpacing.Around'#2#6#7'Caption'#6#30'I' - +'ncludeSystemVariablesCheckBox'#7'Enabled'#8#8'TabOrder'#2#0#0#0#9'TGroupBox' - +#21'UserOverridesGroupBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6 - +#6'Height'#3#161#0#3'Top'#3#229#0#5'Width'#3#228#1#5'Align'#7#8'alBottom'#7 - +'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#20'BorderSpacing.Around'#2#6#7 - +'Caption'#6#21'UserOverridesGroupBox'#12'ClientHeight'#3#142#0#11'ClientWidt' - +'h'#3#224#1#8'TabOrder'#2#1#0#7'TButton'#22'UserOverridesAddButton'#4'Left'#2 - +#6#6'Height'#2#31#3'Top'#2'f'#5'Width'#3#179#0#7'Anchors'#11#6'akLeft'#8'akB' - +'ottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#25'BorderSpacing.InnerB' - +'order'#2#4#7'Caption'#6#22'UserOverridesAddButton'#7'OnClick'#7#27'UserOver' - +'ridesAddButtonClick'#8'TabOrder'#2#0#0#0#7'TButton'#23'UserOverridesEditBut' - +'ton'#22'AnchorSideLeft.Control'#7#22'UserOverridesAddButton'#19'AnchorSideL' - +'eft.Side'#7#9'asrBottom'#4'Left'#3#191#0#6'Height'#2#31#3'Top'#2'f'#5'Width' - +#3#178#0#7'Anchors'#11#6'akLeft'#8'akBottom'#0#8'AutoSize'#9#20'BorderSpacin' - +'g.Around'#2#6#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#23'UserOverrid' - +'esEditButton'#7'OnClick'#7#28'UserOverridesEditButtonClick'#8'TabOrder'#2#1 - +#0#0#7'TButton'#25'UserOverridesDeleteButton'#22'AnchorSideLeft.Control'#7#23 - +'UserOverridesEditButton'#19'AnchorSideLeft.Side'#7#9'asrBottom'#4'Left'#3'w' - +#1#6'Height'#2#31#3'Top'#2'f'#5'Width'#3#196#0#7'Anchors'#11#6'akLeft'#8'akB' - +'ottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#25'BorderSpacing.InnerB' - +'order'#2#4#7'Caption'#6#25'UserOverridesDeleteButton'#7'OnClick'#7#30'UserO' - +'verridesDeleteButtonClick'#8'TabOrder'#2#2#0#0#9'TListView'#21'UserOverride' - +'sListView'#24'AnchorSideBottom.Control'#7#22'UserOverridesAddButton'#4'Left' - +#2#6#6'Height'#2'Z'#3'Top'#2#6#5'Width'#3#212#1#5'Align'#7#5'alTop'#7'Anchor' - +'s'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2 - +#6#7'Columns'#14#1#8'AutoSize'#9#7'Caption'#6#7'Caption'#5'Width'#2';'#0#1#8 - +'AutoSize'#9#7'Caption'#6#7'Caption'#5'Width'#3#135#1#0#0#9'RowSelect'#9#8'S' - +'ortType'#7#6'stText'#8'TabOrder'#2#3#9'ViewStyle'#7#8'vsReport'#0#0#0#9'TGr' - +'oupBox'#23'SystemVariablesGroupBox'#4'Left'#2#6#6'Height'#3#217#0#3'Top'#2#6 - +#5'Width'#3#228#1#5'Align'#7#8'alClient'#20'BorderSpacing.Around'#2#6#7'Capt' - +'ion'#6#23'SystemVariablesGroupBox'#12'ClientHeight'#3#198#0#11'ClientWidth' - +#3#224#1#8'TabOrder'#2#2#0#9'TListView'#23'SystemVariablesListView'#4'Left'#2 - +#6#6'Height'#3#186#0#3'Top'#2#6#5'Width'#3#212#1#5'Align'#7#8'alClient'#20'B' - +'orderSpacing.Around'#2#6#7'Columns'#14#1#8'AutoSize'#9#7'Caption'#6#7'Capti' - +'on'#5'Width'#2';'#0#1#8'AutoSize'#9#7'Caption'#6#7'Caption'#5'Width'#3#135#1 - +#0#0#9'RowSelect'#9#8'SortType'#7#6'stText'#8'TabOrder'#2#0#9'ViewStyle'#7#8 - +'vsReport'#0#0#0#0#0#0 + +'Anchors'#11#5'akTop'#7'akRight'#8'akBottom'#0#8'AutoSize'#9#17'BorderSpacin' + +'g.Top'#2#6#19'BorderSpacing.Right'#2#6#25'BorderSpacing.InnerBorder'#2#4#7 + +'Caption'#6#19'WorkingDirectoryBtn'#7'OnClick'#7#24'WorkingDirectoryBtnClick' + +#8'TabOrder'#2#0#0#0#9'TComboBox'#24'WorkingDirectoryComboBox'#22'AnchorSide' + +'Left.Control'#7#24'WorkingDirectoryGroupBox'#21'AnchorSideTop.Control'#7#24 + +'WorkingDirectoryGroupBox'#23'AnchorSideRight.Control'#7#19'WorkingDirectory' + +'Btn'#4'Left'#2#6#6'Height'#2#27#3'Top'#2#6#5'Width'#3'9'#1#7'Anchors'#11#5 + +'akTop'#6'akLeft'#7'akRight'#0#16'AutoCompleteText'#11#22'cbactEndOfLineComp' + +'lete'#20'cbactSearchAscending'#0#20'BorderSpacing.Around'#2#6#9'MaxLength'#2 + +#0#8'TabOrder'#2#1#4'Text'#6#24'WorkingDirectoryComboBox'#0#0#0#0#5'TPage'#11 + +'EnvVarsPage'#7'Caption'#6#11'EnvVarsPage'#11'ClientWidth'#3#240#1#12'Client' + +'Height'#3#168#1#0#9'TCheckBox'#30'IncludeSystemVariablesCheckBox'#4'Left'#2 + +#6#6'Height'#2#22#3'Top'#3#140#1#5'Width'#3#228#1#5'Align'#7#8'alBottom'#20 + +'BorderSpacing.Around'#2#6#7'Caption'#6#30'IncludeSystemVariablesCheckBox'#7 + +'Enabled'#8#8'TabOrder'#2#0#0#0#9'TGroupBox'#21'UserOverridesGroupBox'#18'An' + +'chorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#3#161#0#3'Top'#3#229 + +#0#5'Width'#3#228#1#5'Align'#7#8'alBottom'#7'Anchors'#11#5'akTop'#6'akLeft'#7 + +'akRight'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#21'UserOverridesGroupB' + +'ox'#12'ClientHeight'#3#142#0#11'ClientWidth'#3#224#1#8'TabOrder'#2#1#0#7'TB' + +'utton'#22'UserOverridesAddButton'#4'Left'#2#6#6'Height'#2#31#3'Top'#2'f'#5 + +'Width'#3#179#0#7'Anchors'#11#6'akLeft'#8'akBottom'#0#8'AutoSize'#9#20'Borde' + +'rSpacing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#22'User' + +'OverridesAddButton'#7'OnClick'#7#27'UserOverridesAddButtonClick'#8'TabOrder' + +#2#0#0#0#7'TButton'#23'UserOverridesEditButton'#22'AnchorSideLeft.Control'#7 + +#22'UserOverridesAddButton'#19'AnchorSideLeft.Side'#7#9'asrBottom'#4'Left'#3 + +#191#0#6'Height'#2#31#3'Top'#2'f'#5'Width'#3#178#0#7'Anchors'#11#6'akLeft'#8 + +'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#25'BorderSpacing.Inn' + +'erBorder'#2#4#7'Caption'#6#23'UserOverridesEditButton'#7'OnClick'#7#28'User' + +'OverridesEditButtonClick'#8'TabOrder'#2#1#0#0#7'TButton'#25'UserOverridesDe' + +'leteButton'#22'AnchorSideLeft.Control'#7#23'UserOverridesEditButton'#19'Anc' + +'horSideLeft.Side'#7#9'asrBottom'#4'Left'#3'w'#1#6'Height'#2#31#3'Top'#2'f'#5 + +'Width'#3#196#0#7'Anchors'#11#6'akLeft'#8'akBottom'#0#8'AutoSize'#9#20'Borde' + +'rSpacing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#25'User' + +'OverridesDeleteButton'#7'OnClick'#7#30'UserOverridesDeleteButtonClick'#8'Ta' + +'bOrder'#2#2#0#0#9'TListView'#21'UserOverridesListView'#24'AnchorSideBottom.' + +'Control'#7#22'UserOverridesAddButton'#4'Left'#2#6#6'Height'#2'Z'#3'Top'#2#6 + +#5'Width'#3#212#1#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akR' + +'ight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#7'Columns'#14#1#8'AutoSize' + +#9#7'Caption'#6#7'Caption'#5'Width'#2';'#0#1#8'AutoSize'#9#7'Caption'#6#7'Ca' + +'ption'#5'Width'#3#135#1#0#0#9'RowSelect'#9#8'SortType'#7#6'stText'#8'TabOrd' + +'er'#2#3#9'ViewStyle'#7#8'vsReport'#0#0#0#9'TGroupBox'#23'SystemVariablesGro' + +'upBox'#4'Left'#2#6#6'Height'#3#217#0#3'Top'#2#6#5'Width'#3#228#1#5'Align'#7 + +#8'alClient'#20'BorderSpacing.Around'#2#6#7'Caption'#6#23'SystemVariablesGro' + +'upBox'#12'ClientHeight'#3#198#0#11'ClientWidth'#3#224#1#8'TabOrder'#2#2#0#9 + +'TListView'#23'SystemVariablesListView'#4'Left'#2#6#6'Height'#3#186#0#3'Top' + +#2#6#5'Width'#3#212#1#5'Align'#7#8'alClient'#20'BorderSpacing.Around'#2#6#7 + +'Columns'#14#1#8'AutoSize'#9#7'Caption'#6#7'Caption'#5'Width'#2';'#0#1#8'Aut' + +'oSize'#9#7'Caption'#6#7'Caption'#5'Width'#3#135#1#0#0#9'RowSelect'#9#8'Sort' + +'Type'#7#6'stText'#8'TabOrder'#2#0#9'ViewStyle'#7#8'vsReport'#0#0#0#0#0#0 ]); diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 52178dbbfb..d5db677064 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -1567,7 +1567,7 @@ end; ------------------------------------------------------------------------------} procedure TControl.ParentFormHandleInitialized; begin - // The form is real connection to the target screen. For example, the gtk + // The form is really connection to the target screen. For example, the gtk // under X gathers some screen information not before form creation. // But this information is needed to create DeviceContexts, which // are needed to calculate Text Size and such stuff needed for AutoSizing. @@ -2068,7 +2068,8 @@ Begin If AutoSize <> Value then begin FAutoSize := Value; //debugln('TControl.SetAutoSize ',DbgSName(Self)); - AdjustSize; + if FAutoSize then + AdjustSize; end; end; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 8e61692b62..67a5394a5a 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -25,15 +25,20 @@ // {$DEFINE ASSERT_IS_ON} {$ENDIF} -{ $DEFINE CHECK_POSITION} +{off $DEFINE VerboseAutoSizeCtrlData} + +{off $DEFINE CHECK_POSITION} {$IFDEF CHECK_POSITION} const CheckPostionClassName = 'xxxTPage'; -const CheckPostionName = 'xxxPathsPage'; +const CheckPostionName = 'WorkingDirectoryGroupBox'; +const CheckPostionParentName = 'WorkingDirectoryGroupBox'; function CheckPosition(AControl: TControl): boolean; begin Result:=(CompareText(AControl.ClassName,CheckPostionClassName)=0) - or (CompareText(AControl.Name,CheckPostionName)=0); + or (CompareText(AControl.Name,CheckPostionName)=0) + or ((AControl.Parent<>nil) + and (CompareText(AControl.Parent.Name,CheckPostionParentName)=0)); end; {$ENDIF} { $DEFINE VerboseMouseBugfix} @@ -93,10 +98,10 @@ type procedure SumTable; procedure ResizeTable(ChildSizing: TControlChildSizing; TargetWidth, TargetHeight: integer); - function SetTableControlBounds(ChildSizing: TControlChildSizing): boolean; + function SetTableControlBounds(ChildSizing: TControlChildSizing): boolean;// true if changed function AlignControlsInTable(ListOfControls: TFPList; ChildSizing: TControlChildSizing; - TargetWidth, TargetHeight: integer): boolean; + TargetWidth, TargetHeight: integer): boolean;// true if changed // debugging procedure WriteDebugReport; @@ -248,6 +253,7 @@ var for i := 0 to AlignList.Count - 1 do begin Child:=TControl(AlignList[i]); ChildData:=Childs[Child]; + //DebugLn('DoAlign ',DbgSName(Child),' ',dbgs(Child.Align)); for a:=Low(TAnchorKind) to High(TAnchorKind) do if a in AnchorAlign[TheAlign] then begin @@ -256,6 +262,7 @@ var ChildData.Sides[a].Side:=asrLeft else ChildData.Sides[a].Side:=asrRight; + //DebugLn('DoAlign ',DbgSName(Child),' ',dbgs(a),' ',dbgs(a,ChildData.Sides[a].Side)); end; case TheAlign of @@ -317,22 +324,28 @@ begin SiblingData:=ChildData.Sides[a].CtrlData; // aligned or anchored to a sibling if a in [akLeft,akTop] then begin - NewSpace:=Max(WinControl.ChildSizing.HorizontalSpacing, - ChildData.Borders[a]); - if ChildData.Sides[a].Side=asrLeft then - NewSpace:=Max(NewSpace,SiblingData.Borders[akLeft]) - else if ChildData.Sides[a].Side=asrRight then - NewSpace:=Max(NewSpace,SiblingData.Borders[akRight]) + NewSpace:=ChildData.Borders[a]; + if ChildData.Sides[a].Side=asrRight then begin + NewSpace:=Max(NewSpace,WinControl.ChildSizing.HorizontalSpacing); + if a=akLeft then + NewSpace:=Max(NewSpace,SiblingData.Borders[akRight]) + else + NewSpace:=Max(NewSpace,SiblingData.Borders[akBottom]); + end else if ChildData.Sides[a].Side=asrLeft then + else if ChildData.Sides[a].Side=asrCenter then NewSpace:=0; ChildData.Sides[a].Space:=NewSpace; end else begin - NewSpace:=Max(WinControl.ChildSizing.VerticalSpacing, - ChildData.Borders[a]); - if ChildData.Sides[a].Side=asrTop then - NewSpace:=Max(NewSpace,SiblingData.Borders[akTop]) - else if ChildData.Sides[a].Side=asrBottom then - NewSpace:=Max(NewSpace,SiblingData.Borders[akBottom]) + NewSpace:=ChildData.Borders[a]; + if ChildData.Sides[a].Side=asrTop then begin + NewSpace:=Max(NewSpace,WinControl.ChildSizing.VerticalSpacing); + if a=akRight then + NewSpace:=Max(NewSpace,SiblingData.Borders[akLeft]) + else + NewSpace:=Max(NewSpace,SiblingData.Borders[akTop]); + end else if ChildData.Sides[a].Side=asrBottom then + else if ChildData.Sides[a].Side=asrCenter then NewSpace:=0; ChildData.Sides[a].Space:=NewSpace; @@ -895,12 +908,16 @@ begin // setup space for dependencies SetupSpace; - //WriteDebugReport('Space completed',''); + {$IFDEF VerboseAutoSizeCtrlData} + WriteDebugReport('Space completed',''); + {$ENDIF} // calculate the needed positions for all childs until ComputePositions; - //WriteDebugReport('Positions completed',''); + {$IFDEF VerboseAutoSizeCtrlData} + WriteDebugReport('Positions completed',''); + {$ENDIF} // compute needed clientwidth/clientheight for i:=0 to ChildCount-1 do begin @@ -923,7 +940,9 @@ begin end; end; - //DebugLn(['TAutoSizeCtrlData.ComputePreferredClientArea END ',DbgSName(Control),' PreferredClientWidth/height=',PreferredClientWidth,',',PreferredClientHeight]); + {$IFDEF VerboseAutoSizeCtrlData} + DebugLn(['TAutoSizeCtrlData.ComputePreferredClientArea END ',DbgSName(Control),' PreferredClientWidth/height=',PreferredClientWidth,',',PreferredClientHeight]); + {$ENDIF} end; procedure TAutoSizeCtrlData.FixControlProperties(Child: TControl); @@ -2024,6 +2043,8 @@ procedure TWinControl.AlignControls(AControl: TControl; var AlignList: TFPList; BoundsMutated: boolean; + LastBoundsMutated: TControl; + LastBoundsMutatedOld: TRect; RemainingBorderSpace: TRect; // borderspace around RemainingClientRect // e.g. Right=3 means borderspace of 3 @@ -2459,6 +2480,10 @@ var //DebugLn(['DoPosition ',DbgSName(Control),' ',cfAutoSizeNeeded in Control.FControlFlags]); NewBounds:=Control.BoundsRect; BoundsMutated:=not CompareRect(@OldBounds,@NewBounds); + if BoundsMutated then begin + LastBoundsMutated:=Control; + LastBoundsMutatedOld:=OldBounds; + end; // Sometimes SetBounds change the bounds. For example due to constraints. // update the new bounds with Control do @@ -2472,7 +2497,7 @@ var //if csDesigning in Control.ComponentState then if CheckPosition(Control) then with Control do - DebugLn('[TWinControl.AlignControls.DoPosition] AFTER SETBOUND Control=',Name,':',ClassName,' Bounds=',DbgS(Left,Top,Width,Height)); + DebugLn('[TWinControl.AlignControls.DoPosition] AFTER SETBOUND Control=',DbgSName(Control),' Bounds=',DbgS(Control.BoundsRect)); {$ENDIF} end; @@ -2579,6 +2604,7 @@ var //debugln('DoAlignNotAligned ',DbgSName(Self),' AlignList.Count=',dbgs(AlignList.Count)); if AlignList.Count=0 then exit; + LastBoundsMutated:=nil; AlignNonAlignedControls(AlignList,BoundsMutated); end; @@ -2587,11 +2613,21 @@ var ChildControl: TControl; OldRemainingClientRect: TRect; OldRemainingBorderSpace: TRect; + MaxTries: LongInt; begin if wcfAligningControls in FWinControlFlags then exit; Include(FWinControlFlags,wcfAligningControls); //debugln('TWinControl.AlignControls ',DbgSName(Self)); + // call delayed autosize + for i:=ControlCount-1 downto 0 do begin + ChildControl:=Controls[i]; + if cfAutoSizeNeeded in ChildControl.FControlFlags then begin + //DebugLn(['TWinControl.AlignControls ',DbgSName(Self),' autosize needed for child ',DbgSName(ChildControl)]); + ChildControl.AdjustSize; + end; + end; + // unset all align needed flags Exclude(FWinControlFlags,wcfReAlignNeeded); for i:=ControlCount-1 downto 0 do begin @@ -2620,7 +2656,9 @@ begin // and so forth. This is allowed, so do up to n loop step. // Do not more, to avoid endless loops, if there are circle // dependencies. - for i:=0 to ControlCount-1 do begin + MaxTries:=ControlCount; + {$IFDEF CHECK_POSITION}inc(MaxTries);{$ENDIF} + for i:=1 to MaxTries do begin // align and anchor child controls BoundsMutated:=false; OldRemainingClientRect:=RemainingClientRect; @@ -2634,6 +2672,11 @@ begin DoAlign(alNone); DoAlignNotAligned; if not BoundsMutated then break; + if (i=ControlCount+1) then begin + DebugLn(['TWinControl.AlignControls ENDLESS LOOP STOPPED ',DbgSName(Self),' i=',i]); + if LastBoundsMutated<>nil then + DebugLn(['TWinControl.AlignControls LAST CHANGED: ',DbgSName(LastBoundsMutated),' Old=',dbgs(LastBoundsMutatedOld),' Now=',dbgs(LastBoundsMutated.BoundsRect)]); + end; // update again RemainingClientRect:=OldRemainingClientRect; RemainingBorderSpace:=OldRemainingBorderSpace;