IDE: designer: fixed csDesignFixedBounds

git-svn-id: trunk@40153 -
This commit is contained in:
mattias 2013-02-03 11:51:16 +00:00
parent a49c504df0
commit 251a4c02ff

View File

@ -403,7 +403,7 @@ type
function OnlyNonVisualPersistentsSelected: boolean; function OnlyNonVisualPersistentsSelected: boolean;
function OnlyVisualComponentsSelected: boolean; function OnlyVisualComponentsSelected: boolean;
function OnlyInvisiblePersistentsSelected: boolean; function OnlyInvisiblePersistentsSelected: boolean;
function OnlyBoundLessComponentsSelected: boolean; function OnlyBoundlessComponentsSelected: boolean;
function LookupRootSelected: boolean; function LookupRootSelected: boolean;
// resizing, moving, aligning, mirroring, ... // resizing, moving, aligning, mirroring, ...
@ -1185,66 +1185,78 @@ var
i: integer; i: integer;
OldLeftTop: TPoint; OldLeftTop: TPoint;
NewLeft, NewTop, NewRight, NewBottom, NewWidth, NewHeight: integer; NewLeft, NewTop, NewRight, NewBottom, NewWidth, NewHeight: integer;
Item: TSelectedControl;
begin begin
BeginUpdate; BeginUpdate;
if Count=1 then begin try
// single selection if Count=1 then begin
NewLeft:=FLeft; // single selection
NewTop:=FTop; NewLeft:=FLeft;
NewRight:=FLeft+FWidth; NewTop:=FTop;
NewBottom:=FTop+FHeight; NewRight:=FLeft+FWidth;
{$IFDEF VerboseDesigner} NewBottom:=FTop+FHeight;
DebugLn('[TControlSelection.DoApplyUserBounds] S Old=', {$IFDEF VerboseDesigner}
DbgS(FOldLeft,FOldTop,FOldWidth,FOldHeight), DebugLn('[TControlSelection.DoApplyUserBounds] S Old=',
' User=',Dbgs(FLeft,FTop,FWidth,FHeight)); DbgS(FOldLeft,FOldTop,FOldWidth,FOldHeight),
{$ENDIF} ' User=',Dbgs(FLeft,FTop,FWidth,FHeight));
//DebugLn(['TControlSelection.DoApplyUserBounds BEFORE ',Items[0].Left,' ',Items[0].Top]); {$ENDIF}
Items[0].SetFormRelativeBounds( Item:=Items[0];
Min(NewLeft,NewRight), //DebugLn(['TControlSelection.DoApplyUserBounds BEFORE ',Items.Left,' ',Items[0].Top]);
Min(NewTop,NewBottom), if Item.IsTComponent
Abs(FWidth), and (not ComponentBoundsDesignable(TComponent(Item.Persistent))) then
Abs(FHeight) exit;
); Item.SetFormRelativeBounds(
//DebugLn(['TControlSelection.DoApplyUserBounds AFTER ',Items[0].Left,' ',Items[0].Top]); Min(NewLeft,NewRight),
InvalidateGuideLinesCache; Min(NewTop,NewBottom),
end else if Count>1 then begin Abs(FWidth),
// multi selection Abs(FHeight)
{$IFDEF VerboseDesigner} );
DebugLn('[TControlSelection.DoApplyUserBounds] M Old=', //DebugLn(['TControlSelection.DoApplyUserBounds AFTER ',Items.Left,' ',Items[0].Top]);
DbgS(FOldLeft,FOldTop,FOldWidth,FOldHeight),
' User=',DbgS(FLeft,FTop,FWidth,FHeight));
{$ENDIF}
// ToDo: sort selection with parent level and size/move parents first
if (FOldWidth<>0) and (FOldHeight<>0) then begin
for i:=0 to Count-1 do begin
OldLeftTop:=Items[i].OldFormRelativeLeftTop;
NewLeft:=FLeft + (((OldLeftTop.X-FOldLeft) * FWidth) div FOldWidth);
NewTop:=FTop + (((OldLeftTop.Y-FOldTop) * FHeight) div FOldHeight);
NewWidth:=(Items[i].OldWidth*FWidth) div FOldWidth;
NewHeight:=(Items[i].OldHeight*FHeight) div FOldHeight;
if NewWidth<0 then begin
NewWidth:=-NewWidth;
dec(NewLeft,NewWidth);
end;
if NewWidth<1 then NewWidth:=1;
if NewHeight<0 then begin
NewHeight:=-NewHeight;
dec(NewTop,NewHeight);
end;
if NewHeight<1 then NewHeight:=1;
Items[i].SetFormRelativeBounds(NewLeft,NewTop,NewWidth,NewHeight);
{$IFDEF VerboseDesigner}
DebugLn(' i=',Dbgs(i),' ',DbgSName(Items[i].Persistent),
' ',DbgS(Items[i].Left,Items[i].Top,Items[i].Width,Items[i].Height));
{$ENDIF}
end;
InvalidateGuideLinesCache; InvalidateGuideLinesCache;
end else if Count>1 then begin
// multi selection
{$IFDEF VerboseDesigner}
DebugLn('[TControlSelection.DoApplyUserBounds] M Old=',
DbgS(FOldLeft,FOldTop,FOldWidth,FOldHeight),
' User=',DbgS(FLeft,FTop,FWidth,FHeight));
{$ENDIF}
// ToDo: sort selection with parent level and size/move parents first
if (FOldWidth<>0) and (FOldHeight<>0) then begin
for i:=0 to Count-1 do begin
Item:=Items[i];
if Item.IsTComponent
and (not ComponentBoundsDesignable(TComponent(Item.Persistent))) then
continue;
OldLeftTop:=Items[i].OldFormRelativeLeftTop;
NewLeft:=FLeft + (((OldLeftTop.X-FOldLeft) * FWidth) div FOldWidth);
NewTop:=FTop + (((OldLeftTop.Y-FOldTop) * FHeight) div FOldHeight);
NewWidth:=(Item.OldWidth*FWidth) div FOldWidth;
NewHeight:=(Item.OldHeight*FHeight) div FOldHeight;
if NewWidth<0 then begin
NewWidth:=-NewWidth;
dec(NewLeft,NewWidth);
end;
if NewWidth<1 then NewWidth:=1;
if NewHeight<0 then begin
NewHeight:=-NewHeight;
dec(NewTop,NewHeight);
end;
if NewHeight<1 then NewHeight:=1;
Item.SetFormRelativeBounds(NewLeft,NewTop,NewWidth,NewHeight);
{$IFDEF VerboseDesigner}
DebugLn(' i=',Dbgs(i),' ',DbgSName(Item.Persistent),
' ',DbgS(Item.Left,Item.Top,Item.Width,Item.Height));
{$ENDIF}
end;
InvalidateGuideLinesCache;
end;
end; end;
finally
UpdateBounds;
EndUpdate;
end; end;
UpdateBounds;
EndUpdate;
end; end;
procedure TControlSelection.UpdateRealBounds; procedure TControlSelection.UpdateRealBounds;
@ -2722,7 +2734,7 @@ begin
Result:=cssOnlyInvisibleSelected in FStates; Result:=cssOnlyInvisibleSelected in FStates;
end; end;
function TControlSelection.OnlyBoundLessComponentsSelected: boolean; function TControlSelection.OnlyBoundlessComponentsSelected: boolean;
var var
i: Integer; i: Integer;
begin begin