(defvar *patch-list* nil)
(defvar *glut-window-opened* nil)
-(defvar *dimensions* nil)
+(defvar *dimensions* nil) ; This is a useful placeholder for other view properties
(defvar *window-width* 1024)
(defvar *window-height* 768)
(gl:viewport 0 0 *window-width* *window-height*)
(gl:matrix-mode :projection)
- (gl:with-pushed-matrix
- (gl:load-identity)
- (gl:ortho 0 *window-width* 0 *window-height* 0 5000)
- (render-widgets)
+ (let*
+ ((left (getf *dimensions* :left))
+ (top (getf *dimensions* :top))
+ (view-x1 left)
+ (view-x2 (+ view-x1 width))
+ (view-y1 (- *window-height* height top))
+ (view-y2 (- *window-height* top)))
+
+ (gl:with-pushed-matrix
+ (gl:load-identity)
+ (gl:ortho 0 *window-width* 0 *window-height* 0 5000)
+ (render-widgets)
- (gl:begin :lines)
- (gl:vertex (- *window-width* width 10) (- *window-height* height 10))
- (gl:vertex (- *window-width* width 10) (- *window-height* 9))
+ (gl:begin :lines)
+ (gl:vertex view-x1 view-y1)
+ (gl:vertex view-x1 (+ view-y2 1))
- (gl:vertex (- *window-width* width 10) (- *window-height* 9))
- (gl:vertex (- *window-width* 9) (- *window-height* 9))
+ (gl:vertex view-x1 (+ view-y2 1))
+ (gl:vertex (+ view-x2 1) (+ view-y2 1))
- (gl:vertex (- *window-width* 9) (- *window-height* 9))
- (gl:vertex (- *window-width* 9) (- *window-height* height 10))
+ (gl:vertex (+ view-x2 1) (+ view-y2 1))
+ (gl:vertex (+ view-x2 1) (- view-y1 1))
- (gl:vertex (- *window-width* 9) (- *window-height* height 10))
- (gl:vertex (- *window-width* width 10) (- *window-height* height 10))
- (gl:end))
+ (gl:vertex (+ view-x2 1) view-y1)
+ (gl:vertex (- view-x1 1) view-y1)
+ (gl:end))
- (gl:viewport (- *window-width* width 10) (- *window-height* height 10) width height)
- (render-scene)))
+ (gl:viewport view-x1 view-y1 width height)
+ (render-scene))))
(defun display ()
(render)
See http://github.com/frankduncan/clnl for more information about CLNL and to
keep apprised of any updates that may happen.")
-(defun initialize (&key dims buttons)
- "INITIALIZE &key DIMS BUTTONS => RESULT
+(defun initialize (&key dims view buttons)
+ "INITIALIZE &key DIMS VIEW BUTTONS => RESULT
DIMS: (:xmin XMIN :xmax XMAX :ymin YMIN :ymax YMAX :patch-size PATCH-SIZE)
+ VIEW: (:left LEFT :top TOP)
BUTTONS: BUTTON-DEF*
BUTTON-DEF: (:left LEFT :top TOP :height HEIGHT :width WIDTH :display DISPLAY)
the interface lives. From here, one can go into headless or running
mode, but for certain things this interface will still need to act,
and also allows for bringing up and taking down of visual elements."
- (setf *dimensions* dims)
+ (setf *dimensions* (append dims view))
(let
((known-button-names nil))
(setf *widgets*
,@(when initialize-interface
`((clnl-interface:initialize
:dims ',(clnl-model:world-dimensions model)
+ :view ',(clnl-model:view model)
:buttons ',(clnl-model:buttons model)))))))))
(setf (documentation 'model->single-form-lisp 'function)
,@(when initialize-interface
`((clnl-interface:initialize
:dims ',(clnl-model:world-dimensions model)
+ :view ',(clnl-model:view model)
:buttons ',(clnl-model:buttons model)))))
,@(when netlogo-callback-fn
`((defun ,netlogo-callback-fn (,(intern "NETLOGO-CODE" *model-package*))
(make-model
:code ""
:interface (list
- (make-view :min-pxcor -5 :max-pxcor 5 :min-pycor -5 :max-pycor 5 :patch-size 13d0))))
+ (make-view :left 10 :top 10 :min-pxcor -5 :max-pxcor 5 :min-pycor -5 :max-pycor 5 :patch-size 13d0))))
(defun read-from-nlogo (str)
"READ-FROM-NLOGO STR => MODEL
:display (button-display-name widget)))))
(model-interface model))))
+(defun view (model)
+ "BUTTONS MODEL => VIEW-DEF
+
+ VIEW-DEF: (:left LEFT :top TOP)
+
+ARGUMENTS AND VALUES:
+
+ MODEL: A valid model
+ LEFT: An integer representing the left position
+ TOP: An integer representing the top position
+
+DESCRIPTION:
+
+ Returns the view definition that get declared in the view of the
+ MODEL. This is used to initialize the interface."
+ (let
+ ((view (find-if #'view-p (model-interface model))))
+ (list :left (view-left view) :top (view-top view))))
+
(defun code (model)
"CODE MODEL => CODE