<commit_before>// Javascript for Jamoma: assemble the gui component
// By <NAME>, Copyright  2005
// License: GNU LGPL


/*******************************************************************
 * SETUP
 *******************************************************************/

// CONSTANTS
const HEIGHT_1U = 60;						// pixel dimensions
const WIDTH_HALF = 255;						// ...
const NUM_DEFAULT_INLETS_AND_OUTLETS = 32;	// number of these in the jcom.gui

// GLOBALS
var attr_module_type = "audio";
var attr_skin = "default";
var attr_inspector = 0;
var attr_displayfreeze_toggle = 0;
var attr_meterfreeze_toggle = 0;
var attr_preview = 0;						// preview is not turned on by default
var attr_bypass = 0;
var attr_mute = 0;
var attr_freeze = 0;
var attr_size = "1Uh";
var height = 1;
var width = "half";
var	p = this.patcher;
var offset_x = 0;
var offset_y = 0;
var menu_items = new Array();
var menu_num_presets = 0;
var has_run = 0;				// flag indicating that this module has previously been built
var grandparent_name;			// this is the scripting name of the object box hosting the module's patch
var preset_items = new Array();		// holds preset names at an index
var panel_has_moved = 0;

// CONFIGURATION
inlets = 1;
outlets = 5;


// INITIALIZATION
function init()
{
	// set up assistance strings
	setinletassist(0, "set attributes, etc.");
	setoutletassist(0, "connect to a thispatcher object");
	setoutletassist(1, "connect to a bg pictctrl");
	setoutletassist(2, "unused");
	setoutletassist(3, "connect to the module's umenu");
	setoutletassist(4, "messages to be sent to the module's hub");
}
init.local = 1;		// hide the init function
init();			// run the init function


// This is run at the loadbang time...
function loadbang()
{
	var gui = this.patcher.wind.assoc.box;
	this.patcher.parentpatcher.sendtoback(gui);
}


// Respond to global jcom.init initialization
function jmod_init()
{
/*	if(this.patcher.parentpatcher.box){
		grandparent_name = this.patcher.parentpatcher.box.varname;
		if(grandparent_name){
			outlet(4, "MODULE_TITLE", grandparent_name);
		}
	}
	else{
		outlet(4, "MODULE_TITLE", "editing_this_module");
	}
*/	
	// This should send the gui bpatcher in a module to the back
	// 	hopefully this will then keep everything else on top of 
	//	it visible...
	var gui = this.patcher.wind.assoc.box;
	this.patcher.parentpatcher.sendtoback(gui);
}


/*******************************************************************
 * METHODS
 *******************************************************************/
 
/* BANG: build the gui component
 *
 *	There are some things here that may not seem very elegant.  As of
 *	Max 4.5.4, New items scripted into a patch, that is loaded in a
 *	bpatcher within a bpatcher (such as jcom.gui), are scripted into place
 *	using the coordinates of the patcher window - not the bpatcher's 
 *	viewable region.  This means that a number of objects are pre-included
 *	in the jcom.gui patch and then deleted or moved dynamically, rather than
 *	creating what is needed.
 */
function bang()
{
	// Choose the skin, if needed
	if(attr_skin == "default"){
		if((attr_module_type == "audio") || (attr_module_type == "audio.no_panel") || (attr_module_type == "audio.ambisonic"))
			attr_skin = "j4.audio";
		else if(attr_module_type == "video")
			attr_skin = "j4.video";
		else if(attr_module_type == "control")
			attr_skin = "j4.control";
	}
	
	// Change the background graphic to match the skin (object autosizes to match it)
	outlet(1, "picture", "jcom.bg." + attr_skin + "." + attr_size + ".pct");

	if((attr_module_type == "audio") || (attr_module_type == "audio.no_panel") || (attr_module_type == "audio.ambisonic")){	
		if(has_run == 0){
			if(attr_module_type == "audio.ambisonic"){
				// Replace the panel with a specific ambisonic panel
				// Position determined according to current position of the "controls" panel.
				outlet(0, "script", "replace", "controls", "bpatcher", this.patcher.getnamed("controls").rect, 0, -190, "jcom.gui.ambi-component.mxt", 0);
			}
			else if(attr_module_type == "audio.no_panel"){
				outlet(0, "script", "delete", "controls");
			}
			
			// move the controls if neccessary
			if(panel_has_moved == 0){
				if((width == 1) && (attr_module_type != "audio.no_panel"))
					outlet(0, "script", "offset", "controls", -255, 0);
				panel_has_moved = 1;

				// delete the video preview window
				outlet(0, "script", "delete", "pwindow");

				// Handle the Inspector Button
				inspector_button(attr_inspector);
			}
		
			// Setup the Menu
			menu_clear();<commit_msg>fixed offset for ambi panel when it is used in a module.  SF#1686936<commit_after>// Javascript for Jamoma: assemble the gui component
// By <NAME>, Copyright  2005
// License: GNU LGPL


/*******************************************************************
 * SETUP
 *******************************************************************/

// CONSTANTS
const HEIGHT_1U = 60;						// pixel dimensions
const WIDTH_HALF = 255;						// ...
const NUM_DEFAULT_INLETS_AND_OUTLETS = 32;	// number of these in the jcom.gui

// GLOBALS
var attr_module_type = "audio";
var attr_skin = "default";
var attr_inspector = 0;
var attr_displayfreeze_toggle = 0;
var attr_meterfreeze_toggle = 0;
var attr_preview = 0;						// preview is not turned on by default
var attr_bypass = 0;
var attr_mute = 0;
var attr_freeze = 0;
var attr_size = "1Uh";
var height = 1;
var width = "half";
var	p = this.patcher;
var offset_x = 0;
var offset_y = 0;
var menu_items = new Array();
var menu_num_presets = 0;
var has_run = 0;				// flag indicating that this module has previously been built
var grandparent_name;			// this is the scripting name of the object box hosting the module's patch
var preset_items = new Array();		// holds preset names at an index
var panel_has_moved = 0;

// CONFIGURATION
inlets = 1;
outlets = 5;


// INITIALIZATION
function init()
{
	// set up assistance strings
	setinletassist(0, "set attributes, etc.");
	setoutletassist(0, "connect to a thispatcher object");
	setoutletassist(1, "connect to a bg pictctrl");
	setoutletassist(2, "unused");
	setoutletassist(3, "connect to the module's umenu");
	setoutletassist(4, "messages to be sent to the module's hub");
}
init.local = 1;		// hide the init function
init();			// run the init function


// This is run at the loadbang time...
function loadbang()
{
	var gui = this.patcher.wind.assoc.box;
	this.patcher.parentpatcher.sendtoback(gui);
}


// Respond to global jcom.init initialization
function jmod_init()
{
/*	if(this.patcher.parentpatcher.box){
		grandparent_name = this.patcher.parentpatcher.box.varname;
		if(grandparent_name){
			outlet(4, "MODULE_TITLE", grandparent_name);
		}
	}
	else{
		outlet(4, "MODULE_TITLE", "editing_this_module");
	}
*/	
	// This should send the gui bpatcher in a module to the back
	// 	hopefully this will then keep everything else on top of 
	//	it visible...
	var gui = this.patcher.wind.assoc.box;
	this.patcher.parentpatcher.sendtoback(gui);
}


/*******************************************************************
 * METHODS
 *******************************************************************/
 
/* BANG: build the gui component
 *
 *	There are some things here that may not seem very elegant.  As of
 *	Max 4.5.4, New items scripted into a patch, that is loaded in a
 *	bpatcher within a bpatcher (such as jcom.gui), are scripted into place
 *	using the coordinates of the patcher window - not the bpatcher's 
 *	viewable region.  This means that a number of objects are pre-included
 *	in the jcom.gui patch and then deleted or moved dynamically, rather than
 *	creating what is needed.
 */
function bang()
{
	// Choose the skin, if needed
	if(attr_skin == "default"){
		if((attr_module_type == "audio") || (attr_module_type == "audio.no_panel") || (attr_module_type == "audio.ambisonic"))
			attr_skin = "j4.audio";
		else if(attr_module_type == "video")
			attr_skin = "j4.video";
		else if(attr_module_type == "control")
			attr_skin = "j4.control";
	}
	
	// Change the background graphic to match the skin (object autosizes to match it)
	outlet(1, "picture", "jcom.bg." + attr_skin + "." + attr_size + ".pct");

	if((attr_module_type == "audio") || (attr_module_type == "audio.no_panel") || (attr_module_type == "audio.ambisonic")){	
		if(has_run == 0){
			if(attr_module_type == "audio.ambisonic"){
				// Replace the panel with a specific ambisonic panel
				// Position determined according to current position of the "controls" panel.
				outlet(0, "script", "replace", "controls", "bpatcher", this.patcher.getnamed("controls").rect, -40, -190, "jcom.gui.ambi-component.mxt", 0);
			}
			else if(attr_module_type == "audio.no_panel"){
				outlet(0, "script", "delete", "controls");
			}
			
			// move the controls if neccessary
			if(panel_has_moved == 0){
				if((width == 1) && (attr_module_type != "audio.no_panel"))
					outlet(0, "script", "offset", "controls", -255, 0);
				panel_has_moved = 1;

				// delete the video preview window
				outlet(0, "script", "delete", "pwindow");

				// Handle the Inspector Button
				inspector_button(attr_inspector);
			}
		
			// Setup the Menu
			menu_clear();
{'fraction_non_alphanumeric': 0.17745986676859232, 'fraction_numerical': 0.014196789341487387, 'mean_word_length': 3.9989082969432315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3826677', 'n_tokens_mistral': 3329, 'n_tokens_neox': 2932, 'n_words': 925}