1 ! Copyright (C) 2009 Eduardo Cavazos
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel namespaces opengl ui.render ui.gadgets accessors ;
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12 TUPLE: slate < gadget action pdim graft ungraft ;
14 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 : init-slate ( slate -- slate )
23 : <slate> ( action -- slate )
28 M: slate pref-dim* ( slate -- dim ) pdim>> ;
30 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32 USING: combinators arrays sequences math math.geometry
33 opengl.gl ui.gadgets.worlds ;
35 : screen-y* ( gadget -- loc )
44 : screen-loc* ( gadget -- loc )
52 : setup-viewport ( gadget -- gadget )
61 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
63 : default-coordinate-system ( gadget -- gadget )
75 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
77 M: slate graft* ( slate -- ) graft>> call ;
78 M: slate ungraft* ( slate -- ) ungraft>> call ;
80 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
82 GENERIC: establish-coordinate-system ( gadget -- gadget )
84 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86 M: slate establish-coordinate-system ( slate -- slate )
87 default-coordinate-system ;
89 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
91 GENERIC: draw-slate ( slate -- slate )
93 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
95 M: slate draw-slate ( slate -- slate ) dup action>> call ;
97 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
99 M: slate draw-gadget* ( slate -- )
101 GL_PROJECTION glMatrixMode glPushMatrix glLoadIdentity
103 establish-coordinate-system
105 GL_MODELVIEW glMatrixMode glPushMatrix glLoadIdentity
111 GL_PROJECTION glMatrixMode glPopMatrix glLoadIdentity
112 GL_MODELVIEW glMatrixMode glPopMatrix glLoadIdentity
116 ! The world coordinate system is a little wacky:
117 dup { [ drop 0 ] [ width ] [ height ] [ drop 0 ] } cleave -1 1 glOrtho
122 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!