Re: [Lazarus] RFC: Selection Editors to extend handling of object inspector selections
Juha Manninen via lazarus schrieb am Di., 31. März 2020, 13:40: > On Sun, Nov 10, 2019 at 11:26 PM Sven Barth via lazarus < > lazarus@lists.lazarus-ide.org> wrote: > >> I've got a RFC for a feature that allows to extend the IDE. It's based >> on something that Delphi supports as well: Selection Editors. >> > > I finally took a proper look at this. First remark without testing is that > unit SelEdits should be in LCL instead of IdeIntf. > It says > Abstract: >This unit contains selection editors for various LCL components. > > Thus it is not needed by external IDE plugin packages which use IdeIntf. > I will test the patches later. > Thank you for taking a first look. The problem is that selection editors derive from TBaseSelectionEditor which in turn depends on IdeIntf functionality. Also they are only really required inside the IDE (for third party components they'd be part of a design time package), not during runtime of the application. In that sense they are similar to component editors which are in IdeIntf as well (e.g. TFlowPanelComponentEditor in unit ComponentEditors). Regards, Sven > -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] RFC: Selection Editors to extend handling of object inspector selections
On Sun, Nov 10, 2019 at 11:26 PM Sven Barth via lazarus < lazarus@lists.lazarus-ide.org> wrote: > I've got a RFC for a feature that allows to extend the IDE. It's based > on something that Delphi supports as well: Selection Editors. > I finally took a proper look at this. First remark without testing is that unit SelEdits should be in LCL instead of IdeIntf. It says Abstract: This unit contains selection editors for various LCL components. Thus it is not needed by external IDE plugin packages which use IdeIntf. I will test the patches later. Juha -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] RFC: Selection Editors to extend handling of object inspector selections
Am 10.11.2019 um 22:26 schrieb Sven Barth: Hello together! I've got a RFC for a feature that allows to extend the IDE. It's based on something that Delphi supports as well: Selection Editors. Unlike Component Editors these are supposed to be used to interact with a specific selection in the designer and (in Delphi) allow the following extensions: - adding menu items for the context menu for the selection (like component editors) - add additional units when the component is dropped onto the form (though I wonder why that isn't part of component editors) - add or remove properties to/from the object inspector for the selection My current RFC only implements the last one and also a bit different than Delphi does cause they added that functionality only later (see below). Due to their dependencies Selection Editors live in the PropEdits unit and like component and property editors they are registered at an approbriate location (be it some Register function or a unit initialization). When the object inspector requests the properties it also checks all selection editors involved in the selection (included the parent classes) and calls the selection editor's FilterProperties method if GetAttributes contains seaFilterProperties (Delphi does not provide a GetAttributes method, instead it provides FilterProperties through an interface that needs to be implemented by a selection editor). FilterProperties receives both the current selection of the object inspector as well as the list of property editors. It is then free to add or remove property editors as it sees fit. The behavior when collecting the property editors is such that multiple FilterProperties methods might be called on the same selection, thus it might received an already filtered property editor list. I've attached a patch that implements selection editors (selection-editors.patch) as well as an example implementation for a component that Lazarus already supports and Delphi provides a selection editor for: TFlowPanel (tflowpanel-seledit.patch). For that component for each child control a virtual ControlIndex property is exposed which allows to easily change the order of the components in the object inspector instead of going through some collection editor. Also the Top and Left properties are removed as they aren't useful for such components. Delphi behaves the same here. Another example use would be TGridPanel which we don't have yet: it allows to implement the Row- and ColumnSpan properties on each child control of the panel. To work correctly I also had to adjust the object inspector a little bit (respect-parevertable.patch), cause it is not using only the virtual functions provided by TPropertyEditor: namely to respect the paRevertable attribute and only initialize and use the undo values if the property is deemed revertable. For demonstration purposes I've disabled the paRevertable attribute for the ControlIndex property editor, cause otherwise there'd be an exception when the object inspector tries to read the original value. It would be better if the object inspector would only call virtual methods of TPropertyEditor however or ones that can be easily faked (like I did by faking a TPropInfo entry, though that does not feel really nice either). Suggestions and criticism are welcome though I can't tell how much time I currently can and want to invest to improve this further. It might also need some step-by-step improvement of the existing TPropertyEditor interface to function smoothly. Really? No further interest here? I don't want to put it on Mantis yet, because I'm not yet sure whether everything is alright and Mantis is not a discussion platform... Regards, Sven -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
[Lazarus] RFC: Selection Editors to extend handling of object inspector selections
Hello together! I've got a RFC for a feature that allows to extend the IDE. It's based on something that Delphi supports as well: Selection Editors. Unlike Component Editors these are supposed to be used to interact with a specific selection in the designer and (in Delphi) allow the following extensions: - adding menu items for the context menu for the selection (like component editors) - add additional units when the component is dropped onto the form (though I wonder why that isn't part of component editors) - add or remove properties to/from the object inspector for the selection My current RFC only implements the last one and also a bit different than Delphi does cause they added that functionality only later (see below). Due to their dependencies Selection Editors live in the PropEdits unit and like component and property editors they are registered at an approbriate location (be it some Register function or a unit initialization). When the object inspector requests the properties it also checks all selection editors involved in the selection (included the parent classes) and calls the selection editor's FilterProperties method if GetAttributes contains seaFilterProperties (Delphi does not provide a GetAttributes method, instead it provides FilterProperties through an interface that needs to be implemented by a selection editor). FilterProperties receives both the current selection of the object inspector as well as the list of property editors. It is then free to add or remove property editors as it sees fit. The behavior when collecting the property editors is such that multiple FilterProperties methods might be called on the same selection, thus it might received an already filtered property editor list. I've attached a patch that implements selection editors (selection-editors.patch) as well as an example implementation for a component that Lazarus already supports and Delphi provides a selection editor for: TFlowPanel (tflowpanel-seledit.patch). For that component for each child control a virtual ControlIndex property is exposed which allows to easily change the order of the components in the object inspector instead of going through some collection editor. Also the Top and Left properties are removed as they aren't useful for such components. Delphi behaves the same here. Another example use would be TGridPanel which we don't have yet: it allows to implement the Row- and ColumnSpan properties on each child control of the panel. To work correctly I also had to adjust the object inspector a little bit (respect-parevertable.patch), cause it is not using only the virtual functions provided by TPropertyEditor: namely to respect the paRevertable attribute and only initialize and use the undo values if the property is deemed revertable. For demonstration purposes I've disabled the paRevertable attribute for the ControlIndex property editor, cause otherwise there'd be an exception when the object inspector tries to read the original value. It would be better if the object inspector would only call virtual methods of TPropertyEditor however or ones that can be easily faked (like I did by faking a TPropInfo entry, though that does not feel really nice either). Suggestions and criticism are welcome though I can't tell how much time I currently can and want to invest to improve this further. It might also need some step-by-step improvement of the existing TPropertyEditor interface to function smoothly. Regards, Sven Index: components/ideintf/propedits.pp === --- components/ideintf/propedits.pp (revision 62212) +++ components/ideintf/propedits.pp (working copy) @@ -23,7 +23,7 @@ uses // RTL / FCL - Classes, TypInfo, SysUtils, types, RtlConsts, variants, Contnrs, strutils, + Classes, TypInfo, SysUtils, types, RtlConsts, variants, Contnrs, strutils, FGL, // LCL LCLType, LCLIntf, LCLProc, Forms, Controls, GraphType, ButtonPanel, Graphics, StdCtrls, Buttons, Menus, ExtCtrls, ComCtrls, Dialogs, EditBtn, Grids, ValEdit, @@ -416,7 +416,9 @@ end; TPropertyEditorClass=class of TPropertyEditor; - + + TPropertyEditorList = specialize TFPGObjectList; + { THiddenPropertyEditor A property editor, to hide a published property. If you can't unpublish it, hide it. } @@ -1180,6 +1182,39 @@ TDateTimeProperty = TDateTimePropertyEditor; +type + TSelectionEditorAttribute = ( +seaFilterProperties + ); + TSelectionEditorAttributes = set of TSelectionEditorAttribute; + + { TBaseSelectionEditor } + + TBaseSelectionEditor = class +constructor Create({%H-}ADesigner: TIDesigner; {%H-}AHook: TPropertyEditorHook); virtual; +function GetAttributes: TSelectionEditorAttributes; virtual; abstract; +procedure FilterProperties(ASelection: TPersistentSelectionList; AProperties: TPropertyEditorList); virtual; abstract; + end; + + TSelectionEditor