IDE: update edit menu for designer. Issue #31519

git-svn-id: trunk@54382 -
This commit is contained in:
ondrej 2017-03-10 15:09:31 +00:00
parent bc9ea113b6
commit 8ea54156de
3 changed files with 27 additions and 7 deletions

View File

@ -320,6 +320,7 @@ type
FLookupRoot: TComponent;// component owning the selected components FLookupRoot: TComponent;// component owning the selected components
FStates: TControlSelStates; FStates: TControlSelStates;
FUpdateLock: integer; FUpdateLock: integer;
FChangeStamp: int64;
function CompareBottom(Index1, Index2: integer): integer; function CompareBottom(Index1, Index2: integer): integer;
function CompareHorCenter(Index1, Index2: integer): integer; function CompareHorCenter(Index1, Index2: integer): integer;
@ -523,6 +524,7 @@ type
property OnSelectionFormChanged: TOnSelectionFormChanged property OnSelectionFormChanged: TOnSelectionFormChanged
read FOnSelectionFormChanged write FOnSelectionFormChanged; read FOnSelectionFormChanged write FOnSelectionFormChanged;
property LookupRoot: TComponent read FLookupRoot; property LookupRoot: TComponent read FLookupRoot;
property ChangeStamp: int64 read FChangeStamp;
end; end;
@ -2083,6 +2085,9 @@ begin
else else
begin begin
Exclude(FStates, cssChangedDuringLock); Exclude(FStates, cssChangedDuringLock);
{$push}{$R-} // range check off
Inc(FChangeStamp);
{$pop}
if Assigned(FOnChange) then if Assigned(FOnChange) then
FOnChange(Self, ForceUpdate); FOnChange(Self, ForceUpdate);
end; end;

View File

@ -3661,7 +3661,8 @@ var
CurWordAtCursor: string; CurWordAtCursor: string;
begin begin
GetCurrentUnit(ASrcEdit, AnUnitInfo); GetCurrentUnit(ASrcEdit, AnUnitInfo);
if not UpdateEditorCommandsStamp.Changed(ASrcEdit, DisplayState) then ActiveDesigner := GetActiveDesignerSkipMainBar;
if not UpdateEditorCommandsStamp.Changed(ASrcEdit, ActiveDesigner as TDesigner, DisplayState) then
Exit; Exit;
Editable := Assigned(ASrcEdit) and not ASrcEdit.ReadOnly; Editable := Assigned(ASrcEdit) and not ASrcEdit.ReadOnly;
@ -3669,7 +3670,6 @@ begin
SelEditable := Editable and SelAvail; SelEditable := Editable and SelAvail;
SrcEditorActive := DisplayState = dsSource; SrcEditorActive := DisplayState = dsSource;
DsgEditorActive := DisplayState = dsForm; DsgEditorActive := DisplayState = dsForm;
ActiveDesigner := GetActiveDesignerSkipMainBar;
if ASrcEdit<>nil then if ASrcEdit<>nil then
begin begin

View File

@ -53,7 +53,7 @@ uses
ControlSelection, FormEditor, EmptyMethodsDlg, BaseDebugManager, TransferMacros, ControlSelection, FormEditor, EmptyMethodsDlg, BaseDebugManager, TransferMacros,
BuildManager, EditorMacroListViewer, FindRenameIdentifier, GenericCheckList, BuildManager, EditorMacroListViewer, FindRenameIdentifier, GenericCheckList,
ViewUnit_Dlg, DiskDiffsDialog, InputHistory, CheckLFMDlg, PublishModule, etMessagesWnd, ViewUnit_Dlg, DiskDiffsDialog, InputHistory, CheckLFMDlg, PublishModule, etMessagesWnd,
ConvCodeTool, BasePkgManager, PackageDefs, PackageSystem; ConvCodeTool, BasePkgManager, PackageDefs, PackageSystem, Designer;
type type
@ -105,8 +105,13 @@ type
FDisplayState: TDisplayState; FDisplayState: TDisplayState;
FEditorComponentStamp: int64; FEditorComponentStamp: int64;
FEditorCaretStamp: int64; FEditorCaretStamp: int64;
FDesigner: TDesigner;
FDesignerSelectionStamp: int64;
FDesignerStamp: int64;
public public
function Changed(ASrcEdit: TSourceEditor; ADisplayState: TDisplayState): Boolean; function Changed(ASrcEdit: TSourceEditor; ADesigner: TDesigner;
ADisplayState: TDisplayState): Boolean;
end; end;
{ TFileOpener } { TFileOpener }
@ -546,25 +551,35 @@ end;
{ TSourceEditorCommandsStamp } { TSourceEditorCommandsStamp }
function TSourceEditorCommandsStamp.Changed(ASrcEdit: TSourceEditor; function TSourceEditorCommandsStamp.Changed(ASrcEdit: TSourceEditor;
ADisplayState: TDisplayState): Boolean; ADesigner: TDesigner; ADisplayState: TDisplayState): Boolean;
begin begin
Result := not( Result := not(
(FSrcEdit = ASrcEdit) (FSrcEdit = ASrcEdit)
and (FDesigner = ADesigner)
and (FDisplayState = ADisplayState)
and ((ASrcEdit = nil) or ( and ((ASrcEdit = nil) or (
(FDisplayState = ADisplayState) (FEditorComponentStamp = ASrcEdit.EditorComponent.ChangeStamp)
and (FEditorComponentStamp = ASrcEdit.EditorComponent.ChangeStamp)
and (FEditorCaretStamp = ASrcEdit.EditorComponent.CaretStamp))) and (FEditorCaretStamp = ASrcEdit.EditorComponent.CaretStamp)))
and ((ADesigner = nil) or (
(FDesignerSelectionStamp = ADesigner.Selection.ChangeStamp)
and (FDesignerStamp = ADesigner.ChangeStamp)))
); );
if not Result then Exit; if not Result then Exit;
FSrcEdit := ASrcEdit; FSrcEdit := ASrcEdit;
FDesigner := ADesigner;
FDisplayState := ADisplayState; FDisplayState := ADisplayState;
if ASrcEdit<>nil then if ASrcEdit<>nil then
begin begin
FEditorComponentStamp := ASrcEdit.EditorComponent.ChangeStamp; FEditorComponentStamp := ASrcEdit.EditorComponent.ChangeStamp;
FEditorCaretStamp := ASrcEdit.EditorComponent.CaretStamp; FEditorCaretStamp := ASrcEdit.EditorComponent.CaretStamp;
end; end;
if ADesigner<>nil then
begin
FDesignerSelectionStamp := ADesigner.Selection.ChangeStamp;
FDesignerStamp := ADesigner.ChangeStamp;
end;
end; end;
//============================================================================== //==============================================================================