Objects with editing windows

Sep 11, 2009 at 3:13am

Objects with editing windows

Hi there,

I am in the process of writing an external which is supposed to display some graphics in a separate editing window. After some research on how to accomplish this task, all I could find was the scripto example in the SDK. However scripto is using scripting (like the name suggests) to achieve this.

Is that the recommended way to do it?
Could scripting be avoided in place of a more code-oriented way?

Any advice is appreciated.
Thank you.

- Luigi

#45424
Sep 11, 2009 at 12:50pm

Scripting is the way we do that in Max 5 (buffer~, table, the inspectors, file browser…). One of the cool thing is that you can manage to make one UI object that you’ll be able to use in both patcher or external window that way.

#163769
Sep 12, 2009 at 3:14am

Hi Emmanuel,

yes, I understand… it makes sense.

Now, I have been studying the scripto example thoroughly and I’ve got a pretty good understanding of it, however there are still some basic things I am not able to do.

For example:

- How do I make the patcher window of a fixed size?
I want the user not to be able to resize my patcher window, but only open it or close it.

- How do I track the coordinates of the origin of the patcher window (upper left corner) ?
I want to be able to remember the last position where the window was closed and reopen it at the same location on the screen.

Thanks for your help.

- Luigi

#163770
Sep 12, 2009 at 7:45pm

Here you go.

Luigi Castelli wrote on Sat, 12 September 2009 05:14
- How do I make the patcher window of a fixed size?
I want the user not to be able to resize my patcher window, but only open it or close it.

t_atom rv;
t_object *patcher = (t_object *)object_new_typed(CLASS_NOBOX,gensym("jpatcher"),1,argv);
object_attr_setlong(patcher,gensym("locked"),1);
object_attr_setlong(patcher, gensym("noedit"), 1);		// don't let unlock
object_method_parse(patcher, gensym("window"), "flags nozoom", &rv);
object_method_parse(patcher, gensym("window"), "flags nominimize", &rv);
object_method_parse(patcher, gensym("window"), "flags nogrow", &rv);
object_method_parse(patcher, gensym("window"), "exec", &rv);
Quote:
- How do I track the coordinates of the origin of the patcher window (upper left corner) ?
I want to be able to remember the last position where the window was closed and reopen it at the same location on the screen.

long i, ac = 0;
t_atom *av = NULL;

object_attr_getvalueof(patcher, gensym("rect"), &ac, &av);

if (av)
	sysmem_freeptr(av);
#163771
Sep 12, 2009 at 7:54pm

You’re the best.

Thanks you so much.

- Luigi

#163772
Sep 12, 2009 at 11:27pm

Hi there,

too early for victory…

I have some more for you:

- How do I receive notifications from the patcher window when it is moved or resized ? I need to be able to resize on the fly the UI object that it is contained in the patcher window, so that the size of the object follows the size of the window.

- How do I close an opened patcher window with a Max message.
(like the ‘wclose’ message that table receives)
Do I need to defer the message ?

- How do I create an empty toolbar on the bottom of the patcher window ?

Thanks again for your time.

- Luigi

#163773
Sep 13, 2009 at 2:51pm
Luigi Castelli wrote on Sun, 13 September 2009 01:27
- How do I receive notifications from the patcher window when it is moved or resized ? I need to be able to resize on the fly the UI object that it is contained in the patcher window, so that the size of the object follows the size of the window.

You need to listen to the notification of the patcherview:

x->patcherview = object_attr_getobj(x->j_patcher, _sym_firstview);
object_attach_byptr_register(x, x->patcherview, _sym_nobox);

then your notify method will be called. You need to check if the sender is x->patcherview, and grab only the notification that you want.

Quote:
- How do I close an opened patcher window with a Max message.
(like the ‘wclose’ message that table receives)
Do I need to defer the message ?

object_method(patcher, gensym("wclose"));
#163774
Sep 14, 2009 at 8:08pm

ok, great.

All of the above works perfectly. Thanks.

Now, how do I dim out all the View menu items that would otherwise let the user interfere with my window ?

For example I would like to dim out the New View, Presentation, Zoom In, Zoom Out and Toolbar items from the View menu.

Also I would like to dim out the Modify Read-Only item from the File menu.

Thank you.

- Luigi

#163775
Sep 14, 2009 at 8:14pm

You can set the “toolbarid” attribute to something other than the default. For example “@toolbarid luigiswindow”.

This is what we do in the File Browser, for example.

#163776
Sep 16, 2009 at 1:33am

Yes, but then I need to add a ‘luigiswindow’ definition in the maxinterface.json file otherwise no toolbar is going to appear.
I am trying to avoid that since I don’t want to mess with C74 private files… and also, in case I want to distribute my external, I will have to include the modified .json file…

Any way other than that to create an empty toolbar ???

- Luigi

#163777

You must be logged in to reply to this topic.