|
|
|
04-02-2017, 11:08 AM
|
#1
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
SWS Extensions - how ro register actions in ME section ?
I'm trying to do "toggle triplet/dotted grid" actions for the MIDI editor (similar to AW's toggle action for the arrange).
They work but are currently registered in the Main section. How would I go registering them in the ME section instead ?
My problem currently is, I don't fully understand the COMMAND_T struct. I only know that 32060 is the magic number I have to put there somewhere but that's it.
Here's how it looks currently when regestistering in the Main section (admittedly borrowed a good bit from AW's toggle actions):
Code:
{ { DEFACCEL, "SWS/NF: Toggle triplet grid" }, "_NF_TOGGLETRIPLET_MIDI", NFToggleTripletMIDI, NULL, 0, IsMIDIGridTriplet }
Last edited by nofish; 04-02-2017 at 11:20 AM.
|
|
|
04-02-2017, 12:38 PM
|
#2
|
Human being with feelings
Join Date: May 2009
Location: Brazil
Posts: 323
|
I'm trying to understand this myself, take a look at the thread in
http://forum.cockos.com/showpost.php...2&postcount=76
I managed to register actions to ME based on the method Xenakios created in this thread mixed up with SWS code. Still I don't understand well the logical path. I just crated another thread asking about it.
__________________
Ceanganb
|
|
|
04-02-2017, 01:18 PM
|
#3
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Code:
enum { MainSection, MidiEditorSection = 32060 };
custom_action_register_t action{MidiEditorSection, "ACTION_NAME", "Description of the action"};
const int actionId = plugin_register("custom_action", &action);
Here's a minimal extension that displays a message box when the registered ME action is run: http://sprunge.us/gIda?cpp
Looking at SWS's code, it does the above when the uniqueSectionId and onAction members of the COMMAND_T object are set and onCommand is unset. So (untested):
Code:
enum { MidiEditorSection = 32060 };
COMMAND_T command{
{DEFACCEL, "SWS/NF: Toggle triplet grid" },
"NF_TOGGLETRIPLET_MIDI",
// avoiding writing a bunch of nullptr and 0s and losing track of where we are in the struct...
};
command.getEnabled = IsMIDIGridTriplet;
command.uniqueSectionId = MidiEditorSection;
command.onAction = NFToggleTripletMIDI;
SWSRegisterCmd(&command, "value for cFile");
Last edited by cfillion; 04-02-2017 at 02:00 PM.
|
|
|
04-02-2017, 01:36 PM
|
#4
|
Human being with feelings
Join Date: May 2009
Location: Brazil
Posts: 323
|
What's the practical difference of gaccel_register_t to custom_action_register_t, then?
__________________
Ceanganb
|
|
|
04-02-2017, 01:41 PM
|
#5
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
edit:
cfillion's post makes it clearer I think than what I posted originally.
Last edited by nofish; 04-02-2017 at 02:10 PM.
|
|
|
04-02-2017, 01:43 PM
|
#6
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by ceanganb
What's the practical difference of gaccel_register_t to custom_action_register_t, then?
|
As far as I know, gaccel_register_t is main section only but it can set a keyboard shortcut (with the ACCEL member). Also custom_action_register_t can be used to register scripts (thanks to Jeff0S!).
Last edited by cfillion; 04-02-2017 at 02:04 PM.
|
|
|
04-02-2017, 01:53 PM
|
#7
|
Human being with feelings
Join Date: May 2009
Location: Brazil
Posts: 323
|
Quote:
Originally Posted by cfillion
As far as I know, gaccel_register_t is main section only but it can set a keyboard shortcut. Also custom_action_register_t can be used to register scripts.
|
Yep, gaccel is for main only. Now, if the only advantage is registering a shortcut, I guess I could use custom_action_register_t exclusively. I'm sure there are more technical details, but it seems enough for my needs.
Thanks so much, cfillion.
__________________
Ceanganb
|
|
|
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 09:07 AM.
|