2009-02-09 21:57:26 -05:00
|
|
|
! Copyright (C) 2007 Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-03-10 17:58:35 -04:00
|
|
|
USING: accessors images images.loader io.pathnames kernel namespaces
|
|
|
|
opengl opengl.gl opengl.textures sequences strings ui ui.gadgets
|
2009-02-10 19:42:21 -05:00
|
|
|
ui.gadgets.panes ui.render ;
|
2009-02-09 21:57:26 -05:00
|
|
|
IN: images.viewer
|
|
|
|
|
|
|
|
TUPLE: image-gadget < gadget { image image } ;
|
|
|
|
|
|
|
|
M: image-gadget pref-dim*
|
2009-02-10 19:42:21 -05:00
|
|
|
image>> dim>> ;
|
|
|
|
|
2009-03-02 20:38:28 -05:00
|
|
|
: draw-image ( image -- )
|
2009-02-10 19:42:21 -05:00
|
|
|
0 0 glRasterPos2i 1.0 -1.0 glPixelZoom
|
2009-03-10 17:58:35 -04:00
|
|
|
[ dim>> first2 ] [ component-order>> component-order>format ] [ bitmap>> ] tri
|
|
|
|
glDrawPixels ;
|
2009-02-09 21:57:26 -05:00
|
|
|
|
|
|
|
M: image-gadget draw-gadget* ( gadget -- )
|
2009-02-27 02:01:51 -05:00
|
|
|
image>> draw-image ;
|
2009-02-09 21:57:26 -05:00
|
|
|
|
|
|
|
: <image-gadget> ( image -- gadget )
|
2009-03-07 02:22:21 -05:00
|
|
|
\ image-gadget new
|
2009-02-09 21:57:26 -05:00
|
|
|
swap >>image ;
|
|
|
|
|
|
|
|
: image-window ( path -- gadget )
|
2009-02-12 05:25:33 -05:00
|
|
|
[ load-image <image-gadget> dup ] [ open-window ] bi ;
|
2009-02-09 21:57:26 -05:00
|
|
|
|
2009-02-10 19:52:28 -05:00
|
|
|
GENERIC: image. ( object -- )
|
2009-02-09 21:57:26 -05:00
|
|
|
|
2009-02-10 19:52:28 -05:00
|
|
|
: default-image. ( path -- )
|
|
|
|
<image-gadget> gadget. ;
|
2009-02-09 21:57:26 -05:00
|
|
|
|
2009-02-12 05:25:33 -05:00
|
|
|
M: string image. ( image -- ) load-image default-image. ;
|
2009-02-09 21:57:26 -05:00
|
|
|
|
2009-02-12 05:25:33 -05:00
|
|
|
M: pathname image. ( image -- ) load-image default-image. ;
|
2009-02-10 19:52:28 -05:00
|
|
|
|
|
|
|
M: image image. ( image -- ) default-image. ;
|