20 void ui_register_info(t_ui* obj)
35 jamoma_patcher_get_info((t_object*)obj, &obj->patcherPtr, obj->patcherContext, obj->patcherClass, obj->patcherName);
38 obj->uiSubscriber.get(
"contextAddress", v);
39 obj->viewAddress = v[0];
42 ui_receiver_create(obj, anObject, gensym(
"return_model_address"),
TTSymbol(
"model:address"), obj->viewAddress, YES);
46 void ui_unregister_info(t_ui *obj)
49 if (obj->uiSubscriber.valid())
53 if (obj->uiInfo.valid())
57 void ui_data_interface(t_ui *x,
TTSymbol name)
59 char filename[MAX_FILENAME_CHARS];
61 t_fourcc type, filetype =
'JSON';
67 strncpy_zero(filename,
"j.reference_interface.maxpat", MAX_FILENAME_CHARS);
68 locatefile_extended(filename, &path, &type, &filetype, 1);
69 dictionary_read(filename, path, &d);
72 p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, &a);
73 object_attr_setlong(p, _sym_locked, 1);
74 object_attr_setchar(p, _sym_enablehscroll, 0);
75 object_attr_setchar(p, _sym_enablevscroll, 0);
76 object_attr_setchar(p, _sym_openinpresentation, 1);
77 object_attr_setchar(p, _sym_toolbarvisible, 0);
78 object_attr_setsym(p, _sym_title, gensym(
"reference_interface"));
79 object_method_parse(p, _sym_window,
"constrain 5 320 200 500", NULL);
80 object_attach_byptr_register(x, p, _sym_nobox);
82 object_method(p, _sym_vis);
83 object_attr_setobj(jpatcher_get_firstview(p), _sym_owner, (t_object*)x);
87 OBJ_ATTR_SYM(p,
"arguments", 0, gensym((
char*)address.
c_str()));
89 object_method(p, _sym_loadbang);
101 returnValueCallback =
TTObject(
"callback");
104 returnValueCallback.
set(kTTSym_baton, baton);
106 args.
append(returnValueCallback);
108 returnedReceiver =
TTObject(kTTSym_Receiver, args);
111 if (appendNameAsAttribute)
117 obj->hash_receivers->append(name, returnedReceiver);
120 returnedReceiver.
set(kTTSym_address, adrs);
123 void ui_receiver_destroy_all(t_ui *obj)
130 if (obj->hash_receivers) {
132 if (!obj->hash_receivers->isEmpty()) {
134 obj->hash_receivers->getKeys(hk);
136 for (i=0; i<obj->hash_receivers->getSize(); i++) {
139 if (!obj->hash_receivers->lookup(key, v)) {
142 receiver.
set(kTTSym_address, kTTAdrsEmpty);
146 obj->hash_receivers->clear();
153 TTAddress viewAddress, viewerAddress, adrs;
155 returnedViewer =
TTObject(kTTSym_Viewer);
158 returnedViewer.
set(kTTSym_baton, baton);
163 obj->uiSubscriber.get(
"contextAddress", v);
167 args =
TTValue(viewerAddress, returnedViewer, (
TTPtr)obj->patcherPtr);
168 JamomaApplication.
send(
"ObjectRegister", args, none);
171 viewerAddress = kTTAdrsEmpty;
177 args =
TTValue(returnedViewer);
178 args.
append(viewerAddress);
179 obj->hash_viewers->append(name, args);
182 returnedViewer.
set(kTTSym_address, adrs);
185 void ui_viewer_destroy(t_ui *obj,
TTSymbol name)
190 if (obj->hash_viewers)
191 if (!obj->hash_viewers->lookup(name, v)) {
194 viewer.
set(kTTSym_address, kTTAdrsEmpty);
197 viewerAddress = v[1];
198 JamomaApplication.
send(
"ObjectUnregister", viewerAddress, none);
199 obj->hash_viewers->remove(name);
203 void ui_viewer_destroy_all(t_ui *obj)
210 if (obj->hash_viewers) {
212 if (!obj->hash_viewers->isEmpty()) {
214 obj->hash_viewers->getKeys(hk);
216 for (i=0; i<obj->hash_viewers->getSize(); i++) {
219 if (!obj->hash_viewers->lookup(key, v)) {
222 viewer.
set(kTTSym_address, kTTAdrsEmpty);
225 viewerAddress = v[1];
226 JamomaApplication.
send(
"ObjectUnregister", viewerAddress, none);
230 delete obj->hash_viewers;
231 obj->hash_viewers = NULL;
241 if (obj->hash_viewers) {
242 err = obj->hash_viewers->lookup(name, storedObject);
245 anObject = storedObject[0];
246 if (anObject.
valid())
247 anObject.
send(kTTSym_Send, v, none);
258 if (obj->hash_viewers) {
259 err = obj->hash_viewers->lookup(name, storedObject);
262 anObject = storedObject[0];
263 if (anObject.
valid())
264 anObject.
set(kTTSym_highlight, s);
275 if (obj->hash_viewers) {
276 err = obj->hash_viewers->lookup(name, storedObject);
279 anObject = storedObject[0];
280 if (anObject.
valid())
281 anObject.
set(kTTSym_freeze, f);
288 #pragma mark message handlers
291 void ui_explorer_create(t_object *x,
TTObject& returnedExplorer, t_symbol *method)
297 returnValueCallback =
TTObject(
"callback");
299 returnValueCallback.
set(kTTSym_baton, baton);
301 args.
append(returnValueCallback);
305 returnedExplorer =
TTObject(kTTSym_Explorer, args);
308 void ui_modelParamExplorer_callback(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
310 t_ui* obj = (t_ui*)
self;
311 t_symobject *item = NULL;
314 if (obj->modelAddress != kTTAdrsEmpty) {
317 for (
long i=0; i<argc; i++) {
318 item = (t_symobject *)symobject_new(atom_getsym(argv+i));
319 linklist_append(obj->refmenu_items, item);
324 void ui_modelMessExplorer_callback(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
326 t_ui* obj = (t_ui*)
self;
327 t_symobject *item = NULL;
330 if (obj->modelAddress != kTTAdrsEmpty) {
333 for (
long i=0; i<argc; i++) {
334 item = (t_symobject *)symobject_new(atom_getsym(argv+i));
335 linklist_append(obj->refmenu_items, item);
340 void ui_modelRetExplorer_callback(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
342 t_ui* obj = (t_ui*)
self;
343 t_symobject *item = NULL;
346 if (obj->modelAddress != kTTAdrsEmpty) {
349 for (
long i=0; i<argc; i++) {
350 item = (t_symobject *)symobject_new(atom_getsym(argv+i));
351 linklist_append(obj->refmenu_items, item);
356 void ui_view_panel_attach(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
358 t_ui *obj = (t_ui*)
self;
360 t_outlet *myoutlet = NULL;
361 t_dll *connecteds = NULL;
367 object_obex_lookup(obj, _sym_pound_B, &box);
368 myoutlet = (t_outlet*)jbox_getoutlet((t_jbox*)box, panel_out);
370 connecteds = (t_dll*)myoutlet->o_dll;
373 o = (t_object*)connecteds->d_x1;
374 name = object_classname(o);
375 if (name == _sym_inlet) {
376 o = ((t_inlet *)connecteds->d_x1)->i_owner;
377 name = object_classname(o);
378 if (name == _sym_jpatcher) {
380 obj->patcher_panel = o;
381 obj->has_panel =
true;
383 jbox_redraw(&obj->box);
389 connecteds = connecteds->d_next;
393 void ui_return_mute(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
395 t_ui* obj = (t_ui*)
self;
397 obj->is_muted = atom_getlong(argv);
398 jbox_redraw(&obj->box);
401 void ui_return_bypass(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
403 t_ui* obj = (t_ui*)
self;
405 obj->is_bypassed = atom_getlong(argv);
406 jbox_redraw(&obj->box);
409 void ui_return_mix(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
411 t_ui* obj = (t_ui*)
self;
413 obj->mix = atom_getlong(argv);
414 jbox_redraw(&obj->box);
417 void ui_return_gain(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
419 t_ui* obj = (t_ui*)
self;
421 obj->gain = atom_getlong(argv);
422 jbox_redraw(&obj->box);
425 void ui_return_freeze(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
427 t_ui* obj = (t_ui*)
self;
429 obj->is_frozen = atom_getlong(argv);
430 jbox_redraw(&obj->box);
433 void ui_return_active(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
435 t_ui* obj = (t_ui*)
self;
437 obj->is_active = atom_getlong(argv);
438 jbox_redraw(&obj->box);
441 void ui_return_model_address(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
443 t_object *obj = (t_object*)
self;
448 defer_low(obj, (method)ui_subscribe, atom_getsym(argv), 0, 0);
451 void ui_return_model_init(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
453 t_ui* obj = (t_ui*)
self;
454 long init = atom_getlong(argv);
461 if (obj->hash_receivers->lookup(kTTSym_content, v))
465 ui_receiver_create(obj, aReceiver, gensym(
"return_model_content"), kTTSym_content, obj->modelAddress, NO, YES);
471 aReceiver.
set(kTTSym_address, obj->modelAddress.appendAttribute(kTTSym_content));
476 void ui_return_model_content(
TTPtr self, t_symbol *msg,
long argc, t_atom* argv)
478 t_ui* obj = (t_ui*)
self;
496 if (!obj->hash_viewers)
500 if (obj->modelAddress != kTTAdrsEmpty) {
503 for (
long i=0; i<argc; i++) {
505 relativeAddress =
TTAddress(atom_getsym(argv+i)->s_name);
531 if (dataInput || dataOutput)
534 if (dataInput && dataOutput)
537 if (audioInput || audioOutput)
540 if (audioInput && audioOutput) {
551 if (gain != obj->has_gain) {
552 obj->has_gain = gain;
554 ui_viewer_create(obj, anObject, gensym(
"return_gain"),
TTSymbol(
"audio/gain"), obj->modelAddress, NO);
556 ui_viewer_destroy(obj,
TTSymbol(
"audio/gain"));
560 if (mix != obj->has_mix) {
563 ui_viewer_create(obj, anObject, gensym(
"return_mix"),
TTSymbol(
"audio/mix"), obj->modelAddress, NO);
565 ui_viewer_destroy(obj,
TTSymbol(
"audio/mix"));
571 if (bypass != obj->has_bypass) {
572 obj->has_bypass = bypass;
574 ui_viewer_create(obj, anObject, gensym(
"return_bypass"),
TTSymbol(
"*.*/bypass"), obj->modelAddress, NO);
576 ui_viewer_destroy(obj,
TTSymbol(
"*.*/bypass"));
582 if (freeze != obj->has_freeze) {
583 obj->has_freeze = freeze;
585 ui_viewer_create(obj, anObject, gensym(
"return_freeze"),
TTSymbol(
"data/freeze"), obj->modelAddress, NO);
587 ui_viewer_destroy(obj,
TTSymbol(
"data/freeze"));
593 if (active != obj->has_active) {
594 obj->has_active = active;
596 ui_viewer_create(obj, anObject, gensym(
"return_active"),
TTSymbol(
"data/active"), obj->modelAddress, NO);
598 ui_viewer_destroy(obj,
TTSymbol(
"data/active"));
599 obj->hash_viewers->remove(
TTSymbol(
"data/active"));
606 if (mute != obj->has_mute) {
607 obj->has_mute = mute;
609 ui_viewer_create(obj, anObject, gensym(
"return_mute"),
TTSymbol(
"*.*/mute"), obj->modelAddress, NO);
611 ui_viewer_destroy(obj,
TTSymbol(
"*.*/mute"));
617 if (preset != obj->has_preset) {
618 obj->has_preset = preset;
620 ui_viewer_create(obj, anObject, gensym(
"return_preset_names"),
TTSymbol(
"preset:names"), obj->modelAddress, NO);
623 ui_viewer_destroy(obj,
TTSymbol(
"preset:names"));
630 if (model != obj->has_model)
631 obj->has_model = model;
634 jbox_redraw(&obj->box);
TTAddress appendAddress(const TTAddress &toAppend)
Return a new TTAddress with the appended part.
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
TTAddress appendAttribute(TTSymbol anAttribute)
Return a new TTAddress with attribute part.
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
TTAddress getParent()
Get a pointer to the parent address.
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Create and use Jamoma object instances.
j.ui : Provide standard user interface component for modules
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
void * TTPtr
A generic pointer.
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
const char * c_str() const
Return a pointer to the internal string as a C-string.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTBoolean valid() const
Determine if the object contained by this TTObject is truly ready for use.
TTSymbol & getName()
Get the name part.
[doxygenAppendixC_copyExample]
unsigned char TTUInt8
8 bit unsigned integer (char)