SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

`Layout::Label` constructor will not accept `Layout::FormattedText` as 1st argument #733

Open DanRathbun opened 2 years ago

DanRathbun commented 2 years ago

LayOut Ruby API Issue

Layout::Label constructor will not accept Layout::FormattedText as 1st argument.

This makes no sense. The constructor forces use of a plain ol' String argument even though the class docstring states ...

This is an interface to a label entity. A Label consists of a FormattedText and the label leader Path. A Label may be connected to another Entity via a ConnectionPoint.

In order to set the text of a Label to FormattedText we are forced to pass formatted_text.display_text or formatted_text.plain_text to Layout::Label::new and afterward call label.text= formatted_text.

~

ackarkka commented 2 years ago

That makes sense to allow a FormattedText object. Would the expectation be that the text object is positioned in the expected location already so an anchor_point wouldn't be necessary?

DanRathbun commented 2 years ago

In the first overload (4 args) where the anchor point is not given, the Label constructor would (if the text argument is a FormattedText object,) take the anchor point from the argument object.

For the 2nd overload (5 args) the Label constructor would use it's 4th argument as an override to whatever the FormattedText object's anchor point is.

It could also be true that coders might pass the 4th argument using the same point reference that they used for creating the FormattedText object. I can also see that the latter might have been created with a temporary anchor point, and that code would calculate the anchor point for the label afterward, so I think that that Label constructor should override the FormattedText object in the 2nd overload.

I am new to playing with the LayOut API so I am not sure what the difference is for label.connection_type= and the last anchor_type argument of the 2nd (5 args) Label constructor overload.

DanRathbun commented 2 years ago

Also noticed there are no #target_point and #anchor_point getters for the Label class for post creation data. Are these points supposed to be gotten from the #leader_line Path object ?