Ejemplo n.º 1
0
static gboolean
sequence_tick (gpointer *foo)
{
  GtkTreeSelection *selection;
  GtkTreePath *path;
  GtkTreeIter iter;
  gdouble perc;

  if (!current_step)
    {
      if (!sequence_next ())
        {
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (play_button), FALSE);
          return FALSE;
        }

      selection = gtk_tree_view_get_selection (sequence_view);
      if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
        {
          return FALSE;
        }
      
      path = gtk_tree_model_get_path (GTK_TREE_MODEL (sequence_store), &iter);
  
      gtk_tree_model_get (GTK_TREE_MODEL (sequence_store), &iter,
                          COLUMN_DATA, &current_step,
                          -1);
      current_step->progress = 0;
      g_print ("new current step. time = %d\n", current_step->time);
    }

  if ((current_step->type == STEP_TYPE_DIMM ||
       current_step->type == STEP_TYPE_SLEEP) &&
       current_step->time > 0)
    {
      perc = ((gdouble) (current_step->progress) / (gdouble) current_step->time) * 0.95;

      gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_bar), perc);
    }

  if (step_tick (current_step) == FALSE)
    {
      if (current_step->type == STEP_TYPE_DIMM)
        last_scene = current_step->scene;

      current_step = NULL;
      gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_bar), 0);

      return TRUE;
    }

  return TRUE;
}
Ejemplo n.º 2
0
static void step_float(t_step *x, t_float f)
{
    double timenow = clock_getsystime();
    if (x->x_gotinlet && x->x_in1val > 0 && x->x_step != 0 && f != x->x_setval)
    {
    	if (timenow > x->x_targettime) x->x_setval = x->x_targetval;
    	else x->x_setval = x->x_setval + x->x_1overtimediff *
    	    (timenow - x->x_prevtime)
    	    * (x->x_targetval - x->x_setval);
    	x->x_prevtime = timenow;
    	x->x_targetval = f;		/* where to end */
		x->x_stepcall = 0;
			/* how long does it take ? */
    	x->x_targettime = clock_getsystimeafter(x->x_in1val);
		if(x->x_setval < x->x_targetval)
		{
			x->x_steptime = x->x_in1val / (int)((x->x_targetval - x->x_setval) / x->x_step);
		}
		else
		{
			x->x_steptime = x->x_in1val / (int)((x->x_setval - x->x_targetval) / x->x_step);
		}
		// post("steptime %g", x->x_steptime);
    	step_tick(x);
    	x->x_gotinlet = 0;
    	x->x_1overtimediff = 1./ (x->x_targettime - timenow);
			/* call tick function */
    	clock_delay(x->x_clock, x->x_steptime);
    
    }
    else
    {
    	clock_unset(x->x_clock);
    	x->x_targetval = x->x_setval = f;
    	outlet_float(x->x_obj.ob_outlet, f);
    }
    x->x_gotinlet = 0;
}