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