Skip to content

Commit

Permalink
Moved out the demo of multi-window functionality to a new example
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jun 21, 2010
1 parent 7dd0a3e commit 1cc1d45
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
7 changes: 2 additions & 5 deletions examples/basic.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
(when (eq keysym :escape)
(uid:close-window window)))

(defparameter *engine* (make-instance 'my-engine))
(defparameter *engine* (make-instance 'my-engine :windows (list (make-instance 'my-window))))

(defun run ()
(let ((window1 (make-instance 'my-window))
(window2 (make-instance 'my-window)))
(setf (uid:windows *engine*) (list window1 window2))
(uid:run *engine*)))
(uid:run *engine*))
47 changes: 47 additions & 0 deletions examples/multi-window.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(defpackage #:until-it-dies.examples.multi-window
(:use :cl))
(in-package #:until-it-dies.examples.multi-window)

(defclass my-engine (uid:engine)
()
(:default-initargs :fps-limit 60))

(defclass my-window (uid:window)
()
(:default-initargs :clear-color (uid:mix-colors uid:*blue* uid:*white* uid:*green*)))

(defclass my-big-window (my-window)
()
(:default-initargs
:width 800 :height 600))

(defclass my-small-window (my-window)
()
(:default-initargs
:width 640 :height 480))

(defmethod uid:on-draw ((window my-window))
(uid:clear window)
(uid:draw-rectangle (- (/ (uid:right-edge (uid:view window)) 2) 25)
(- (/ (uid:top-edge (uid:view window)) 2) 25)
50 50 :color uid:*red*))

(defmethod uid:on-key-down :after ((window my-window) keycode keysym string)
(declare (ignore keycode string))
(when (eq keysym :escape)
(uid:close-window window)))

(defmethod uid:on-key-down ((window my-big-window) keycode keysym string)
(format t "~&Press on Big Window - Keycode: [~S], Keysym: [~S], String: [~S]~%"
keycode keysym string))

(defmethod uid:on-key-down ((window my-small-window) keycode keysym string)
(format t "~&Press on Small Window - Keycode: [~S], Keysym: [~S], String: [~S]~%"
keycode keysym string))

(defparameter *engine* (make-instance 'my-engine
:windows (list (make-instance 'my-big-window)
(make-instance 'my-small-window))))

(defun run ()
(uid:run *engine*))

0 comments on commit 1cc1d45

Please sign in to comment.