1. Reid van Melle
  2. clutter-ocaml

Commits

Reid van Melle  committed e63c361

Many updates to the props and enums... added several wrapper classes

  • Participants
  • Parent commits 404e4fa
  • Branches default

Comments (0)

Files changed (17)

File TODO

View file
 - figure out how to do #define functions properly
 - figure out how to connect to signals
 - figure out how to pass custom data (gpointer data) Pointer_val?
+- figure out if we need any of the routines in wrappers.c
+- decide if we really new `gtk tag
+- figure out GTK_IS_OBJECT problem

File clutter/_tags

View file
 <*>: use_clutter
-<clutterEnums.*> or <clutterProps.*>: use_gtk
+<clutterEnums.*> or <clutterProps.*> or <oclutterProps.*>: use_gtk
+<clutterEllipse.*>: use_gtk
 <clutter.*>: use_gtk
 <ml_clutter.*>: use_gtk2

File clutter/clutter.ml

View file
 
 type 'a obj = 'a Gobject.obj
 type actor
+type behaviour = [`behaviour]
 type rectangle = [`gtk|`rectangle]
 type texture =   [`gtk|`texture]
   
 type stage =     [`container|`stage|`actor|`group] 
 type group =     [`container|`group|`actor] 
     
-type ellipse =   [`behaviour|`ellipse] 
+type behaviour_ellipse =   [`gtk|`behaviour|`behaviourellipse]
+type ellipse = behaviour_ellipse
 type opacity =   [`behaviour|`opacity] 
 type rotate =    [`behaviour|`rotate] 
 type bspline =   [`behaviour|`bspline] 
 type path =      [`behaviour|`path] 
 type scale =     [`behaviour|`scale] 
 	
-type timeline =  [`timeline] 
+type timeline =  [`gtk|`timeline] 
 type pixbuf =    GdkPixbuf.pixbuf
 
 external main : unit -> unit = "clutter_main"
   type t
 end;;
 
+(** ClutterVertex object *)
 module Vertex = struct
   type t
+  external x : t -> int = "ml_clutter_vertex_get_x"
+  external y : t -> int = "ml_clutter_vertex_get_y"
+  external z : t -> int = "ml_clutter_vertex_get_z"
+  external set_x : t -> int -> unit = "ml_clutter_vertex_set_x"
+  external set_y : t -> int -> unit = "ml_clutter_vertex_set_y"
+  external set_z : t -> int -> unit = "ml_clutter_vertex_set_z"
+  external create : x:int -> y:int -> z:int -> t = "ml_clutter_vertex_new"
 end;;
 
+class vertex obj = object
+  method as_vertex : Vertex.t = obj
+  method x = Vertex.x obj
+  method y = Vertex.y obj
+  method z = Vertex.z obj    
+  method set_x = Vertex.set_x obj
+  method set_y = Vertex.set_y obj
+  method set_z = Vertex.set_z obj
+end
+
+let vertex ~x ~y ~z =
+  let k = Vertex.create ~x ~y ~z in
+  new vertex k
+
+(**
+   ClutterKnot wrapper object
+*)
+module Knot = struct
+  type t
+  external x : t -> int = "ml_clutter_knot_get_x"
+  external y : t -> int = "ml_clutter_knot_get_y"
+  external set_x : t -> int -> unit = "ml_clutter_knot_set_x"
+  external set_y : t -> int -> unit = "ml_clutter_knot_set_y"
+  external create : x:int -> y:int -> t = "ml_clutter_knot_new"
+end;;
+
+class knot obj = object
+  method as_knot : Knot.t = obj
+  method x = Knot.x obj
+  method y = Knot.y obj
+  method set_x = Knot.set_x obj
+  method set_y = Knot.set_y obj
+end
+
+let knot ~x ~y =
+  let k = Knot.create ~x ~y in
+  new knot k
+
 module Event = struct
   type any
 end;;
 
 end;;
 
-module Timeline = struct
-	
-  external create : n:int -> fps:int -> timeline obj = "ml_clutter_timeline_new"
-  external start : timeline obj -> unit = "ml_clutter_timeline_start"
-  
-  module P = struct
-    let loop : ([>`timeline],_) Gobject.property =
-      {Gobject.name="loop"; conv=Gobject.Data.boolean}
-  end
-
-end;;
-
 module Stage = struct
   external get_default : unit -> stage obj = "ml_clutter_stage_get_default"
 end;;
 
 
 
+
+

File clutter/clutter.props

View file
 open GtkSignal
 open Gobject
 open Data
-open GtkProps
+open ClutterProps
 
 (* Redefining saves space in bytecode! *)
 let set = set
   ClutterVertex "Clutter.Vertex.t"
   ClutterGeometry "Clutter.Geometry.t"
   ClutterColor "Clutter.Color.t"
+  ClutterKnot "Clutter.Knot.t"
 }
 
 classes {
   GdkPixbuf "GdkPixbuf.pixbuf"
+  ClutterAlpha "Clutter.alpha obj"
+  ClutterBehaviour "Clutter.behaviour obj"
+  ClutterTimeline "Clutter.timeline obj"
 }
 
-class Actor abstract : Object {
+class Actor abstract wrap wrapsig : Object {
   "clip"                     ClutterGeometry       : Read / Write
   "depth"                    gint                  : Read / Write
   "has-clip"                 gboolean              : Read
   "has-border"               gboolean              : Read / Write
 }
 
-class Texture set wrap : Actor {
+class Texture set wrap wrapsig : Actor {
   "filter-quality"           gint               : Read / Write
   "pixbuf"                   GdkPixbuf          : Read / Write
   "pixel-format"             gint               : Read
   signal size_change : ClutterTexture int int (*gpointer*)
 }
 
+class Behaviour abstract wrap wrapsig : Object {
+  "alpha"                    ClutterAlpha         : Read / Write
+  signal applied : ClutterBehaviour ClutterActor (*gpointer*)
+  signal removed : ClutterBehaviour ClutterActor (*gpointer*)
+  method apply : "Clutter.behaviour -> Clutter.actor -> unit"
+  method remove : "Clutter.behaviour -> Clutter.actor -> unit"
+  method remove_all : "Clutter.behaviour -> unit"
+  method is_applied : "Clutter.behaviour -> Clutter.actor -> bool"
+  (* actors_foreach *)
+  (* get_actors *)
+  method get_n_actors : "Clutter.behaviour -> unit"
+  method get_nth_actor : "Clutter.behaviour -> int -> Clutter.actor"
+}
 
+class BehaviourEllipse set wrap : Behaviour {
+  "angle-end"                gdouble               : Read / Write
+  "angle-start"              gdouble               : Read / Write
+  "angle-tilt-x"             gdouble               : Read / Write
+  "angle-tilt-y"             gdouble               : Read / Write
+  "angle-tilt-z"             gdouble               : Read / Write
+  "center"                   ClutterKnot          : Read / Write
+  "direction"                ClutterRotateDirectionType  : Read / Write
+  "height"                   gint                  : Read / Write
+  "width"                    gint                  : Read / Write
+  (* FIXME: from Behaviour *)
+  "alpha"                    ClutterAlpha          : Read / Write
+}
+
+class Timeline set wrap wrapsig {
+  "delay"                    guint                 : Read / Write
+  "direction"                ClutterTimelineDirectionType  : Read / Write
+  "duration"                 guint                 : Read / Write
+  "fps"                      guint                 : Read / Write
+  "loop"                     gboolean              : Read / Write
+  "num-frames"               guint                 : Read / Write
+  signal completed : ClutterTimeline (*gpointer*)
+  signal new_frame : ClutterTimeline int (*gpointer*)
+  signal paused : ClutterTimeline (*gpointer*)
+  signal started : ClutterTimeline (*gpointer*)
+  method start : "Clutter.timeline -> unit"
+  method pause : "Clutter.timeline -> unit"
+  method stop : "Clutter.timeline -> unit"
+  method rewind : "Clutter.timeline -> unit"
+  method skip : "Clutter.timeline -> int -> unit"
+  method advance : "Clutter.timeline -> int -> unit"
+  method get_current_frame : "Clutter.timeline -> int"
+  method get_delta : "Clutter.timeline -> int -> int"
+  method get_progress : "Clutter.timeline -> float"
+  method get_progressx : "Clutter.timeline -> int"
+  method is_playing : "Clutter.timeline -> bool"
+}
+
+

File clutter/clutterEllipse.ml

View file
+open OclutterProps
+open ClutterProps
+open Clutter
+
+
+class ellipse_skel obj = object (self)
+  inherit behaviour_ellipse_props
+  inherit behaviour_props
+  method private obj : ellipse Clutter.obj = obj
+  method as_behaviour = obj
+end
+
+class ellipse obj = object
+  inherit ellipse_skel (obj : [> `behaviourellipse] Clutter.obj)
+end
+
+let make_ellipse ~create ~cx ~cy =
+  let knot = Knot.create ~x:cx ~y:cy in
+  BehaviourEllipse.make_params ~center:knot ~cont:
+    (fun pl () ->
+       let (e : #ellipse_skel) = create pl in
+       e)
+
+let ellipse ?(cx=0) ?(cy=0) =
+  make_ellipse [] ~cx ~cy ~create:
+    (fun pl ->
+       let e = BehaviourEllipse.create pl in
+       (*Gobject.set_params e pl;*)
+       new ellipse e)

File clutter/clutterEnums.ml

View file
 
 type rotate_axis_type = [ `X_AXIS | `Y_AXIS | `Z_AXIS ]
 type rotate_direction_type = [ `ROTATE_CW | `ROTATE_CCW ]
+type timeline_direction_type = [ `FORWARD | `BACKWARD ]
 
 (**/**)
 
 external _get_tables : unit ->
     rotate_axis_type variant_table
   * rotate_direction_type variant_table
+  * timeline_direction_type variant_table
   = "ml_clutter_get_tables"
 
 
-let rotate_axis_type, rotate_direction_type = _get_tables ()
+let rotate_axis_type, rotate_direction_type,
+    timeline_direction_type = _get_tables ()
 
 let rotate_axis_type_conv = Gobject.Data.enum rotate_axis_type
 let rotate_direction_type_conv = Gobject.Data.enum rotate_direction_type
+let timeline_direction_type_conv = Gobject.Data.enum timeline_direction_type

File clutter/clutterProps.ml

View file
 open Gobject
 open Data
 
+module PrivateProps = struct
+  let alpha = {name="alpha"; conv=(gobject : Clutter.alpha obj data_conv)}
+  let height = {name="height"; conv=int}
+  let width = {name="width"; conv=int}
+end
+
 let may_cons = Property.may_cons
 let may_cons_opt = Property.may_cons_opt
 
       {name="clip"; conv=(unsafe_pointer : Clutter.Geometry.t data_conv)}
     let depth : ([>`actor],_) property = {name="depth"; conv=int}
     let has_clip : ([>`actor],_) property = {name="has-clip"; conv=boolean}
-    let height : ([>`actor],_) property = {name="height"; conv=int}
+    let height : ([>`actor],_) property = PrivateProps.height
     let name : ([>`actor],_) property = {name="name"; conv=string}
     let opacity : ([>`actor],_) property = {name="opacity"; conv=uchar}
     let reactive : ([>`actor],_) property = {name="reactive"; conv=boolean}
     let scale_x : ([>`actor],_) property = {name="scale-x"; conv=double}
     let scale_y : ([>`actor],_) property = {name="scale-y"; conv=double}
     let visible : ([>`actor],_) property = {name="visible"; conv=boolean}
-    let width : ([>`actor],_) property = {name="width"; conv=int}
+    let width : ([>`actor],_) property = PrivateProps.width
     let x : ([>`actor],_) property = {name="x"; conv=int}
     let y : ([>`actor],_) property = {name="y"; conv=int}
   end
     cont pl
 end
 
+module Behaviour = struct
+  let cast w : Clutter.behaviour obj = try_cast w "ClutterBehaviour"
+  module P = struct
+    let alpha : ([>`behaviour],_) property = PrivateProps.alpha
+  end
+  module S = struct
+    open GtkSignal
+    let applied =
+      {name="applied"; classe=`behaviour; marshaller=fun f ->
+       marshal2 (gobject : Clutter.behaviour obj data_conv)
+         (gobject : Clutter.actor obj data_conv)
+         "ClutterBehaviour::applied" f}
+    let removed =
+      {name="removed"; classe=`behaviour; marshaller=fun f ->
+       marshal2 (gobject : Clutter.behaviour obj data_conv)
+         (gobject : Clutter.actor obj data_conv)
+         "ClutterBehaviour::removed" f}
+  end
+  external apply :
+    [>`behaviour] obj -> Clutter.behaviour -> Clutter.actor -> unit
+    = "ml_clutter_behaviour_apply"
+  external remove :
+    [>`behaviour] obj -> Clutter.behaviour -> Clutter.actor -> unit
+    = "ml_clutter_behaviour_remove"
+  external remove_all : [>`behaviour] obj -> Clutter.behaviour -> unit
+    = "ml_clutter_behaviour_remove_all"
+  external is_applied :
+    [>`behaviour] obj -> Clutter.behaviour -> Clutter.actor -> bool
+    = "ml_clutter_behaviour_is_applied"
+  external get_n_actors : [>`behaviour] obj -> Clutter.behaviour -> unit
+    = "ml_clutter_behaviour_get_n_actors"
+  external get_nth_actor :
+    [>`behaviour] obj -> Clutter.behaviour -> int -> Clutter.actor
+    = "ml_clutter_behaviour_get_nth_actor"
+end
+
+module BehaviourEllipse = struct
+  let cast w : Clutter.behaviour_ellipse obj =
+    try_cast w "ClutterBehaviourEllipse"
+  module P = struct
+    let angle_end : ([>`behaviourellipse],_) property =
+      {name="angle-end"; conv=double}
+    let angle_start : ([>`behaviourellipse],_) property =
+      {name="angle-start"; conv=double}
+    let angle_tilt_x : ([>`behaviourellipse],_) property =
+      {name="angle-tilt-x"; conv=double}
+    let angle_tilt_y : ([>`behaviourellipse],_) property =
+      {name="angle-tilt-y"; conv=double}
+    let angle_tilt_z : ([>`behaviourellipse],_) property =
+      {name="angle-tilt-z"; conv=double}
+    let center : ([>`behaviourellipse],_) property =
+      {name="center"; conv=(unsafe_pointer : Clutter.Knot.t data_conv)}
+    let direction : ([>`behaviourellipse],_) property =
+      {name="direction"; conv=ClutterEnums.rotate_direction_type_conv}
+    let height : ([>`behaviourellipse],_) property = PrivateProps.height
+    let width : ([>`behaviourellipse],_) property = PrivateProps.width
+    let alpha : ([>`behaviourellipse],_) property = PrivateProps.alpha
+  end
+  let create pl : Clutter.behaviour_ellipse obj =
+    Object.make "ClutterBehaviourEllipse" pl
+  let make_params ~cont pl ?angle_end ?angle_start ?angle_tilt_x
+      ?angle_tilt_y ?angle_tilt_z ?center ?direction ?height ?width ?alpha =
+    let pl = (
+      may_cons P.angle_end angle_end (
+      may_cons P.angle_start angle_start (
+      may_cons P.angle_tilt_x angle_tilt_x (
+      may_cons P.angle_tilt_y angle_tilt_y (
+      may_cons P.angle_tilt_z angle_tilt_z (
+      may_cons P.center center (
+      may_cons P.direction direction (
+      may_cons P.height height (
+      may_cons P.width width (
+      may_cons P.alpha alpha pl)))))))))) in
+    cont pl
+end
+
+module Timeline = struct
+  let cast w : Clutter.timeline obj = try_cast w "ClutterTimeline"
+  module P = struct
+    let delay : ([>`timeline],_) property = {name="delay"; conv=uint}
+    let direction : ([>`timeline],_) property =
+      {name="direction"; conv=ClutterEnums.timeline_direction_type_conv}
+    let duration : ([>`timeline],_) property = {name="duration"; conv=uint}
+    let fps : ([>`timeline],_) property = {name="fps"; conv=uint}
+    let loop : ([>`timeline],_) property = {name="loop"; conv=boolean}
+    let num_frames : ([>`timeline],_) property =
+      {name="num-frames"; conv=uint}
+  end
+  module S = struct
+    open GtkSignal
+    let completed =
+      {name="completed"; classe=`timeline; marshaller=fun f ->
+       marshal1 (gobject : Clutter.timeline obj data_conv)
+         "ClutterTimeline::completed" f}
+    let new_frame =
+      {name="new_frame"; classe=`timeline; marshaller=fun f ->
+       marshal2 (gobject : Clutter.timeline obj data_conv) int
+         "ClutterTimeline::new_frame" f}
+    let paused =
+      {name="paused"; classe=`timeline; marshaller=fun f ->
+       marshal1 (gobject : Clutter.timeline obj data_conv)
+         "ClutterTimeline::paused" f}
+    let started =
+      {name="started"; classe=`timeline; marshaller=fun f ->
+       marshal1 (gobject : Clutter.timeline obj data_conv)
+         "ClutterTimeline::started" f}
+  end
+  let create pl : Clutter.timeline obj = Object.make "ClutterTimeline" pl
+  external start : [>`timeline] obj -> Clutter.timeline -> unit
+    = "ml_clutter_timeline_start"
+  external pause : [>`timeline] obj -> Clutter.timeline -> unit
+    = "ml_clutter_timeline_pause"
+  external stop : [>`timeline] obj -> Clutter.timeline -> unit
+    = "ml_clutter_timeline_stop"
+  external rewind : [>`timeline] obj -> Clutter.timeline -> unit
+    = "ml_clutter_timeline_rewind"
+  external skip : [>`timeline] obj -> Clutter.timeline -> int -> unit
+    = "ml_clutter_timeline_skip"
+  external advance : [>`timeline] obj -> Clutter.timeline -> int -> unit
+    = "ml_clutter_timeline_advance"
+  external get_current_frame : [>`timeline] obj -> Clutter.timeline -> int
+    = "ml_clutter_timeline_get_current_frame"
+  external get_delta : [>`timeline] obj -> Clutter.timeline -> int -> int
+    = "ml_clutter_timeline_get_delta"
+  external get_progress : [>`timeline] obj -> Clutter.timeline -> float
+    = "ml_clutter_timeline_get_progress"
+  external get_progressx : [>`timeline] obj -> Clutter.timeline -> int
+    = "ml_clutter_timeline_get_progressx"
+  external is_playing : [>`timeline] obj -> Clutter.timeline -> bool
+    = "ml_clutter_timeline_is_playing"
+  let make_params ~cont pl ?delay ?direction ?duration ?fps ?loop
+      ?num_frames =
+    let pl = (
+      may_cons P.delay delay (
+      may_cons P.direction direction (
+      may_cons P.duration duration (
+      may_cons P.fps fps (
+      may_cons P.loop loop (
+      may_cons P.num_frames num_frames pl)))))) in
+    cont pl
+end
+

File clutter/clutterTimeline.ml

View file
+open OclutterProps
+open ClutterProps
+open Clutter
+
+
+class timeline_skel obj = object (self)
+  inherit timeline_props
+  method private obj : timeline Clutter.obj = obj
+  method as_timeline = obj
+  method start = Timeline.start obj `timeline
+end
+
+class timeline obj = object
+  inherit timeline_skel (obj : [> `timeline] Clutter.obj)
+end
+
+let make_timeline ~create =
+  Timeline.make_params ~cont:
+    (fun pl () ->
+       let (e : #timeline_skel) = create pl in
+       e)
+
+let timeline =
+  make_timeline [] ~create:
+    (fun pl ->
+       let t = Timeline.create pl in
+       new timeline t)

File clutter/clutter_tags.c

View file
   { MLTAG_ROTATE_CCW, CLUTTER_ROTATE_CCW },
 };
 
+/* timeline_direction_type : conversion table */
+const lookup_info ml_table_timeline_direction_type[] = {
+  { 0, 2 },
+  { MLTAG_FORWARD, CLUTTER_TIMELINE_FORWARD },
+  { MLTAG_BACKWARD, CLUTTER_TIMELINE_BACKWARD },
+};
+
 CAMLprim value ml_clutter_get_tables ()
 {
   static const lookup_info *ml_lookup_tables[] = {
     ml_table_rotate_axis_type,
     ml_table_rotate_direction_type,
+    ml_table_timeline_direction_type,
   };
   return (value)ml_lookup_tables;}

File clutter/clutter_tags.h

View file
 #define Val_rotate_direction_type(data) ml_lookup_from_c (ml_table_rotate_direction_type, data)
 #define Rotate_direction_type_val(key) ml_lookup_to_c (ml_table_rotate_direction_type, key)
 
+/* timeline_direction_type : tags and macros */
+#define MLTAG_FORWARD	Val_int(-442583643)
+#define MLTAG_BACKWARD	Val_int(10382307)
+
+extern const lookup_info ml_table_timeline_direction_type[];
+#define Val_timeline_direction_type(data) ml_lookup_from_c (ml_table_timeline_direction_type, data)
+#define Timeline_direction_type_val(key) ml_lookup_to_c (ml_table_timeline_direction_type, key)
+

File clutter/clutter_tags.var

View file
 type rotate_direction_type = "CLUTTER_" 
   [ `ROTATE_CW | `ROTATE_CCW ]
 
+type timeline_direction_type = "CLUTTER_TIMELINE_"
+  [ `FORWARD | `BACKWARD ]
 

File clutter/ml_clutter.c

View file
 #include "clutter_tags.h"
 #include "clutter_tags.c"
 
+// ClutterVertex
+#define ClutterVertex_val(val) ((ClutterVertex *)Pointer_val(val))
+#define Val_ClutterVertex(val) (Val_pointer(val))
+Make_Extractor (clutter_vertex_get, ClutterVertex_val, x, Val_int)
+Make_Extractor (clutter_vertex_get, ClutterVertex_val, y, Val_int)
+Make_Extractor (clutter_vertex_get, ClutterVertex_val, z, Val_int)
+Make_Setter (clutter_vertex_set, ClutterVertex_val, Int_val, x)
+Make_Setter (clutter_vertex_set, ClutterVertex_val, Int_val, y)
+Make_Setter (clutter_vertex_set, ClutterVertex_val, Int_val, z)
+CAMLprim value ml_clutter_vertex_new(value x, value y, value z) {
+  CAMLparam3(x,y,z);
+  ClutterVertex *v = malloc(sizeof(ClutterVertex));
+  v->x = Int_val(x);
+  v->y = Int_val(y);
+  v->z = Int_val(z);
+  CAMLreturn(Val_ClutterVertex(v));
+}
 
+// ClutterKnot
+#define ClutterKnot_val(val) ((ClutterKnot *)Pointer_val(val))
+#define Val_ClutterKnot(val) (Val_pointer(val))
+Make_Extractor (clutter_knot_get, ClutterKnot_val, x, Val_int)
+Make_Extractor (clutter_knot_get, ClutterKnot_val, y, Val_int)
+Make_Setter (clutter_knot_set, ClutterKnot_val, Int_val, x)
+Make_Setter (clutter_knot_set, ClutterKnot_val, Int_val, y)
+CAMLprim value ml_clutter_knot_new(value x, value y) {
+  CAMLparam2(x,y);
+  ClutterKnot *v = malloc(sizeof(ClutterKnot));
+  v->x = Int_val(x);
+  v->y = Int_val(y);
+  CAMLreturn(Val_ClutterKnot(v));
+}
 
+// Initialization
 value ml_clutter_init(value arguments)
 {
   int argc, i;
   for (i = 0; i < argc; i++) argv[i] = String_val(Field(arguments, i));
   argv[i] = NULL;
   clutter_init(&argc, &argv);
+  volatile GType clutter_type_ellipse = CLUTTER_TYPE_BEHAVIOUR_ELLIPSE;  
   volatile GType clutter_type_rectangle = CLUTTER_TYPE_RECTANGLE;
-  return Val_unit;
+  volatile GType clutter_type_timeline = CLUTTER_TYPE_TIMELINE;
+  int dummy = clutter_type_ellipse + clutter_type_rectangle +
+    clutter_type_timeline;
+  return Val_int(dummy);
 }
 
 CAMLprim value ml_abort(value vba) {

File clutter/oclutterProps.ml

View file
 open GtkSignal
 open Gobject
 open Data
-open GtkProps
+open ClutterProps
 
 (* Redefining saves space in bytecode! *)
 let set = set
 
 open ClutterProps
 
+class virtual actor_props = object (self)
+  method private virtual obj : _ obj
+  method set_clip = set Actor.P.clip self#obj
+  method set_depth = set Actor.P.depth self#obj
+  method set_height = set Actor.P.height self#obj
+  method set_name = set Actor.P.name self#obj
+  method set_opacity = set Actor.P.opacity self#obj
+  method set_reactive = set Actor.P.reactive self#obj
+  method set_rotation_angle_x = set Actor.P.rotation_angle_x self#obj
+  method set_rotation_angle_y = set Actor.P.rotation_angle_y self#obj
+  method set_rotation_angle_z = set Actor.P.rotation_angle_z self#obj
+  method set_rotation_center_x = set Actor.P.rotation_center_x self#obj
+  method set_rotation_center_y = set Actor.P.rotation_center_y self#obj
+  method set_rotation_center_z = set Actor.P.rotation_center_z self#obj
+  method set_scale_x = set Actor.P.scale_x self#obj
+  method set_scale_y = set Actor.P.scale_y self#obj
+  method set_visible = set Actor.P.visible self#obj
+  method set_width = set Actor.P.width self#obj
+  method set_x = set Actor.P.x self#obj
+  method set_y = set Actor.P.y self#obj
+  method clip = get Actor.P.clip self#obj
+  method depth = get Actor.P.depth self#obj
+  method has_clip = get Actor.P.has_clip self#obj
+  method height = get Actor.P.height self#obj
+  method name = get Actor.P.name self#obj
+  method opacity = get Actor.P.opacity self#obj
+  method reactive = get Actor.P.reactive self#obj
+  method rotation_angle_x = get Actor.P.rotation_angle_x self#obj
+  method rotation_angle_y = get Actor.P.rotation_angle_y self#obj
+  method rotation_angle_z = get Actor.P.rotation_angle_z self#obj
+  method rotation_center_x = get Actor.P.rotation_center_x self#obj
+  method rotation_center_y = get Actor.P.rotation_center_y self#obj
+  method rotation_center_z = get Actor.P.rotation_center_z self#obj
+  method scale_x = get Actor.P.scale_x self#obj
+  method scale_y = get Actor.P.scale_y self#obj
+  method visible = get Actor.P.visible self#obj
+  method width = get Actor.P.width self#obj
+  method x = get Actor.P.x self#obj
+  method y = get Actor.P.y self#obj
+end
+
+class virtual actor_sigs = object (self)
+  method private virtual connect :
+    'b. ('a,'b) GtkSignal.t -> callback:'b -> GtkSignal.id
+  method show = self#connect Actor.S.show
+  method hide = self#connect Actor.S.hide
+  method button_press_event = self#connect Actor.S.button_press_event
+  method button_release_event = self#connect Actor.S.button_release_event
+  method captured_event = self#connect Actor.S.captured_event
+  method destroy = self#connect Actor.S.destroy
+end
+
 class virtual rectangle_props = object (self)
   method private virtual obj : _ obj
   method set_border_color = set Rectangle.P.border_color self#obj
   method tiled = get Texture.P.tiled self#obj
 end
 
+class virtual texture_sigs = object (self)
+  method private virtual connect :
+    'b. ('a,'b) GtkSignal.t -> callback:'b -> GtkSignal.id
+  method pixbuf_change = self#connect Texture.S.pixbuf_change
+  method size_change = self#connect Texture.S.size_change
+end
+
+class virtual behaviour_props = object (self)
+  method private virtual obj : _ obj
+  method set_alpha = set Behaviour.P.alpha self#obj
+  method alpha = get Behaviour.P.alpha self#obj
+end
+
+class virtual behaviour_sigs = object (self)
+  method private virtual connect :
+    'b. ('a,'b) GtkSignal.t -> callback:'b -> GtkSignal.id
+  method applied = self#connect Behaviour.S.applied
+  method removed = self#connect Behaviour.S.removed
+end
+
+class virtual behaviour_ellipse_props = object (self)
+  method private virtual obj : _ obj
+  method set_angle_end = set BehaviourEllipse.P.angle_end self#obj
+  method set_angle_start = set BehaviourEllipse.P.angle_start self#obj
+  method set_angle_tilt_x = set BehaviourEllipse.P.angle_tilt_x self#obj
+  method set_angle_tilt_y = set BehaviourEllipse.P.angle_tilt_y self#obj
+  method set_angle_tilt_z = set BehaviourEllipse.P.angle_tilt_z self#obj
+  method set_center = set BehaviourEllipse.P.center self#obj
+  method set_direction = set BehaviourEllipse.P.direction self#obj
+  method set_height = set BehaviourEllipse.P.height self#obj
+  method set_width = set BehaviourEllipse.P.width self#obj
+  method set_alpha = set BehaviourEllipse.P.alpha self#obj
+  method angle_end = get BehaviourEllipse.P.angle_end self#obj
+  method angle_start = get BehaviourEllipse.P.angle_start self#obj
+  method angle_tilt_x = get BehaviourEllipse.P.angle_tilt_x self#obj
+  method angle_tilt_y = get BehaviourEllipse.P.angle_tilt_y self#obj
+  method angle_tilt_z = get BehaviourEllipse.P.angle_tilt_z self#obj
+  method center = get BehaviourEllipse.P.center self#obj
+  method direction = get BehaviourEllipse.P.direction self#obj
+  method height = get BehaviourEllipse.P.height self#obj
+  method width = get BehaviourEllipse.P.width self#obj
+  method alpha = get BehaviourEllipse.P.alpha self#obj
+end
+
+class virtual timeline_props = object (self)
+  method private virtual obj : _ obj
+  method set_delay = set Timeline.P.delay self#obj
+  method set_direction = set Timeline.P.direction self#obj
+  method set_duration = set Timeline.P.duration self#obj
+  method set_fps = set Timeline.P.fps self#obj
+  method set_loop = set Timeline.P.loop self#obj
+  method set_num_frames = set Timeline.P.num_frames self#obj
+  method delay = get Timeline.P.delay self#obj
+  method direction = get Timeline.P.direction self#obj
+  method duration = get Timeline.P.duration self#obj
+  method fps = get Timeline.P.fps self#obj
+  method loop = get Timeline.P.loop self#obj
+  method num_frames = get Timeline.P.num_frames self#obj
+end
+
+class virtual timeline_sigs = object (self)
+  method private virtual connect :
+    'b. ('a,'b) GtkSignal.t -> callback:'b -> GtkSignal.id
+  method completed = self#connect Timeline.S.completed
+  method new_frame = self#connect Timeline.S.new_frame
+  method paused = self#connect Timeline.S.paused
+  method started = self#connect Timeline.S.started
+end
+

File clutter/propcc.ml4

View file
 
 let enums = [
   "Clutter", "ClutterEnums",
-  [ "RotateAxis"; "RotateDirection";
+  [ "RotateAxisType"; "RotateDirectionType"; "TimelineDirectionType"
   ];
 ]
 

File clutter/wrappers.c

View file
 int ml_clutter_lookup_to_c (const lookup_info table[], value key)
 {
   int first = 1, last = table[0].data, current;
-  //printf("%li %li %li\n", Val_int(229818664), Val_int(873340295), Val_int(443120102));
-  //printf("lookup: %li\n", key);
-  //int i;
-  //for (i=1; i<=last; i++) {
-  //  printf("table @ %d = %li\n", i, table[i].key);
-  //};
   while (first < last) {
     current = (first+last)/2;
     if (table[current].key >= key) last = current;

File clutter/wrappers.h

View file
 #define Unit(x) ((x), Val_unit)
 #define Id(x) x
 #define Val_char Val_int
+value Val_pointer (void *);
 
 /* parameter conversion */
 #define Bool_ptr(x) ((long) x - 1)
 #endif
 #define GdkPixbuf_val(val)  (check_cast(GDK_PIXBUF, val))
 
+
+#define Make_Extractor(name,conv1,field,conv2) \
+CAMLprim value ml_##name##_##field (value val) \
+{ return conv2 ((conv1(val))->field); }
+
+#define Make_Setter(name,conv1,conv2,field) \
+CAMLprim value ml_##name##_##field (value val, value new) \
+{ (conv1(val))->field = conv2(new); return Val_unit; }
+
+#define Make_Array_Extractor(name,conv1,conv2,field,conv) \
+CAMLprim value ml_##name##_##field (value val, value index) \
+{ return conv ((conv1(val))->field[conv2(index)]); }
+
+#define Make_Array_Setter(name,conv1,conv2,conv3,field) \
+CAMLprim value ml_##name##_##field (value val, value index, value new) \
+{ (conv1(val))->field[conv2(index)] = conv3(new); return Val_unit; }
+
 #define ML_0(cname, conv)						\
 CAMLprim value ml_##cname (value unit) { return conv (cname ()); }
 #define ML_1(cname, conv1, conv) \

File examples/behave.ml

View file
 
+(*
+  let knot = ell#center in
+  let () = Printf.printf "knot=(%d,%d)\n%!"
+    (Clutter.Knot.x knot) (Clutter.Knot.y knot) in
+  Clutter.Knot.set_x knot 200;
+  Clutter.Knot.set_y knot 200;
+  ell#set_center knot;
+  let knot = ell#center in
+  let () = Printf.printf "knot=(%d,%d)\n%!"
+    (Clutter.Knot.x knot) (Clutter.Knot.y knot) in
+*)
 
 open Clutter
 let _ =
   let pixbuf = GdkPixbuf.from_file "./examples/ohpowers.png" in
   let actor = Texture.from_pixbuf pixbuf in
   Container.add stage [actor];
-  let timeline = Timeline.create ~n:100 ~fps:26 in
-  Gobject.set Timeline.P.loop timeline true;
-
-  let alpha = Alpha.create_full timeline `ALPHA_SINE in
-  let behave = Behaviour.ellipse alpha ~cx:200 ~cy:200 ~width:400 ~height:300
-    ~dir:`ROTATE_CW ~start:0. ~finish:360. in
-  Behaviour.apply behave actor;
+  let timeline = ClutterTimeline.timeline ~num_frames:100 ~fps:26 () in
+  timeline#set_loop true;
+  let alpha = Alpha.create_full t#as_timeline `ALPHA_SINE in
+  let ellipse = ClutterEllipse.ellipse ~alpha ~cx:200 ~cy:200 ~width:400
+    ~height:300 ~direction:`ROTATE_CW ~angle_start:0. ~angle_end:360. () in
+  Behaviour.apply ellipse#as_behaviour actor;
   let behave = Behaviour.opacity alpha 0 0xff in
   Behaviour.apply behave actor;
   Actor.show_all stage;
-  Timeline.start timeline;
+  timeline#start;
   main ()