Reset mouse selection after table model changes

db4
Slava Pestov 2009-02-20 20:52:33 -06:00
parent 591472f7a9
commit ee7bbf8654
1 changed files with 11 additions and 10 deletions

View File

@ -1,11 +1,12 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays colors colors.constants fry kernel math USING: accessors arrays colors colors.constants fry kernel math
math.rectangles math.order math.vectors namespaces opengl sequences math.functions math.rectangles math.order math.vectors namespaces
ui.gadgets ui.gadgets.scrollers ui.gadgets.status-bar opengl sequences ui.gadgets ui.gadgets.scrollers ui.gadgets.status-bar
ui.gadgets.worlds ui.gestures ui.render ui.pens.solid ui.text ui.commands ui.gadgets.worlds ui.gestures ui.render ui.pens.solid ui.text
ui.images ui.gadgets.menus ui.gadgets.line-support math.rectangles ui.commands ui.images ui.gadgets.menus ui.gadgets.line-support
models math.ranges sequences combinators fonts locals strings ; math.rectangles models math.ranges sequences combinators fonts locals
strings ;
IN: ui.gadgets.tables IN: ui.gadgets.tables
! Row rendererer protocol ! Row rendererer protocol
@ -61,7 +62,7 @@ GENERIC: cell-height ( font cell -- y )
GENERIC: draw-cell ( font cell -- ) GENERIC: draw-cell ( font cell -- )
M: string cell-width text-width ; M: string cell-width text-width ;
M: string cell-height text-height ; M: string cell-height text-height ceiling ;
M: string draw-cell draw-text ; M: string draw-cell draw-text ;
M: image-name cell-width nip image-dim first ; M: image-name cell-width nip image-dim first ;
@ -245,9 +246,12 @@ PRIVATE>
[ 2drop ] [ 2drop ]
if ; if ;
: hide-mouse-help ( table -- )
f >>mouse-index [ hide-status ] [ relayout-1 ] bi ;
M: table model-changed M: table model-changed
[ nip ] [ initial-selected-index ] 2bi { [ nip ] [ initial-selected-index ] 2bi {
[ >>selected-index drop ] [ >>selected-index f >>mouse-index drop ]
[ show-row-summary ] [ show-row-summary ]
[ drop update-selected-value ] [ drop update-selected-value ]
[ drop relayout ] [ drop relayout ]
@ -316,9 +320,6 @@ PRIVATE>
: next-page ( table -- ) : next-page ( table -- )
1 prev/next-page ; 1 prev/next-page ;
: hide-mouse-help ( table -- )
f >>mouse-index [ hide-status ] [ relayout-1 ] bi ;
: valid-row? ( row table -- ? ) : valid-row? ( row table -- ? )
control-value length 1- 0 swap between? ; control-value length 1- 0 swap between? ;