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