Skip to content

Commit

Permalink
Add file dropping to window
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcman committed Apr 18, 2019
1 parent 457b663 commit 886e7bd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/window-opengl-glfw3/window.lisp
Expand Up @@ -98,6 +98,20 @@ for the current implementation."
(with-float-traps-restored
(push (list char mod-keys) *char-keys*))
)
;;;;;;
(defmacro define-drop-callback (name (window count paths) &body body)
`(claw:defcallback ,name :void ((,window (:pointer %glfw:window))
(,count :int)
(,paths (:pointer (:pointer :char))))
,@body))
;;;FIXME::move to bodge-glfw?
(define-drop-callback drop-callback (window count paths)
(declare (ignorable window))
(with-float-traps-restored
(dotimes (index count)
(push
(cffi:foreign-string-to-lisp (cffi:mem-aref paths :pointer index))
*dropped-files*))))
;;;
(glfw:define-cursor-pos-callback cursor-callback (window x y)
(declare (ignorable window))
Expand Down Expand Up @@ -133,11 +147,16 @@ for the current implementation."
(defparameter *alt* nil)
(defparameter *super* nil)
(defparameter *char-keys* ())
(defparameter *dropped-files* ())
(defun poll ()
#+nil
(when *char-keys*
(print *char-keys*))
(setf *char-keys* nil)
#+nil
(when *dropped-files*
(print *dropped-files*))
(setf *dropped-files* nil)
(setq *status* (let ((value (%glfw:window-should-close *window*)))
(cond ((eql value %glfw:+true+) t)
((eql value %glfw:+false+) nil)
Expand Down Expand Up @@ -186,6 +205,7 @@ for the current implementation."
;;(%glfw:set-char-callback window (cffi:get-callback 'char-callback))
(%glfw:set-char-mods-callback window (cffi:get-callback 'char-mods-callback))
(%glfw:set-cursor-pos-callback window (cffi:get-callback 'cursor-callback))
(%glfw:set-drop-callback window (cffi:get-callback 'drop-callback))
)
(defun wrapper (func &optional (params
'(:title "window"
Expand Down

0 comments on commit 886e7bd

Please sign in to comment.