examples/ObjectPicker/ObjectPicker.cpp
/**
 *  updateSettingsSidebarParameters creates a Settings Widget if it doesn't exist and re-populates it with parameters.
*/
updateSettingsSidebarParameters creates a Settings Widget if it doesn't exist and re-populates it with parameters.
updateSettingsSidebarParameters creates a Settings Widget if it doesn ' t exist and re - populates it with parameters .
void ObjectPicker::updateSettingsSidebarParameters(bool updateNamesOfObjectsList) {
	if (updateNamesOfObjectsList) {
		this->settingsSidebar.updateNamesOfObjectsList( &this->simulationObjectsMap );
	}
	settingsSidebarParameters.reset();
	ivec2 paramWindowSize = ivec2( 200, 400 );
	settingsSidebarParameters = params::InterfaceGl::create( getWindow(), "App parameters", toPixels( paramWindowSize ) );
	if (this->settingsSidebar.getSelectedObject() != NULL) {
		settingsSidebarParameters->addParam("Cube Size",
			(function<void( ci::vec3 )>) [this](ci::vec3 scale){this->settingsSidebar.getSelectedObject()->scale = scale;},
			(function<ci::vec3 ()>)[this]() -> ci::vec3 {return this->settingsSidebar.getSelectedObject()->scale;}
		);
		settingsSidebarParameters->addParam( "Cube Rotation",
			(function<void( glm::highp_quat )>) [this](glm::highp_quat rotation){this->settingsSidebar.getSelectedObject()->rotation = rotation;},
			(function<glm::highp_quat ()>)[this]() -> glm::highp_quat {return this->settingsSidebar.getSelectedObject()->rotation;}
		);
		settingsSidebarParameters->addParam( "Cube Color",
			(function<void( ci::ColorA )>) [this](ci::ColorA color){this->settingsSidebar.getSelectedObject()->color = color;},
			(function<ci::ColorA ()>)[this]() -> ci::ColorA {return this->settingsSidebar.getSelectedObject()->color;}
		);
		settingsSidebarParameters->addSeparator();
		settingsSidebarParameters->addParam( "Selected Object", settingsSidebar.namesOfObjects, &settingsSidebar.selectedObjectIndex )
			.keyDecr( "[" )
			.keyIncr( "]" )
			.updateFn( [this] { 
				settingsSidebar.setSelectedObject( &this->simulationObjectsMap );
			} );
	} else {
		settingsSidebarParameters->addText( "Status Text", "label=`Please add an object and click refresh.`");
	}
	settingsSidebarParameters->addSeparator();
	settingsSidebarParameters->addParam( "print fps", &mPrintFps ).keyIncr( "p" );
	settingsSidebarParameters->addButton( "Refresh",[&]() { ObjectPicker::updateSettingsSidebarParameters(true); });
}
void ObjectPicker :: updateSettingsSidebarParameters ( bool updateNamesOfObjectsList ) { if ( updateNamesOfObjectsList ) { this -> settingsSidebar . updateNamesOfObjectsList ( & this -> simulationObjectsMap ) ; } settingsSidebarParameters . reset ( ) ; ivec2 paramWindowSize = ivec2 ( 200 , 400 ) ; settingsSidebarParameters = params :: InterfaceGl :: create ( getWindow ( ) , " " , toPixels ( paramWindowSize ) ) ; if ( this -> settingsSidebar . getSelectedObject ( ) != NULL ) { settingsSidebarParameters -> addParam ( " " , ( function < void ( ci :: vec3 ) > ) [ this ] ( ci :: vec3 scale ) { this -> settingsSidebar . getSelectedObject ( ) -> scale = scale ; } , ( function < ci :: vec3 ( ) > ) [ this ] ( ) -> ci :: vec3 { return this -> settingsSidebar . getSelectedObject ( ) -> scale ; } ) ; settingsSidebarParameters -> addParam ( " " , ( function < void ( glm :: highp_quat ) > ) [ this ] ( glm :: highp_quat rotation ) { this -> settingsSidebar . getSelectedObject ( ) -> rotation = rotation ; } , ( function < glm :: highp_quat ( ) > ) [ this ] ( ) -> glm :: highp_quat { return this -> settingsSidebar . getSelectedObject ( ) -> rotation ; } ) ; settingsSidebarParameters -> addParam ( " " , ( function < void ( ci :: ColorA ) > ) [ this ] ( ci :: ColorA color ) { this -> settingsSidebar . getSelectedObject ( ) -> color = color ; } , ( function < ci :: ColorA ( ) > ) [ this ] ( ) -> ci :: ColorA { return this -> settingsSidebar . getSelectedObject ( ) -> color ; } ) ; settingsSidebarParameters -> addSeparator ( ) ; settingsSidebarParameters -> addParam ( " " , settingsSidebar . namesOfObjects , & settingsSidebar . selectedObjectIndex ) . keyDecr ( " " ) . keyIncr ( " " ) . updateFn ( [ this ] { settingsSidebar . setSelectedObject ( & this -> simulationObjectsMap ) ; } ) ; } else { settingsSidebarParameters -> addText ( " " , " " ) ; } settingsSidebarParameters -> addSeparator ( ) ; settingsSidebarParameters -> addParam ( " " , & mPrintFps ) . keyIncr ( " " ) ; settingsSidebarParameters -> addButton ( " " , [ & ] ( ) { ObjectPicker :: updateSettingsSidebarParameters ( true ) ; } ) ; }
updateSettingsSidebarParameters creates a Settings Widget if it doesn't exist and re-populates it with parameters.
updateSettingsSidebarParameters creates a Settings Widget if it doesn ' t exist and re - populates it with parameters .