IDE: reduced updating window menu on idle

git-svn-id: trunk@22973 -
This commit is contained in:
mattias 2009-12-05 10:17:51 +00:00
parent 82643dcee2
commit ffa522c0ae
3 changed files with 16 additions and 5 deletions

View File

@ -1260,7 +1260,7 @@ begin
// load package configs
HelpBoss.LoadHelpOptions;
UpdateWindowMenu;
UpdateWindowMenu(true);
end;
procedure TMainIDE.StartIDE;
@ -2025,7 +2025,7 @@ begin
// create new project
DoNewProject(ProjectDescriptorApplication);
UpdateWindowMenu;
UpdateWindowMenu(true);
// load the cmd line files
if CmdLineFiles<>nil then begin

View File

@ -85,6 +85,7 @@ type
FToolStatus: TIDEToolStatus;
protected
FNeedUpdateHighlighters: boolean;
FLastWindowMenuUpdate: TDateTime;
function CreateMenuSeparator : TMenuItem;
procedure CreateMenuItem(Section: TIDEMenuSection;
@ -157,7 +158,7 @@ type
function DoOpenMacroFile(Sender: TObject; const AFilename: string
): TModalResult; override;
procedure UpdateWindowMenu; override;
procedure UpdateWindowMenu(Immediately: boolean = false); override;
procedure SetRecentSubMenu(Section: TIDEMenuSection; FileList: TStringList;
OnClickEvent: TNotifyEvent); override;
procedure UpdateHighlighters(Immediately: boolean = false); override;
@ -1013,7 +1014,9 @@ begin
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofConvertMacros]);
end;
procedure TMainIDEBase.UpdateWindowMenu;
procedure TMainIDEBase.UpdateWindowMenu(Immediately: boolean = false);
const
UpdatePause = 5/864000; // half a second
function GetMenuItem(Index: Integer): TIDEMenuItem; inline;
begin
@ -1029,7 +1032,15 @@ var
i, ItemCount: Integer;
CurMenuItem: TIDEMenuItem;
AForm: TForm;
t: TDateTime;
begin
t:=Now;
if (not Immediately) then begin
if (FLastWindowMenuUpdate<>0) and (t-FLastWindowMenuUpdate<UpdatePause) then
exit;
end;
FLastWindowMenuUpdate:=t;
WindowsList:=TFPList.Create;
// add typical IDE windows at the start of the list
if (SourceNotebook<>nil) and (SourceNotebook.Visible) then

View File

@ -164,7 +164,7 @@ type
function DoFixupComponentReferences(RootComponent: TComponent;
OpenFlags: TOpenFlags): TModalResult; virtual; abstract;
procedure UpdateWindowMenu; virtual; abstract;
procedure UpdateWindowMenu(Immediately: boolean = false); virtual; abstract;
procedure SaveEnvironment; virtual; abstract;
procedure UpdateHighlighters(Immediately: boolean = false); virtual; abstract;
procedure SetRecentSubMenu(Section: TIDEMenuSection; FileList: TStringList;