Esempio n. 1
0
/**
 * Clones the source VisParamContainer into the destination VisParamContainer. When an entry with a certain name
 * already exists in the destination container, it will be overwritten with a new value.
 *
 * @param destcont A pointer to the VisParamContainer in which the VisParamEntry values are copied.
 * @param srccont A pointer to the VisParamContainer from which the VisParamEntry values are copied.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL, on failure.
 */
int visual_param_container_copy (VisParamContainer *destcont, VisParamContainer *srccont)
{
	VisListEntry *le = NULL;
	VisParamEntry *destparam;
	VisParamEntry *srcparam;
	VisParamEntry *tempparam;

	visual_log_return_val_if_fail (destcont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (srccont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);

	while ((srcparam = visual_list_next (&srccont->entries, &le)) != NULL) {
		tempparam = visual_param_container_get (destcont, visual_param_entry_get_name (srcparam));

		/* Already exists, overwrite */
		if (tempparam != NULL) {
			visual_param_entry_set_from_param (tempparam, srcparam);

			continue;
		}

		/* Does not yet exist, create a new entry */
		destparam = visual_param_entry_new (visual_param_entry_get_name (srcparam));
		visual_param_entry_set_from_param (destparam, srcparam);

		visual_param_container_add (destcont, destparam);
	}

	return VISUAL_OK;
}
Esempio n. 2
0
/**
 * Copies matching VisParamEntry elements from srccont into destcont, matching on the name.
 *
 * @param destcont A pointer to the VisParamContainer in which the VisParamEntry values are copied.
 * @param srccont A pointer to the VisParamContainer from which the VisParamEntry values are copied.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL, on failure.
 */
int visual_param_container_copy_match (VisParamContainer *destcont, VisParamContainer *srccont)
{
	VisListEntry *le = NULL;
	VisParamEntry *destparam;
	VisParamEntry *srcparam;

	visual_log_return_val_if_fail (destcont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (srccont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);

	while ((destparam = visual_list_next (&destcont->entries, &le)) != NULL) {
		srcparam = visual_param_container_get (srccont, visual_param_entry_get_name (destparam));

		if (srcparam != NULL)
			visual_param_entry_set_from_param (destparam, srcparam);
	}

	return VISUAL_OK;
}
Esempio n. 3
0
/**
 * Adds a list of VisParamEntry elements, the list is terminated by an entry of type VISUAL_PARAM_ENTRY_TYPE_END.
 * All the elements are reallocated, so this function can be used for static param lists.
 *
 * @param paramcontainer A pointer to the VisParamContainer in which the VisParamEntry elements are added.
 * @param params A pointer to the VisParamEntry elements that are added to the VisParamContainer.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL or -VISUAL_ERROR_PARAM_NULL on failure.
 */
int visual_param_container_add_many (VisParamContainer *paramcontainer, VisParamEntry *params)
{
	VisParamEntry *pnew;
	int i = 0;

	visual_log_return_val_if_fail (paramcontainer != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (params != NULL, -VISUAL_ERROR_PARAM_NULL);

	while (params[i].type != VISUAL_PARAM_ENTRY_TYPE_END) {
		pnew = visual_param_entry_new (visual_param_entry_get_name (&params[i]));
		visual_param_entry_set_from_param (pnew, &params[i]);

		visual_param_container_add (paramcontainer, pnew);

		i++;
	}

	return VISUAL_OK;
}
Esempio n. 4
0
static void set_parameter_lv(void * data, const char * name,
                             const bg_parameter_value_t * val)
  {
  int supported;
  lv_priv_t * priv;
  int index;
  int i_tmp;
  uint8_t r, g, b;
  char * tmp_string;
  VisParamEntry * param;
  VisListEntry * list_entry;

  VisColor * color;
  const bg_parameter_info_t * info;
  
  if(!name)
    return;
  priv = (lv_priv_t*)data;

  info = bg_parameter_find(priv->parameters, name);
  if(!info)
    return;

  /* This would crash if multi_parameters were supported */
  index = info - priv->parameters;

  tmp_string = gavl_strdup(name);
  param = visual_param_entry_new(tmp_string);
  free(tmp_string);
  /* Menus have to be treated specially */
  if(info->type == BG_PARAMETER_STRINGLIST)
    {
    if(!priv->widgets[index])
      return;
    /* Get the selected index */
    supported = 0;
    list_entry = NULL;
    while(visual_list_next(&VISUAL_UI_CHOICE(priv->widgets[index])->choices.choices,
                           &list_entry))
      {
      if(!strcmp(((VisUIChoiceEntry*)(list_entry->data))->name, val->val_str))
        {
        visual_param_entry_set_from_param(param,
                                          ((VisUIChoiceEntry*)(list_entry->data))->value);
        supported = 1;
        break;
        }
      }
    }
  else
    {
    supported = 1;
    switch(priv->params[index]->type)
      {
      case VISUAL_PARAM_ENTRY_TYPE_NULL:     /**< No parameter. */
        supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_STRING:   /**< String parameter. */
        if(val->val_str)
          visual_param_entry_set_string(param, val->val_str);
        else
          supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_INTEGER:  /**< Integer parameter. */
        visual_param_entry_set_integer(param, val->val_i);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_FLOAT:    /**< Floating point parameter. */
        visual_param_entry_set_float(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:   /**< Double floating point parameter. */
        visual_param_entry_set_double(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_COLOR:    /**< VisColor parameter. */
        i_tmp = (int)(val->val_color[0] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        r = i_tmp;
        
        i_tmp = (int)(val->val_color[1] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        g = i_tmp;

        i_tmp = (int)(val->val_color[2] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        b = i_tmp;

        color = visual_color_new();
        visual_color_set(color, r, g, b);
        visual_param_entry_set_color_by_color(param, color);
        visual_object_unref(VISUAL_OBJECT(color));
        break;
      case VISUAL_PARAM_ENTRY_TYPE_PALETTE:  /**< VisPalette parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_OBJECT:   /**< VisObject parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_END:      /**< List end, and used as terminator for VisParamEntry lists. */
        supported = 0;
        break;
      }
    }
  if(supported)
    {
    visual_event_queue_add_param(visual_plugin_get_eventqueue(visual_actor_get_plugin(priv->actor)),
                              param);
    }
  else
    visual_object_unref(VISUAL_OBJECT(param));
  }