/* Timeline handler */
static void
frame_cb (ClutterTimeline *timeline,
	  gint             frame_num,
	  gpointer         data)
{
  SuperOH *oh = data;
  gint     i;

  /* Rotate everything clockwise about stage center*/

  clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
                              CLUTTER_Z_AXIS,
                              frame_num,
			      CLUTTER_STAGE_WIDTH () / 2,
                              CLUTTER_STAGE_HEIGHT () / 2,
			      0);

  for (i = 0; i < n_hands; i++)
    {
      gdouble scale_x, scale_y;

      clutter_actor_get_scale (oh->hand[i], &scale_x, &scale_y);

      /* Rotate each hand around there centers - to get this we need
       * to take into account any scaling.
       *
       * FIXME: scaling causes drift so disabled for now. Need rotation
       * unit based functions to fix.
       */
      clutter_actor_set_rotation (oh->hand[i], CLUTTER_Z_AXIS,
				  - 6.0 * frame_num, 0, 0, 0);
    }
}
Example #2
0
static void
zoom_transition_frame_cb (OptTransition   *trans,
			  gint             frame_num,
			  gpointer         data)
{
  OptSlide             *from, *to;
  OptTransitionPrivate *priv;
  ClutterActor         *stage;
  gint                  n_frames = 0; 

  priv = trans->priv;

  from  = opt_transition_get_from (trans);
  to    = opt_transition_get_to (trans);
  stage = clutter_stage_get_default();

  n_frames = clutter_timeline_get_n_frames (CLUTTER_TIMELINE(trans));

  if (frame_num > n_frames/2)
    {
      clutter_actor_hide (CLUTTER_ACTOR(from));
      clutter_actor_show_all (CLUTTER_ACTOR(to));
      clutter_actor_set_depth (CLUTTER_ACTOR(to), 
			       -1 * ((n_frames * 2000) - (frame_num * 2000)));

      clutter_actor_set_rotation (CLUTTER_ACTOR(to),
            CLUTTER_Z_AXIS,
            frame_num * ((360*2)/n_frames),
            CLUTTER_STAGE_WIDTH()/2,
            CLUTTER_STAGE_HEIGHT()/2,
            0);
    }
  else
    {
      clutter_actor_hide (CLUTTER_ACTOR(to));
      clutter_actor_set_depth (CLUTTER_ACTOR(from), -2000 * frame_num);

      clutter_actor_set_rotation (CLUTTER_ACTOR(from),
            CLUTTER_Z_AXIS,
            frame_num * ((360*2)/n_frames),
            CLUTTER_STAGE_WIDTH()/2,
            CLUTTER_STAGE_HEIGHT()/2,
            0);
    }
}
Example #3
0
static void
on_key_release_event (ClutterStage *stage,
                      ClutterEvent *event,
                      gpointer      null)
{
    static gint i = 0;

    switch (clutter_key_event_symbol ((ClutterKeyEvent*)event))
    {
    case CLUTTER_Escape:
        clutter_main_quit ();
        break;
    case CLUTTER_Left:
        i--;
        if (i == 0)
            i = 359;
        clutter_actor_set_rotation (CLUTTER_ACTOR (stage), CLUTTER_Y_AXIS, i,
                                    CLUTTER_STAGE_WIDTH ()/2,
                                    0,
                                    CLUTTER_STAGE_HEIGHT ());
        break;
    case CLUTTER_Right:
        i++;
        if (i == 360)
            i = 0;
        clutter_actor_set_rotation (CLUTTER_ACTOR (stage), CLUTTER_Y_AXIS, i,
                                    CLUTTER_STAGE_WIDTH ()/2,
                                    0,
                                    CLUTTER_STAGE_HEIGHT ());
        break;
    case CLUTTER_Up:
        if (!clutter_timeline_is_playing (timeline))
            clutter_timeline_start (timeline);
        break;
    default:
        break;
    }
}
Example #4
0
static void
fluttr_viewer_init (FluttrViewer *self)
{
	FluttrViewerPrivate *priv;
	gint width, height;
	ClutterActor *message;
	
	priv = FLUTTR_VIEWER_GET_PRIVATE (self);
	
	priv->mini_token = NULL;
	priv->popping = FALSE;

	width = CLUTTER_STAGE_WIDTH ();
	height = CLUTTER_STAGE_HEIGHT ();
		
	/* message box */
	message = clutter_texture_new ();
	priv->texture = message;
	clutter_group_add (CLUTTER_GROUP (self),message); 
	clutter_actor_set_size (message, width, height);
	clutter_actor_set_position (message, -(width/2),-(height/2));
	
	/* Spinner */
	priv->spinner = fluttr_spinner_new ();
	clutter_group_add (CLUTTER_GROUP (self),priv->spinner); 
	clutter_actor_set_size (priv->spinner, (height/6)-11, (height/6)-11);
	clutter_actor_set_position (priv->spinner, width-(height/6),height-(height/6));	
				    
	/* Setup the pixbuf swap */
	priv->pixbuf = NULL;
	priv->swap_time = clutter_timeline_new (40, 40);
	priv->swap_alpha = clutter_alpha_new_full (priv->swap_time,
					           alpha_linear_inc_func,
					           NULL, NULL);
	priv->swap_behave = fluttr_behave_new (priv->swap_alpha,
					       fluttr_viewer_swap_alpha_func,
					       (gpointer)self);
					  				    
	priv->timeline = clutter_timeline_new (40, 80);
	priv->alpha = clutter_alpha_new_full (priv->timeline,
					      alpha_sine_inc_func,
					      NULL, NULL);
	priv->behave = fluttr_behave_new (priv->alpha,
					  fluttr_viewer_alpha_func,
					  (gpointer)self);
		
}
Example #5
0
/* Fade out text, change text, then fade in, all within one play of the timeline
   just to keep things interesting :) */
static void
fluttr_viewer_swap_alpha_func (ClutterBehaviour *behave,
		       	      guint		alpha_value,
		              gpointer		data)
{
	FluttrViewerPrivate *priv;
	gfloat factor;
	guint width = CLUTTER_STAGE_WIDTH ();
	guint height = CLUTTER_STAGE_HEIGHT ();
	guint w, h;
	
       	g_return_if_fail (FLUTTR_IS_VIEWER (data));
	priv = FLUTTR_VIEWER_GET_PRIVATE(data);
	
	factor = (gfloat) alpha_value / CLUTTER_ALPHA_MAX_ALPHA;
	
	if (priv->pixbuf != NULL && factor > 0.5) {
		clutter_texture_set_pixbuf (CLUTTER_TEXTURE (priv->texture),
					    priv->pixbuf, NULL);
		clutter_actor_get_size (priv->texture, &w, &h);
		
		clutter_actor_set_position (priv->texture, 
					    (width/2) - (w/2),
					    (height/2) - (h/2));    
	}
	if (factor < 0.5) {
		factor *= 2;
		factor = 1.0 - factor;
	} else {
		factor -= 0.5;
		factor /= 0.5;
	}
	
	clutter_actor_set_opacity (CLUTTER_ACTOR (priv->texture), 
					   255 * factor);
	clutter_actor_set_opacity (priv->spinner, 255 * (1-factor));
	
	if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(data)))
		clutter_actor_queue_redraw (CLUTTER_ACTOR(data));	
}
Example #6
0
int
main (int argc, char **argv)
{
    AainaLibrary *library;
    AainaSource *source;
    ClutterActor *stage;
    ClutterAlpha *alpha;
    ClutterBehaviour *behave;
    ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
    GError *error = NULL;

    g_thread_init (NULL);

    g_set_application_name ("Aaina Image Slideshow");
    clutter_init_with_args (&argc, &argv,
                            " - Aaina Image Slideshow", entries,
                            NULL,
                            &error);
    if (error)
    {
        g_print ("Unable to run Aaina: %s", error->message);
        g_error_free (error);
        return EXIT_FAILURE;
    }

    stage = clutter_stage_get_default ();
    clutter_actor_set_size (stage, 720, 480);
    clutter_stage_hide_cursor (CLUTTER_STAGE (stage));

    if (fullscreen)
        clutter_stage_fullscreen (CLUTTER_STAGE (stage));

    clutter_stage_set_color (CLUTTER_STAGE (stage), &black);

    /* Load the test source */
    library = aaina_library_new ();

    if (directories && directories[0])
    {
        gint n_directories, i;

        n_directories = g_strv_length (directories);
        for (i = 0; i < n_directories; i++)
            source = aaina_source_directory_new (library, directories[i]);
    }
    else if (flickr_tags)
        source = aaina_source_flickr_new (library, flickr_tags);
    else
    {
        g_print ("Usage: aaina -d <path>\n"
                 "       aaina -t <tag>[,<tag>,....]\n");
        return EXIT_FAILURE;
    }

    show = aaina_slide_show_get_default ();
    clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR (show));
    clutter_actor_set_position (CLUTTER_ACTOR (show), 0, 0);
    clutter_actor_set_size (CLUTTER_ACTOR (show),
                            CLUTTER_STAGE_WIDTH (),
                            CLUTTER_STAGE_HEIGHT ()) ;
    clutter_actor_show_all (CLUTTER_ACTOR (show));
    g_object_set (G_OBJECT (show), "library", library, NULL);

    clutter_actor_show_all (stage);

    /*clutter_actor_set_scale (stage, 0.25, 0.25);*/

    g_signal_connect (G_OBJECT (stage), "key-release-event",
                      G_CALLBACK (on_key_release_event), (gpointer)stage);


    timeline = clutter_timeline_new (60, 30);
    alpha = clutter_alpha_new_full (timeline,
                                    alpha_sine_inc_func,
                                    NULL, NULL);
    behave = aaina_behave_new (alpha,
                               (AainaBehaveAlphaFunc)spin_me,
                               (gpointer)stage);

    clutter_actor_set_rotation (stage, CLUTTER_Y_AXIS, 0,
                                CLUTTER_STAGE_WIDTH ()/2,
                                0,
                                CLUTTER_STAGE_HEIGHT ());

    g_timeout_add (120000, (GSourceFunc)im_spinning_around, timeline);
    clutter_main ();

    return EXIT_SUCCESS;
}
static gint
get_radius (void)
{
  return (CLUTTER_STAGE_HEIGHT() + CLUTTER_STAGE_HEIGHT()) / n_hands ;
}
int
main (int argc, char *argv[])
{
  ClutterTimeline *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *scaler_1, *scaler_2;
  ClutterActor    *stage;
  ClutterColor     stage_color = { 0x61, 0x64, 0x8c, 0xff };
  SuperOH         *oh;
  gint             i;
  GError          *error;

#ifdef REQ_NON_COMPOSITION
  Window           xwin;
  Atom             non_comp_atom;
  Display         *dpy;
  int              one = 1;
#endif

  error = NULL;

  clutter_init_with_args (&argc, &argv,
                          NULL,
                          super_oh_entries,
                          NULL,
                          &error);
  if (error)
    {
      g_warning ("Unable to initialise Clutter:\n%s",
                 error->message);
      g_error_free (error);

      exit (1);
    }

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 800, 600);

  clutter_stage_set_title (CLUTTER_STAGE (stage), "Actors Test");
  clutter_stage_set_color (CLUTTER_STAGE (stage),
		           &stage_color);

#ifdef REQ_NON_COMPOSITION
  /* request non-composited mode */
  clutter_stage_fullscreen (stage);
  xwin = clutter_x11_get_stage_window (stage);
  dpy = XOpenDisplay(NULL);
  non_comp_atom = XInternAtom(dpy, "_HILDON_NON_COMPOSITED_WINDOW", False);
  XChangeProperty (dpy, xwin, non_comp_atom,
                   XA_INTEGER, 32, PropModeReplace,
                   (unsigned char *) &one, 1);
  printf ("stage win is %lx\n", xwin);
  XSync (dpy, False);
#endif

  oh = g_new(SuperOH, 1);

  /* Create a timeline to manage animation */
  timeline = clutter_timeline_new (360, 60); /* num frames, fps */
  g_object_set (timeline, "loop", TRUE, NULL);   /* have it loop */

  /* fire a callback for frame change */
  g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh);

  /* Set up some behaviours to handle scaling  */
  alpha = clutter_alpha_new_full (timeline, CLUTTER_ALPHA_SINE, NULL, NULL);

  scaler_1 = clutter_behaviour_scale_new (alpha,
					  0.5, 0.5,
					  1.0, 1.0);

  scaler_2 = clutter_behaviour_scale_new (alpha,
					  1.0, 1.0,
					  0.5, 0.5);

  /* create a new group to hold multiple actors in a group */
  oh->group = clutter_group_new();

  oh->hand = g_new (ClutterActor*, n_hands);
  for (i = 0; i < n_hands; i++)
    {
      gint x, y, w, h;
      gint radius = get_radius ();

      /* Create a texture from file, then clone in to same resources */
      if (i == 0)
	{
	  if ((oh->hand[i] = clutter_texture_new_from_file ("redhand.png",
							    &error)) == NULL)
	    {
	      g_error ("image load failed: %s", error->message);
	      exit (1);
	    }
	}
      else
	oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0]));

      /* Place around a circle */
      w = clutter_actor_get_width (oh->hand[0]);
      h = clutter_actor_get_height (oh->hand[0]);

      x = CLUTTER_STAGE_WIDTH () / 2
	+ radius
	* cos (i * M_PI / (n_hands / 2))
	- w / 2;

      y = CLUTTER_STAGE_HEIGHT () / 2
	+ radius
	* sin (i * M_PI / (n_hands / 2))
	- h / 2;

      clutter_actor_set_position (oh->hand[i], x, y);

      clutter_actor_move_anchor_point_from_gravity (oh->hand[i],
						   CLUTTER_GRAVITY_CENTER);

      /* Add to our group group */
      clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);

#if 1 /* FIXME: disabled as causes drift? - see comment above */
      if (i % 2)
	clutter_behaviour_apply (scaler_1, oh->hand[i]);
      else
	clutter_behaviour_apply (scaler_2, oh->hand[i]);
#endif
    }

  /* Add the group to the stage */
  clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                               CLUTTER_ACTOR (oh->group));

  /* Show everying ( and map window ) */
  clutter_actor_show (stage);


  g_signal_connect (stage, "button-press-event",
		    G_CALLBACK (input_cb),
		    oh);
  g_signal_connect (stage, "key-release-event",
		    G_CALLBACK (input_cb),
		    oh);

  /* and start it */
  clutter_timeline_start (timeline);

  clutter_main ();

  g_free (oh->hand);
  g_free (oh);

  return 0;
}
Example #9
0
/* This function does th emain work of creating and configuring the worker 
   thread. the majority of this code is taken from
   NFlick the n800 Flickr photo browser by MDK (see: README) */
void
fluttr_viewer_go (FluttrViewer *viewer, FluttrPhoto *photo)
{
        FluttrViewerPrivate *priv;
        FluttrSettings *settings = fluttr_settings_get_default ();
	NFlickWorker *worker;
        NFlickWorkerStatus status;
        gint width = CLUTTER_STAGE_WIDTH ();
        gint height = CLUTTER_STAGE_HEIGHT();
              
        gchar *token = NULL;
        gchar *photoid = NULL;
	
        g_return_if_fail (FLUTTR_IS_VIEWER (viewer));
        priv = FLUTTR_VIEWER_GET_PRIVATE(viewer);
        
        if (priv->worker)
        	nflick_worker_request_abort (priv->worker);
        
        fluttr_spinner_spin (FLUTTR_SPINNER (priv->spinner), TRUE);
        clutter_actor_set_opacity (priv->spinner, 255);
        
		
	g_object_get (G_OBJECT (settings), "token", &token, NULL);
	g_object_get (G_OBJECT (photo), "photoid", &photoid, NULL);
	
	worker = (NFlickWorker *)nflick_show_worker_new (photoid, 
							 width, 
							 height, 
							 token);
        /* Check if the worker is in the right state */
        g_object_get (G_OBJECT (worker), "status", &status, NULL);
        
        if (status != NFLICK_WORKER_STATUS_IDLE) {
                g_warning ("Bad worker status"); 
                return;
        }
        
        g_object_ref (worker);
        priv->worker = worker;
        
        /* Get the initial message */
        gchar *msg = NULL;
        g_object_get (G_OBJECT (priv->worker), "message", &msg, NULL);
        if (msg != NULL) {
                /* FIXME Escape markup */
        	//g_print ("%s", msg);
        }
        
        /* Set the callback functions */
        nflick_worker_set_custom_data (worker, viewer);
        nflick_worker_set_aborted_idle (worker, 
        			  (NFlickWorkerIdleFunc) on_thread_abort_idle);
        			           
        nflick_worker_set_error_idle (worker, 
        			   (NFlickWorkerIdleFunc) on_thread_error_idle);
        
        nflick_worker_set_ok_idle (worker, 
        			      (NFlickWorkerIdleFunc) on_thread_ok_idle);
        
        nflick_worker_set_msg_change_idle (worker, 
        		      (NFlickWorkerIdleFunc) on_thread_msg_change_idle);
                                        
        nflick_worker_start (priv->worker);
        
        /* Free */
        g_free (msg);
}