-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved out the demo of multi-window functionality to a new example
- Loading branch information
Showing
2 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*)) |