Commits

Reid van Melle committed ae3be4c

Moved to clutter-0.7 series

  • Participants
  • Parent commits 253c3bd

Comments (0)

Files changed (15)

File clutter/_tags

 <clutterEllipse.*> or <clutterTimeline.*> or <clutterData.*>: use_gtk
 <clutter.*>: use_gtk
 <ml_clutter.*>: use_gtk2
+<ml_texture.*>: use_gtk2
 

File clutter/clutter.ml

   let create_full a (b:effect) = _create_full a (Hashtbl.hash b)
 end;;
 
-(*module Texture = struct
-  external from_pixbuf : pixbuf -> [> `actor] obj
-    = "ml_clutter_texture_new_from_pixbuf"    
-end;;*)
-
 module Behaviour = struct
   module E = ClutterEnums
   (* ellipse operations *)

File clutter/clutter.props

 }
 
 class Texture set wrap wrapsig : Actor {
-  "filter-quality"           gint               : Read / Write
-  "pixbuf"                   GdkPixbuf          : Read / Write
-  "pixel-format"             gint               : Read
-  "pixel-type"               gint               : Read
-  "repeat-x"                 gboolean           : Read / Write
-  "repeat-y"                 gboolean           : Read / Write
-  "sync-size"                gboolean           : Read / Write
-  "tile-waste"               gint               : Read / Write / Construct Only
-  "tiled"                    gboolean           : Read / Write / Construct Only
-  signal pixbuf_change : ClutterTexture (*gpointer*) 
-  signal size_change : ClutterTexture int int (*gpointer*)
+  "cogl-texture"             ClutterTextureHandle  : Read / Write
+  "disable-slicing"          gboolean              : Read / Write / Construct Only
+  "filename"                 string                : Write
+  "filter-quality"           ClutterTextureQuality  : Read / Write / Construct
+  "keep-aspect-ratio"        gboolean              : Read / Write
+  "pixel-format"             gint                  : Read
+  "repeat-x"                 gboolean              : Read / Write
+  "repeat-y"                 gboolean              : Read / Write
+  "sync-size"                gboolean              : Read / Write
+  "tile-waste"               gint                  : Read / Write / Construct Only
+  (*method set_from_rgb_data
+    method set_from_yuv_data
+    method set_area_from_rgb_data
+  *)
+  method set_from_file : "string -> bool"
+  method get_base_size : "(int*int)"
+  method get_max_tile_waste : "int"
+  method set_max_tile_waste : "int -> unit"
+  method get_cogl_texture : "Clutter.coglhandle"
+  method set_colg_texture : "Clutter.coglhandle -> unit"
+  signal pixbuf_change : (*gpointer*) 
+  signal size_change : int int (*gpointer*)
 }
 
 class Behaviour abstract wrap wrapsig : Object {

File clutter/clutterActor.ml

   method show_all = Actor.show_all obj
   method set_position = Actor.set_position obj
   method set_rotation = Actor.set_rotation obj
+  method set_size = Actor.set_size obj
+  method realize = Actor.realize obj
 end

File clutter/clutterProps.ml

 module Texture = struct
   let cast w : Clutter.texture obj = try_cast w "ClutterTexture"
   module P = struct
-    let filter_quality : ([>`texture],_) property =
-      {name="filter-quality"; conv=int}
-    let pixbuf : ([>`texture],_) property =
-      {name="pixbuf"; conv=(gobject : GdkPixbuf.pixbuf data_conv)}
+    let disable_slicing : ([>`texture],_) property =
+      {name="disable-slicing"; conv=boolean}
+    let filename : ([>`texture],_) property = {name="filename"; conv=string}
+    let keep_aspect_ratio : ([>`texture],_) property =
+      {name="keep-aspect-ratio"; conv=boolean}
     let pixel_format : ([>`texture],_) property =
       {name="pixel-format"; conv=int}
-    let pixel_type : ([>`texture],_) property = {name="pixel-type"; conv=int}
     let repeat_x : ([>`texture],_) property = {name="repeat-x"; conv=boolean}
     let repeat_y : ([>`texture],_) property = {name="repeat-y"; conv=boolean}
     let sync_size : ([>`texture],_) property =
       {name="sync-size"; conv=boolean}
     let tile_waste : ([>`texture],_) property = {name="tile-waste"; conv=int}
-    let tiled : ([>`texture],_) property = {name="tiled"; conv=boolean}
   end
   module S = struct
     open GtkSignal 
     open ClutterData
     let pixbuf_change =
-      {name="pixbuf_change"; classe=`texture; marshaller=fun f ->
-       marshal1 (gobject : Clutter.texture obj data_conv)
-         "ClutterTexture::pixbuf_change" f}
+      {name="pixbuf_change"; classe=`texture; marshaller=marshal_unit}
     let size_change =
       {name="size_change"; classe=`texture; marshaller=fun f ->
-       marshal3 (gobject : Clutter.texture obj data_conv) int int
-         "ClutterTexture::size_change" f}
+       marshal2 int int "ClutterTexture::size_change" f}
   end
-  let create ?tile_waste ?tiled pl : Clutter.texture obj =
+  let create ?disable_slicing ?tile_waste pl : Clutter.texture obj =
     let pl = (
-      may_cons P.tile_waste tile_waste (
-      may_cons P.tiled tiled pl)) in
+      may_cons P.disable_slicing disable_slicing (
+      may_cons P.tile_waste tile_waste pl)) in
     Object.make "ClutterTexture" pl
-  let make_params ~cont pl ?filter_quality ?pixbuf ?repeat_x ?repeat_y
+  external set_from_file : [>`texture] obj -> string -> bool
+    = "ml_clutter_texture_set_from_file"
+  let make_params ~cont pl ?filename ?keep_aspect_ratio ?repeat_x ?repeat_y
       ?sync_size =
     let pl = (
-      may_cons P.filter_quality filter_quality (
-      may_cons P.pixbuf pixbuf (
+      may_cons P.filename filename (
+      may_cons P.keep_aspect_ratio keep_aspect_ratio (
       may_cons P.repeat_x repeat_x (
       may_cons P.repeat_y repeat_y (
       may_cons P.sync_size sync_size pl))))) in

File clutter/clutterStage.ml

 open ClutterProps
 open Clutter
 
-module Stage = struct
-  (*include Stage*)
-  external get_default : unit -> stage obj = "ml_clutter_stage_get_default"
-end;;
+external get_default : unit -> stage obj = "ml_clutter_stage_get_default"
 
 class type actor_o = object
   method as_actor : [< Clutter.actor] obj
 class ['a] stage_skel obj = object (self)
   inherit stage_props
   inherit actor_props
+  inherit ClutterContainer.container_skel (as_container obj)
+  inherit ClutterActor.actor_skel (as_actor obj)
   method private obj : stage Clutter.obj = obj
   method as_stage = obj
-  method set_size ~width ~height =
-    ClutterProps.Actor.set_size (as_actor obj) ~width ~height
-  method show_all = ClutterProps.Actor.show_all obj
-  method as_container = as_container obj
-  method add_actor (a : actor obj) =
-    ClutterProps.Container.add_actor self#as_container a
-  (*method add_actor : 'a. (#actor_o as 'a) -> unit = fun a ->
-    ClutterProps.Container.add_actor obj `container a#as_actor*)
-  (*method add_actor =   need to wrap container *)
 end
 
 class stage_signals_impl obj = object
   method connect = new stage_signals_impl obj
 end
 
-let get_default () = new stage (Stage.get_default ())
+let get_default () = new stage (get_default ())
 
 
 

File clutter/clutterTexture.ml

 open ClutterProps
 open Clutter
 
+external new_from_file : string -> texture obj =
+    "ml_clutter_texture_new_from_file"
+
 class texture_skel obj = object (self)
   inherit texture_props
   inherit actor_props

File clutter/ml_actor.c

 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_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);

File clutter/ml_texture.c

 #include "wrappers.h"
 #include "ml_actor.h"
+#include "ml_texture.h"
 
-CAMLprim value ml_clutter_texture_new_from_pixbuf(value pixbuf)
-{
-  CAMLparam1(pixbuf);
-  ClutterActor *a = clutter_texture_new_from_pixbuf(GdkPixbuf_val(pixbuf));
+static struct custom_operations ml_clutter_texture_ops = {
+  "ClutterTexture",
+  custom_finalize_default,
+  custom_compare_default,
+  custom_hash_default,
+  custom_serialize_default,
+  custom_deserialize_default
+};
+
+value Val_ClutterTexture_ (ClutterTexture *t, gboolean ref)
+{ 
+  ClutterTexture **p;
+  value ret; 
+  if (t == NULL) ml_raise_null_pointer(); 
+  ret = alloc_custom (&ml_clutter_texture_ops, sizeof t, 
+		      100, 1000);
+  p = Data_custom_val (ret);
+  *p = ref ? g_object_ref (t) : t;
+  return ret; 
+}
+
+// TODO: this isn't really necessary... however we should test
+// if the error handling is ok when setting file via props
+CAMLprim value ml_clutter_texture_new_from_file(value fn) {
+  CAMLparam1(fn);
+  GError *error = NULL;
+  ClutterActor *a = clutter_texture_new_from_file(String_val(fn), &error);
+  if (error)
+    g_error ("Unable to load '%s': %s", String_val(fn), error->message);
   CAMLreturn(Val_ClutterActor(a));
 }
+
+

File clutter/oclutterProps.ml

 
 class virtual texture_props = object (self)
   method private virtual obj : _ obj
-  method set_filter_quality = set Texture.P.filter_quality self#obj
-  method set_pixbuf = set Texture.P.pixbuf self#obj
+  method set_filename = set Texture.P.filename self#obj
+  method set_keep_aspect_ratio = set Texture.P.keep_aspect_ratio self#obj
   method set_repeat_x = set Texture.P.repeat_x self#obj
   method set_repeat_y = set Texture.P.repeat_y self#obj
   method set_sync_size = set Texture.P.sync_size self#obj
-  method filter_quality = get Texture.P.filter_quality self#obj
-  method pixbuf = get Texture.P.pixbuf self#obj
+  method disable_slicing = get Texture.P.disable_slicing self#obj
+  method keep_aspect_ratio = get Texture.P.keep_aspect_ratio self#obj
   method pixel_format = get Texture.P.pixel_format self#obj
-  method pixel_type = get Texture.P.pixel_type self#obj
   method repeat_x = get Texture.P.repeat_x self#obj
   method repeat_y = get Texture.P.repeat_y self#obj
   method sync_size = get Texture.P.sync_size self#obj
   method tile_waste = get Texture.P.tile_waste self#obj
-  method tiled = get Texture.P.tiled self#obj
 end
 
 class virtual texture_sigs = object (self)

File configure.ac

 PKG_CHECK_MODULES([GTK2], [gtk+-2.0 >= 2.12.0])
 PKG_CHECK_MODULES([CAIRO], [cairo >= 1.4.8])
 PKG_CHECK_MODULES([GTHREAD2], [gthread-2.0 >= 2.14.1])
-PKG_CHECK_MODULES([CLUTTER], [clutter-0.6 >= 0.6])
-PKG_CHECK_MODULES([CLUTTER_CAIRO], [clutter-cairo-0.6 >= 0.6])
+PKG_CHECK_MODULES([CLUTTER], [clutter-0.7 >= 0.7])
+#PKG_CHECK_MODULES([CLUTTER_CAIRO], [clutter-cairo-0.6 >= 0.6])
 
 # Check for cairo
 tmp_MODULE_INCLUDES="$MODULE_INCLUDES"

File examples/actor1.ml

   
 let _ =
   let stage = ClutterStage.get_default () in
-  let pixbuf = GdkPixbuf.from_file "./examples/ohpowers.png" in
-  let actor = ClutterTexture.texture ~pixbuf () in
+  stage#set_size ~width:800 ~height:600;
+  let actor = ClutterTexture.texture ~filename:"./examples/ohpowers.png" () in
+  let r = ClutterRectangle.rectangle () in
+  stage#add_actor r#as_actor;
   stage#add_actor actor#as_actor;
   actor#set_position ~x:100 ~y:100;
   actor#set_rotation `Z_AXIS ~angle:180. ~x:(actor#width / 2)

File examples/actor2.ml

 open Clutter
+open Printf
 let display_actor_props a =
   Printf.printf "props: depth=%d has_clip=%b\n%!"
     (Gobject.get ClutterProps.Actor.P.depth a)
     (Gobject.get ClutterProps.Actor.P.has_clip a)
 
 let display_texture_props t =
-  let module P = ClutterProps.Texture.P in
-  let get p = Gobject.get p t in
-  Printf.printf "props: filter_quality=%d pixbuf=(%d,%d)\n%!"
-    (get P.filter_quality) (GdkPixbuf.get_width (get P.pixbuf))
-    (GdkPixbuf.get_height (get P.pixbuf))
+  printf "props: disable-slicing=%b keep-aspect-ratio=%b pixel-format=%d repeat-x=%b repeat-y=%b sync-size=%b tile-waste=%d\n%!" t#disable_slicing t#keep_aspect_ratio t#pixel_format t#repeat_x t#repeat_y t#sync_size t#tile_waste
 
 let test () =
   let module P = ClutterProps.Rectangle.P in
     
 let _ =
   let stage = ClutterStage.get_default () in
-  let pixbuf = GdkPixbuf.from_file "./examples/ohpowers.png" in
+  let r = ClutterRectangle.rectangle () in
+  stage#add_actor r#as_actor;
 
   let group = ClutterGroup.group ()
   and group2 = ClutterGroup.group () in
   let _ = group#connect#add (fun _ _ -> Printf.printf "added\n%!") in
-  let actor1 = ClutterTexture.texture ~pixbuf ~x:0 ~y:0 ()
-  and actor2 = ClutterTexture.texture ~pixbuf ~x:200 ~y:0 () in
-  let actor3 = ClutterTexture.texture ~pixbuf ~x:0 ~y:0 ()
-  and actor4 = ClutterTexture.texture ~pixbuf ~x:200 ~y:0 () in
+  let actor1 = ClutterTexture.texture
+    ~filename:"./examples/ohpowers.png" ~x:0 ~y:0 ()
+  and actor2 = ClutterTexture.texture
+    ~filename:"./examples/ohpowers.png" ~x:200 ~y:0 () in
+  let actor3 = ClutterTexture.texture
+    ~filename:"./examples/ohpowers.png" ~x:0 ~y:0 ()
+  and actor4 = ClutterTexture.texture
+    ~filename:"./examples/ohpowers.png" ~x:200 ~y:0 () in
   group#add_many [|actor1#as_actor; actor2#as_actor|];
   group2#add_many [|actor3#as_actor; actor4#as_actor|];
   
   display_actor_props actor1#as_actor;
   display_actor_props actor2#as_actor;
-  display_texture_props actor1#obj;
+  display_texture_props actor1;
   test ();
 
   stage#add_actor group#as_actor;

File examples/behave.ml

 open Clutter
 let _ =
   let stage = ClutterStage.get_default () in
-  let pixbuf = GdkPixbuf.from_file "./examples/ohpowers.png" in
-  let actor = ClutterTexture.texture ~pixbuf () in
+  let r = ClutterRectangle.rectangle () in
+  stage#add_actor r#as_actor;
+  let actor = ClutterTexture.texture ~filename:"./examples/ohpowers.png" () in
   stage#add_actor actor#as_actor;
   let timeline = ClutterTimeline.timeline ~num_frames:100 ~fps:5 () in
   let _ =

File tests/test-effect.ml

   let tmpl = ClutterEffects.template timeline#as_timeline `RAMP_INC in
 
   let stage = ClutterStage.get_default () in
-  (*let container = stage#as_container*)
 
   let _ = stage#connect#button_press_event
     (fun _ -> printf "got a button press\n%!"; Clutter.quit (); true) in