mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-20 17:48:16 +02:00
LCL: TAnchorSide.GetSidePosition check always for circles
git-svn-id: trunk@20298 -
This commit is contained in:
parent
8ac8d4e9f9
commit
e50a4f4556
@ -1736,6 +1736,7 @@ begin
|
|||||||
CurrentIdentifierList.ContextFlags:=
|
CurrentIdentifierList.ContextFlags:=
|
||||||
CurrentIdentifierList.ContextFlags+[ilcfStartInStatement];
|
CurrentIdentifierList.ContextFlags+[ilcfStartInStatement];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// context in front of
|
// context in front of
|
||||||
StartPosOfVariable:=FindStartOfVariable(IdentStartPos);
|
StartPosOfVariable:=FindStartOfVariable(IdentStartPos);
|
||||||
if StartPosOfVariable>0 then begin
|
if StartPosOfVariable>0 then begin
|
||||||
|
@ -3269,41 +3269,52 @@ var
|
|||||||
MaxChainLength: LongInt;
|
MaxChainLength: LongInt;
|
||||||
OwnerBorderSpacing: LongInt;
|
OwnerBorderSpacing: LongInt;
|
||||||
OwnerParent: TWinControl;
|
OwnerParent: TWinControl;
|
||||||
|
Found: Boolean;
|
||||||
|
CurReferenceControl: TControl;
|
||||||
|
CurReferenceSide: TAnchorSideReference;
|
||||||
begin
|
begin
|
||||||
ReferenceControl:=Control;
|
ReferenceControl:=nil;
|
||||||
ReferenceSide:=Side;
|
ReferenceSide:=Side;
|
||||||
Position:=0;
|
Position:=0;
|
||||||
OwnerParent:=FOwner.Parent;
|
OwnerParent:=FOwner.Parent;
|
||||||
if OwnerParent=nil then begin
|
if OwnerParent=nil then begin
|
||||||
// AnchorSide is only between siblings or its direct parent allowed
|
// AnchorSide is only between siblings or its direct parent allowed
|
||||||
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition OwnerParent=nil']);
|
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition OwnerParent=nil']);
|
||||||
ReferenceControl:=nil;
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
ChainLength:=0;
|
ChainLength:=0;
|
||||||
MaxChainLength:=OwnerParent.ControlCount;
|
MaxChainLength:=OwnerParent.ControlCount;
|
||||||
while ReferenceControl<>nil do begin
|
Found:=false;
|
||||||
|
CurReferenceControl:=Control;
|
||||||
|
CurReferenceSide:=Side;
|
||||||
|
while CurReferenceControl<>nil do begin
|
||||||
|
|
||||||
// check for circles
|
// check for circles
|
||||||
inc(ChainLength);
|
inc(ChainLength);
|
||||||
if ChainLength>MaxChainLength then begin
|
if ChainLength>MaxChainLength then begin
|
||||||
// the chain has more elements than there are siblings -> circle
|
// the chain has more elements than there are siblings -> circle
|
||||||
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition Circle']);
|
//if CheckPosition(Owner) then
|
||||||
|
DebugLn(['TAnchorSide.GetSidePosition Circle ',DbgSName(Owner)]);
|
||||||
ReferenceControl:=nil;
|
ReferenceControl:=nil;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check if ReferenceControl is valid
|
// check if ReferenceControl is valid
|
||||||
if (ReferenceControl.Parent<>OwnerParent)
|
if (CurReferenceControl.Parent<>OwnerParent)
|
||||||
and (ReferenceControl<>OwnerParent) then begin
|
and (CurReferenceControl<>OwnerParent) then begin
|
||||||
// not a sibling and not the parent -> invalid AnchorSide
|
// not a sibling and not the parent -> invalid AnchorSide
|
||||||
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition invalid AnchorSide ',dbgsName(ReferenceControl)]);
|
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition invalid AnchorSide ',dbgsName(ReferenceControl)]);
|
||||||
ReferenceControl:=nil;
|
ReferenceControl:=nil;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if ReferenceControl.IsControlVisible then begin
|
if CurReferenceControl.IsControlVisible then begin
|
||||||
// ReferenceControl is visible
|
// ReferenceControl is visible
|
||||||
|
if not Found then begin
|
||||||
|
Found:=true;
|
||||||
|
ReferenceControl:=CurReferenceControl;
|
||||||
|
ReferenceSide:=CurReferenceSide;
|
||||||
|
|
||||||
// -> calculate Position
|
// -> calculate Position
|
||||||
OwnerBorderSpacing:=FOwner.BorderSpacing.GetSpace(Kind);
|
OwnerBorderSpacing:=FOwner.BorderSpacing.GetSpace(Kind);
|
||||||
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition ',dbgsName(Owner),' ReferenceControl=',dbgsName(ReferenceControl),' ',dbgs(ReferenceControl.BoundsRect),' OwnerBorderSpacing=',OwnerBorderSpacing,' Kind=',dbgs(Kind),' ReferenceSide=',dbgs(Kind,ReferenceSide)]);
|
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition ',dbgsName(Owner),' ReferenceControl=',dbgsName(ReferenceControl),' ',dbgs(ReferenceControl.BoundsRect),' OwnerBorderSpacing=',OwnerBorderSpacing,' Kind=',dbgs(Kind),' ReferenceSide=',dbgs(Kind,ReferenceSide)]);
|
||||||
@ -3421,38 +3432,44 @@ begin
|
|||||||
else
|
else
|
||||||
RaiseInvalidSide;
|
RaiseInvalidSide;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
// side found
|
// side found
|
||||||
exit;
|
// continue to detect circles
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// ReferenceControl is not visible -> try next
|
// try next
|
||||||
NextReferenceSide:=nil;
|
NextReferenceSide:=nil;
|
||||||
if ReferenceControl<>OwnerParent then begin
|
if CurReferenceControl<>OwnerParent then
|
||||||
if ReferenceSide=asrCenter then begin
|
begin
|
||||||
|
if CurReferenceSide=asrCenter then
|
||||||
|
begin
|
||||||
// center can only be anchored to another centered anchor
|
// center can only be anchored to another centered anchor
|
||||||
if Kind in [akLeft,akRight] then begin
|
if Kind in [akLeft,akRight] then
|
||||||
if not GetNextCentered(ReferenceControl,akLeft,NextReferenceSide)
|
begin
|
||||||
then GetNextCentered(ReferenceControl,akRight,NextReferenceSide);
|
if not GetNextCentered(CurReferenceControl,akLeft,NextReferenceSide)
|
||||||
|
then GetNextCentered(CurReferenceControl,akRight,NextReferenceSide);
|
||||||
end else begin
|
end else begin
|
||||||
if not GetNextCentered(ReferenceControl,akTop,NextReferenceSide)
|
if not GetNextCentered(CurReferenceControl,akTop,NextReferenceSide)
|
||||||
then GetNextCentered(ReferenceControl,akBottom,NextReferenceSide);
|
then GetNextCentered(CurReferenceControl,akBottom,NextReferenceSide);
|
||||||
end;
|
end;
|
||||||
end else if (ReferenceSide=asrLeft) = (Kind in [akLeft,akTop]) then begin
|
end else if (CurReferenceSide=asrLeft) = (Kind in [akLeft,akTop]) then
|
||||||
|
begin
|
||||||
// anchor parallel (e.g. a left side to a left side)
|
// anchor parallel (e.g. a left side to a left side)
|
||||||
NextReferenceSide:=ReferenceControl.AnchorSide[Kind];
|
NextReferenceSide:=CurReferenceControl.AnchorSide[Kind];
|
||||||
end else begin
|
end else begin
|
||||||
// anchor opposite (e.g. a left side to a right side)
|
// anchor opposite (e.g. a left side to a right side)
|
||||||
NextReferenceSide:=ReferenceControl.AnchorSide[Kind];
|
NextReferenceSide:=CurReferenceControl.AnchorSide[Kind];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (NextReferenceSide=nil) then begin
|
if (NextReferenceSide=nil) then
|
||||||
|
begin
|
||||||
|
// no further side => anchor ok
|
||||||
//if CheckPosition(Owner) and (Kind=akRight) then
|
//if CheckPosition(Owner) and (Kind=akRight) then
|
||||||
// DebugLn(['TAnchorSide.GetSidePosition not IsControlVisible ReferenceControl=',dbgsName(ReferenceControl)]);
|
// DebugLn(['TAnchorSide.GetSidePosition not IsControlVisible ReferenceControl=',dbgsName(ReferenceControl)]);
|
||||||
ReferenceControl:=nil;
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
ReferenceControl:=NextReferenceSide.Control;
|
CurReferenceControl:=NextReferenceSide.Control;
|
||||||
ReferenceSide:=NextReferenceSide.Side;
|
CurReferenceSide:=NextReferenceSide.Side;
|
||||||
//DebugLn(['TAnchorSide.GetSidePosition ',DbgSName(FOwner),' ReferenceControl=',DbgSName(ReferenceControl),' Kind=',dbgs(Kind),' ReferenceSide=',dbgs(Kind,ReferenceSide)]);
|
//DebugLn(['TAnchorSide.GetSidePosition ',DbgSName(FOwner),' ReferenceControl=',DbgSName(ReferenceControl),' Kind=',dbgs(Kind),' ReferenceSide=',dbgs(Kind,ReferenceSide)]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user