Beispiel #1
0
void ui_preset_interface(t_ui *x)
{
	char			filename[MAX_FILENAME_CHARS];
	short			path;
	t_fourcc		type;
	t_fourcc		filetype = 'JSON';
	t_dictionary*	d;
	t_object*		p;
	t_atom			a;
	
	strncpy_zero(filename, "j.preset_interface.maxpat", MAX_FILENAME_CHARS);
	locatefile_extended(filename, &path, &type, &filetype, 1);
	dictionary_read(filename, path, &d);
	
	atom_setobj(&a, d);
	p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, &a);
	object_attr_setlong(p, _sym_locked, 1);										// start out locked
	object_attr_setchar(p, _sym_enablehscroll, 0);								// turn off scroll bars
	object_attr_setchar(p, _sym_enablevscroll, 0);
	object_attr_setchar(p, _sym_openinpresentation, 1);	
	object_attr_setchar(p, _sym_toolbarvisible, 0);	
	object_attr_setsym(p, _sym_title, gensym("preset_interface"));		
	object_method_parse(p, _sym_window, "constrain 5 320 179 595", NULL);
	object_attach_byptr_register(x, p, _sym_nobox);
	
	object_method(p, _sym_vis);													// "vis" happens immediately, "front" is defer_lowed
	object_attr_setobj(jpatcher_get_firstview(p), _sym_owner, (t_object*)x);	// become the owner
	
	OBJ_ATTR_SYM(p, "arguments", 0, gensym((char*)x->modelAddress.c_str()));	// the patch needs a [j.interfaceArguments.js]
	
	object_method(p, _sym_loadbang);
}
Beispiel #2
0
void cc_open_editor(t_cc *x){
	// this should be done only if the file was actually modified--otherwise, just use the buffer

	//post("%s ofile: %s", __PRETTY_FUNCTION__, x->ofile_fullpath);
	FILE *fp = fopen(x->cfile_fullpath, "r");
	if(fp){
		x->code_len = fread(x->code_buf, sizeof(char), x->code_buf_len, fp);
	}else{
		x->code_len = cc_write_template(x, x->code_buf);
	}
	fclose(fp);
	if(x->ed){
		object_method(x->ed, gensym("settext"), x->code_buf, gensym("utf-8"));
	}else{
		x->ed = (t_object *)object_new(CLASS_NOBOX, gensym("jed"), (t_object *)x, 0);
		if(x->have_valid_filename){
			short path;
			char filename[MAX_FILENAME_CHARS];
			if(path_frompathname(x->cfile_fullpath, &path, filename)){
				error("cc: couldn't find %s", x->cfile_fullpath);
				return;
			}
			object_method(x->ed, gensym("filename"), filename, path);
		}else{
			object_attr_setsym(x->ed, gensym("title"), gensym("Untitled"));
		}
		object_method(x->ed, gensym("settext"), x->code_buf, gensym("utf-8"));
	}

	object_attr_setchar(x->ed, gensym("visible"), 1);
}
Beispiel #3
0
void jsusfx_dblclick(t_jsusfx *x) {
    if (!x->m_editor) {
        t_filehandle fh_read;
        if ( path_opensysfile(x->scriptname, x->path, &fh_read, READ_PERM) ) {
            error("jsusfx~: unable to script file");
            return;
        }
        t_handle texthandle;
        texthandle = sysmem_newhandle(0);
        sysfile_readtextfile(fh_read, texthandle, 0, TEXT_NULL_TERMINATE);
		x->m_editor = reinterpret_cast<t_object *>(object_new(CLASS_NOBOX, gensym("jed"), (t_object *)x, 0));
        object_attr_setchar(x->m_editor, gensym("scratch"), 1);
        object_method(x->m_editor, gensym("settext"), *texthandle, gensym("utf-8"));
        object_method(x->m_editor, gensym("filename"), x->scriptname, x->path);
        sysmem_freehandle(texthandle);
		sysfile_close(fh_read);
    } else {
        object_attr_setchar(x->m_editor, gensym("visible"), 1);
    }
}
Beispiel #4
0
void hub_getstate(t_hub *x)
{
	subscriberList*		subscriber = x->subscriber;	// head of the linked list
	subscriberIterator	i;
	t_subscriber*		t;
	char*				text = NULL;
	long				textsize = 0;

	if(!x->textEditor)
		x->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0);
	
	if(!x->textSize){
		x->textSize = 4096;
		x->text = (char*)malloc(sizeof(char) * x->textSize);
	}
	x->text[0] = 0;
	
	critical_enter(0);
	for(i = subscriber->begin(); i != subscriber->end(); ++i) {
		t = *i;
		if(t->type == jps_subscribe_parameter){
			long	ac = NULL; 
			t_atom* av = NULL;
			
			object_attr_getvalueof(t->object, jps_value, &ac, &av);		// get
			atom_gettext(ac, av, &textsize, &text, 0);
			
			// this is a really lame way to do this...
			if(strlen(x->text) > (x->textSize - 1024)){
				x->textSize += 4096;
				x->text = (char*)realloc(x->text, x->textSize);
			}
			
			strncat_zero(x->text, x->osc_name->s_name, x->textSize);
			strncat_zero(x->text, "/", x->textSize);
			strncat_zero(x->text, t->name->s_name, x->textSize);
			strncat_zero(x->text, " ", x->textSize);
			strncat_zero(x->text, text, x->textSize);
			strncat_zero(x->text, "\n", x->textSize);

			sysmem_freeptr(text);
			text = NULL;
			textsize = 0;
		}
	}
	critical_exit(0);
	
	object_method(x->textEditor, _sym_settext, x->text, _sym_utf_8);
	object_attr_setchar(x->textEditor, gensym("scratch"), 1); 
	object_attr_setsym(x->textEditor, _sym_title, gensym("jamoma module state"));
	
	sysmem_freeptr(text);
}
Beispiel #5
0
// TODO: When running in the debugger, it seems like we are iterating through this function a whole bunch of times!
// Can we put it in a qelem or something so that it only gets called once? [TAP]
// But actually, maybe it is just a Max 4.6 funky Runtime thing?  Let's take a look again when we get to Max 5
void hub_examine_context(t_hub *x)
{
	AtomCount	argc = 0;
	AtomPtr		argv = NULL;
	SymbolPtr	context = jamoma_patcher_getcontext(x->container);

	// Try to get OSC Name of module from an argument
	jamoma_patcher_getargs(x->container, &argc, &argv);	// <-- this call allocates memory for argv
	if(argc){
		x->osc_name = atom_getsym(argv+(argc-1));
		sysmem_freeptr(argv);
	}
	else
		x->osc_name = _sym_nothing;
	
	// Try to get OSC Name of module from scripting name
	if(x->osc_name == _sym_nothing)
		x->osc_name = jamoma_patcher_getvarname(x->container);

	// In this case we overwrite whatever happened above
	if(context == gensym("toplevel")){
		x->osc_name = gensym("/editing_this_module");
		x->editing = true;
	}
	else{
		t_object*	patcher = jamoma_object_getpatcher((t_object*)x);
		t_object*	box = object_attr_getobj(patcher, jps_box);
		t_object*	ui = NULL;
		t_symbol*	objclass = NULL;
		
		x->editing = false;		
		ui = object_attr_getobj(patcher, gensym("firstobject"));
		while(ui){
			objclass = object_attr_getsym(ui, gensym("maxclass"));
			if(objclass == gensym("jcom.ui"))
				break;
			ui = object_attr_getobj(ui, gensym("nextobject"));
		}
		
		if(ui){
			t_rect	boxRect;
			t_rect	uiRect;
			
			if(context == gensym("bpatcher")){
				object_attr_get_rect(ui, _sym_presentation_rect, &uiRect);
				object_attr_get_rect(box, _sym_patching_rect, &boxRect);
				boxRect.width = uiRect.width;
				boxRect.height = uiRect.height;
				object_attr_set_rect(box, _sym_patching_rect, &boxRect);

				object_attr_get_rect(box, _sym_presentation_rect, &boxRect);
				boxRect.width = uiRect.width;
				boxRect.height = uiRect.height;
				object_attr_set_rect(box, _sym_presentation_rect, &boxRect);
			}
			else if(context == gensym("subpatcher")){
				object_attr_get_rect(ui, _sym_presentation_rect, &uiRect);
				object_attr_get_rect(patcher, _sym_defrect, &boxRect);
				boxRect.width = uiRect.width;
				boxRect.height = uiRect.height;
				object_attr_set_rect(patcher, _sym_defrect, &boxRect);				
				object_attr_setchar(patcher, _sym_toolbarvisible, 0);				
			}
		
		}
	}

	object_attr_setsym(x, _sym_name, x->osc_name);
	
	hub_subscriptions_refresh(x);
	hub_internals_create(x);

	qelem_unset(x->init_qelem);		// clear the last thing to make sure we don't call into this a bunch of times
	qelem_set(x->init_qelem);		// flag the queue for initialization
}
Beispiel #6
0
void *odisplay_new(t_symbol *msg, short argc, t_atom *argv){
	t_odisplay *x;
    
	t_dictionary *d = NULL;
 	long boxflags;
    
	// box setup
	if(!(d = object_dictionaryarg(argc, argv))){
		return NULL;
	}
    
	boxflags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_NODRAWBOX
    | JBOX_DRAWINLAST
    | JBOX_TRANSPARENT
    //| JBOX_NOGROW
    //| JBOX_GROWY
    //| JBOX_GROWBOTH
    //| JBOX_HILITE
    //| JBOX_BACKGROUND
    //| JBOX_DRAWBACKGROUND
    //| JBOX_NOFLOATINSPECTOR
    //| JBOX_MOUSEDRAGDELTA
    | JBOX_TEXTFIELD
    ;
    
	if((x = (t_odisplay *)object_alloc(odisplay_class))){
		jbox_new((t_jbox *)x, boxflags, argc, argv);
 		x->ob.b_firstin = (void *)x;
		x->outlet = outlet_new(x, NULL);
		//x->proxy = proxy_new(x, 1, &(x->inlet));
		x->bndl_u = NULL;
		x->bndl_s = NULL;
		x->newbndl = 0;
		x->textlen = 0;
		x->text = NULL;
		//x->bndl_has_been_checked_for_subs = 0;
		//x->bndl_has_subs = 0;
		critical_new(&(x->lock));
		x->qelem = qelem_new((t_object *)x, (method)odisplay_refresh);
		x->new_data_indicator_clock = clock_new((t_object *)x, (method)odisplay_refresh);
		x->have_new_data = 1;
		x->draw_new_data_indicator = 0;
		attr_dictionary_process(x, d);
        
		t_object *textfield = jbox_get_textfield((t_object *)x);
		if(textfield){
			object_attr_setchar(textfield, gensym("editwhenunlocked"), 0);
            textfield_set_readonly(textfield, '1');
            textfield_set_selectallonedit(textfield, '1');
			textfield_set_textmargins(textfield, 5, 5, 5, 15);
			textfield_set_textcolor(textfield, &(x->text_color));
		}
        
 		jbox_ready((t_jbox *)x);
		//odisplay_gettext(x);
        odisplay_clear(x);
		return x;
	}
	return NULL;
}
int main(void)
{
	common_symbols_init();
	PlugtasticInit();

	plugtastic_classinit();
	sPlugtasticObject = (t_object*)plugtastic_new();
	ps_plugtastic = GENSYM("plugtastic");
	ps_plugtastic->s_thing = sPlugtasticObject;

	sMaxObject = _sym_max->s_thing;
	ps_objectfile				= GENSYM("objectfile");
	ps_db_object_addinternal	= GENSYM("db.object_addinternal");
	ps_oblist					= GENSYM("oblist");
	ps_db_addmetadata			= GENSYM("db.addmetadata");
	
	//defer_low(sMaxObject, (method)plug_setup_db, NULL, 0, NULL);
	plug_setup_db();
	
	post("Plugtastic                                            Version %s | 74Objects.com", PLUGTASTIC_VERSION);
	

	// This tells Max 5.0.6 and higher that we want the patcher files to be saved such that they are sorted.
	// Having the saved this way makes our SVN diffs much more meaningful.
	object_method_long(sMaxObject, GENSYM("sortpatcherdictonsave"), 1, NULL);
	
	// This tells Max 4.5.7 and higher to take any posts to the Max window and also make the
	// post to the system console, which greatly aids in debugging problems and crashes
	object_method_long(sMaxObject, GENSYM("setmirrortoconsole"), 1, NULL);
	
	
	// OPEN THE SPLASH
	
	if (sPlugtasticSplash) {
		char			name[MAX_FILENAME_CHARS];
		short			path = 0;
		long			type = 0;
		long			typelist[2] = {'JSON', 'TEXT'};
		short			err;
		t_dictionary*	d;
		t_object*		p;
		t_atom			a[2];
		
		strncpy_zero(name, "Plugtastic.maxpat", MAX_FILENAME_CHARS);
		err = locatefile_extended(name, &path, &type, typelist, 2);
		dictionary_read(name, path, &d);
		
		atom_setobj(a, d);
		p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, a);
		object_attr_setlong(p, _sym_locked, 1);			// start out locked
		object_attr_setchar(p, _sym_enablehscroll, 0);		// turn off scroll bars
		object_attr_setchar(p, _sym_enablevscroll, 0);
		object_attr_setchar(p, _sym_toolbarvisible, 0);	
		object_attr_setsym(p, _sym_title, gensym("Welcome to Plugtastic"));		
		object_attr_setparse(p, _sym_rect, "271 170 799 489");
		object_attr_setparse(p, _sym_defrect, "271 170 799 489");

		object_method(p, _sym_vis);	// "vis" happens immediately, "front" is defer_lowed
		object_method(p, _sym_loadbang);

//		object_method_parse(p, _sym_window, "constrain 799 489 799 489", NULL);
		object_method_parse(p, _sym_window, "flags nozoom", NULL);
		object_method_parse(p, _sym_window, "flags nogrow", NULL);
		object_method_parse(p, _sym_window, "exec", NULL);
	}	
	
	
	return 0;
}
Beispiel #8
0
void cue_edit(TTPtr self, t_symbol *msg, long argc, const t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTString			*buffer;
	char				title[MAX_FILENAME_CHARS];
	TTObject            aTextHandler;
	TTHashPtr			allCues;
	TTValue				v, o;
	TTSymbol			name = kTTSymEmpty;
    t_atom				a;
	TTErr				tterr;
	
	// choose object to edit : default the cuelist
	*EXTRA->toEdit = x->wrappedObject;
	EXTRA->cueName = kTTSymEmpty;
	
	if (argc && argv)
    {
		if (atom_gettype(argv) == A_LONG)
        {
            TTUInt32 index = atom_getlong(argv);
			
			// get cues names
			x->wrappedObject.get("names", v);
			
			if (index > 0 && index <= v.size())
				name = v[index-1];
			else
            {
				object_error((t_object*)x, "%d doesn't exist", atom_getlong(argv));
				return;
			}
		}
		else if (atom_gettype(argv) == A_SYM)
			name = TTSymbol(atom_getsym(argv)->s_name);
		
		if (name != kTTSymEmpty)
        {
			// get cue object table
			x->wrappedObject.get("cues", v);
			allCues = TTHashPtr((TTPtr)v[0]);
			
			if (allCues)
            {
				// get cue to edit
				if (!allCues->lookup(name, v))
                {
					// edit a cue
					*EXTRA->toEdit = v[0];
					EXTRA->cueName = name;
				}
				else
                {
					object_error((t_object*)x, "%s doesn't exist", atom_getsym(argv)->s_name);
					return;
				}
			}
		}
	}
	
	// only one editor can be open in the same time
	if (!EXTRA->textEditor) {
		
		EXTRA->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0);
		
		buffer = new TTString();
		
		// get the buffer handler
		tterr = x->internals->lookup(kTTSym_TextHandler, o);
		
		if (!tterr) {
			
			aTextHandler = o[0];
			
			critical_enter(0);
			aTextHandler.set(kTTSym_object, *EXTRA->toEdit);
			tterr = aTextHandler.send(kTTSym_Write, (TTPtr)buffer);
			critical_exit(0);
		}
		
		// pass the buffer to the editor
		object_method(EXTRA->textEditor, _sym_settext, buffer->c_str(), _sym_utf_8);
		object_attr_setchar(EXTRA->textEditor, gensym("scratch"), 1);
		
		snprintf(title, MAX_FILENAME_CHARS, "cuelist editor");
		object_attr_setsym(EXTRA->textEditor, _sym_title, gensym(title));
        
        // output a flag
        atom_setsym(&a, gensym("opened"));
        object_obex_dumpout(self, gensym("editor"), 1, &a);
		
		buffer->clear();
		delete buffer;
		buffer = NULL;
	}
    else
    {
        object_attr_setchar(EXTRA->textEditor, gensym("visible"), 1);
    }
}