factor/library/ui/world.factor

46 lines
1.2 KiB
Factor
Raw Normal View History

2006-03-12 23:21:01 -05:00
! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2005-01-31 22:32:06 -05:00
IN: gadgets
2006-03-21 02:40:16 -05:00
USING: errors freetype gadgets-layouts generic hashtables kernel
2006-03-23 17:46:35 -05:00
math namespaces opengl sequences ;
2005-02-01 19:00:16 -05:00
2005-01-31 22:32:06 -05:00
! The world gadget is the top level gadget that all (visible)
2006-03-18 01:57:57 -05:00
! gadgets are contained in.
! fonts: mapping font tuples to sprite vectors
! handle: native resource
2006-03-24 03:28:46 -05:00
TUPLE: world status focus fonts handle ;
2006-03-18 01:57:57 -05:00
: free-fonts ( world -- )
dup world-handle select-gl-context
2006-03-18 01:57:57 -05:00
world-fonts dup hash-values [ free-sprites ] each
clear-hash ;
: font-sprites ( font world -- sprites )
world-fonts [ drop V{ } clone ] cache ;
2005-08-26 00:55:56 -04:00
: add-status ( status world -- )
[ set-world-status ] 2keep @bottom frame-add ;
C: world ( gadget status -- world )
dup delegate>frame
t over set-gadget-root?
2006-03-18 01:57:57 -05:00
H{ } clone over set-world-fonts
[ add-status ] keep
2006-03-24 22:58:03 -05:00
[ @center frame-add ] 2keep
swap request-focus ;
2005-07-08 01:32:29 -04:00
GENERIC: find-world ( gadget -- world )
M: f find-world ;
M: gadget find-world gadget-parent find-world ;
M: world find-world ;
2006-03-17 20:24:28 -05:00
M: world pref-dim* ( world -- dim )
delegate pref-dim* { 1024 768 0 } vmin ;
2006-03-19 01:07:36 -05:00
: focused-ancestors ( world -- seq )
world-focus parents reverse-slice ;