diff --git a/components/ideintf/componenteditors.pas b/components/ideintf/componenteditors.pas index 56f4e03838..acb9557051 100644 --- a/components/ideintf/componenteditors.pas +++ b/components/ideintf/componenteditors.pas @@ -64,6 +64,8 @@ type function GetHandlerCount(HookType: TComponentEditorDesignerHookType): integer; procedure AddHandler(HookType: TComponentEditorDesignerHookType; const Handler: TMethod); procedure RemoveHandler(HookType: TComponentEditorDesignerHookType; const Handler: TMethod); + function GetShowNonVisualComponents: boolean; virtual; abstract; + procedure SetShowNonVisualComponents(AValue: boolean); virtual; abstract; public FUndoState: TUndoCompState; @@ -101,6 +103,7 @@ type const NewComponentClass: TComponentClass); virtual; abstract; procedure DrawDesignerItems(OnlyIfNeeded: boolean); virtual; abstract; + property ShowNonVisualComponents: boolean read GetShowNonVisualComponents write SetShowNonVisualComponents; function CreateUniqueComponentName(const AClassName: string ): string; virtual; abstract; property PropertyEditorHook: TPropertyEditorHook read GetPropertyEditorHook; diff --git a/components/ideintf/idecommands.pas b/components/ideintf/idecommands.pas index eae1cb1f05..400e44284d 100644 --- a/components/ideintf/idecommands.pas +++ b/components/ideintf/idecommands.pas @@ -357,6 +357,7 @@ const ecDesignerMoveToBack = ecFirstLazarus + 1005; ecDesignerForwardOne = ecFirstLazarus + 1006; ecDesignerBackOne = ecFirstLazarus + 1007; + ecDesignerToggleNonVisComps= ecFirstLazarus + 1008; (* SynEdit Plugins @@ -1914,7 +1915,7 @@ begin end; const - IDEEditorCommandStrs: array[0..316] of TIdentMapEntry = ( + IDEEditorCommandStrs: array[0..317] of TIdentMapEntry = ( // search (Value: ecFind; Name: 'ecFind'), (Value: ecFindAgain; Name: 'ecFindAgain'), @@ -2218,6 +2219,7 @@ const (Value: ecDesignerMoveToBack; Name: 'ecDesignerMoveToBack'), (Value: ecDesignerForwardOne; Name: 'ecDesignerForwardOne'), (Value: ecDesignerBackOne; Name: 'ecDesignerBackOne'), + (Value: ecDesignerToggleNonVisComps; Name: 'ecDesignerToggleNonVisComps'), // TSynPluginTemplateEdit - In cell (Value: ecIdePTmplEdNextCell; Name: 'ecIdePTmplEdNextCell'), diff --git a/components/pas2js/pjsdsgnregister.pas b/components/pas2js/pjsdsgnregister.pas index b69119dc1f..0120754f65 100644 --- a/components/pas2js/pjsdsgnregister.pas +++ b/components/pas2js/pjsdsgnregister.pas @@ -491,6 +491,7 @@ function TProjectPas2JSWebApp.InitProject(AProject: TLazProject): TModalResult; var MainFile, HTMLFile : TLazProjectFile; + CompOpts: TLazCompilerOptions; begin Result:=inherited InitProject(AProject); @@ -498,8 +499,9 @@ begin MainFile.IsPartOfProject:=true; AProject.AddFile(MainFile,false); AProject.MainFileID:=0; - SetDefaultWebCompileOptions(AProject.LazCompilerOptions); - AProject.LazCompilerOptions.TargetFilename:='project1'; + CompOpts:=AProject.LazCompilerOptions; + SetDefaultWebCompileOptions(CompOpts); + CompOpts.TargetFilename:='project1'; SetDefaultWebRunParams(AProject.RunParameters.GetOrCreate('Default')); AProject.MainFile.SetSourceText(CreateProjectSource,true); AProject.CustomData.Values[PJSProjectWebBrowser]:='1'; diff --git a/designer/designer.pp b/designer/designer.pp index 524f622093..fe0b9d902f 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -82,6 +82,7 @@ type dfDuringPaintControl, dfShowEditorHints, dfShowComponentCaptions, + dfShowNonVisualComponents, dfDestroyingForm, dfNeedPainting ); @@ -194,6 +195,8 @@ type procedure HandlePopupMenu(Sender: TControl; var Message: TLMContextMenu); procedure GetMouseMsgShift(TheMessage: TLMMouse; out Shift: TShiftState; out Button: TMouseButton); + function GetShowNonVisualComponents: boolean; override; + procedure SetShowNonVisualComponents(AValue: boolean); override; // procedures for working with components and persistents function GetDesignControl(AControl: TControl): TControl; @@ -256,6 +259,7 @@ type procedure OnSelectAllMenuClick(Sender: TObject); procedure OnChangeClassMenuClick(Sender: TObject); procedure OnChangeParentMenuClick(Sender: TObject); + procedure OnShowNonVisualComponentsMenuClick(Sender: TObject); procedure OnSnapToGridOptionMenuClick(Sender: TObject); procedure OnShowOptionsMenuItemClick(Sender: TObject); procedure OnSnapToGuideLinesOptionMenuClick(Sender: TObject); @@ -394,6 +398,7 @@ type property ShowEditorHints: boolean read GetShowEditorHints write SetShowEditorHints; property ShowComponentCaptions: boolean read GetShowComponentCaptions write SetShowComponentCaptions; + property ShowNonVisualComponents: boolean read GetShowNonVisualComponents write SetShowNonVisualComponents; property SnapToGrid: boolean read GetSnapToGrid write SetSnapToGrid; property TheFormEditor: TCustomFormEditor read FTheFormEditor write FTheFormEditor; property DefaultFormBounds: TRect read FDefaultFormBounds write SetDefaultFormBounds; @@ -428,6 +433,7 @@ var DesignerMenuSaveAsXML: TIDEMenuCommand; DesignerMenuCenterForm: TIDEMenuCommand; + DesignerMenuShowNonVisualComponents: TIDEMenuCommand; DesignerMenuSnapToGridOption: TIDEMenuCommand; DesignerMenuSnapToGuideLinesOption: TIDEMenuCommand; DesignerMenuShowOptions: TIDEMenuCommand; @@ -456,6 +462,7 @@ type MinClass: TComponentClass; IgnoreHidden: boolean; OnlyNonVisual: boolean; + IgnoreNonVisual: boolean; Mediator: TDesignerMediator; Root: TComponent; procedure Gather(Child: TComponent); @@ -497,9 +504,12 @@ begin else IsNonVisual := DesignerProcs.ComponentIsNonVisual(Child); - if IsNonVisual and Assigned(IDEComponentsMaster) then - if not IDEComponentsMaster.DrawNonVisualComponents(Root) then + if IsNonVisual then begin + if IgnoreNonVisual then exit; + if Assigned(IDEComponentsMaster) + and not IDEComponentsMaster.DrawNonVisualComponents(Root) then Exit; + end; if Child.InheritsFrom(MinClass) and (IsNonVisual or not OnlyNonVisual) then begin @@ -624,6 +634,10 @@ begin // register options section DesignerMenuSectionOptions:=RegisterIDEMenuSection(DesignerMenuRoot,'Options section'); + DesignerMenuShowNonVisualComponents:=RegisterIDEMenuCommand(DesignerMenuSectionMisc, + 'Show non visual components', + lisDsgShowNonVisualComponents); + DesignerMenuShowNonVisualComponents.ShowAlwaysCheckable:=true; DesignerMenuSnapToGridOption:=RegisterIDEMenuCommand(DesignerMenuSectionOptions, 'Snap to grid',fdmSnapToGridOption); DesignerMenuSnapToGuideLinesOption:=RegisterIDEMenuCommand(DesignerMenuSectionOptions, @@ -658,7 +672,7 @@ begin FLookupRoot := FForm; Selection := AControlSelection; - FFlags := []; + FFlags := [dfShowNonVisualComponents]; FGridColor := clGray; FHintTimer := TTimer.Create(nil); @@ -1735,6 +1749,7 @@ begin ecDesignerMoveToBack : DoChangeZOrder(1); ecDesignerForwardOne : DoChangeZOrder(2); ecDesignerBackOne : DoChangeZOrder(3); + ecDesignerToggleNonVisComps: ShowNonVisualComponents:=not ShowNonVisualComponents; else Exit; end; @@ -3318,6 +3333,11 @@ begin OnChangeParent(Self); end; +procedure TDesigner.OnShowNonVisualComponentsMenuClick(Sender: TObject); +begin + ShowNonVisualComponents:=not ShowNonVisualComponents; +end; + procedure TDesigner.OnSnapToGridOptionMenuClick(Sender: TObject); begin EnvironmentOptions.SnapToGrid := not EnvironmentOptions.SnapToGrid; @@ -3399,6 +3419,11 @@ begin Result:=EnvironmentOptions.ShowGrid; end; +function TDesigner.GetShowNonVisualComponents: boolean; +begin + Result:=dfShowNonVisualComponents in FFlags; +end; + function TDesigner.GetGridSizeX: integer; begin Result:=EnvironmentOptions.GridSizeX; @@ -3433,6 +3458,38 @@ begin Form.Invalidate; end; +procedure TDesigner.SetShowNonVisualComponents(AValue: boolean); +var + i: Integer; + SelControl: TSelectedControl; + Changed: Boolean; +begin + if ShowNonVisualComponents=AValue then exit; + if AValue then begin + Include(FFlags,dfShowNonVisualComponents); + Form.Invalidate; + end else begin + Exclude(FFlags,dfShowNonVisualComponents); + try + Changed:=false; + for i:=Selection.Count-1 downto 0 do begin + SelControl:=Selection[i]; + if not SelControl.IsNonVisualComponent then continue; + if not Changed then begin + Selection.BeginUpdate; + Changed:=true; + end; + Selection.Delete(i); + end; + finally + if Changed then begin + Selection.EndUpdate; + Form.Invalidate; + end; + end; + end; +end; + procedure TDesigner.SetGridSizeX(const AValue: integer); begin if GridSizeX=AValue then exit; @@ -3610,12 +3667,12 @@ end; procedure TDesigner.DrawNonVisualComponents(aDDC: TDesignerDeviceContext); begin + if not ShowNonVisualComponents then exit; FSurface := nil; FDDC := aDDC; DrawNonVisualComponent(FLookupRoot); FDDC := nil; - if FSurface <> nil then - FSurface.Free; + FreeAndNil(FSurface); end; procedure TDesigner.DrawDesignerItems(OnlyIfNeeded: boolean); @@ -3760,6 +3817,7 @@ function TDesigner.NonVisualComponentAtPos(X, Y: integer): TComponent; var s: TComponentSearch; begin + // Note: Do not check ShowNonVisualComponents s := TComponentSearch.Create(nil); try s.MinClass := TComponent; @@ -3796,7 +3854,8 @@ 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; @@ -3815,6 +3874,7 @@ begin s.AtPos := APos; s.MinClass := AClass; s.IgnoreHidden := IgnoreHidden; + s.IgnoreNonVisual := not ShowNonVisualComponents; s.Search(FLookupRoot); s.Mediator := Mediator; Result := s.Best; @@ -3921,6 +3981,8 @@ begin DesignerMenuSaveAsXML.OnClick:=@OnSaveAsXMLMenuClick; DesignerMenuCenterForm.OnClick:=@OnCenterFormMenuClick; + DesignerMenuShowNonVisualComponents.OnClick:=@OnShowNonVisualComponentsMenuClick; + DesignerMenuShowNonVisualComponents.ShowAlwaysCheckable:=true; DesignerMenuSnapToGridOption.OnClick:=@OnSnapToGridOptionMenuClick; DesignerMenuSnapToGridOption.ShowAlwaysCheckable:=true; DesignerMenuSnapToGuideLinesOption.OnClick:=@OnSnapToGuideLinesOptionMenuClick; @@ -3991,6 +4053,7 @@ begin DesignerMenuViewLFM.Enabled := not UnitIsVirtual; DesignerMenuChangeParent.Enabled := HasChangeParentCandidates; DesignerMenuSnapToGridOption.Checked := EnvironmentOptions.SnapToGrid; + DesignerMenuShowNonVisualComponents.Checked := ShowNonVisualComponents; DesignerMenuSnapToGuideLinesOption.Checked := EnvironmentOptions.SnapToGuideLines; end; diff --git a/examples/imagelist_highdpi_designtime/unit1.lfm b/examples/imagelist_highdpi_designtime/unit1.lfm index 3d2fb8619c..97be3cb817 100644 --- a/examples/imagelist_highdpi_designtime/unit1.lfm +++ b/examples/imagelist_highdpi_designtime/unit1.lfm @@ -1,10 +1,10 @@ object Form1: TForm1 - Left = 233 + Left = 277 Height = 384 - Top = 275 + Top = 89 Width = 958 Caption = 'Form1' - ClientHeight = 364 + ClientHeight = 384 ClientWidth = 958 Menu = MainMenu1 LCLVersion = '1.9.0.0' @@ -103,8 +103,8 @@ object Form1: TForm1 ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 2 - ClientHeight = 27 - ClientWidth = 300 + ClientHeight = 25 + ClientWidth = 296 Columns = 2 ItemIndex = 0 Items.Strings = ( @@ -126,9 +126,9 @@ object Form1: TForm1 end object SpeedButton1: TSpeedButton Left = 104 - Height = 30 - Top = 309 - Width = 30 + Height = 51 + Top = 288 + Width = 80 Images = ImageList1 ImageIndex = 3 ImageWidth = 24 @@ -136,8 +136,8 @@ object Form1: TForm1 object ImageList1: TImageList Scaled = True OnGetWidthForPPI = ImageList1GetWidthForPPI - Left = 680 - Top = 296 + left = 680 + top = 296 Bitmap = { 4C69050000001000000010000000000000000000000078483671784836FE7848 36FD784836FD784836FD784836FC784836FC794937E55EACB1084FE9FC2F53E9 @@ -1357,8 +1357,8 @@ object Form1: TForm1 end object MainMenu1: TMainMenu Images = ImageList1 - Left = 720 - Top = 296 + left = 816 + top = 296 object MenuItem1: TMenuItem Caption = 'MenuItem1' SubMenuImages = ImageList1 diff --git a/ide/keymapping.pp b/ide/keymapping.pp index d72917b26f..f611ce393c 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -1381,6 +1381,7 @@ begin ecDesignerMoveToBack: SetSingle(VK_NEXT,[ssShift]); ecDesignerForwardOne: SetSingle(VK_PRIOR,[XCtrl]); ecDesignerBackOne: SetSingle(VK_NEXT,[XCtrl]); + ecDesignerToggleNonVisComps: SetSingle(VK_UNKNOWN,[]); // macro ecSynMacroRecord: SetSingle(VK_R,[ssShift, XCtrl]); @@ -1820,6 +1821,7 @@ begin ecDesignerMoveToBack: SetSingle(VK_NEXT,[ssShift]); ecDesignerForwardOne: SetSingle(VK_PRIOR,[ssCtrl]); ecDesignerBackOne: SetSingle(VK_NEXT,[ssCtrl]); + ecDesignerToggleNonVisComps: SetSingle(VK_UNKNOWN,[]); // macro ecSynMacroRecord: SetSingle(VK_R,[ssShift, ssCtrl]); @@ -2446,6 +2448,7 @@ begin ecDesignerMoveToBack: SetSingle(VK_NEXT,[ssShift]); ecDesignerForwardOne: SetSingle(VK_PRIOR,[ssMeta]); ecDesignerBackOne: SetSingle(VK_NEXT,[ssMeta]); + ecDesignerToggleNonVisComps: SetSingle(VK_UNKNOWN,[]); // macro ecSynMacroRecord: SetSingle(VK_R,[ssShift, ssCtrl]); @@ -3162,6 +3165,8 @@ begin AddDefault(C, 'Move component to back', lisDsgOrderMoveToBack, ecDesignerMoveToBack); AddDefault(C, 'Move component one forward', lisDsgOrderForwardOne, ecDesignerForwardOne); AddDefault(C, 'Move component one back', lisDsgOrderBackOne, ecDesignerBackOne); + AddDefault(C, 'Toggle showing non visual components', + lisDsgToggleShowingNonVisualComponents, ecDesignerToggleNonVisComps); // object inspector - without menu items in the IDE bar (at least no direct) C:=Categories[AddCategory('Object Inspector',lisKeyCatObjInspector,IDECmdScopeObjectInspectorOnly)]; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 1f91f43530..5d706935d2 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -6436,6 +6436,9 @@ resourcestring lisUnableToRun2 = 'Unable to run "%s"'; lisSelectFrame = 'Select Frame'; + lisDsgToggleShowingNonVisualComponents = 'Toggle showing non visual ' + +'components'; + lisDsgShowNonVisualComponents = 'Show non visual components'; implementation end.