mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 05:01:50 +02:00
IDE: anchor editor: warn for circles
git-svn-id: trunk@26219 -
This commit is contained in:
parent
061e3724eb
commit
60adf0cc86
@ -406,6 +406,7 @@ var
|
||||
NewValue: String;
|
||||
UseNeighbours: boolean;
|
||||
OldPositions,OldPositions2: array of Integer;
|
||||
|
||||
function NeighbourPosition(c: tcontrol):Integer;
|
||||
begin
|
||||
case CurNeighbour of
|
||||
@ -436,6 +437,10 @@ var
|
||||
result:=tcontrol(SelectedControls[resultId]);
|
||||
end;
|
||||
|
||||
var
|
||||
ReferenceControl: TControl;
|
||||
ReferenceSide: TAnchorSideReference;
|
||||
CheckPosition: Integer;
|
||||
begin
|
||||
//debugln('TAnchorDesigner.SiblingComboBoxChange ',DbgSName(Sender),' ',TComboBox(Sender).Text);
|
||||
if FUpdating or (Values=nil) then exit;
|
||||
@ -484,10 +489,10 @@ begin
|
||||
setlength(OldPositions,SelectedControls.Count);
|
||||
setlength(OldPositions2,SelectedControls.Count);
|
||||
for i:=0 to SelectedControls.Count-1 do begin
|
||||
OldPositions[i]:=NeighbourPosition(tcontrol(SelectedControls[i]));
|
||||
OldPositions[i]:=NeighbourPosition(TControl(SelectedControls[i]));
|
||||
case CurNeighbour of
|
||||
akLeft,akRight: OldPositions2[i]:=tcontrol(SelectedControls[i]).top;
|
||||
akTop,akBottom: OldPositions2[i]:=tcontrol(SelectedControls[i]).Left;
|
||||
akLeft,akRight: OldPositions2[i]:=TControl(SelectedControls[i]).top;
|
||||
akTop,akBottom: OldPositions2[i]:=TControl(SelectedControls[i]).Left;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
@ -496,6 +501,27 @@ begin
|
||||
if NewSibling=nil then exit;
|
||||
end;
|
||||
end;
|
||||
// check
|
||||
for i:=0 to SelectedControls.Count-1 do begin
|
||||
CurControl:=TControl(SelectedControls[i]);
|
||||
if UseNeighbours then begin
|
||||
NewSibling:=findNeighbour(i);
|
||||
if (NewSibling=nil) and (i<>0) then continue;
|
||||
end;
|
||||
if not CurControl.AnchorSide[Kind].CheckSidePosition(NewSibling,
|
||||
CurControl.AnchorSide[Kind].Side,
|
||||
ReferenceControl,ReferenceSide,CheckPosition)
|
||||
then begin
|
||||
if MessageDlg(lisCCOWarningCaption,
|
||||
lisThisWillCreateACircle, mtWarning, [mbIgnore, mbCancel], 0)<>
|
||||
mrIgnore
|
||||
then begin
|
||||
Refresh(false);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// commit
|
||||
for i:=0 to SelectedControls.Count-1 do begin
|
||||
CurControl:=TControl(SelectedControls[i]);
|
||||
if UseNeighbours then begin
|
||||
@ -526,6 +552,9 @@ var
|
||||
SelectedControls: TList;
|
||||
i: Integer;
|
||||
CurControl: TControl;
|
||||
ReferenceControl: TControl;
|
||||
ReferenceSide: TAnchorSideReference;
|
||||
CheckPosition: Integer;
|
||||
begin
|
||||
//debugln('TAnchorDesigner.ReferenceSideButtonClicked ',DbgSName(Sender),' ',dbgs(TSpeedButton(Sender).Down));
|
||||
if FUpdating or (Values=nil) then exit;
|
||||
@ -585,6 +614,23 @@ begin
|
||||
// user changed a sibling
|
||||
SelectedControls:=GetSelectedControls;
|
||||
if SelectedControls=nil then exit;
|
||||
// check
|
||||
for i:=0 to SelectedControls.Count-1 do begin
|
||||
CurControl:=TControl(SelectedControls[i]);
|
||||
if not CurControl.AnchorSide[Kind].CheckSidePosition(
|
||||
CurControl.AnchorSide[Kind].Control,Side,
|
||||
ReferenceControl,ReferenceSide,CheckPosition)
|
||||
then begin
|
||||
if MessageDlg(lisCCOWarningCaption,
|
||||
lisThisWillCreateACircle, mtWarning, [mbIgnore, mbCancel], 0)<>
|
||||
mrIgnore
|
||||
then begin
|
||||
Refresh(false);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// commit
|
||||
for i:=0 to SelectedControls.Count-1 do begin
|
||||
CurControl:=TControl(SelectedControls[i]);
|
||||
CurControl.AnchorSide[Kind].Side:=Side;
|
||||
@ -694,7 +740,7 @@ begin
|
||||
//debugln('TAnchorDesigner.Refresh A ');
|
||||
if not Force then begin
|
||||
// check if uddate is needed
|
||||
if not Visible then exit;
|
||||
if not IsVisible then exit;
|
||||
end;
|
||||
if FUpdating then exit;
|
||||
FUpdating:=true;
|
||||
|
@ -4274,6 +4274,7 @@ resourcestring
|
||||
lisLeftGroupBoxCaption = 'Left anchoring';
|
||||
lisBottomGroupBoxCaption = 'Bottom anchoring';
|
||||
lisUnableToSetAnchorSideControl = 'Unable to set AnchorSide Control';
|
||||
lisThisWillCreateACircle = 'This will create a circle.';
|
||||
lisAnchorEditorNoControlSelected = 'Anchor Editor - no control selected';
|
||||
lisAnchorsOfSelectedControls = 'Anchors of selected controls';
|
||||
lisDebugOptionsFrmAdditionalSearchPath = 'Additional search path';
|
||||
|
@ -3675,8 +3675,13 @@ begin
|
||||
// DebugLn(['TAnchorSide.GetSidePosition Success ',DbgSName(Owner),' ReferenceControl=',dbgsName(ReferenceControl),' CurReferenceControl=',DbgSName(CurReferenceControl),' CurReferenceSide=',dbgs(Kind,CurReferenceSide)]);
|
||||
exit(true);
|
||||
end;
|
||||
if NextReferenceSide=Self then begin
|
||||
CurReferenceControl:=NewControl;
|
||||
CurReferenceSide:=NewSide;
|
||||
end else begin
|
||||
CurReferenceControl:=NextReferenceSide.Control;
|
||||
CurReferenceSide:=NextReferenceSide.Side;
|
||||
end;
|
||||
//DebugLn(['TAnchorSide.GetSidePosition ',DbgSName(FOwner),' ReferenceControl=',DbgSName(ReferenceControl),' Kind=',dbgs(Kind),' ReferenceSide=',dbgs(Kind,ReferenceSide)]);
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user