Simplify the component palette update system after packages are loaded.

git-svn-id: trunk@48310 -
This commit is contained in:
juha 2015-03-12 23:01:55 +00:00
parent 0fc74606c5
commit 1efe3b0e31
3 changed files with 11 additions and 63 deletions

View File

@ -216,8 +216,6 @@ type
procedure CacheOrigComponentPages; procedure CacheOrigComponentPages;
function CreatePagesFromUserOrder: Boolean; function CreatePagesFromUserOrder: Boolean;
procedure DoChange; virtual; procedure DoChange; virtual;
procedure DoBeginUpdate; virtual;
procedure DoEndUpdate(Changed: boolean); virtual;
procedure OnPageAddedComponent({%H-}Component: TRegisteredComponent); virtual; procedure OnPageAddedComponent({%H-}Component: TRegisteredComponent); virtual;
procedure OnPageRemovedComponent({%H-}Page: TBaseComponentPage; procedure OnPageRemovedComponent({%H-}Page: TBaseComponentPage;
{%H-}Component: TRegisteredComponent); virtual; {%H-}Component: TRegisteredComponent); virtual;
@ -267,10 +265,7 @@ type
property OrigPagePriorities: TPagePriorityList read fOrigPagePriorities; property OrigPagePriorities: TPagePriorityList read fOrigPagePriorities;
property ComponentPageClass: TBaseComponentPageClass read FComponentPageClass property ComponentPageClass: TBaseComponentPageClass read FComponentPageClass
write FComponentPageClass; write FComponentPageClass;
property UpdateLock: integer read FUpdateLock;
property ChangeStamp: integer read fChangeStamp; property ChangeStamp: integer read fChangeStamp;
property OnBeginUpdate: TNotifyEvent read FOnBeginUpdate write FOnBeginUpdate;
property OnEndUpdate: TEndUpdatePaletteEvent read FOnEndUpdate write FOnEndUpdate;
property HideControls: boolean read FHideControls write FHideControls; property HideControls: boolean read FHideControls write FHideControls;
property Selected: TRegisteredComponent read GetSelected write SetSelected; property Selected: TRegisteredComponent read GetSelected write SetSelected;
// User ordered + original pages and components. // User ordered + original pages and components.
@ -876,16 +871,6 @@ begin
Update(False); Update(False);
end; end;
procedure TBaseComponentPalette.DoBeginUpdate;
begin
end;
procedure TBaseComponentPalette.DoEndUpdate(Changed: boolean);
begin
if Assigned(OnEndUpdate) then OnEndUpdate(Self,Changed);
end;
procedure TBaseComponentPalette.OnPageAddedComponent(Component: TRegisteredComponent); procedure TBaseComponentPalette.OnPageAddedComponent(Component: TRegisteredComponent);
begin begin
DoChange; DoChange;
@ -924,19 +909,19 @@ end;
procedure TBaseComponentPalette.BeginUpdate(Change: boolean); procedure TBaseComponentPalette.BeginUpdate(Change: boolean);
begin begin
inc(FUpdateLock); inc(FUpdateLock);
if FUpdateLock=1 then begin if FUpdateLock=1 then
fChanged:=Change; fChanged:=Change
DoBeginUpdate; else
if Assigned(OnBeginUpdate) then OnBeginUpdate(Self);
end else
fChanged:=fChanged or Change; fChanged:=fChanged or Change;
end; end;
procedure TBaseComponentPalette.EndUpdate; procedure TBaseComponentPalette.EndUpdate;
begin begin
if FUpdateLock<=0 then RaiseException('TBaseComponentPalette.EndUpdate'); if FUpdateLock<=0 then
RaiseException('TBaseComponentPalette.EndUpdate');
dec(FUpdateLock); dec(FUpdateLock);
if FUpdateLock=0 then DoEndUpdate(fChanged); if (FUpdateLock=0) and fChanged then
Update(False);
end; end;
function TBaseComponentPalette.IsUpdateLocked: boolean; function TBaseComponentPalette.IsUpdateLocked: boolean;

View File

@ -101,7 +101,6 @@ type
fComponentButtons: TComponentButtonMap; fComponentButtons: TComponentButtonMap;
// Visual container for tabs // Visual container for tabs
FPageControl: TPageControl; FPageControl: TPageControl;
fNoteBookNeedsUpdate: boolean;
FOnOpenPackage: TNotifyEvent; FOnOpenPackage: TNotifyEvent;
FOnOpenUnit: TNotifyEvent; FOnOpenUnit: TNotifyEvent;
FOnClassSelected: TNotifyEvent; FOnClassSelected: TNotifyEvent;
@ -137,7 +136,6 @@ type
function GetSelectButtonIcon: TCustomBitmap; function GetSelectButtonIcon: TCustomBitmap;
function SelectAButton(Button: TSpeedButton): boolean; function SelectAButton(Button: TSpeedButton): boolean;
protected protected
procedure DoEndUpdate(Changed: boolean); override;
procedure OnPageAddedComponent(Component: TRegisteredComponent); override; procedure OnPageAddedComponent(Component: TRegisteredComponent); override;
procedure OnPageRemovedComponent(Page: TBaseComponentPage; procedure OnPageRemovedComponent(Page: TBaseComponentPage;
Component: TRegisteredComponent); override; Component: TRegisteredComponent); override;
@ -642,7 +640,6 @@ begin
{$IFDEF VerboseComponentPalette} {$IFDEF VerboseComponentPalette}
DebugLn(['TComponentPalette.SetPageControl, calling UpdateNoteBookButtons, ', AValue]); DebugLn(['TComponentPalette.SetPageControl, calling UpdateNoteBookButtons, ', AValue]);
{$ENDIF} {$ENDIF}
UpdateNoteBookButtons(False);
end; end;
procedure TComponentPalette.SelectionToolClick(Sender: TObject); procedure TComponentPalette.SelectionToolClick(Sender: TObject);
@ -798,17 +795,6 @@ begin
PopupMenu.Items.Add(MenuItem); PopupMenu.Items.Add(MenuItem);
end; end;
procedure TComponentPalette.DoEndUpdate(Changed: boolean);
begin
if Changed or fNoteBookNeedsUpdate then begin
{$IFDEF VerboseComponentPalette}
DebugLn(['TComponentPalette.DoEndUpdate, calling UpdateNoteBookButtons, Changed=', Changed]);
{$ENDIF}
UpdateNoteBookButtons(False);
end;
inherited DoEndUpdate(Changed);
end;
procedure TComponentPalette.OnPageMouseWheel(Sender: TObject; Shift: TShiftState; procedure TComponentPalette.OnPageMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin begin
@ -839,8 +825,7 @@ end;
procedure TComponentPalette.Update(ForceUpdateAll: Boolean); procedure TComponentPalette.Update(ForceUpdateAll: Boolean);
begin begin
{$IFDEF VerboseComponentPalette} {$IFDEF VerboseComponentPalette}
DebugLn(['TComponentPalette.Update, calling UpdateNoteBookButtons, fUpdatingPageControl=', DebugLn(['TComponentPalette.Update, calling UpdateNoteBookButtons, fUpdatingPageControl=', fUpdatingPageControl]);
fUpdatingPageControl, ', fNoteBookNeedsUpdate=', fNoteBookNeedsUpdate]);
{$ENDIF} {$ENDIF}
UpdateNoteBookButtons(ForceUpdateAll); UpdateNoteBookButtons(ForceUpdateAll);
end; end;
@ -974,14 +959,8 @@ var
Pg: TComponentPage; Pg: TComponentPage;
begin begin
if fUpdatingPageControl then exit; if fUpdatingPageControl then exit;
if IsUpdateLocked then begin Assert(not IsUpdateLocked, 'TComponentPalette.UpdateNoteBookButtons: IsUpdateLocked');
fNoteBookNeedsUpdate:=true; if FPageControl=Nil then exit;
exit;
end;
if FPageControl=nil then begin
fNoteBookNeedsUpdate:=false;
exit;
end;
// lock // lock
fUpdatingPageControl:=true; fUpdatingPageControl:=true;
FPageControl.DisableAlign; FPageControl.DisableAlign;
@ -1048,7 +1027,6 @@ begin
finally finally
// unlock // unlock
fUpdatingPageControl:=false; fUpdatingPageControl:=false;
fNoteBookNeedsUpdate:=false;
FPageControl.EnableAlign; FPageControl.EnableAlign;
end; end;
end; end;

View File

@ -150,8 +150,6 @@ type
procedure MainIDEitmPackageLinksClicked(Sender: TObject); procedure MainIDEitmPackageLinksClicked(Sender: TObject);
// component palette // component palette
procedure IDEComponentPaletteEndUpdate(Sender: TObject;
PaletteChanged: boolean);
procedure IDEComponentPaletteOpenPackage(Sender: TObject); procedure IDEComponentPaletteOpenPackage(Sender: TObject);
procedure IDEComponentPaletteOpenUnit(Sender: TObject); procedure IDEComponentPaletteOpenUnit(Sender: TObject);
@ -215,7 +213,6 @@ type
procedure SetRecentPackagesMenu; override; procedure SetRecentPackagesMenu; override;
procedure AddToMenuRecentPackages(const Filename: string); procedure AddToMenuRecentPackages(const Filename: string);
procedure SaveSettings; override; procedure SaveSettings; override;
procedure UpdateVisibleComponentPalette; override;
procedure ProcessCommand(Command: word; var Handled: boolean); override; procedure ProcessCommand(Command: word; var Handled: boolean); override;
procedure OnSourceEditorPopupMenu(const AddMenuItemProc: TAddMenuItemProc); override; procedure OnSourceEditorPopupMenu(const AddMenuItemProc: TAddMenuItemProc); override;
procedure TranslateResourceStrings; override; procedure TranslateResourceStrings; override;
@ -465,13 +462,6 @@ begin
end; end;
end; end;
procedure TPkgManager.IDEComponentPaletteEndUpdate(Sender: TObject;
PaletteChanged: boolean);
begin
if PaletteChanged then
UpdateVisibleComponentPalette;
end;
procedure TPkgManager.IDEComponentPaletteOpenPackage(Sender: TObject); procedure TPkgManager.IDEComponentPaletteOpenPackage(Sender: TObject);
begin begin
if (Sender=nil) or (not (Sender is TLazPackage)) then exit; if (Sender=nil) or (not (Sender is TLazPackage)) then exit;
@ -2913,7 +2903,6 @@ begin
// componentpalette // componentpalette
IDEComponentPalette:=TComponentPalette.Create; IDEComponentPalette:=TComponentPalette.Create;
CompPalette:=TComponentPalette(IDEComponentPalette); CompPalette:=TComponentPalette(IDEComponentPalette);
CompPalette.OnEndUpdate:=@IDEComponentPaletteEndUpdate;
CompPalette.OnOpenPackage:=@IDEComponentPaletteOpenPackage; CompPalette.OnOpenPackage:=@IDEComponentPaletteOpenPackage;
CompPalette.OnOpenUnit:=@IDEComponentPaletteOpenUnit; CompPalette.OnOpenUnit:=@IDEComponentPaletteOpenUnit;
@ -3089,6 +3078,7 @@ begin
PackageGraph.LoadStaticBasePackages; PackageGraph.LoadStaticBasePackages;
LoadStaticCustomPackages; LoadStaticCustomPackages;
LoadAutoInstallPackages; LoadAutoInstallPackages;
TComponentPalette(IDEComponentPalette).PageControl:=MainIDEBar.ComponentPageControl;
finally finally
IDEComponentPalette.EndUpdate; IDEComponentPalette.EndUpdate;
end; end;
@ -3107,11 +3097,6 @@ begin
end; end;
end; end;
procedure TPkgManager.UpdateVisibleComponentPalette;
begin
TComponentPalette(IDEComponentPalette).PageControl:=MainIDEBar.ComponentPageControl;
end;
procedure TPkgManager.ProcessCommand(Command: word; var Handled: boolean); procedure TPkgManager.ProcessCommand(Command: word; var Handled: boolean);
begin begin
Handled:=true; Handled:=true;