Chris00 / ocaml-cairo

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

How do I create cairo context from pointer? #40

Open bigos opened 3 days ago

bigos commented 3 days ago

I am experimenting with Gtk4.

https://docs.gtk.org/gtk4/callback.DrawingAreaDrawFunc.html

and try to write a callback.

Can you provide example how to use the cr in Gtk4 and get to using it as the cr in the examples.

My doubtful understanding is that I need to create context from the pointer.

I am a noob and trying various gives me errors that I do not understand.

https://github.com/bigos/gtk_minimal/blob/main/bin/main.ml

Chris00 commented 3 days ago

Can you provide example how to use the cr in Gtk4 and get to using it as the cr in the examples.

I'm sorry but I haven't used this library for a long time, and never with Gtk4.

bigos commented 2 days ago

No worries. I have an alternative solution for working with Gtk4.

Thank you for reply.

Chris00 commented 2 days ago

[…] I have an alternative solution for working with Gtk4.

Good. You may want to post it here so as to help others that have the same question.

bigos commented 2 days ago

Somebody has suggested to do it his way.

https://github.com/bigos/gtk_minimal/blob/8265e7d47b771c1cb434ca582c84a8c62b2a9ecf/bin/main.ml#L105

bigos commented 2 days ago

You have: https://github.com/Chris00/ocaml-cairo/blob/918ef6ee0b5ccef2947fafb11bd2f4ec7730a810/src/cairo_stubs.c#L40

but in https://github.com/garrigue/lablgtk/blob/afbd6d2ee90b98cb0ea49cba34659e15b00cbfe3/src/cairo_pango_stubs.c#L152

there seems to be a way to create another type of context using a pointer

Is that what I am looking for?