A system that uses cl-gtk4 and allows other apps to use its GUI capabilities for drawing canvas, menu and events. Quite limited subset of Gtk4 capabilities has been implemented, but it may be enough for simple 2D graphics or games.
So far it can only do multiple windows that contain only one widget, that is DrawingArea. The examples folder will contain examples of using the system.
There is a limitation bohonghuang/cl-gtk4#58 of what the underlying library can do, so you may have to implement your own widget system similar to those in Smalltalk systems.
Perhaps it would be possible to have a declarative way to define other widgets
than DrawingArea, in similar manner to function menu-bar-menu
is used for menu,
but that is not my priority.
https://github.com/bigos/basic-editor
Occasionally, I run into problems where some binding are missing.
For example in file: ./src/gui-window-gtk.lisp, in function: present-file-save- dialog, I did not have the ability to set the needed properties.
I had to fall back to cl-gobject-introspection (gir). The documentation for it is on those pages:
https://gnome.pages.gitlab.gnome.org/gobject-introspection/girepository/
https://github.com/andy128k/cl-gobject-introspection
https://github.com/andy128k/cl-gobject-introspection/tree/master/examples
https://github.com/bohonghuang/cl-gobject-introspection-wrapper
To run a simple key operated resizing evaluate:
(load "~/Programming/Lisp/clops-gui/examples/moving-boxes.lisp")
Key press operations can be found at: file:~/Programming/Lisp/clops-gui/examples/moving-boxes.lisp::214
(defmethod move-b1 ((model model) direction)
(cond ((equal direction "Left")
(setf (bbx model) (- (bbx model) 5)))
((equal direction "Right")
(setf (bbx model) (+ (bbx model) 5)))
((equal direction "q")
(setf (grw model) (- (grw model) 5)))
((equal direction "w")
(setf (grw model) (+ (grw model) 5)))
((equal direction "b")
(setf (grh model) (- (grh model) 5)))
((equal direction "h")
(setf (grh model) (+ (grh model) 5)))
((equal direction "a")
(setf (tbw model) (- (tbw model) 5)))
((equal direction "s")
(setf (tbw model) (+ (tbw model) 5)))
(T
(warn "un-handled key"))))
To run a simple counter evaluate:
(load "~/Programming/Lisp/clops-gui/examples/counter.lisp")
The counter responds to mouse clicks.
You need SBCL, quicklisp and ultralisp. Please follow the relevant instructions.
also install development libraries
sudo apt install libgtk-4-dev
discussion about prepending functions with % https://www.reddit.com/r/Common_Lisp/comments/jgj9lu/naming_conventions/
And some programmers will name particularly low-level functions with names that start with % or even %%. https://gigamonkeys.com/book/syntax-and-semantics
http://www.mohamedelafrit.com/education/ENSEIRB/lisp/standards.pdf
https://ccrma.stanford.edu/CCRMA/Courses/AlgoComp/cm/doc/contrib/lispstyle.html https://lisp-lang.org/style-guide/
https://github.com/bbatsov/emacs-lisp-style-guide
https://www.cliki.net/naming+conventions
https://softwareengineering.stackexchange.com/questions/363084/use-labels-or-nested-flet
not so good, rather disappointing
CL-USER> (ql:quickload :sblint) CL-USER> (sblint:run-lint-directory "~/Programming/Lisp/clops-gui/")
https://docs.gtk.org/gtk4/drawing-model.html
Some events, like mouse motion are compressed so that only a single mouse motion event per clock cycle
running animation
geometry changes, sizes and positions
redrawing what needs redrawing
Because of horrible documentation in Gtk4 I will need to implement my own file requester, possibly being inspired by Emacs
https://lisp-journey.gitlab.io/resources/
https://en.wikipedia.org/wiki/Archy_(software)
Archy has been compared as similar to the Emacs text editor, although its design begins from a clean slate.
file:~/.config/common-lisp/source-registry.conf.d/
(:tree #P"/home/jacek/Programming/Lisp/")
file:~/Programming/Lisp/lispy-experiments/window-canvas/src/window-canvas.lisp::1
file:~/Programming/Lisp/clops-gui/examples/example.lisp::1
file:src/gui-window.lisp::(defmethod add-child and the method below need to be somehow moved to gui-box
file:~/Programming/Lisp/lispy-experiments/window-canvas-boxes/notes.org::1
file:~/Programming/Lisp/clos-sweeper/tests/ file:~/Programming/Lisp/clos-sweeper/clos-sweeper.asd::(asdf:defsystem #:clos-sweeper/tests
file:~/Programming/Lisp/clops-gui/tests/terminal-test-loader.lisp::1
(ql:quickload :clops-gui/tests)
(asdf:test-system :clops-gui/tests)