Fix performance regression
parent
f5acf7e3d6
commit
91036cf323
|
@ -166,14 +166,13 @@ DEFER: relayout
|
||||||
|
|
||||||
DEFER: in-layout?
|
DEFER: in-layout?
|
||||||
|
|
||||||
: do-invalidate ( gadget -- gadget )
|
GENERIC: dim-changed ( gadget -- )
|
||||||
in-layout? get [ dup invalidate ] [ dup invalidate* ] if ;
|
|
||||||
|
M: gadget dim-changed
|
||||||
|
in-layout? get [ invalidate ] [ invalidate* ] if ;
|
||||||
|
|
||||||
M: gadget (>>dim) ( dim gadget -- )
|
M: gadget (>>dim) ( dim gadget -- )
|
||||||
2dup dim>> =
|
2dup dim>> = [ 2drop ] [ tuck call-next-method dim-changed ] if ;
|
||||||
[ 2drop ]
|
|
||||||
[ tuck call-next-method do-invalidate drop ]
|
|
||||||
if ;
|
|
||||||
|
|
||||||
GENERIC: pref-dim* ( gadget -- dim )
|
GENERIC: pref-dim* ( gadget -- dim )
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,6 @@ USING: io kernel math namespaces math.vectors ui.gadgets
|
||||||
ui.gadgets.packs accessors math.geometry.rect ;
|
ui.gadgets.packs accessors math.geometry.rect ;
|
||||||
IN: ui.gadgets.incremental
|
IN: ui.gadgets.incremental
|
||||||
|
|
||||||
! Incremental layout allows adding lines to panes to be O(1).
|
|
||||||
! Note that incremental packs are distinct from ordinary packs
|
|
||||||
! defined in layouts.factor, since you don't want all packs to
|
|
||||||
! be incremental. In particular, incremental packs do not
|
|
||||||
! support non-default values for pack-align, pack-fill and
|
|
||||||
! pack-gap.
|
|
||||||
|
|
||||||
! The cursor is the current size of the incremental pack.
|
|
||||||
! New gadgets are added at
|
|
||||||
! incremental-cursor gadget-orientation v*
|
|
||||||
|
|
||||||
TUPLE: incremental < pack cursor ;
|
TUPLE: incremental < pack cursor ;
|
||||||
|
|
||||||
: <incremental> ( -- incremental )
|
: <incremental> ( -- incremental )
|
||||||
|
@ -29,29 +18,33 @@ M: incremental pref-dim*
|
||||||
|
|
||||||
: next-cursor ( gadget incremental -- cursor )
|
: next-cursor ( gadget incremental -- cursor )
|
||||||
[
|
[
|
||||||
swap rect-dim swap cursor>>
|
[ rect-dim ] [ cursor>> ] bi*
|
||||||
2dup v+ >r vmax r>
|
[ vmax ] [ v+ ] 2bi
|
||||||
] keep orientation>> set-axis ;
|
] keep orientation>> set-axis ;
|
||||||
|
|
||||||
: update-cursor ( gadget incremental -- )
|
: update-cursor ( gadget incremental -- )
|
||||||
[ next-cursor ] keep (>>cursor) ;
|
tuck next-cursor >>cursor drop ;
|
||||||
|
|
||||||
: incremental-loc ( gadget incremental -- )
|
: incremental-loc ( gadget incremental -- )
|
||||||
[ cursor>> ] [ orientation>> ] bi v*
|
[ cursor>> ] [ orientation>> ] bi v*
|
||||||
>>loc drop ;
|
>>loc drop ;
|
||||||
|
|
||||||
: prefer-incremental ( gadget -- )
|
: prefer-incremental ( gadget -- ) USE: slots.private
|
||||||
dup forget-pref-dim dup pref-dim >>dim drop ;
|
dup forget-pref-dim dup pref-dim >>dim drop ;
|
||||||
|
|
||||||
|
M: incremental dim-changed drop ;
|
||||||
|
|
||||||
: add-incremental ( gadget incremental -- )
|
: add-incremental ( gadget incremental -- )
|
||||||
not-in-layout
|
not-in-layout
|
||||||
2dup swap (add-gadget) drop
|
2dup swap (add-gadget) drop
|
||||||
|
t in-layout? [
|
||||||
over prefer-incremental
|
over prefer-incremental
|
||||||
over layout-later
|
over layout-later
|
||||||
2dup incremental-loc
|
2dup incremental-loc
|
||||||
tuck update-cursor
|
tuck update-cursor
|
||||||
dup prefer-incremental
|
dup prefer-incremental
|
||||||
parent>> [ invalidate* ] when* ;
|
parent>> [ invalidate* ] when*
|
||||||
|
] with-variable ;
|
||||||
|
|
||||||
: clear-incremental ( incremental -- )
|
: clear-incremental ( incremental -- )
|
||||||
not-in-layout
|
not-in-layout
|
||||||
|
|
Loading…
Reference in New Issue