designer: cancel move/resize operation on ESC key press (issue #0010981)

git-svn-id: trunk@21755 -
This commit is contained in:
paul 2009-09-18 07:36:09 +00:00
parent f4defcfde3
commit 6daf1895cc
2 changed files with 45 additions and 15 deletions

View File

@ -397,7 +397,6 @@ type
procedure AssignSelection(const ASelection: TPersistentSelectionList); procedure AssignSelection(const ASelection: TPersistentSelectionList);
function IsSelected(APersistent: TPersistent): Boolean; function IsSelected(APersistent: TPersistent): Boolean;
function IsOnlySelected(APersistent: TPersistent): Boolean; function IsOnlySelected(APersistent: TPersistent): Boolean;
procedure SaveBounds;
function ParentLevel: integer; function ParentLevel: integer;
function OnlyNonVisualPersistentsSelected: boolean; function OnlyNonVisualPersistentsSelected: boolean;
function OnlyVisualComponentsSelected: boolean; function OnlyVisualComponentsSelected: boolean;
@ -409,7 +408,9 @@ type
function IsResizing: boolean; function IsResizing: boolean;
procedure BeginResizing; procedure BeginResizing;
procedure EndResizing(ApplyUserBounds: boolean); procedure EndResizing(ApplyUserBounds: boolean);
procedure SaveBounds;
procedure UpdateBounds; procedure UpdateBounds;
procedure RestoreBounds;
procedure MoveSelection(dx, dy: integer); procedure MoveSelection(dx, dy: integer);
function MoveSelectionWithSnapping(TotalDX, TotalDY: integer): boolean; function MoveSelectionWithSnapping(TotalDX, TotalDY: integer): boolean;
@ -1098,6 +1099,29 @@ begin
Exclude(FStates,cssBoundsNeedsUpdate); Exclude(FStates,cssBoundsNeedsUpdate);
end; end;
procedure TControlSelection.RestoreBounds;
var
i: integer;
OldLeftTop: TPoint;
begin
BeginUpdate;
FLeft := OldLeft;
FTop := OldTop;
FWidth := FOldWidth;
FHeight := FOldHeight;
for i := 0 to Count - 1 do
begin
with Items[i] do
begin
OldLeftTop := OldFormRelativeLeftTop;
SetFormRelativeBounds(OldLeftTop.X, OldLeftTop.Y, OldWidth, OldHeight);
end;
InvalidateGuideLinesCache;
end;
UpdateRealBounds;
EndUpdate;
end;
procedure TControlSelection.AdjustGrabbers; procedure TControlSelection.AdjustGrabbers;
var g:TGrabIndex; var g:TGrabIndex;
OutPix, InPix, NewGrabberLeft, NewGrabberTop: integer; OutPix, InPix, NewGrabberLeft, NewGrabberTop: integer;
@ -1931,15 +1955,18 @@ begin
end; end;
procedure TControlSelection.SaveBounds; procedure TControlSelection.SaveBounds;
var i:integer; var
i: integer;
g: TGrabIndex; g: TGrabIndex;
begin begin
if cssNotSavingBounds in FStates then exit; if cssNotSavingBounds in FStates then exit;
//debugln('TControlSelection.SaveBounds'); //debugln('TControlSelection.SaveBounds');
if FUpdateLock>0 then begin if FUpdateLock > 0 then
begin
Include(FStates, cssBoundsNeedsSaving); Include(FStates, cssBoundsNeedsSaving);
exit; Exit;
end; end;
for i := 0 to FControls.Count - 1 do Items[i].SaveBounds; for i := 0 to FControls.Count - 1 do Items[i].SaveBounds;
for g := Low(TGrabIndex) to High(TGrabIndex) do FGrabbers[g].SaveBounds; for g := Low(TGrabIndex) to High(TGrabIndex) do FGrabbers[g].SaveBounds;
FOldLeft := FRealLeft; FOldLeft := FRealLeft;

View File

@ -735,8 +735,10 @@ procedure TDesigner.SelectParentOfSelection;
var var
i: Integer; i: Integer;
begin begin
if ControlSelection.ActiveGrabber <> nil then // resizing or moving
if dfHasSized in FFlags then
begin begin
ControlSelection.RestoreBounds;
ControlSelection.ActiveGrabber := nil; ControlSelection.ActiveGrabber := nil;
if ControlSelection.RubberbandActive then if ControlSelection.RubberbandActive then
ControlSelection.RubberbandActive := False; ControlSelection.RubberbandActive := False;
@ -756,6 +758,7 @@ begin
Exit; Exit;
end; end;
// if not component moving then select parent
i:=ControlSelection.Count-1; i:=ControlSelection.Count-1;
while (i>=0) while (i>=0)
and ( (ControlSelection[i].ParentInSelection) and ( (ControlSelection[i].ParentInSelection)