Chris00 / ocaml-cairo

Binding to Cairo, a 2D Vector Graphics Library.
GNU Lesser General Public License v3.0
54 stars 8 forks source link

ocaml-cairo and lablgtk3 #9

Closed cedlemo closed 3 years ago

cedlemo commented 6 years ago

I am trying to help to update lablgtk in order to support gtk3. Currently (https://github.com/garrigue/lablgtk/issues/6#issuecomment-390555172) I try to add the draw signal for widgets :


gboolean
user_function (GtkWidget    *widget,
               CairoContext *cr,
               gpointer      user_data)

My first idea was to add an OCaml CairoContext type based on the same C code of OCaml-Cairo so that we will be able to use your module in the callback. I would like to know your thoughts about it.

Chris00 commented 6 years ago

Thanks for letting me know about this (my name is mistyped in the referenced issue) and for working on this. I know little about Gtk3 but that looks to me like a valid approach. On the OCaml side, the question is how widget will be made available in the new Gtk3 bindings — otherwise some helper functions such as gtk_widget_get_allocated_width, gtk_widget_get_allocated_height, gtk_widget_get_style_context, gtk_render_background(context,cr,0,0,width,height),... must be made available.

cedlemo commented 6 years ago

I know little about Gtk3 but that looks to me like a valid approach nice !

On the OCaml side, the question is how widget will be made available in the new Gtk3 bindings

Sorry I am not sure to fully understand your answer. At first glance, there will be no significant change compared to Gtk2.

gtk_widget_get_allocated_width, gtk_widget_get_allocated_height, gtk_widget_get_style_context, gtk_render_background(context,cr,0,0,width,height),... must be made available.

Ah yes of course, I will have to find all the functions that use or that are needed to use a CairoContext .

Chris00 commented 6 years ago

At first glance, there will be no significant change compared to Gtk2.

I have only looked at a glace so I may be wrong but, with the old binding, the Cairo module alone was responsible for the representation of Cairo.context. Now Gtk3 bindings and Cairo modules must agree on the representation on the OCaml side (Cairo installs cairo_ocaml.h so a dependency of Gtk3 on Cairo is possible).

cedlemo commented 6 years ago

Ah my bad I misundertood you. I thought that you were talking about Gtk::Widget ( the question is how widget will be made available in the new Gtk3 bindings).

Chris00 commented 6 years ago

Sorry. What I meant is that, in order to use Cairo properly, some information (width, height,...) that requires a widget argument is needed. If it is Cairo that must call Gtk3, then widget (including its C bindings headers) must be available.

sacerdot commented 5 years ago

Dear Chris00, please have a look at lablgtk issue 6 again. I have a first "working" implementation (I can run gtk-demo.exe in examples-gtk on lablgtk3), but it uses an Obj.magic and an hard decision must be taken between you and Jacques before I can submit pull requests to both of you.

Chris00 commented 5 years ago

@sacerdot Anything left for me to do?

Chris00 commented 3 years ago

@sacerdot Gentle ping.

sacerdot commented 3 years ago

Hi Chris. Not as long as I remember. I think that this issue can be closed.