(loop p)
w))))
#t)
- ((#\? #\c-h)
- (popup-help widget))
+ ((#\? #\h #\H #\c-h |F1|)
+ (popup-help widget)
+ #t)
((|Up|)
(cond ((fix:= bits char-bit:control) (tilt! widget 5.))
((fix:= bits 0) (step! widget 1.))
(gtk-widget-queue-draw widget)
#t)
+(define help-window #f)
+
(define (popup-help widget)
- ;; For now, just write to stdout.
(declare (ignore widget))
- (display "ESC - quit
-Up/Down - move forward/backward
-Left/Right - turn left/right
-Ctrl-Up/Down - tilt up/down\n")
- #t)
+ (if (or (not help-window)
+ (gtk-widget-destroyed? help-window))
+ (let ((window (gtk-window-new 'toplevel))
+ (label (gtk-label-new
+ "Key - Viewport command
+ESC - Quit.
+Up/Down - Move forward/backward.
+Left/Right - Turn left/right.
+Ctrl-Up/Down - Tilt up/down.")))
+ (gtk-window-set-type-hint window 'utility)
+ (gtk-window-set-accept-focus window #f)
+ (gtk-window-set-title window "Help")
+ (gtk-container-set-border-width window 20)
+ (gtk-container-add window label)
+ (set! help-window window)
+ (gtk-widget-show-all window)))
+ (gtk-window-present help-window))
(define-integrable (flo:3d x y z)
(let ((v (flo:vector-cons 3)))
(%trace "key-press-handler "widget" "key" "bits)
;;(declare (ignore bits))
(case key
- ((#\escape #\q #\Q) (gtk-widget-destroy (gtk-widget-parent widget)))
+ ((#\escape #\q #\Q)
+ (gtk-widget-destroy (gtk-widget-parent widget)))
+ ((#\? #\h #\H #\c-h |F1|)
+ (popup-help widget)
+ #t)
((#\a #\A)
(if (glxgears-demo-animate? widget)
(begin
(set-glxgears-demo-view-roty!
widget (+ incr (glxgears-demo-view-roty widget))))
+(define help-window #f)
+
+(define (popup-help widget)
+ (declare (ignore widget))
+ (if (or (not help-window)
+ (gtk-widget-destroyed? help-window))
+ (let ((window (gtk-window-new 'toplevel))
+ (label (gtk-label-new
+ "Key - GLX Gears demo command.
+ESC - Quit.
+Up/Down/Left/Right - Orbit.
+A - Toggle animation.
+I - Toggle frame rate reports.")))
+ (gtk-window-set-type-hint window 'utility)
+ (gtk-window-set-accept-focus window #f)
+ (gtk-window-set-title window "Help")
+ (gtk-container-set-border-width window 20)
+ (gtk-container-add window label)
+ (set! help-window window)
+ (gtk-widget-show-all window)))
+ (gtk-window-present help-window))
+
(define (motion-handler widget modifiers x y)
(%trace2 "motion-handler "widget" "modifiers" "x"x"y)
#f)
fix-rect-x fix-rect-y fix-rect-width fix-rect-height
fix-widget-geometry fix-widget-window)
(import (gtk)
+ <fix-widget>
error-if-null
- gtk-window-new
- gtk-widget-destroy gtk-widget-parent
- gtk-widget-show-all
- gtk-widget-queue-draw
- set-gtk-widget-draw-callback!
- gtk-window-set-title
- set-gtk-window-delete-event-callback!
- gtk-container-set-border-width
+ fix-widget-new-geometry-callback
+ fix-widget-realize-callback
gtk-container-add
+ gtk-container-set-border-width
+ gtk-label-new
+ gtk-widget-destroy
+ gtk-widget-destroyed?
+ gtk-widget-parent
+ gtk-widget-queue-draw
gtk-widget-show-all
- <fix-widget>
- fix-widget-realize-callback
- fix-widget-new-geometry-callback
- set-fix-widget-key-press-handler!)
+ gtk-window-new
+ gtk-window-present
+ gtk-window-set-accept-focus
+ gtk-window-set-title
+ gtk-window-set-type-hint
+ set-fix-widget-key-press-handler!
+ set-gtk-widget-draw-callback!
+ set-gtk-window-delete-event-callback!)
(export (gl)
make-glx-widget <glx-widget>
with-glx-widget glx:swap-buffers
(files "gl-glxgears")
(parent (gl))
(import (gtk)
- gtk-widget-destroyed? gtk-widget-destroy
- gtk-widget-parent gtk-widget-show-all gtk-widget-queue-draw
- set-gtk-widget-draw-callback!
- gtk-container-add gtk-container-set-border-width
- gtk-window-new gtk-window-set-title
- set-gtk-window-delete-event-callback!
fix-widget-new-geometry-callback
fix-widget-realize-callback
fix-widget-unrealize-callback
- set-fix-widget-key-press-handler!
+ gtk-container-add
+ gtk-container-set-border-width
+ gtk-label-new
+ gtk-widget-destroy
+ gtk-widget-destroyed?
+ gtk-widget-parent
+ gtk-widget-queue-draw
+ gtk-widget-show-all
+ gtk-window-new
+ gtk-window-present
+ gtk-window-set-accept-focus
+ gtk-window-set-title
+ gtk-window-set-type-hint
set-fix-widget-button-handler!
set-fix-widget-enter-notify-handler!
set-fix-widget-focus-change-handler!
+ set-fix-widget-key-press-handler!
set-fix-widget-leave-notify-handler!
set-fix-widget-motion-handler!
- set-fix-widget-visibility-notify-handler!)
+ set-fix-widget-visibility-notify-handler!
+ set-gtk-widget-draw-callback!
+ set-gtk-window-delete-event-callback!)
(import (gtk fix-layout)
fix-rect-width fix-rect-height
fix-widget-geometry)