1. Reid van Melle
  2. clutter-ocaml

Source

clutter-ocaml / tests / test-score.ml

open OClutter
open Printf

let _ =

  let [|timeline1; timeline2; timeline3; timeline4; timeline5|] =
    Array.init 5
      (fun i ->
	 let t = Timeline.new_for_duration 1000 () in
	 (*Gobject.Property.set_dyn t#obj "timeline-name"
	   (`STRING (Some (sprintf "Timeline %d" i)));*)
	 t) in
  
  timeline2#add_marker_at_time "foo" 500;
  let score = Score.create () in
  let level = ref 1 in
  let _ = score#connect#timeline_started
    (fun _ t ->
       for i=1 to !level do printf " " done;
       printf "Started timeline: '%d'\n%!" 0;
       (* (match Gobject.Property.get_dyn t "timeline-name" with
	      `STRING Some x -> x
	    | _ -> "wft?");*)
       incr level;
    )
  and _ = score#connect#timeline_completed
    (fun _ t ->
       decr level;
       for i=1 to !level do printf " " done;
       printf "Completed timeline: '%d'\n%!" 0;
	(* (match Gobject.Property.get_dyn t "timeline-name" with
	      `STRING Some x -> x
	    | _ -> "wft?");*)
    )
  and _ = score#connect#completed
    (fun _ -> clutter_quit ())
  in
  let _ = score#append timeline1 
  and _ = score#append ~parent:timeline1 timeline2
  and _ = score#append ~parent:timeline1 timeline3
  and _ = score#append ~parent:timeline3 timeline4 in

  score#append_at_marker ~parent:timeline2 ~marker:"foo" timeline5;

  let timelines = score#list_timelines in
  printf "timelines=%d\n%!" (List.length timelines);
  assert ((List.length timelines) = 5);

  score#start;

  clutter_main()