Jamoma API  0.6.0.a19
Max/source/j.ui/j.ui.presets.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationMaxExternals
4  *
5  * @brief j.ui : Preset management functionalities for j.ui
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright © 2007 by Tim Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "j.ui.h"
18 
19 void ui_return_preset_names(TTPtr self, t_symbol *msg, long argc, t_atom* argv)
20 {
21  t_ui* obj = (t_ui*)self;
22 
23  obj->preset_num = argc;
24 
25  if (obj->preset_names)
26  sysmem_freeptr(obj->preset_names);
27  obj->preset_names = (t_atom*)sysmem_newptr(sizeof(t_atom) * argc);
28 
29  for (int i=0; i<argc; i++) {
30  atom_setsym(&obj->preset_names[i], atom_getsym(&argv[i]));
31  }
32 }
33 
34 void ui_preset_interface(t_ui *x)
35 {
36  char filename[MAX_FILENAME_CHARS];
37  short path;
38  t_fourcc type;
39  t_fourcc filetype = 'JSON';
40  t_dictionary* d;
41  t_object* p;
42  t_atom a;
43 
44  strncpy_zero(filename, "j.preset_interface.maxpat", MAX_FILENAME_CHARS);
45  locatefile_extended(filename, &path, &type, &filetype, 1);
46  dictionary_read(filename, path, &d);
47 
48  atom_setobj(&a, d);
49  p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, &a);
50  object_attr_setlong(p, _sym_locked, 1); // start out locked
51  object_attr_setchar(p, _sym_enablehscroll, 0); // turn off scroll bars
52  object_attr_setchar(p, _sym_enablevscroll, 0);
53  object_attr_setchar(p, _sym_openinpresentation, 1);
54  object_attr_setchar(p, _sym_toolbarvisible, 0);
55  object_attr_setsym(p, _sym_title, gensym("preset_interface"));
56  object_method_parse(p, _sym_window, "constrain 5 320 179 595", NULL);
57  object_attach_byptr_register(x, p, _sym_nobox);
58 
59  object_method(p, _sym_vis); // "vis" happens immediately, "front" is defer_lowed
60  object_attr_setobj(jpatcher_get_firstview(p), _sym_owner, (t_object*)x); // become the owner
61 
62  OBJ_ATTR_SYM(p, "arguments", 0, gensym((char*)x->modelAddress.c_str())); // the patch needs a [j.interfaceArguments.js]
63 
64  object_method(p, _sym_loadbang);
65 }
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
j.ui : Provide standard user interface component for modules