Example #1
0
/**
 * Copies the value of the src param into the param. Also sets the param to the type of which the
 * source param is.
 *
 * @param param Pointer to the VisParamEntry to which a parameter is set.
 * @param src Pointer to the VisParamEntry from which the value is retrieved.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_NULL, -VISUAL_ERROR_PARAM_INVALID_TYPE on failure.
 */
int visual_param_entry_set_from_param (VisParamEntry *param, VisParamEntry *src)
{
	visual_log_return_val_if_fail (param != NULL, -VISUAL_ERROR_PARAM_NULL);
	visual_log_return_val_if_fail (src != NULL, -VISUAL_ERROR_PARAM_NULL);

	switch (src->type) {
		case VISUAL_PARAM_ENTRY_TYPE_NULL:

			break;

		case VISUAL_PARAM_ENTRY_TYPE_STRING:
			visual_param_entry_set_string (param, visual_param_entry_get_string (src));
			break;

		case VISUAL_PARAM_ENTRY_TYPE_INTEGER:
			visual_param_entry_set_integer (param, visual_param_entry_get_integer (src));
			
			break;

		case VISUAL_PARAM_ENTRY_TYPE_FLOAT:
			visual_param_entry_set_float (param, visual_param_entry_get_float (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:
			visual_param_entry_set_double (param, visual_param_entry_get_double (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_COLOR:
			visual_param_entry_set_color_by_color (param, visual_param_entry_get_color (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_PALETTE:
			visual_param_entry_set_palette (param, visual_param_entry_get_palette (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_OBJECT:
			visual_param_entry_set_object (param, visual_param_entry_get_object (src));

			break;
		
		default:
			visual_log (VISUAL_LOG_CRITICAL, _("param type is not valid"));

			return -VISUAL_ERROR_PARAM_INVALID_TYPE;

			break;
	}
	
	return VISUAL_OK;
}
Example #2
0
/**
 * reflect the new values.
 */
static void _config_load_preset(BlurskPrivate *priv, BlurskConfig *conf)
{
    struct
    {
        char *name;
        int type;
        void *val;
    }entries[] =
    {
        {"color", VISUAL_PARAM_ENTRY_TYPE_COLOR, &conf->color},
        {"color_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->color_style},
        {"fade_speed", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->fade_speed},
        {"signal_color", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->signal_color},
        {"contour_lines", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->contour_lines},
        {"hue_on_beats", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->hue_on_beats},
        {"background", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->background},
        {"blur_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_style},
        {"transition_speed", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->transition_speed},
        {"blur_when", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_when},
        {"blur_stencil", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_stencil},
        {"slow_motion", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->slow_motion},
        {"signal_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->signal_style},
        {"plot_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->plot_style},
        {"thick_on_beats", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->thick_on_beats},
        {"flash_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->flash_style},
        {"overall_effect", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->overall_effect},
        {"floaters", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->floaters},
    };
    
    
    
    int i;
        
    for(i = 0; i < QTY(entries); i++)
    {
        VisParamContainer *paramcontainer = visual_plugin_get_params(priv->plugin);
        VisParamEntry *ptmp = visual_param_container_get(paramcontainer, entries[i].name);
        
        switch(entries[i].type)
        {
            case VISUAL_PARAM_ENTRY_TYPE_INTEGER:
            {
                int *integer = entries[i].val;
                
                /* only update if values differ */
                if(*integer != visual_param_entry_get_integer(ptmp))
                    visual_param_entry_set_integer(ptmp, *integer);
                break;
            }
            
            
            case VISUAL_PARAM_ENTRY_TYPE_COLOR:
            {
                VisColor *color = visual_param_entry_get_color(ptmp);
                VisColor ncolor;
                uint32_t nicolor = (((color->b)<<16) + ((color->g)<<8) + color->r);
                uint32_t *icolor = entries[i].val;
            
                /* only update if values differ */
                if(*icolor != nicolor)
                {
                    visual_color_set(&ncolor, (*icolor&0xFF0000)>>16, (*icolor&0xFF00)>>8, (*icolor&0xFF));
                    visual_param_entry_set_color_by_color(ptmp, &ncolor);
                }
                break;
            }
            
            
            case VISUAL_PARAM_ENTRY_TYPE_STRING:
            {
                char **string = entries[i].val;
            
                /* only update if values differ */
                if(strcmp(*string, visual_param_entry_get_string(ptmp)) != 0)
                    visual_param_entry_set_string(ptmp, *string);
                break;
            }
        }
    }