Several wishes regarding Selection Tool and Shape types

Mar 16, 2013 at 4:19 PM
Edited Mar 20, 2013 at 3:12 PM
Hi,

To my strongest belief, it would be nice to have the following changes in the Selection Tool:
  • make property CurrentToolAction public (currently it's protected),
  • make methods FindPreviewOfShape and FindShapeOfPreview protected (currently they are private),
  • make enum Action public (currently it's private),
  • expose two new public events - ToolKeyEvent and ToolMouseEvent (maybe even in the Tool type and not in the SelectionTool type),
  • expose new public property ActiveHandle (or ActiveControlPoint); if we suggest that the FindPreviewOfShape becomes public and that we're dealing with a custom selection tool (derived from SelectionTool) and that we need to know active handle for our custom shapes only - then we can determine the active handle ourselves (by overriding the MovePointByCore method of the preview shape); however - too much suggestions to my opinion... better to have new public property like ActiveHandle - in this case we always know (and for any selection tool) which handle (control point) is used to perform resizing or connection...
And in the Shape types:
  • make constants like RectangleBase.TopCenterControlPoint public (currently they are private); this wish is related to to this topic.
[UPDATE] If you explore code of my demo-project mentioned in this topic, you will see that without the above listed improvements we are pushed to use reflection (to access private methods), to hardcode for integers (instead of enum members) and to write a substantial amount of other code - all this certainly doesn't make our code better!
Apr 8, 2013 at 4:07 PM
Up!
What can You say about these wishes?
Any chances to see some of them in the nearest release?
Coordinator
Apr 11, 2013 at 8:15 AM
We have not discussed this wishes yet, sorry.
May 15, 2013 at 8:27 AM
Hi,

Any progress?
Coordinator
May 21, 2013 at 2:52 PM
Hi Comanche,

I have a few questions and remarks concerning your wishes.
  • CurrentToolAction is rather implementation specific and cannot be published as such. Could you please describe a scenario that demonstrates how you would used it?
  • We will publish FindPreviewOfShape and FindShapeOfPreview as GetPreviewOfShape and GetShapeOfPreview.
  • We will make enum Action protected
  • What would you be able to do with ToolKeyEvent and ToolMouseEvent that you cannot do with Display.KeyPress et al?
  • We could consider to introduce a property ActiveHandle/ControlPoint that is protected, could you please explain, why it should be public?
  • We will make the fixed control point ids of the base shapes public.
Thanks
Peter
Jun 10, 2013 at 5:14 PM
Edited Jun 10, 2013 at 5:16 PM
Hi Peter.

I apologize for the delay - I couldn't access forum earlier.
Answering Your questions:

ppohmann wrote:
  • CurrentToolAction is rather implementation specific and cannot be published as such. Could you please describe a scenario that demonstrates how you would used it?
Imagine that we do not use any custom Selection Tool - we just use the built-in one because its behavior is enough for our needs. But imagine that we also need to know if this tool is performing a resize or move operation - for example, to calculate clipping rectangle and possibly suppress this operation (it can be done in the Display.MouseMove event handler). Creating a derived (custom) Selection Tool just to know its current action seems to be on overhead: such kind of info should be available as a public read-only property, to my strongest belief (derivation must be used when changing behavior and not just extending public info). If the property stays protected - then we are forced to derive our own tool :(

If You expose the CurrentToolAction property as public - then the Action enum should be also public.

If You dislike the idea to publish CurrentToolAction (of the ActionDef type) because it is "rather implementation specific" - then maybe you can expose some other public property with the Action type (enum)? i.e. expose only CurrentToolAction.Action member as a separate read-only public property.

ppohmann wrote:
  • We will make enum Action protected
See above. I think it should be public.

ppohmann wrote:
  • We will publish FindPreviewOfShape and FindShapeOfPreview as GetPreviewOfShape and GetShapeOfPreview.
Nice!

ppohmann wrote:
  • What would you be able to do with ToolKeyEvent and ToolMouseEvent that you cannot do with Display.KeyPress et al?
Code of the Display.OnKeyDown() is written so that there's no chance to suppress any key. I think Kurt has confirmed it in this topic. If the next release really gets it fixed - then the suggested ToolKeyEvent and ToolMouseEvent events are not really needed. Otherwise some solution is required; and if we want this solution to work without deriving our custom Selection Tool - then those events seem to be a good choice.

ppohmann wrote:
  • We could consider to introduce a property ActiveHandle/ControlPoint that is protected, could you please explain, why it should be public?
Please see a demo project available for download here. Please open the ShellMouseController class - You can find the following code there (in the OnMouseMove method):
if (mySelTool.IsResizing && _display.SelectedShapes.First() is IMyShape)
{
    var previewShape = mySelTool.FindPreviewOfShape(_display.SelectedShapes.First());
    _shapeResizeHandle = (previewShape as IMyShape).ActiveResizeHandle;
}
Value of the _shapeResizeHandle field is then used to calculate clipping rectangle and possibly restrict shape resizing. I think it's obvious that clipping rectangle depends upon the active resize handle - search code for "switch (_shapeResizeHandle)", it clearly demonstrates this.

If active resize handle is exposed as a public property (as IMyShape.ActiveResizeHandle in my demo) - then we are able to control resizing for ANY shape, which is a powerful feature. If not (i.e. if exposed as protected) - then we control it only for OUR CUSTOM shapes, and that's a strange limitation :(

ppohmann wrote:
  • We will make the fixed control point ids of the base shapes public.
Great!