From 6d447cb939c8ab96f5591c4316ee8862cdd34c13 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 20 Sep 2012 17:52:54 -0700 Subject: [PATCH] ui.gadgets.tables: cache table rows only on model-changed. --- basis/ui/gadgets/tables/tables.factor | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/basis/ui/gadgets/tables/tables.factor b/basis/ui/gadgets/tables/tables.factor index 7909526e86..a6268af901 100644 --- a/basis/ui/gadgets/tables/tables.factor +++ b/basis/ui/gadgets/tables/tables.factor @@ -80,12 +80,6 @@ CONSTANT: image-padding 2 M: image-name cell-dim nip image-dim first2 image-padding ; M: image-name draw-cell nip draw-image ; -: table-rows ( table -- rows ) - [ control-value ] [ renderer>> ] bi '[ _ row-columns ] map ; - -: update-table-rows ( table -- ) - [ table-rows ] [ rows<< ] bi ; inline - : column-offsets ( widths gap -- x xs ) [ 0 ] dip '[ _ + + ] accumulate ; @@ -129,9 +123,7 @@ CONSTANT: column-title-background COLOR: light-gray [ [ + ] change-nth ] [ 3drop ] if ; M: table layout* - [ update-table-rows ] - [ update-cached-widths ] - [ update-filled-column ] tri ; + [ update-cached-widths ] [ update-filled-column ] bi ; : row-rect ( table row -- rect ) [ [ line-height ] dip * 0 swap 2array ] @@ -279,6 +271,13 @@ PRIVATE> [ model>> value>> ] [ renderer>> ] bi '[ _ row-value? ] with find drop ; +: update-table-rows ( table -- ) + [ + [ control-value ] [ renderer>> ] bi + '[ _ row-columns ] map + ] + [ rows<< ] bi ; inline + : update-selection ( table -- ) [ { @@ -294,6 +293,7 @@ PRIVATE> M: table model-changed nip + dup update-table-rows dup update-selection dup update-mouse-index [ dup mouse-index>> show-row-summary ] [ relayout ] bi ;