bohonghuang / cl-gtk4

GTK4/Libadwaita/WebKit2 bindings for Common Lisp.
GNU Lesser General Public License v3.0
215 stars 9 forks source link

Please comment on canvas testing in separation form the rest of Gtk4. #31

Closed bigos closed 1 year ago

bigos commented 1 year ago

https://github.com/bigos/Pyrulis/blob/7086cd1a1cf455b2cf876e88ab7c511b50280232/Lisp/cl-gtk4-tictactoe.lisp#L1211

https://github.com/bigos/Pyrulis/blob/7086cd1a1cf455b2cf876e88ab7c511b50280232/Lisp/cl-gtk4-tictactoe.lisp#L326

What do you think about the idea of developing complex UI in separation from Gtk?

bohonghuang commented 1 year ago

Could you please clarify what you mean by "complex UI"? In fact, if you want to create a new widget in GTK, it is also done by using Cairo for drawing. However, currently, subclassing a GObject class in Lisp is not supported at present.

bigos commented 1 year ago

What if I want to create my own widgets and widget system to depend on Gtk as little as possible?

Here, you have the example of a simple tic-tac-toe game. But if I want to go further, creating more complex games, diagram programs, or specialist editors, the UI will become complex. My approach explores the ability to test the UI model without the use of Gtk. So, in the end, I can run a function that does the same as the callback for Cairo canvas drawing, but instead of drawing to a widget, it draws to a PNG file. That gives me the ability to visually verify that the code did what I want. I can have a series of snapshots and way to compare to previous runs without constantly creating screen grabs.

On Wed, 27 Sept 2023 at 07:11, bohonghuang @.***> wrote:

Could you please clarify what you mean by "complex UI"? In fact, if you want to create a new widget in GTK, it is also done by using Cairo for drawing. However, currently, subclassing a GObject class in Lisp is not supported at present.

— Reply to this email directly, view it on GitHub https://github.com/bohonghuang/cl-gtk4/issues/31#issuecomment-1736763081, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC72MQT556LVEVEJT6RE5DX4O7RPANCNFSM6AAAAAA5IL62XU . You are receiving this because you authored the thread.Message ID: @.***>

bohonghuang commented 1 year ago

If you want to create complex applications like games, Cairo may not be the best choice, and an immediate UI based on OpenGL might better suit your needs. In OpenGL, you have the ability to draw any control you want and handle complex mouse or keyboard interactions on your own.

raygui

GTK supports creating an OpenGL context, and you can also use a lighter-weight library like GLFW. Common Lisp has mature bindings for these libraries as well.

bigos commented 1 year ago

Yes, but following discussions here:https://github.com/kaveh808/kons-9/discussions, I can see other issues. I was wondering how far I can go with Cairo before I need to switch to GLFW. And how can I test the underlying model without using Gtk.

Maybe that is a speculation outside the scope of your project.

Please feel free to close the issue.

bohonghuang commented 1 year ago

Maybe that is a speculation outside the scope of your project.

Yes, but at the same time, I'm glad to see your attempts in this regard.