SketchUp / api-issue-tracker

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

PDF cursors on Mac can fail to display #474

Open Fredosixx opened 4 years ago

Fredosixx commented 4 years ago

Since SU2016, the Tool class seems to support SVG cursors on Windows and this works fine.

However, I just realized that on Mac, PDF cursors are not supported. I use PDF cursors in FredoSpline.

In the API documentation, it is written:

Since SketchUp 2016 it is possible to provide vector images for the cursors. SVG format for Windows and PDF format for OS X.

Am I correct?

Or is there a particular way to encode the PDF?

Fredosixx commented 4 years ago

I made some additional tests and the problem is related to the HotSpot arguments and very specific to Mac OSX.

in UI.create_cursor(img_path, hx, hy), there is a limit to the value hx and hy, whether PDF or PNG format.

For FredoSpline, I need a hot spot in the bottom-left corner. So, with cursors of size 32x32, I would use hx=0 and hy= 32. The cursor seems to be created and I get back a cursor id. HOWEVER, it does not display.

From my tests, it seems that the maximum value of hy is 23. Above, the cursor does not display.

On Windows, everything works correct, so this is definitely an issue for Mac OSX (I am on Catalina)

I attach one cursor used by FredoSpline, in PDF and in PNG so that you can try to reproduce the issue:

SPL_cursor_creation.pdf

SPL_cursor_creation

DanRathbun commented 4 years ago

With the addition of support for display scaling, it might be beneficial for coders if the x and y values could accept a Float value as a percentage of the scaled size from the top left corner of the cursor's "field".

So, using Fredo's above example, it would be nice if he could pass 0.0, 1.0 for x and y.

Fredosixx commented 4 years ago

Definitely, a relative position of the hot spot would be welcome, especially when you use vector-based cursors (SVG or PDF).

thomthom commented 4 years ago

From my tests, it seems that the maximum value of hy is 23. Above, the cursor does not display.

Oh, that's interesting. A good clue.

I'm using PDFs for vector cursors in my extensions and I had not observed this. But a quick scan of my cursors indicate my max y value has been 19.

DanRathbun commented 4 years ago

The UI::create_cursor documentation is not at all clear what that the nominal cursor size is.

... and what happens with respect to display scaling. (Is it automatic, or is UI::scale_factor required to be used?)


@thomthom I've opened a documentation specific issue for this method. See #918

sketchupbot commented 4 years ago

SU-46196