Re-organize things so that bootstrap.ui doesn't load ui.text
parent
51e43d69ab
commit
474e74a232
|
@ -10,12 +10,4 @@ IN: bootstrap.ui
|
|||
{ [ os unix? ] [ "x11" ] }
|
||||
} cond
|
||||
] unless* "ui.backend." prepend require
|
||||
|
||||
"ui-text-backend" get [
|
||||
{
|
||||
{ [ os macosx? ] [ "core-text" ] }
|
||||
{ [ os windows? ] [ "pango" ] }
|
||||
{ [ os unix? ] [ "pango" ] }
|
||||
} cond
|
||||
] unless* "ui.text." prepend require
|
||||
] when
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
USING: accessors arrays assocs continuations kernel math models
|
||||
namespaces opengl sequences io combinators combinators.short-circuit
|
||||
fry math.vectors math.rectangles cache ui.gadgets ui.gestures
|
||||
ui.render ui.text ui.text.private ui.backend ui.gadgets.tracks
|
||||
ui.commands ;
|
||||
ui.render ui.backend ui.gadgets.tracks ui.commands ;
|
||||
IN: ui.gadgets.worlds
|
||||
|
||||
TUPLE: world < track
|
||||
|
@ -53,7 +52,6 @@ M: world request-focus-on ( child gadget -- )
|
|||
swap >>status
|
||||
swap >>title
|
||||
swap 1 track-add
|
||||
dup init-text-rendering
|
||||
dup request-focus ;
|
||||
|
||||
: <world> ( gadget title status -- world )
|
||||
|
@ -74,15 +72,20 @@ M: world remove-gadget
|
|||
2dup layers>> memq?
|
||||
[ layers>> delq ] [ call-next-method ] if ;
|
||||
|
||||
SYMBOL: flush-layout-cache-hook
|
||||
|
||||
flush-layout-cache-hook [ [ ] ] initialize
|
||||
|
||||
: (draw-world) ( world -- )
|
||||
dup handle>> [
|
||||
{
|
||||
[ init-gl ]
|
||||
[ draw-gadget ]
|
||||
[ finish-text-rendering ]
|
||||
[ text-handle>> [ purge-cache ] when* ]
|
||||
[ images>> [ purge-cache ] when* ]
|
||||
} cleave
|
||||
] with-gl-context ;
|
||||
] with-gl-context
|
||||
flush-layout-cache-hook get call( -- ) ;
|
||||
|
||||
: draw-world? ( world -- ? )
|
||||
#! We don't draw deactivated worlds, or those with 0 size.
|
||||
|
|
|
@ -18,12 +18,11 @@ M: core-text-renderer string-dim
|
|||
[ cached-line dim>> ]
|
||||
if-empty ;
|
||||
|
||||
M: core-text-renderer finish-text-rendering
|
||||
text-handle>> purge-cache
|
||||
M: core-text-renderer flush-layout-cache
|
||||
cached-lines get purge-cache ;
|
||||
|
||||
: rendered-line ( font string -- texture )
|
||||
world get text-handle>>
|
||||
world get world-text-handle
|
||||
[ cached-line [ image>> ] [ loc>> ] bi <texture> ]
|
||||
2cache ;
|
||||
|
||||
|
|
|
@ -14,12 +14,11 @@ M: pango-renderer string-dim
|
|||
[ " " string-dim { 0 1 } v* ]
|
||||
[ cached-layout logical-rect>> dim>> [ >integer ] map ] if-empty ;
|
||||
|
||||
M: pango-renderer finish-text-rendering
|
||||
text-handle>> purge-cache
|
||||
M: pango-renderer flush-layout-cache
|
||||
cached-layouts get purge-cache ;
|
||||
|
||||
: rendered-layout ( font string -- texture )
|
||||
world get text-handle>>
|
||||
world get world-text-handle
|
||||
[ cached-layout [ image>> ] [ text-position vneg ] bi <texture> ]
|
||||
2cache ;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel arrays sequences math math.order opengl opengl.gl
|
||||
strings fonts colors accessors ;
|
||||
strings fonts colors accessors namespaces ui.gadgets.worlds ;
|
||||
IN: ui.text
|
||||
|
||||
<PRIVATE
|
||||
|
@ -10,9 +10,13 @@ SYMBOL: font-renderer
|
|||
|
||||
HOOK: init-text-rendering font-renderer ( world -- )
|
||||
|
||||
HOOK: finish-text-rendering font-renderer ( world -- )
|
||||
: world-text-handle ( world -- handle )
|
||||
dup text-handle>> [ dup init-text-rendering ] unless
|
||||
text-handle>> ;
|
||||
|
||||
M: object finish-text-rendering drop ;
|
||||
HOOK: flush-layout-cache font-renderer ( -- )
|
||||
|
||||
[ flush-layout-cache ] flush-layout-cache-hook set-global
|
||||
|
||||
HOOK: string-dim font-renderer ( font string -- dim )
|
||||
|
||||
|
@ -68,4 +72,14 @@ M: array draw-text
|
|||
[ draw-string ]
|
||||
[ [ 0.0 ] 2dip string-height 0.0 glTranslated ] 2bi
|
||||
] with each
|
||||
] do-matrix ;
|
||||
] do-matrix ;
|
||||
|
||||
USING: vocabs.loader namespaces system combinators ;
|
||||
|
||||
"ui-backend" get [
|
||||
{
|
||||
{ [ os macosx? ] [ "core-text" ] }
|
||||
{ [ os windows? ] [ "pango" ] }
|
||||
{ [ os unix? ] [ "pango" ] }
|
||||
} cond
|
||||
] unless* "ui.text." prepend require
|
|
@ -4,8 +4,7 @@ USING: arrays assocs io kernel math models namespaces make dlists
|
|||
deques sequences threads sequences words continuations init
|
||||
combinators hashtables concurrency.flags sets accessors calendar fry
|
||||
destructors ui.gadgets ui.gadgets.private ui.gadgets.worlds
|
||||
ui.gadgets.tracks ui.gestures ui.backend ui.render ui.text
|
||||
ui.text.private ;
|
||||
ui.gadgets.tracks ui.gestures ui.backend ui.render ;
|
||||
IN: ui
|
||||
|
||||
<PRIVATE
|
||||
|
@ -63,7 +62,7 @@ M: world graft*
|
|||
: (ungraft-world) ( world -- )
|
||||
{
|
||||
[ handle>> select-gl-context ]
|
||||
[ text-handle>> dispose ]
|
||||
[ text-handle>> [ dispose ] when* ]
|
||||
[ images>> [ dispose ] when* ]
|
||||
[ hand-clicked close-global ]
|
||||
[ hand-gadget close-global ]
|
||||
|
@ -95,8 +94,7 @@ M: world ungraft*
|
|||
: restore-world ( world -- )
|
||||
{
|
||||
[ reset-world ]
|
||||
[ init-text-rendering ]
|
||||
[ f >>images drop ]
|
||||
[ f >>text-handle f >>images drop ]
|
||||
[ restore-gadget ]
|
||||
} cleave ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue