Old 04-02-2017, 11:08 AM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default 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.
nofish is offline   Reply With Quote
Old 04-02-2017, 12:38 PM   #2
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 323
Default

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
ceanganb is offline   Reply With Quote
Old 04-02-2017, 01:18 PM   #3
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

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.
cfillion is offline   Reply With Quote
Old 04-02-2017, 01:36 PM   #4
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 323
Default

What's the practical difference of gaccel_register_t to custom_action_register_t, then?
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 04-02-2017, 01:41 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

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.
nofish is offline   Reply With Quote
Old 04-02-2017, 01:43 PM   #6
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by ceanganb View Post
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.
cfillion is offline   Reply With Quote
Old 04-02-2017, 01:53 PM   #7
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 323
Default

Quote:
Originally Posted by cfillion View Post
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
ceanganb is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.