Designer: Move code from TComponentPalette.CheckComponentDesignerVisible to function ComponentIsInvisible.

git-svn-id: trunk@64163 -
This commit is contained in:
juha 2020-11-30 19:42:22 +00:00
parent e47ecfcbaa
commit d99c3b888f
4 changed files with 26 additions and 57 deletions

View File

@ -238,7 +238,7 @@ type
cssOnlyNonVisualNeedsUpdate,
cssOnlyNonVisualSelected,
cssOnlyVisualNeedsUpdate,
cssOnlyVisualNeedsSelected,
cssOnlyVisualSelected,
cssOnlyInvisibleNeedsUpdate,
cssOnlyInvisibleSelected,
cssOnlyBoundLessNeedsUpdate,
@ -610,8 +610,7 @@ begin
FIsTWinControl:=FPersistent is TWinControl;
FDesignerForm:=GetDesignerForm(FPersistent);
GetIsNonVisualComponent;
FIsVisible:=FIsTComponent
and (not ComponentIsInvisible(TComponent(APersistent)));
FIsVisible:=FIsTComponent and not ComponentIsInvisible(TComponent(APersistent));
end;
function TSelectedControl.GetIsNonVisualComponent: boolean;
@ -1468,8 +1467,7 @@ begin
if Result<1 then Result:=1;
end;
function TControlSelection.PersistentAlignable(
APersistent: TPersistent): boolean;
function TControlSelection.PersistentAlignable(APersistent: TPersistent): boolean;
var
CurParentLevel: integer;
AComponent: TComponent;
@ -1498,9 +1496,7 @@ begin
end;
end else begin
if ComponentIsInvisible(AComponent) then exit;
if Count>0 then begin
if OnlyVisualComponentsSelected then exit;
end;
if (Count>0) and OnlyVisualComponentsSelected then exit;
end;
if IsSelected(AComponent) then exit;
@ -2962,12 +2958,12 @@ begin
break;
end;
if Result then
Include(FStates,cssOnlyVisualNeedsSelected)
Include(FStates,cssOnlyVisualSelected)
else
Exclude(FStates,cssOnlyVisualNeedsSelected);
Exclude(FStates,cssOnlyVisualSelected);
Exclude(FStates,cssOnlyVisualNeedsUpdate);
end else
Result:=cssOnlyVisualNeedsSelected in FStates;
Result:=cssOnlyVisualSelected in FStates;
end;
function TControlSelection.OnlyInvisiblePersistentsSelected: boolean;

View File

@ -3739,7 +3739,7 @@ end;
function TDesigner.ComponentIsIcon(AComponent: TComponent): boolean;
begin
Result:=DesignerProcs.ComponentIsNonVisual(AComponent);
Result:=ComponentIsNonVisual(AComponent);
if Result and (Mediator<>nil) then
Result:=Mediator.ComponentIsIcon(AComponent);
end;
@ -3841,8 +3841,7 @@ begin
end;
function TDesigner.ComponentClassAtPos(const AClass: TComponentClass;
const APos: TPoint; const UseRootAsDefault, IgnoreHidden: boolean
): TComponent;
const APos: TPoint; const UseRootAsDefault, IgnoreHidden: boolean): TComponent;
var
s: TComponentSearch;
MediatorFlags: TDMCompAtPosFlags;
@ -3869,7 +3868,6 @@ begin
s.Free;
end;
end;
if (Result = nil) and UseRootAsDefault and (FLookupRoot.InheritsFrom(AClass)) then
Result := LookupRoot;
end;

View File

@ -39,7 +39,7 @@ uses
// LCL
LCLIntf, LCLType, Forms, Controls, Graphics,
// IdeIntf
FormEditingIntf;
FormEditingIntf, ComponentReg;
type
TDesignerDCFlag = (
@ -89,13 +89,7 @@ type
const
NonVisualCompBorder = 2;
type
TOnComponentIsInvisible = procedure(AComponent: TComponent;
var Invisible: boolean) of object;
var
OnComponentIsInvisible: TOnComponentIsInvisible;
procedure ScaleNonVisual(aParent: TComponent; AFromPPI, AToPPI: Integer);
function NonVisualCompWidth: integer;
function GetParentLevel(AControl: TControl): integer;
function ControlIsInDesignerVisible(AControl: TControl): boolean;
@ -118,12 +112,9 @@ function GetComponentWidth(AComponent: TComponent): integer;
function GetComponentHeight(AComponent: TComponent): integer;
procedure InvalidateDesignerRect(aHandle: HWND; ARect: pRect);
procedure WriteComponentStates(aComponent: TComponent; Recursive: boolean;
const Prefix: string = '');
procedure ScaleNonVisual(const aParent: TComponent;
const AFromPPI, AToPPI: Integer);
implementation
@ -334,8 +325,7 @@ begin
end;
end;
procedure ScaleNonVisual(const aParent: TComponent; const AFromPPI,
AToPPI: Integer);
procedure ScaleNonVisual(aParent: TComponent; AFromPPI, AToPPI: Integer);
var
I: Integer;
Comp: TComponent;
@ -370,21 +360,25 @@ end;
function ControlIsInDesignerVisible(AControl: TControl): boolean;
begin
Result:=true;
while AControl<>nil do begin
if csNoDesignVisible in AControl.ControlStyle then begin
Result:=false;
exit;
end;
if csNoDesignVisible in AControl.ControlStyle then
exit(false);
AControl:=AControl.Parent;
end;
Result:=true;
end;
function ComponentIsInvisible(AComponent: TComponent): boolean;
var
RegComp: TRegisteredComponent;
begin
Result:=false;
if Assigned(OnComponentIsInvisible) then
OnComponentIsInvisible(AComponent,Result);
if (AComponent is TControl) then
Result:=(csNoDesignVisible in TControl(AComponent).ControlStyle)
else begin
Assert(Assigned(IDEComponentPalette), 'ComponentIsInvisible: IDEComponentPalette=Nil');
RegComp:=IDEComponentPalette.FindComponent(AComponent.ClassName);
Result:=(RegComp=nil) or (RegComp.OrigPageName='');
end;
end;
function ComponentIsNonVisual(AComponent: TComponent): boolean;

View File

@ -133,7 +133,6 @@ type
function SelectAButton(Button: TSpeedButton): boolean;
procedure ComponentWasAdded({%H-}ALookupRoot, {%H-}AComponent: TComponent;
{%H-}ARegisteredComponent: TRegisteredComponent);
procedure CheckComponentDesignerVisible(AComponent: TComponent; var Invisible: boolean);
public
constructor Create;
destructor Destroy; override;
@ -830,29 +829,13 @@ begin
UpdateNoteBookButtons(ForceUpdateAll);
end;
procedure TComponentPalette.CheckComponentDesignerVisible(
AComponent: TComponent; var Invisible: boolean);
var
RegComp: TRegisteredComponent;
AControl: TControl;
begin
if (AComponent is TControl) then begin
AControl:=TControl(AComponent);
Invisible:=(csNoDesignVisible in AControl.ControlStyle)
end else begin
RegComp:=FindComponent(AComponent.ClassName);
Invisible:=(RegComp=nil) or (RegComp.OrigPageName='');
end;
end;
constructor TComponentPalette.Create;
begin
inherited Create(EnvironmentOptions.Desktop.ComponentPaletteOptions);
fComponentButtons:=TComponentButtonMap.Create;
fComponentButtons.Sorted:=True;
OnComponentIsInvisible:=@CheckComponentDesignerVisible;
{IDEComponentPalette.} AddHandlerComponentAdded(@ComponentWasAdded);
{IDEComponentPalette.} AddHandlerSelectionChanged(@SelectionWasChanged);
AddHandlerComponentAdded(@ComponentWasAdded);
AddHandlerSelectionChanged(@SelectionWasChanged);
ComponentPageClass := TComponentPage; // Used by CreatePagesFromUserOrder
end;
@ -860,8 +843,6 @@ destructor TComponentPalette.Destroy;
var
i: Integer;
begin
if OnComponentIsInvisible=@CheckComponentDesignerVisible then
OnComponentIsInvisible:=nil;
PageControl:=nil;
for i := 0 to fComponentButtons.Count-1 do
fComponentButtons.Data[i].Free;