Commits

Reid van Melle committed 173eacb

Got most of a new test working (still some bugs)
- also made a few updates to the build system

Comments (0)

Files changed (9)

 
 # Manual page.
 include ../Make.rules
+include .depend

src/clutterActor.ml

   method get_abs_allocation_vertices = Actor.get_abs_allocation_vertices obj
   method move_by = Actor.move_by obj
   method raise_top = Actor.raise_top obj
+  method hide = Actor.hide obj
   method show = Actor.show obj
   method show_all = Actor.show_all obj
   method set_position = Actor.set_position obj
   method set_scale = Actor.set_scale obj
   method get_size = self#width, self#height
   method set_size = Actor.set_size obj
+  method get_parent = Actor.get_parent obj
   method realize = Actor.realize obj
   method unrealize = Actor.unrealize obj
   method paint = Actor.paint obj

src/clutterRectangle.ml

     (fun pl ->
        let t = Rectangle.create pl in
        new rectangle t)
+
+let new_with_color color = create ~color
 external get_coords : 'a event -> (int*int) = "ml_clutter_event_get_coords"
 external get_state : 'a event -> modifier_type list = "ml_clutter_event_get_state"
 external get_time : 'a event -> int = "ml_clutter_event_get_time"
-external get_source : 'a event -> Clutter.actor = "ml_clutter_event_get_source"
-external get_stage : 'a event -> Clutter.stage = "ml_clutter_event_get_stage"
+external get_source : 'a event -> Clutter.actor Clutter.obj
+  = "ml_clutter_event_get_source"
+external get_stage : 'a event -> Clutter.stage Clutter.obj
+  = "ml_clutter_event_get_stage"
+external keysym_to_unicode : int -> int = "ml_clutter_keysym_to_unicode"
     
 module Button = struct
-  type types = [`BUTTON_PRESS | `BUTTON_RELEASE]
+  type types = [ `BUTTON_PRESS | `BUTTON_RELEASE]
   type t = types event
 
+  let cast ev : t = cast ev ~kind:[`BUTTON_PRESS; `BUTTON_RELEASE]
   external x : t -> int = "ml_ClutterButtonEvent_y"
   external y : t -> int = "ml_ClutterButtonEvent_y"
   external get_click_count : t -> int = "ml_ClutterButtonEvent_click_count"
 end
 
 module Key = struct
-  type types = [`KEY_PRESS | `KEY_RELEASE]
+  type types = [ `KEY_PRESS | `KEY_RELEASE]
   type t = types event
+
+  let cast ev : t = cast ev ~kind:[`KEY_PRESS; `KEY_RELEASE]
+  external get_symbol : t -> int = "ml_ClutterKeyEvent_symbol"
+  external get_code : t -> int = "ml_ClutterKeyEvent_hardware_keycode"
+  external unicode : t -> int = "ml_ClutterKeyEvent_unicode"
 end
 
 module Motion = struct
 module Scroll = struct
   type t = [`SCROLL] event
 
+  let cast ev : t = cast ev ~kind:[`SCROLL]
   external get_direction : t -> scroll_direction_type
     = "ml_ClutterScrollEvent_direction"
 end
 ML_3(clutter_actor_allocate, ClutterActor_val, ClutterActorBox_val, Bool_val, Unit)
 ML_3(clutter_actor_move_by, ClutterActor_val, Int_val, Int_val, Unit)
 
-ML_1(clutter_actor_get_width, ClutterActor_val, Val_int);
-ML_1(clutter_actor_get_height, ClutterActor_val, Val_int);
+ML_1(clutter_actor_get_width, ClutterActor_val, Val_int)
+ML_1(clutter_actor_get_height, ClutterActor_val, Val_int)
 ML_2(clutter_actor_set_anchor_point_from_gravity,  ClutterActor_val,
-     Gravity_type_val, Unit);
-ML_1(clutter_actor_realize, ClutterActor_val, Unit);
-ML_1(clutter_actor_unrealize, ClutterActor_val, Unit);
-ML_1(clutter_actor_paint, ClutterActor_val, Unit);
-ML_1(clutter_actor_destroy, ClutterActor_val, Unit);
-ML_1(clutter_actor_queue_redraw, ClutterActor_val, Unit);
-ML_1(clutter_actor_queue_relayout, ClutterActor_val, Unit);
-ML_3(clutter_actor_set_size, ClutterActor_val, Int_val, Int_val, Unit);
-ML_3(clutter_actor_set_position, ClutterActor_val, Int_val, Int_val, Unit);
-ML_6(clutter_actor_set_rotation, ClutterActor_val, Rotate_axis_type_val, Float_val, Int_val, Int_val, Int_val, Unit);
-ML_bc6(ml_clutter_actor_set_rotation);
+     Gravity_type_val, Unit)
+ML_1(clutter_actor_hide, ClutterActor_val, Unit)
+ML_1(clutter_actor_realize, ClutterActor_val, Unit)
+ML_1(clutter_actor_unrealize, ClutterActor_val, Unit)
+ML_1(clutter_actor_get_parent, ClutterActor_val, Val_ClutterActor)
+ML_1(clutter_actor_paint, ClutterActor_val, Unit)
+ML_1(clutter_actor_destroy, ClutterActor_val, Unit)
+ML_1(clutter_actor_queue_redraw, ClutterActor_val, Unit)
+ML_1(clutter_actor_queue_relayout, ClutterActor_val, Unit)
+ML_3(clutter_actor_set_size, ClutterActor_val, Int_val, Int_val, Unit)
+ML_3(clutter_actor_set_position, ClutterActor_val, Int_val, Int_val, Unit)
+ML_6(clutter_actor_set_rotation, ClutterActor_val, Rotate_axis_type_val, Float_val, Int_val, Int_val, Int_val, Unit)
+ML_bc6(ml_clutter_actor_set_rotation)

tests/Makefile.in

 
 OCAMLOPTLIBS	:= $(OCAMLCLIBS) -cclib '$(CLUTTER_FLAGS)' -cclib '$(CLUTTER_CAIRO_FLAGS)' -cclib -lclutter-ocaml ../src/mlclutter.cmxa
 
-# test-cogl-tex-file --> need to finish this one
-TARGETS	:= test-behave test-cogl-primitives \
+# test-cogl-tex-file --> need to finish this one test-events
+TARGETS	:= test-behave test-events test-cogl-primitives \
 	test-depth test-effect test-entry test-project \
 	test-rotate test-score
 BYTE_TARGETS    := $(TARGETS:=.byte)
 OPT_TARGETS	:= $(TARGETS:=.opt)
 
-all: $(OPT_TARGETS)
+all: $(OPT_TARGETS) ../src/mlclutter.cmxa
 byte: $(BYTE_TARGETS)
 
 test-behave: test-behave.cmo
 test-behave.opt: test-behave.cmx
 	ocamlfind ocamlopt $(OCAMLOPTPACKAGES) $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) -o $@ $^
 
+test-events: test-events.cmo
+	ocamlfind ocamlc $(OCAMLCPACKAGES) $(OCAMLCFLAGS) $(OCAMLCLIBS) -o $@ $^
+
+test-events.opt: test-events.cmx
+	ocamlfind ocamlopt $(OCAMLOPTPACKAGES) $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) -o $@ $^
+
 test-cogl-primitives: test-cogl-primitives.cmo
 	ocamlfind ocamlc $(OCAMLCPACKAGES) $(OCAMLCFLAGS) $(OCAMLCLIBS) -o $@ $^
 
 
 # Manual page.
 include ../Make.rules
+include .depend

tests/test-events.ml

-#include <clutter/clutter.h>
-#include <string.h>
+module Stage = ClutterStage
+module Actor = ClutterActor
+module Rectangle = ClutterRectangle
+module Group = ClutterGroup
+open Clutter
 
-gboolean IsFullScreen = FALSE, IsMotion = TRUE;
 
-static void
-stage_state_cb (ClutterStage    *stage,
-		gpointer         data)
-{
-  gchar *detail = (gchar*)data;
+let is_full_screen = ref false
+let is_motion = ref true
 
-  printf("[stage signal] %s\n", detail);
-}
+let stage_state_cb detail stage =
+  Printf.printf "[stage signal] %s\n%!" detail
 
-static gboolean
-blue_button_cb (ClutterActor    *actor,
-		ClutterEvent    *event,
-		gpointer         data)
-{
-  ClutterActor *stage;
+let blue_button_cb actor evt =
+  let stage = Stage.get_default () in
+  is_full_screen := not !is_full_screen;
+  stage#set_fullscreen !is_full_screen;
+  Printf.printf "*** Fullscreen %s ***\n%!"
+    (if !is_full_screen then "enabled" else "disabled");
+  false
 
-  stage = clutter_stage_get_default ();
+let red_button_cb actor evt =
+  is_motion := not !is_motion;
+  Clutter.set_motion_events_enabled !is_motion;
+  Printf.printf "*** Per actor motion events %s ***\n%!"
+    (if !is_motion then "enabled" else "disabled");
+  false
 
-  if (IsFullScreen)
-    IsFullScreen = FALSE;
-  else
-    IsFullScreen = TRUE;
+let capture_cb actor evt =
+  Printf.printf "* captured event for type '%s' *\n%!"
+    (Gobject.Type.name (Gobject.get_type actor#obj));
+  false
 
-  g_object_set (stage, "fullscreen", IsFullScreen, NULL);
+let key_focus_in_cb focus_box actor () =
+  (*if actor#obj = Stage.get_default () then
+    focus_box#hide
+  else begin*)
+  focus_box#set_position ~x:(actor#x - 5) ~y:(actor#y - 5);
+  focus_box#set_size ~width:(actor#width + 10) ~height:(actor#height + 10);
+  focus_box#show
 
-  g_print ("*** Fullscreen %s ***\n",
-           IsFullScreen ? "enabled" : "disabled");
+let fill_keybuf key_event =
+  let result = List.fold_left
+    (fun acc m ->
+       acc ^ (match m with
+		  `SHIFT_MASK -> "<Shift>"
+		| `LOCK_MASK  -> "<Lock>"
+		| `CONTROL_MASK -> "<Control>"
+		| `MOD1_MASK -> "<Mod1>"
+		| `MOD2_MASK -> "<Mod2>"
+		| `MOD3_MASK -> "<Mod3>"
+		| `MOD4_MASK -> "<Mod4>"
+		| `MOD5_MASK -> "<Mod5>"
+		| _ -> "<ERROR>")) "" (Event.get_state key_event) in
+  (string_of_int (Event.Key.get_code key_event)) ^ result
 
-  return FALSE;
-}
+let input_cb data actor (event:Event.any) =
+  Printf.printf "input_cb\n%!";
+  let stage = Stage.get_default () in
+  let () = match Event.get_type event with
+      `KEY_PRESS -> Printf.printf "[%s] KEY PRESS %s" data
+	(fill_keybuf (Event.Key.cast event))
+    | `KEY_RELEASE -> Printf.printf "[%s] KEY RELEASE %s" data
+	(fill_keybuf (Event.Key.cast event))
+    | `MOTION -> Printf.printf "[%s] MOTION" data
+    | `ENTER -> Printf.printf "[%s] ENTER" data
+    | `LEAVE -> Printf.printf "[%s] LEAVE" data
+    | `BUTTON_PRESS -> Printf.printf "[%s] BUTTON PRESS (click count:%d)"
+	data (Event.Button.get_click_count (Event.Button.cast event))
+		(*(Event.cast `BUTTON_PRESS event))*)
+    | `BUTTON_RELEASE -> Printf.printf "[%s] BUTTON RELEASE (click count:%d)"
+	data (Event.Button.get_click_count (Event.Button.cast event));
+	if (Event.get_source event) = stage#as_actor then
+	  stage#set_key_focus stage
+	  (* FIXME: stage#set_key_focus None*)
+	else if (Event.get_source event) = actor#obj then
+	  (* FIXME: && (Gobject.coerce actor#get_parent#obj) =
+	     (Gobject.coerce stage#obj) then *)
+	    stage#set_key_focus actor;
+    | `SCROLL -> Printf.printf "[%s] BUTTON SCROLL (click count:%d)"
+	data (Event.Button.get_click_count (Event.Button.cast event))
+    | `STAGE_STATE -> Printf.printf "[%s] STAGE STAGE" data
+    | `DESTROY_NOTIFY -> Printf.printf "[%s] DESTROY NOTIFY" data
+    | `CLIENT_MESSAGE -> Printf.printf "[%s] CLIENT MESSAGE" data
+    | `DELETE -> Printf.printf "[%s] DELETE" data
+    | `NOTHING -> ()
+  in
+  if Event.get_source event = actor#obj then
+    Printf.printf " *source* ";
+  Printf.printf "\n%!";
+  false
 
-static gboolean
-red_button_cb (ClutterActor    *actor,
-		ClutterEvent    *event,
-		gpointer         data)
-{
+let _ = 
+  let rcol = Color.rgba (0xff,0,0,0xff)
+  and bcol = Color.rgba (0,0,0xff,0xff)
+  and gcol = Color.rgba (0,0xff,0,0xff)
+  and ycol = Color.rgba (0xff,0xff,0,0xff)
+  and ncol = Color.rgba (0,0,0,0xff) in
+    
+  let stage = Stage.get_default () in
+  let _ = stage#connect#event (input_cb "stage" (stage :> Actor.actor))
+  and _ = stage#connect#fullscreen (stage_state_cb "fullscreen")
+  and _ = stage#connect#unfullscreen (stage_state_cb "unfullscreen")
+  and _ = stage#connect#activate (stage_state_cb "activate")
+  and _ = stage#connect#deactivate (stage_state_cb "deactivate")
+  and _ = stage#connect#captured_event (capture_cb stage) in
+    (*(fun x -> stage_state_cb "captured_event" x; false) in*)
 
-  if (IsMotion)
-    IsMotion = FALSE;
-  else
-    IsMotion = TRUE;
+  let focus_box = Rectangle.new_with_color ncol () in
+  stage#add focus_box;
+  let actor = Rectangle.new_with_color rcol () in
+  actor#set_size 100 100;
+  actor#set_position ~x:100 ~y:100;
+  actor#set_reactive true;
+  
+  stage#add actor;
+  let _ = actor#connect#event (input_cb "red box" (actor :> Actor.actor))
+  and _ = actor#connect#focus_in (key_focus_in_cb focus_box actor)
 
-  clutter_set_motion_events_enabled (IsMotion);
+  (* Toggle motion - enter/leave capture *)
+  and _ = actor#connect#button_press_event (red_button_cb actor) in
+  stage#set_key_focus actor;
+  let actor = Rectangle.new_with_color gcol () in
+  actor#set_size 100 100;
+  actor#set_position 250 100;
+  actor#set_reactive true;
+  stage#add actor;
 
-  g_print ("*** Per actor motion events %s ***\n",
-           IsMotion ? "enabled" : "disabled");
+  let _ = actor#connect#event (input_cb "green box" (actor :> Actor.actor))
+  and _ = actor#connect#focus_in (key_focus_in_cb focus_box actor)
+  and _ = actor#connect#captured_event (capture_cb actor) in
 
-  return FALSE;
-}
+  let actor = Rectangle.new_with_color bcol () in
+  actor#set_size 100 100;
+  actor#set_position 400 100;
+  actor#set_reactive true;
+  stage#add actor;
 
-static gboolean
-capture_cb (ClutterActor *actor,
-	    ClutterEvent *event,
-	    gpointer      data)
-{
-  g_print ("* captured event for type '%s' *\n",
-           G_OBJECT_TYPE_NAME (actor));
+  let _ = actor#connect#event (input_cb "blue box" (actor :> Actor.actor))
+  and _ = actor#connect#focus_in (key_focus_in_cb focus_box actor)
+    (* Fullscreen *)
+  and _ = actor#connect#button_press_event (blue_button_cb actor) in
 
-  return FALSE;
-}
+  (* non reactive *)
+  let actor = Rectangle.new_with_color ncol () in
+  actor#set_size 400 50;
+  actor#set_position 100 250;
+  stage#add actor;
 
-static void
-key_focus_in_cb (ClutterActor    *actor,
-		 gpointer         data)
-{
-  ClutterActor *focus_box = CLUTTER_ACTOR(data);  
+  let _ = actor#connect#event (input_cb "white? box" (actor :> Actor.actor))
+  and _ = actor#connect#focus_in (key_focus_in_cb focus_box actor) in
 
-  if (actor == clutter_stage_get_default ())
-    clutter_actor_hide (focus_box);
-  else
-    {
-      clutter_actor_set_position (focus_box,
-				  clutter_actor_get_x (actor) - 5,
-				  clutter_actor_get_y (actor) - 5);
+  (* non reactive group, with reactive child *)
+  let actor = Rectangle.new_with_color ycol () in
+  actor#set_size 100 100;
+  actor#set_reactive true;
+  let _ = actor#connect#event (input_cb "yellow box" (actor :> Actor.actor)) in
+  
+  (* note group not reactive *)
+  let group = Group.create () in
+  group#add actor;
+  stage#add group;
+  group#set_position 100 350;
+  group#show_all;
+  stage#show_all;
 
-      clutter_actor_set_size (focus_box,
-			      clutter_actor_get_width (actor) + 10,
-			      clutter_actor_get_height (actor) + 10);
-      clutter_actor_show (focus_box);
-    }
-}
+  clutter_main ()
 
-static void
-fill_keybuf (char *keybuf, ClutterKeyEvent *event)
-{
-  char utf8[6];
-  int len;
-
-  /* printable character, if any (ß, ∑) */
-  len = g_unichar_to_utf8 (event->unicode_value, utf8);
-  utf8[len] = '\0';
-  sprintf(keybuf, "'%s' ", utf8);
-
-  /* key combination (<Mod1>s, <Shift><Mod1>S, <Ctrl><Mod1>Delete) */
-  len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->keyval),
-                           utf8);
-  utf8[len] = '\0';
-
-  if (event->modifier_state & CLUTTER_SHIFT_MASK)
-    strcat (keybuf, "<Shift>");
-  if (event->modifier_state & CLUTTER_LOCK_MASK)
-    strcat (keybuf, "<Lock>");
-  if (event->modifier_state & CLUTTER_CONTROL_MASK)
-    strcat (keybuf, "<Control>");
-  if (event->modifier_state & CLUTTER_MOD1_MASK)
-    strcat (keybuf, "<Mod1>");
-  if (event->modifier_state & CLUTTER_MOD2_MASK)
-    strcat (keybuf, "<Mod2>");
-  if (event->modifier_state & CLUTTER_MOD3_MASK)
-    strcat (keybuf, "<Mod3>");
-  if (event->modifier_state & CLUTTER_MOD4_MASK)
-    strcat (keybuf, "<Mod4>");
-  if (event->modifier_state & CLUTTER_MOD5_MASK)
-    strcat (keybuf, "<Mod5>");
-  strcat (keybuf, utf8);
-}
-
-static gboolean
-input_cb (ClutterActor    *actor,
-	  ClutterEvent    *event,
-	  gpointer         data)
-{
-  ClutterStage *stage = CLUTTER_STAGE (clutter_stage_get_default ());
-  gchar keybuf[128], *source = (gchar*)data;
-
-  switch (event->type)
-    {
-    case CLUTTER_KEY_PRESS:
-      fill_keybuf (keybuf, &event->key);
-      printf ("[%s] KEY PRESS %s", source, keybuf);
-      break;
-    case CLUTTER_KEY_RELEASE:
-      fill_keybuf (keybuf, &event->key);
-      printf ("[%s] KEY RELEASE %s", source, keybuf);
-      break;
-    case CLUTTER_MOTION:
-      g_print ("[%s] MOTION", source);
-      break;
-    case CLUTTER_ENTER:
-      g_print ("[%s] ENTER", source);
-      break;
-    case CLUTTER_LEAVE:
-      g_print ("[%s] LEAVE", source);
-      break;
-    case CLUTTER_BUTTON_PRESS:
-      g_print ("[%s] BUTTON PRESS (click count:%i)", 
-	       source, event->button.click_count);
-      break;
-    case CLUTTER_BUTTON_RELEASE:
-      g_print ("[%s] BUTTON RELEASE (click count:%i)", 
-	       source, event->button.click_count);
-
-      if (clutter_event_get_source (event) == CLUTTER_ACTOR (stage))
-        clutter_stage_set_key_focus (stage, NULL);
-      else if (clutter_event_get_source (event) == actor
-	       && clutter_actor_get_parent (actor) == CLUTTER_ACTOR (stage))
-	clutter_stage_set_key_focus (stage, actor);
-      break;
-    case CLUTTER_SCROLL:
-      g_print ("[%s] BUTTON SCROLL (click count:%i)",
-	       source, event->button.click_count);
-      break;
-    case CLUTTER_STAGE_STATE:
-      g_print ("[%s] STAGE STATE", source);
-      break;
-    case CLUTTER_DESTROY_NOTIFY:
-      g_print ("[%s] DESTROY NOTIFY", source);
-      break;
-    case CLUTTER_CLIENT_MESSAGE:
-      g_print ("[%s] CLIENT MESSAGE", source);
-      break;
-    case CLUTTER_DELETE:
-      g_print ("[%s] DELETE", source);
-      break;
-    case CLUTTER_NOTHING:
-      return FALSE;
-    }
-
-  if (clutter_event_get_source (event) == actor)
-    g_print (" *source*");
-  
-  g_print ("\n");
-
-  return FALSE;
-}
-
-int
-main (int argc, char *argv[])
-{
-  ClutterActor    *stage, *actor, *focus_box, *group;
-  ClutterColor    rcol = { 0xff, 0, 0, 0xff}, 
-                  bcol = { 0, 0, 0xff, 0xff },
-		  gcol = { 0, 0xff, 0, 0xff },
-		  ycol = { 0xff, 0xff, 0, 0xff },
-		  ncol = { 0, 0, 0, 0xff };
-
-  clutter_init (&argc, &argv);
-
-
-
-  stage = clutter_stage_get_default ();
-  g_signal_connect (stage, "event", G_CALLBACK (input_cb), "stage");
-
-  g_signal_connect (stage, "fullscreen", 
-		    G_CALLBACK (stage_state_cb), "fullscreen");
-  g_signal_connect (stage, "unfullscreen", 
-		    G_CALLBACK (stage_state_cb), "unfullscreen");
-  g_signal_connect (stage, "activate", 
-		    G_CALLBACK (stage_state_cb), "activate");
-  g_signal_connect (stage, "deactivate", 
-		    G_CALLBACK (stage_state_cb), "deactivate");
-
-  g_signal_connect (stage, "captured-event", G_CALLBACK (capture_cb), NULL);
-
-  focus_box = clutter_rectangle_new_with_color (&ncol);
-  clutter_container_add (CLUTTER_CONTAINER(stage), focus_box, NULL);
-
-  actor = clutter_rectangle_new_with_color (&rcol);
-  clutter_actor_set_size (actor, 100, 100);
-  clutter_actor_set_position (actor, 100, 100);
-
-  clutter_actor_set_reactive (actor, TRUE);
-
-  clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
-
-  g_signal_connect (actor, "event", G_CALLBACK (input_cb), "red box");
-  g_signal_connect (actor, "focus-in", G_CALLBACK (key_focus_in_cb), 
-		    focus_box);
-
-  /* Toggle motion - enter/leave capture */
-  g_signal_connect (actor, "button-press-event",
-                    G_CALLBACK (red_button_cb), NULL);
-
-  clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor);
-
-  actor = clutter_rectangle_new_with_color (&gcol);
-  clutter_actor_set_size (actor, 100, 100);
-  clutter_actor_set_position (actor, 250, 100);
-
-  clutter_actor_set_reactive (actor, TRUE);
-
-  clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
-
-  g_signal_connect (actor, "event", G_CALLBACK (input_cb), "green box");
-  g_signal_connect (actor, "focus-in", G_CALLBACK (key_focus_in_cb), 
-		    focus_box);
-
-  g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL);
-
-  actor = clutter_rectangle_new_with_color (&bcol);
-  clutter_actor_set_size (actor, 100, 100);
-  clutter_actor_set_position (actor, 400, 100);
-
-  clutter_actor_set_reactive (actor, TRUE);
-
-  clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL);
-
-  g_signal_connect (actor, "event", G_CALLBACK (input_cb), "blue box");
-  g_signal_connect (actor, "focus-in", G_CALLBACK (key_focus_in_cb), 
-		    focus_box);
-  /* Fullscreen */
-  g_signal_connect (actor, "button-press-event",
-                    G_CALLBACK (blue_button_cb), NULL);
-
-  /* non reactive */
-  actor = clutter_rectangle_new_with_color (&ncol);
-  clutter_actor_set_size (actor, 400, 50);
-  clutter_actor_set_position (actor, 100, 250);
-
-  clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL);
-
-  g_signal_connect (actor, "event", G_CALLBACK (input_cb), "blue box");
-  g_signal_connect (actor, "focus-in", G_CALLBACK (key_focus_in_cb), 
-		    focus_box);
-
-  g_signal_connect (stage, "focus-in", G_CALLBACK (key_focus_in_cb), 
-		    focus_box);
-
-  /* non reactive group, with reactive child */
-  actor = clutter_rectangle_new_with_color (&ycol);
-  clutter_actor_set_size (actor, 100, 100);
-  clutter_actor_set_reactive (actor, TRUE);
-
-  g_signal_connect (actor, "event", G_CALLBACK (input_cb), "yellow box");
-
-  /* note group not reactive */
-  group = clutter_group_new ();
-  clutter_container_add (CLUTTER_CONTAINER (group), actor, NULL);
-  clutter_container_add (CLUTTER_CONTAINER (stage), group, NULL);
-  clutter_actor_set_position (group, 100, 350);
-  clutter_actor_show_all (group);
-
-  clutter_actor_show_all (CLUTTER_ACTOR (stage));
-
-  clutter_main();
-
-  return 0;
-}

tests/test-scale.c

+#include <stdlib.h>
+#include <clutter/clutter.h>
+
+static const ClutterGravity gravities[] = {
+  CLUTTER_GRAVITY_NORTH_EAST,
+  CLUTTER_GRAVITY_NORTH,
+  CLUTTER_GRAVITY_NORTH_WEST,
+  CLUTTER_GRAVITY_WEST,
+  CLUTTER_GRAVITY_SOUTH_WEST,
+  CLUTTER_GRAVITY_SOUTH,
+  CLUTTER_GRAVITY_SOUTH_EAST,
+  CLUTTER_GRAVITY_EAST,
+  CLUTTER_GRAVITY_CENTER,
+  CLUTTER_GRAVITY_NONE
+};
+
+static gint gindex = 0;
+
+static void
+on_timeline_completed (ClutterTimeline *cluttertimeline,
+		       gpointer         data)
+{
+  ClutterActor *actor = CLUTTER_ACTOR (data);
+
+  if (++gindex >= G_N_ELEMENTS (gravities))
+    gindex = 0;
+
+  clutter_actor_move_anchor_point_from_gravity (actor, gravities[gindex]);
+}
+
+int
+main (int argc, char *argv[])
+{
+  ClutterActor    *stage, *rect;
+  ClutterColor     stage_color = { 0x0, 0x0, 0x0, 0xff };
+  ClutterColor     rect_color = { 0xff, 0xff, 0xff, 0x99 };
+  ClutterTimeline *timeline;
+  ClutterAlpha    *alpha;
+  ClutterBehaviour *behave;
+
+  clutter_init (&argc, &argv);
+
+  stage = clutter_stage_get_default ();
+
+  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+  clutter_actor_set_size (stage, 300, 300);
+
+  rect = clutter_rectangle_new_with_color (&rect_color);
+  clutter_actor_set_size (rect, 100, 100);
+  clutter_actor_set_position (rect, 100, 100);
+
+  clutter_group_add (CLUTTER_GROUP (stage), rect);
+
+  rect_color.alpha = 0xff;
+  rect = clutter_rectangle_new_with_color (&rect_color);
+  clutter_actor_set_position (rect, 100, 100);
+  clutter_actor_set_size (rect, 100, 100);
+  clutter_actor_move_anchor_point_from_gravity (rect, CLUTTER_GRAVITY_CENTER);
+
+  clutter_group_add (CLUTTER_GROUP (stage), rect);
+
+  timeline = clutter_timeline_new_for_duration (750);
+  alpha    = clutter_alpha_new_full (timeline,
+				     CLUTTER_ALPHA_RAMP,
+				     NULL, NULL);
+
+  behave = clutter_behaviour_scale_new (alpha,
+					0.0, 0.0,  /* scale start */
+					1.0, 1.0); /* scale end */
+
+  clutter_behaviour_apply (behave, rect);
+
+  clutter_timeline_set_loop (timeline, TRUE);
+  g_signal_connect (timeline, "completed",
+		    G_CALLBACK(on_timeline_completed), rect);
+  clutter_timeline_start (timeline);
+
+  clutter_actor_show_all (stage);
+
+  clutter_main();
+
+  g_object_unref (timeline);
+  g_object_unref (behave);
+
+  return EXIT_SUCCESS;
+}

tests/test-scale.ml

-#include <stdlib.h>
-#include <clutter/clutter.h>
-
-static const ClutterGravity gravities[] = {
-  CLUTTER_GRAVITY_NORTH_EAST,
-  CLUTTER_GRAVITY_NORTH,
-  CLUTTER_GRAVITY_NORTH_WEST,
-  CLUTTER_GRAVITY_WEST,
-  CLUTTER_GRAVITY_SOUTH_WEST,
-  CLUTTER_GRAVITY_SOUTH,
-  CLUTTER_GRAVITY_SOUTH_EAST,
-  CLUTTER_GRAVITY_EAST,
-  CLUTTER_GRAVITY_CENTER,
-  CLUTTER_GRAVITY_NONE
-};
-
-static gint gindex = 0;
-
-static void
-on_timeline_completed (ClutterTimeline *cluttertimeline,
-		       gpointer         data)
-{
-  ClutterActor *actor = CLUTTER_ACTOR (data);
-
-  if (++gindex >= G_N_ELEMENTS (gravities))
-    gindex = 0;
-
-  clutter_actor_move_anchor_point_from_gravity (actor, gravities[gindex]);
-}
-
-int
-main (int argc, char *argv[])
-{
-  ClutterActor    *stage, *rect;
-  ClutterColor     stage_color = { 0x0, 0x0, 0x0, 0xff };
-  ClutterColor     rect_color = { 0xff, 0xff, 0xff, 0x99 };
-  ClutterTimeline *timeline;
-  ClutterAlpha    *alpha;
-  ClutterBehaviour *behave;
-
-  clutter_init (&argc, &argv);
-
-  stage = clutter_stage_get_default ();
-
-  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
-  clutter_actor_set_size (stage, 300, 300);
-
-  rect = clutter_rectangle_new_with_color (&rect_color);
-  clutter_actor_set_size (rect, 100, 100);
-  clutter_actor_set_position (rect, 100, 100);
-
-  clutter_group_add (CLUTTER_GROUP (stage), rect);
-
-  rect_color.alpha = 0xff;
-  rect = clutter_rectangle_new_with_color (&rect_color);
-  clutter_actor_set_position (rect, 100, 100);
-  clutter_actor_set_size (rect, 100, 100);
-  clutter_actor_move_anchor_point_from_gravity (rect, CLUTTER_GRAVITY_CENTER);
-
-  clutter_group_add (CLUTTER_GROUP (stage), rect);
-
-  timeline = clutter_timeline_new_for_duration (750);
-  alpha    = clutter_alpha_new_full (timeline,
-				     CLUTTER_ALPHA_RAMP,
-				     NULL, NULL);
-
-  behave = clutter_behaviour_scale_new (alpha,
-					0.0, 0.0,  /* scale start */
-					1.0, 1.0); /* scale end */
-
-  clutter_behaviour_apply (behave, rect);
-
-  clutter_timeline_set_loop (timeline, TRUE);
-  g_signal_connect (timeline, "completed",
-		    G_CALLBACK(on_timeline_completed), rect);
-  clutter_timeline_start (timeline);
-
-  clutter_actor_show_all (stage);
-
-  clutter_main();
-
-  g_object_unref (timeline);
-  g_object_unref (behave);
-
-  return EXIT_SUCCESS;
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.