Use Sketchup default cursors
-
Thank you for such a "dirty" code!
Now I get it -
In the onMouseMove definition, view.invalidate match better. (I've seen that thanks to an old post from Jim)
def onMouseMove(flags, x, y, view) view.invalidate end
I don't really understand why in deactivate(view) refresh makes it and not in onMouseMove. Nevermind.
It's now easy to follow the mouse move and to replace the cursor with the .draw method.Thanks again!
-
ah, the
.refresh
method is new to 7.1 I think - I was just testing it - comparing it to the old.invalidate
.Also, note that my test code is by no means a standard for best practice. For a real tool that draws you probably want to add extra code to ensure you only draw when you have new changes to draw. Drawing on every mousemove isn't very efficient - it's just a quick'n dirty way to test some code.
-
Do SU use
.cur
files? Isn't it just.png
? -
I've only used .pngs', but I suspect the extension is less important. I think SU uses the freeimage lib which supports many formats. (I'm clearly making a lot of guesses about how things work.)
-
If it reads .cur format, I wonder how it deals with the hotspot point of the cursor. Since the .cur format has that stored within, but .png does not. And the method that creates the cursor expected you to input hotspot co-ords.
Only way is to test it.
-
Yea, weird that the .cur format isn't supported. With these PNGs you always have to remember where the hotspot for the cursor is...
-
UPDATED!
Here are 4 Yellow pencil cursors I made myself with Visual Studio (and converted to png with Paint.NET)
They point NorthEast, NorthWest, SouthEast & SouthWest.Given in Windows .curformat, so you may use with any Windows Application; .. OR..
and in .pngimage format for use with Sketchup custom tool(s) / plugins.
- 32x32 png cursor images have hotpoint as part of filename
- button images have size (16 or 24) as part of filename
I grant permission to use freely for NON-COMMERCIAL purposes. I however reserve and retain Copyright under US code, and International Treaty (Berne Convention.)
[read Copyright.txt for tips on use with Ruby, where to install etc.]
UPDATED! Originally only in .cur format; Now given in png format with small and large button images as well. Cleaned up the bmp after conversion to png, and did anti-aliasing work on edges. ENJOY!
-
%(#408000)[Yellow Pencil Cursors UPDATED!
Now also in png image format; w/ new anti-aliasing edge work, small and large button images.
See original post link below:]http://forums.sketchucation.com/viewtopic.php?f=180&t=22204&p=198338#p198338
-
@thomthom said:
Do SU use
.cur
files? Isn't it just.png
?Yes your right Thom, I boo-boo'd. Posted before I tested.
SU does NOT recognize
****.cur****
files. If you try it the id for the cursor = 0. (I'm once again flabbergasted at whomever wrote the SU ruby API. They've earned 20 lashes with a Nerf-Noodle!)The API states 'image' but does not say what formats are acceptable.
I've already begun extracting the 4 images files from the cursor files, decided to do a bit of anti-aliasing work on the edges of the pencils.
DONE (Original posting now has updated zip with png images for SU cursors and buttons.)Get them...
Will also look at the Windows API and see if I can cobble up a system call to load a cursor file instead of making a call to UI.create_cursor, as UI.set_cursor should not care how the cursor got loaded into memory, it only wants a pointer (id). [Some testing has shown the UI.set_cursor canNOT deal with Windows Cursor resources, so a 'special' set_win_cursor method would be needed, using a direct Win32 API call.]
-
@thomthom said:
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/ui.html#create_cursor
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/ui.html#set_cursor
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tool.html#onSetCursorThese links you give me 404 errors . I know I've read about this somewhere else recently but can't remember where now.
EDIT:
It might have been from when I read in TT lib the other day to understand how the win32api works. Found this page now: https://bitbucket.org/thomthom/tt-library-2/src/9ff3a5f08604ed477eb4b17fd63612bfc42832dd/TT_Lib2/cursor.rb?at=Version%202.9
-
Advertisement