//-------------------------------------------------------------- void Timeline::M_getPropertiesJS() { // Javascript properties ofxJSValue retVal; ofxJSValue args[1]; args[0] = string_TO_ofxJSValue(string("d")); ofxJSCallFunctionNameGlobal("getTimelineCycle", args, 1, retVal); m_cycleDuration = ofxJSValue_TO_float(retVal); args[0] = string_TO_ofxJSValue(string("dScene")); ofxJSCallFunctionNameGlobal("getTimelineCycle", args, 1, retVal); m_cycleDurationScene = ofxJSValue_TO_float(retVal); args[0] = string_TO_ofxJSValue(string("dEcoute")); ofxJSCallFunctionNameGlobal("getTimelineCycle", args, 1, retVal); m_cycleDurationEcoute = ofxJSValue_TO_float(retVal); args[0] = string_TO_ofxJSValue(string("dCompteur")); ofxJSCallFunctionNameGlobal("getTimelineCycle", args, 1, retVal); m_cycleDurationCompteur = ofxJSValue_TO_float(retVal); args[0] = string_TO_ofxJSValue(string("dContemplation")); ofxJSCallFunctionNameGlobal("getTimelineCycle", args, 1, retVal); m_cycleDurationContemplation = ofxJSValue_TO_float(retVal); }
//-------------------------------------------------------------- void Animation::onNewPacket(DevicePacket* pPacket, string deviceId, float xNorm, float yNorm) { // Scripting if (mp_script && mp_obj && pPacket) { ofxJSValue retVal; ofxJSValue args[4]; args[0] = string_TO_ofxJSValue(deviceId); args[1] = float_TO_ofxJSValue(pPacket->m_volume); args[2] = float_TO_ofxJSValue(xNorm); args[3] = float_TO_ofxJSValue(yNorm); ofxJSCallFunctionNameObject_IfExists(mp_obj,"onNewPacket", args,4,retVal); } }
//-------------------------------------------------------------- void Animation::guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); int kind = e.widget->getKind(); if (kind == OFX_UI_WIDGET_SLIDER_H || kind == OFX_UI_WIDGET_SLIDER_V) { if (name == "volume") { m_soundPlayer.setVolume( ((ofxUISlider*) e.widget)->getScaledValue() ); } else { if (mp_obj) { ofxJSValue retVal; ofxJSValue args[2]; args[0] = string_TO_ofxJSValue( name ); args[1] = float_TO_ofxJSValue( ((ofxUISlider*) e.widget)->getScaledValue() ); ofxJSCallFunctionNameObject_IfExists(mp_obj,"eventUI", args,2,retVal); } } } else if (kind == OFX_UI_WIDGET_TOGGLE) { // TODO : not cool here if (guiEventTogglesSound(name)) { m_soundPlayer.m_listSoundNames.clear(); for (int i=0; i<m_listSoundNames.size(); i++){ ofxUIToggle* pSoundToggle = (ofxUIToggle*) mp_UIcanvas->getWidget( m_listSoundNames[i] ); if (pSoundToggle->getValue()){ // ofLog() << m_name << " / " << m_listSoundNames[i]; m_soundPlayer.add( m_listSoundNames[i] ); } } } else { if (mp_obj) { bool valToggle = ((ofxUIToggle*) e.widget)->getValue() ; ofxJSValue retVal; ofxJSValue args[2]; args[0] = string_TO_ofxJSValue( name ); args[1] = int_TO_ofxJSValue( valToggle ? 1 : 0 ); ofxJSCallFunctionNameObject_IfExists(mp_obj,"eventUI", args,2,retVal); } } } else if (kind == OFX_UI_WIDGET_LABELBUTTON) { if ( e.getButton()->getValue()) { if (name == "Save") { string filename = mp_teConfigName->getTextString(); saveConfiguration(filename); m_configurationCurrent = filename; } else if (name == "Load") { string filename = mp_teConfigName->getTextString(); m_configurationCurrent = filename; loadConfiguration(filename); } else if (name == "exportTemplate") { exportMidiSettingsTemplate(); } } } }