1. Reid van Melle
  2. clutter-ocaml

Commits

Reid van Melle  committed c2c02ef

Finished pretty much all of the actor routines

  • Participants
  • Parent commits a135bc3
  • Branches default

Comments (0)

Files changed (3)

File src/clutter.props

View file
   signal parent_set : ClutterActor
   signal scroll_event : ClutterEvent -> bool
   signal show
+  method set_anchor_point : "x:int -> y:int -> unit"
+  method get_anchor_point : "int*int"
+  method set_anchor_point_from_gravity : "ClutterEnums.gravity_type -> unit"
+  method move_anchor_point : "x:int -> y:int -> unit"
+  method move_anchor_point_from_gravity : "ClutterEnums.gravity_type -> unit"
+  method id : "int"
+  method allocate : "Clutter.ActorBox.t -> bool -> unit"
+  method allocate_preferred_size : "bool -> unit"
+  method get_preferred_size : "Clutter.units * Clutter.units * Clutter.units * Clutter.units"
+  method get_preferred_width : "Clutter.units -> (Clutter.units * Clutter.units)"
+  method get_preferred_height : "Clutter.units -> (Clutter.units * Clutter.units)"
+  method get_allocation_coords : "int*int*int*int"
+  method get_allocation_box : "Clutter.ActorBox.t"  
+  method get_allocation_geometry : "Clutter.geometry"
+  method get_allocation_vertices : "Clutter.actor obj option -> (Clutter.vertex *Clutter.vertex * Clutter.vertex * Clutter.vertex)"
   method show : "unit"
   method show_all : "unit"
   method hide : "unit"
   method queue_redraw : "unit"
   method queue_relayout : "unit"
   method destroy : "unit"
-  (* request_coords *)
-  (* query_coords *)
-  method event : "'a Clutter.event -> bool -> bool"
+  method event : "Event.any -> bool -> bool"
   method pick : "Clutter.Color.t -> unit"
-  method allocate : "Clutter.ActorBox.t -> bool -> unit"
-  method get_allocation_box : "Clutter.ActorBox.t"
+
   method should_pick_paint : "bool"
   method set_geometry : "Clutter.geometry -> unit"
   method get_geometry : "Clutter.geometry"
-  (*method get_coords : "Clutter.coords"*)
   method set_size : "width:int -> height:int -> unit"
-  (* method get_size : "(int*int) *)
+  method get_size : "(int*int)"
   method set_position: "x:int -> y:int -> unit"
-  (* method get_position: "(int*int) *)
-  (* method get_abs_position: "(int*int) *)
+  method get_position: "(int*int)"
   method move_by: "dx:int -> dy:int -> unit"
   method set_rotation: "ClutterEnums.rotate_axis_type -> angle:float -> x: int -> y:int -> z:int -> unit"
-  (* method get_rotation: "Clutter.rotate_axis -> *)
+  method get_rotation: "ClutterEnums.rotate_axis_type -> (float*int*int*int)"
   method is_rotated: "bool"
   method get_gid: "int"
-  (*method set_clip: "xoff:int -> yoff:int -> width:int -> height:int -> unit"*)
   method remove_clip: "unit"
   method has_clip: "bool"
-  (* method get_clip: "*)
   method set_parent : "unit"
   method get_parent : "Clutter.actor obj"
   method reparent : "Clutter.actor obj -> unit"
   method is_scaled : "bool"
   method apply_transform_to_point : "Clutter.vertex -> Clutter.vertex"
   method transform_stage_point : "x:Clutter.units -> y:Clutter.units -> (units*units*bool)"
-  method apply_relative_transform_to_point : "ancestor:Clutter.actor obj -> point:Clutter.vertex -> vertex:Clutter.vertex -> unit"
+  method apply_relative_transform_to_point : "ancestor:Clutter.actor obj option -> point:Clutter.vertex -> vertex:Clutter.vertex -> unit"
   method get_transformed_position : "int*int"
   method get_transformed_size : "int*int"
   method get_paint_opacity : "int"
   method get_abs_allocation_vertices : "Clutter.vertex * Clutter.vertex * Clutter.vertex * Clutter.vertex"
   method box_get_from_vertices : "Clutter.vertex -> Clutter.vertex -> Clutter.vertex -> Clutter.vertex -> Clutter.actorbox"
-  method set_anchor_point : "x:int -> y:int -> unit"
-  method get_anchor_point : "int*int"
-  method set_anchor_point_from_gravity : "ClutterEnums.gravity_type -> unit"
-  method move_anchor_point : "x:int -> y:int -> unit"
-  method move_anchor_point_from_gravity : "ClutterEnums.gravity_type -> unit"
-  (* much more *)
+
+
 }
 
 class Container abstract wrap {

File src/clutterActor.ml

View file
   inherit actor_props
   method virtual obj : 'a obj
   method set_anchor_point = Actor.set_anchor_point obj
+  method get_anchor_point = Actor.get_anchor_point obj
   method set_anchor_point_from_gravity =
     Actor.set_anchor_point_from_gravity obj
   method move_anchor_point = Actor.move_anchor_point obj
   method move_anchor_point_from_gravity =
     Actor.move_anchor_point_from_gravity obj
-  method transform_stage_point = Actor.transform_stage_point obj
   method id = Gobject.get_oid obj
   method as_actor = obj
   method allocate box = Actor.allocate obj (ActorBox.unwrap box)
+  method allocate_preferred_size = Actor.allocate_preferred_size obj
+  method get_preferred_size = Actor.get_preferred_size obj
+  method get_preferred_width = Actor.get_preferred_width obj
+  method get_preferred_height = Actor.get_preferred_height obj
+  method get_allocation_coords = Actor.get_allocation_coords obj
   method get_allocation_box = ActorBox.wrap (Actor.get_allocation_box obj)
+  method get_allocation_geometry = Actor.get_allocation_geometry obj
+  method get_allocation_vertices = Actor.get_allocation_vertices obj
   method apply_transform_to_point = Actor.apply_transform_to_point obj
+  method transform_stage_point = Actor.transform_stage_point obj
   method get_abs_allocation_vertices = Actor.get_abs_allocation_vertices obj
+  method apply_relative_transform_to_point = Actor.apply_relative_transform_to_point obj
+  method get_transformed_position = Actor.get_transformed_position obj
+  method get_transformed_size = Actor.get_transformed_size obj
+  method get_paint_opacity = Actor.get_paint_opacity obj
+  method is_scaled = Actor.is_scaled obj
   method move_by = Actor.move_by obj
   method raise_top = Actor.raise_top obj
+  method raise = Actor.raise obj
+  method lower = Actor.lower obj
+  method lower_bottom = Actor.lower_bottom obj
+  method remove_clip = Actor.remove_clip obj
   method hide = Actor.hide obj
+  method hide_all = Actor.hide_all obj
+  method event = Actor.event obj
   method show = Actor.show obj
   method show_all = Actor.show_all obj
+  method get_gid = Actor.get_gid obj
   method set_position = Actor.set_position obj
+  method get_position = Actor.get_position obj
   method set_rotation = Actor.set_rotation obj
+  method get_rotation = Actor.get_rotation obj
+  method is_rotated = Actor.is_rotated 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 set_parent = Actor.set_parent obj
+  method reparent = Actor.reparent obj
   method realize = Actor.realize obj
   method unrealize = Actor.unrealize obj
   method paint = Actor.paint obj
   method destroy = Actor.destroy obj
   method set_geometry = Actor.set_geometry obj
   method get_geometry = Actor.get_geometry obj
+  (*method set_shader = Actor.set_shader obj
+  method get_shader = Actor.get_shader obj
+  method set_shader_param = Actor.set_shader_param obj*)
 end
 
 let to_actor a = (a :> [< `actor] actor_skel)

File src/ml_actor.c

View file
 // ClutterActorBox
 #define ClutterActorBox_val(val) ((ClutterActorBox *)Pointer_val(val))
 #define Val_ClutterActorBox(val) (Val_pointer(val))
-//Make_Val_final_pointer(ClutterActorBox, Ignore, free, 1);
+//FIXME: Make_Val_final_pointer(ClutterActorBox, Ignore, free, 1);
 Make_Extractor (clutter_actorbox_get, ClutterActorBox_val, x1, Val_long)
 Make_Extractor (clutter_actorbox_get, ClutterActorBox_val, y1, Val_long)
 Make_Extractor (clutter_actorbox_get, ClutterActorBox_val, x2, Val_long)
 
 void ml_clutter_actor_callback (ClutterActor *a, gpointer data)
 {
-    value val, *clos = (value*)data;
-    val = Val_ClutterActor(a);
-    callback_exn (*clos, val);
-    ml_global_root_destroy(clos);
+  value val, *clos = (value*)data;
+  val = Val_ClutterActor(a);
+  callback_exn (*clos, val);
+  ml_global_root_destroy(clos);
 }
 
+#define Val_ClutterVertex(v,result) result = caml_alloc(3,0);	\
+  Store_field( result, 0, Val_int( v.x)); \
+  Store_field( result, 1, Val_int( v.y)); \
+  Store_field( result, 2, Val_int( v.z));
+
 CAMLprim value ml_clutter_actor_get_abs_allocation_vertices(value _a) {
   CAMLparam1(_a);
   CAMLlocal5(result,v1,v2,v3,v4);
   ClutterVertex point = { Triple(_point, Int_val, Int_val, Int_val) };
   ClutterVertex vertex;
   clutter_actor_apply_transform_to_point(a, &point, &vertex);
-  result = caml_alloc(3,0);
-  Store_field(result, 0, Val_int(vertex.x));
-  Store_field(result, 1, Val_int(vertex.y));
-  Store_field(result, 2, Val_int(vertex.z));
+  Val_ClutterVertex(vertex, result);
   CAMLreturn(result);
 }
 
   CAMLreturn(Val_ClutterActorBox(b));
 }
 
+CAMLprim value ml_clutter_actor_get_allocation_vertices(value _a, value _anc)
+{
+  CAMLparam2(_a, _anc);
+  CAMLlocal5(result,v1,v2,v3,v4);
+  ClutterActor* a = ClutterActor_val(_a);
+  ClutterActor* ancestor = Option_val(_anc, ClutterActor_val, NULL);
+  ClutterVertex    v[4];  
+  clutter_actor_get_allocation_vertices (a, ancestor, v);
+  result = caml_alloc(4,0);
+  v1 = caml_alloc(3,0);
+  v2 = caml_alloc(3,0);
+  v3 = caml_alloc(3,0);
+  v4 = caml_alloc(3,0);
+  value*          values[4] = {&v1,&v2,&v3,&v4};
+  Store_field(result, 0, v1);
+  Store_field(result, 1, v2);
+  Store_field(result, 2, v3);
+  Store_field(result, 3, v4);
+  int i;
+  for (i=0; i<4; i++) {
+    Store_field(*values[i], 0, Val_int(v[i].x));
+    Store_field(*values[i], 1, Val_int(v[i].y));
+    Store_field(*values[i], 2, Val_int(v[i].z));
+  }
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_anchor_point(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  gint anchor_x, anchor_y;
+  clutter_actor_get_anchor_point(a, &anchor_x, &anchor_y);
+  result = caml_alloc(2,0);
+  Store_field(result, 0, Val_int(anchor_x));
+  Store_field(result, 1, Val_int(anchor_y));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_position(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  gint x, y;
+  clutter_actor_get_position(a, &x, &y);
+  result = caml_alloc(2,0);
+  Store_field(result, 0, Val_int(x));
+  Store_field(result, 1, Val_int(y));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_transformed_position(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  gint x, y;
+  clutter_actor_get_transformed_position(a, &x, &y);
+  result = caml_alloc(2,0);
+  Store_field(result, 0, Val_int(x));
+  Store_field(result, 1, Val_int(y));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_transformed_size(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  guint width, height;
+  clutter_actor_get_transformed_size(a, &width, &height);
+  result = caml_alloc(2,0);
+  Store_field(result, 0, Val_int(width));
+  Store_field(result, 1, Val_int(height));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_preferred_size(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  ClutterUnit m,n,o,p;
+  clutter_actor_get_preferred_size(a, &m, &n, &o, &p);
+  result = caml_alloc(4,0);
+  Store_field(result, 0, Val_int(m));
+  Store_field(result, 1, Val_int(n));
+  Store_field(result, 2, Val_int(o));
+  Store_field(result, 3, Val_int(p));  
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_preferred_width(value _a, value _h)
+{
+  CAMLparam2(_a, _h);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  ClutterUnit h = Int_val(_h);
+  ClutterUnit m,n;
+  clutter_actor_get_preferred_width(a,h,&m,&n);
+  result = caml_alloc(2,0);
+  Store_field(result, 0, Val_int(m));
+  Store_field(result, 1, Val_int(n));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_preferred_height(value _a, value _w)
+{
+  CAMLparam2(_a, _w);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  ClutterUnit w = Int_val(_w);
+  ClutterUnit m,n;
+  clutter_actor_get_preferred_height(a,w,&m,&n);
+  result = caml_alloc(2,0);
+  Store_field(result, 0, Val_int(m));
+  Store_field(result, 1, Val_int(n));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_rotation(value _a, value _axis)
+{
+  CAMLparam1(_a);
+  CAMLlocal2(result, v_angle);
+  ClutterActor *a = ClutterActor_val(_a);
+  ClutterRotateAxis axis = Rotate_axis_type_val(_axis);
+  gint x,y,z;
+  gdouble angle = clutter_actor_get_rotation(a, axis, &x, &y, &z);
+  v_angle = caml_copy_double(angle);
+  result = caml_alloc(4,0);
+  Store_field(result, 0, v_angle);
+  Store_field(result, 1, Val_int(x));
+  Store_field(result, 2, Val_int(y));
+  Store_field(result, 3, Val_int(z));  
+  CAMLreturn(result);
+}
+
 /** Geometry object */
 Make_Val_final_pointer(ClutterGeometry, Ignore, free, 5)
 CAMLprim value ml_clutter_geometry_create(value _geom)
   CAMLreturn(Val_unit);
 }
 
+CAMLprim value ml_clutter_actor_apply_relative_transform_to_point(value _a, value _ancestor, value _point)
+{
+  CAMLparam3(_a, _ancestor, _point);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  ClutterActor *ancestor = Option_val(_ancestor, ClutterActor_val, NULL);
+  ClutterVertex point = { Triple(_point, Int_val, Int_val, Int_val) };
+  ClutterVertex vertex;
+  clutter_actor_apply_relative_transform_to_point(a, ancestor, &point, &vertex);
+  Val_ClutterVertex(vertex, result);
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_allocation_coords(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  gint x1, x2, y1, y2;
+  clutter_actor_get_allocation_coords(a, &x1, &y1, &x2, &y2);
+  result = caml_alloc(4,0);
+  Store_field(result, 0, Val_int(x1));
+  Store_field(result, 1, Val_int(y1));
+  Store_field(result, 2, Val_int(x2));
+  Store_field(result, 3, Val_int(x2));
+  CAMLreturn(result);
+}
+
+CAMLprim value ml_clutter_actor_get_allocation_geometry(value _a)
+{
+  CAMLparam1(_a);
+  CAMLlocal1(result);
+  ClutterActor *a = ClutterActor_val(_a);
+  ClutterGeometry g;
+  clutter_actor_get_allocation_geometry(a, &g);
+  result = caml_alloc(4,0);
+  Store_field(result, 0, Val_int(g.x));
+  Store_field(result, 1, Val_int(g.y));
+  Store_field(result, 2, Val_int(g.width));
+  Store_field(result, 3, Val_int(g.height));
+  CAMLreturn(result);
+}
+
+
+ML_3(clutter_actor_event, ClutterActor_val, Pointer_val, Bool_val, Val_bool)
+ML_1(clutter_actor_get_paint_opacity, ClutterActor_val, Val_int)
+ML_1(clutter_actor_get_gid, ClutterActor_val, Val_int)
+ML_2(clutter_actor_set_parent, ClutterActor_val, ClutterActor_val, Unit)
+ML_2(clutter_actor_reparent, ClutterActor_val, ClutterActor_val, Unit)
 ML_1(clutter_actor_raise_top, ClutterActor_val, Unit)
+ML_1(clutter_actor_lower_bottom, ClutterActor_val, Unit)
+ML_2(clutter_actor_raise, ClutterActor_val, ClutterActor_val, Unit)
+ML_2(clutter_actor_lower, ClutterActor_val, ClutterActor_val, Unit)
+ML_1(clutter_actor_remove_clip, ClutterActor_val, Unit)
+ML_1(clutter_actor_is_scaled, ClutterActor_val, Val_bool)
+ML_1(clutter_actor_is_rotated, ClutterActor_val, Val_bool)
 ML_1(clutter_actor_show_all, ClutterActor_val, Unit)
 ML_1(clutter_actor_show, ClutterActor_val, Unit)
 ML_3(clutter_actor_set_scale, ClutterActor_val, Double_val, Double_val, Unit)
 ML_3(clutter_actor_allocate, ClutterActor_val, ClutterActorBox_val, Bool_val, Unit)
+ML_2(clutter_actor_allocate_preferred_size, ClutterActor_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)
      Gravity_type_val, Unit)
 ML_3(clutter_actor_move_anchor_point, ClutterActor_val, Int_val, Int_val, Unit)
 ML_1(clutter_actor_hide, ClutterActor_val, Unit)
+ML_1(clutter_actor_hide_all, 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)