|
|
|
07-01-2018, 04:22 AM
|
#1
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
WDL/SWELL and C++ extensions: How to change mouse cursor?
Does anyone know how to do the following?
* Load REAPER's custom cursors. (I know how to load Windows' standard cursors, but not REAPER's.)
* Prevent REAPER from changing the cursor while the script is running. (When I change the cursor, REAPER immediately changes it back.)
* Do all this via WDL/SWELL. (The swell-functions.h file states: LoadCursor(). ** Notes: hinstance parameter ignored, currently only supports loading some of the predefined values.)
|
|
|
07-01-2018, 12:25 PM
|
#2
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
Not sure if it helps, but some stuff in SWS use their own cursors e.g. Zoom tool, Breeder's Grid warp, maybe have a look how it's done there.
https://github.com/reaper-oss/sws/bl...nsion.rc#L2008
edit:
I don't know how to load / use Reaper's custom cursors though.
Last edited by nofish; 07-01-2018 at 12:32 PM.
|
|
|
07-01-2018, 12:52 PM
|
#3
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
On Windows, possibly with LoadCursor and the MAKEINTRESOURCE macro. The Reaper custom cursors look like they start at number 236. No idea about OS-X/SWELL. (Maybe the same technique works.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
07-01-2018, 09:35 PM
|
#4
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
For example, to use the snap offset cursor on all platforms (I don't know if this supports theme-specific cursors):
Code:
// C++11
// Note: The SWELL implementation must be provided by the host application to use its cursors
enum struct REAPERCursor {
SNAPOFFS = 183,
};
HCURSOR LoadREAPERCursor(const REAPERCursor id)
{
#ifdef _WIN32
HINSTANCE reaper = GetModuleHandle(nullptr);
return LoadCursor(reaper, MAKEINTRESOURCE(id));
#else
return SWELL_LoadCursor(MAKEINTRESOURCE(id));
#endif
}
// Usage
HCURSOR cursor = LoadREAPERCursor(REAPERCursor::SNAPOFFS);
SetCursor(cursor);
You can use something like Resource Hacker on Windows to find the ID of the cursors embedded in the binary (under the Cursor Group group – not a typo).
Last edited by cfillion; 07-02-2018 at 01:19 AM.
|
|
|
07-03-2018, 06:26 AM
|
#5
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Thanks everyone!
It seems the trick with question 1 was to get the correct cursor IDs. The numbers given in the Cockos website are not the actual IDs (and the list is outdated, since it doesn't include the new notation cursors, for example).
The trick with question 2 is to keep the script running in a while loop -- NOT a defer loop. When scripts use defer loops, REAPER restores the cursor in each cycle.
SWS functions such as Zoom and WarpGrid that run in the arrange view can use while loops, since the arrange view can be updated using UpdateArrange while the loop is running. The MIDI editor does not have such a function, and only updates during defer cycles.
|
|
|
07-04-2018, 01:32 PM
|
#6
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Xenakios
The Reaper custom cursors look like they start at number 236.
|
Quote:
Originally Posted by cfillion
For example, to use the snap offset cursor on all platforms
SNAPOFFS = 183,
|
According to Resource Hacker, the cursor numbers start at 236, as Xenakios wrote.
However, to load these cursor, I have to use completely different IDs, as cfillion did: 105 for cursor 236 (adjustfade) and then 182-191 for a few others, etc,
What is going on here?
|
|
|
07-04-2018, 01:51 PM
|
#7
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
The good news is that LoadCursorFromFile seems to work well.
So, we can simply include all of REAPER's native cursors as .cur files in SWS (as long as Justin doesn't object) - and even lots of other cute and weird cursors!
|
|
|
07-04-2018, 07:18 PM
|
#8
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by juliansader
What is going on here?
|
Look in the "Cursor Group" group, not the "Cursor" group. No need to include REAPER's cursors into SWS.
Last edited by cfillion; 07-04-2018 at 07:27 PM.
|
|
|
07-05-2018, 02:38 AM
|
#9
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by cfillion
Look in the "Cursor Group" group, not the "Cursor" group.
|
Oops, got it!
Quote:
Originally Posted by cfillion
No need to include REAPER's cursors into SWS.
|
Will these same IDs also work on MacOS and Linux? (I.e. can SWELL_LoadCursor load Win32-type predefined cursors (with IDs >32000) as well as REAPER's embedded cursors (with IDs < 2000), even though it doesn't utilize a hInstance as first parameter?)
EDIT: Looking at the WDL/SWELL code, it seems that SWELL_LoadCursor can indeed do either standard system cursors, or "registered cursors".
The standard cursors are that SWELL_LoadCursor can load are:
IDC_NO, IDC_SIZENWSE, IDC_SIZENESW, IDC_SIZEALL, IDC_SIZEWE, IDC_SIZENS, IDC_ARROW, IDC_HAND, IDC_UPARROW and IDC_IBEAM.
Last edited by juliansader; 07-05-2018 at 03:53 AM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:17 AM.
|