use 1&& in a few places, clean up some more ui code
parent
a273cbb68e
commit
474e02020c
|
|
@ -107,9 +107,9 @@ CONSTANT: key-codes
|
||||||
: valid-input? ( string gesture -- ? )
|
: valid-input? ( string gesture -- ? )
|
||||||
over empty? [ 2drop f ] [
|
over empty? [ 2drop f ] [
|
||||||
mods>> { f { S+ } } member? [
|
mods>> { f { S+ } } member? [
|
||||||
[ [ 127 = not ] [ CHAR: \s >= ] bi and ] all?
|
[ { [ 127 = not ] [ CHAR: \s >= ] } 1&& ] all?
|
||||||
] [
|
] [
|
||||||
[ [ 127 = not ] [ CHAR: \s >= ] [ alpha? not ] tri and and ] all?
|
[ { [ 127 = not ] [ CHAR: \s >= ] [ alpha? not ] } 1&& ] all?
|
||||||
] if
|
] if
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
! Copyright (C) 2005, 2009 Slava Pestov.
|
! Copyright (C) 2005, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays kernel math models namespaces sequences
|
USING: accessors arrays assocs classes classes.tuple colors
|
||||||
strings quotations assocs combinators classes colors colors.constants
|
colors.constants combinators combinators.short-circuit
|
||||||
classes.tuple opengl opengl.gl math.vectors ui.commands ui.gadgets
|
combinators.smart fry kernel locals math math.rectangles
|
||||||
ui.gadgets.borders ui.gadgets.labels ui.gadgets.tracks
|
math.vectors models namespaces opengl opengl.gl quotations
|
||||||
ui.gadgets.packs ui.gadgets.worlds ui.gestures ui.pens ui.pens.solid
|
sequences strings ui.commands ui.gadgets ui.gadgets.borders
|
||||||
ui.pens.image ui.pens.tile math.rectangles locals fry
|
ui.gadgets.labels ui.gadgets.packs ui.gadgets.tracks
|
||||||
combinators.smart ;
|
ui.gadgets.worlds ui.gestures ui.pens ui.pens.image
|
||||||
|
ui.pens.solid ui.pens.tile ;
|
||||||
FROM: models => change-model ;
|
FROM: models => change-model ;
|
||||||
IN: ui.gadgets.buttons
|
IN: ui.gadgets.buttons
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ PRIVATE>
|
||||||
|
|
||||||
: button-update ( button -- )
|
: button-update ( button -- )
|
||||||
dup
|
dup
|
||||||
[ mouse-clicked? ] [ button-rollover? ] bi and
|
{ [ mouse-clicked? ] [ button-rollover? ] } 1&&
|
||||||
buttons-down? and
|
buttons-down? and
|
||||||
>>pressed?
|
>>pressed?
|
||||||
relayout-1 ;
|
relayout-1 ;
|
||||||
|
|
@ -42,8 +43,9 @@ PRIVATE>
|
||||||
dup "" swap show-status button-update ;
|
dup "" swap show-status button-update ;
|
||||||
|
|
||||||
: button-clicked ( button -- )
|
: button-clicked ( button -- )
|
||||||
dup button-update
|
[ ]
|
||||||
dup button-rollover?
|
[ button-update ]
|
||||||
|
[ button-rollover? ] tri
|
||||||
[ dup quot>> call( button -- ) ] [ drop ] if ;
|
[ dup quot>> call( button -- ) ] [ drop ] if ;
|
||||||
|
|
||||||
button H{
|
button H{
|
||||||
|
|
@ -67,7 +69,9 @@ C: <button-pen> button-pen
|
||||||
|
|
||||||
: button-pen ( button pen -- button pen )
|
: button-pen ( button pen -- button pen )
|
||||||
over find-button {
|
over find-button {
|
||||||
{ [ dup [ pressed?>> ] [ selected?>> ] bi and ] [ drop pressed-selected>> ] }
|
{ [ dup { [ pressed?>> ] [ selected?>> ] } 1&& ]
|
||||||
|
[ drop pressed-selected>>
|
||||||
|
] }
|
||||||
{ [ dup pressed?>> ] [ drop pressed>> ] }
|
{ [ dup pressed?>> ] [ drop pressed>> ] }
|
||||||
{ [ dup selected?>> ] [ drop selected>> ] }
|
{ [ dup selected?>> ] [ drop selected>> ] }
|
||||||
{ [ dup button-rollover? ] [ drop rollover>> ] }
|
{ [ dup button-rollover? ] [ drop rollover>> ] }
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ M: glue pref-dim* drop { 0 0 } ;
|
||||||
length 1 + * [-] ; inline
|
length 1 + * [-] ; inline
|
||||||
|
|
||||||
: -center) ( pref-dim gap filled-cell dims -- )
|
: -center) ( pref-dim gap filled-cell dims -- )
|
||||||
[ nip available-space ] 2keep [ remove-nth sum [-] ] 2keep set-nth ; inline
|
[ nip available-space ]
|
||||||
|
[ [ remove-nth sum [-] ] [ set-nth ] 2bi ] 2bi ; inline
|
||||||
|
|
||||||
: (fill-center) ( frame grid-layout quot1 quot2 -- ) (fill- -center) ; inline
|
: (fill-center) ( frame grid-layout quot1 quot2 -- ) (fill- -center) ; inline
|
||||||
|
|
||||||
|
|
@ -35,7 +36,7 @@ M: glue pref-dim* drop { 0 0 } ;
|
||||||
[ [ second ] [ row-heights>> ] (fill-center) ] 2bi ;
|
[ [ second ] [ row-heights>> ] (fill-center) ] 2bi ;
|
||||||
|
|
||||||
: <frame-layout> ( frame -- grid-layout )
|
: <frame-layout> ( frame -- grid-layout )
|
||||||
dup <grid-layout> [ fill-center ] keep ;
|
dup <grid-layout> [ fill-center ] [ ] bi ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ M: gadget contains-point? ( loc gadget -- ? )
|
||||||
: pick-up ( point gadget -- child/f )
|
: pick-up ( point gadget -- child/f )
|
||||||
2dup [ dup point>rect ] dip children-on
|
2dup [ dup point>rect ] dip children-on
|
||||||
[ contains-point? ] with find-last nip
|
[ contains-point? ] with find-last nip
|
||||||
[ [ loc>> v- ] keep pick-up ] [ nip ] ?if ;
|
[ [ loc>> v- ] [ pick-up ] bi ] [ nip ] ?if ;
|
||||||
|
|
||||||
: max-dim ( dims -- dim ) { 0 0 } [ vmax ] reduce ;
|
: max-dim ( dims -- dim ) { 0 0 } [ vmax ] reduce ;
|
||||||
|
|
||||||
|
|
@ -115,7 +115,7 @@ M: gadget gadget-text-separator
|
||||||
gadget-text-separator '[ _ % ] [ gadget-text* ] interleave ;
|
gadget-text-separator '[ _ % ] [ gadget-text* ] interleave ;
|
||||||
|
|
||||||
M: gadget gadget-text*
|
M: gadget gadget-text*
|
||||||
[ children>> ] keep gadget-seq-text ;
|
[ children>> ] [ gadget-seq-text ] bi ;
|
||||||
|
|
||||||
M: array gadget-text*
|
M: array gadget-text*
|
||||||
[ gadget-text* ] each ;
|
[ gadget-text* ] each ;
|
||||||
|
|
@ -183,7 +183,7 @@ GENERIC: pref-dim* ( gadget -- dim )
|
||||||
|
|
||||||
: pref-dim ( gadget -- dim )
|
: pref-dim ( gadget -- dim )
|
||||||
dup pref-dim>> [ ] [
|
dup pref-dim>> [ ] [
|
||||||
[ pref-dim* ] keep dup layout-state>>
|
[ pref-dim* ] [ dup layout-state>> ] bi
|
||||||
[ drop ] [ dupd (>>pref-dim) ] if
|
[ drop ] [ dupd (>>pref-dim) ] if
|
||||||
] ?if ;
|
] ?if ;
|
||||||
|
|
||||||
|
|
@ -267,7 +267,7 @@ M: gadget ungraft* drop ;
|
||||||
|
|
||||||
: notify ( gadget -- )
|
: notify ( gadget -- )
|
||||||
dup graft-state>>
|
dup graft-state>>
|
||||||
[ first { f f } { t t } ? >>graft-state ] keep
|
[ first { f f } { t t } ? >>graft-state ] [ ] bi
|
||||||
{
|
{
|
||||||
{ { f t } [ dup activate-control graft* ] }
|
{ { f t } [ dup activate-control graft* ] }
|
||||||
{ { t f } [ dup deactivate-control ungraft* ] }
|
{ { t f } [ dup deactivate-control ungraft* ] }
|
||||||
|
|
@ -388,7 +388,7 @@ M: gadget request-focus-on parent>> request-focus-on ;
|
||||||
M: f request-focus-on 2drop ;
|
M: f request-focus-on 2drop ;
|
||||||
|
|
||||||
: request-focus ( gadget -- )
|
: request-focus ( gadget -- )
|
||||||
[ focusable-child ] keep request-focus-on ;
|
[ focusable-child ] [ request-focus-on ] bi ;
|
||||||
|
|
||||||
: focus-path ( gadget -- seq )
|
: focus-path ( gadget -- seq )
|
||||||
[ focus>> ] follow ;
|
[ focus>> ] follow ;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ PRIVATE>
|
||||||
: grid-child ( grid pair -- gadget ) grid@ nth ;
|
: grid-child ( grid pair -- gadget ) grid@ nth ;
|
||||||
|
|
||||||
: grid-add ( grid child pair -- grid )
|
: grid-add ( grid child pair -- grid )
|
||||||
[ nip grid-child unparent ] [ drop add-gadget ] [ swapd grid@ set-nth ] 3tri ;
|
[ nip grid-child unparent ]
|
||||||
|
[ drop add-gadget ]
|
||||||
|
[ swapd grid@ set-nth ] 3tri ;
|
||||||
|
|
||||||
: grid-remove ( grid pair -- grid ) [ <gadget> ] dip grid-add ;
|
: grid-remove ( grid pair -- grid ) [ <gadget> ] dip grid-add ;
|
||||||
|
|
||||||
|
|
@ -114,8 +116,7 @@ M: grid layout* [ grid>> ] [ <grid-layout> ] bi grid-layout ;
|
||||||
M: grid children-on ( rect gadget -- seq )
|
M: grid children-on ( rect gadget -- seq )
|
||||||
dup children>> empty? [ 2drop f ] [
|
dup children>> empty? [ 2drop f ] [
|
||||||
[ { 0 1 } ] dip grid>>
|
[ { 0 1 } ] dip grid>>
|
||||||
[ 0 <column> fast-children-on ] keep
|
[ 0 <column> fast-children-on ] [ <slice> concat ] bi
|
||||||
<slice> concat
|
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: grid gadget-text*
|
M: grid gadget-text*
|
||||||
|
|
@ -123,4 +124,4 @@ M: grid gadget-text*
|
||||||
[ [ gadget-text ] map ] map format-table
|
[ [ gadget-text ] map ] map format-table
|
||||||
[ CHAR: \n , ] [ % ] interleave ;
|
[ CHAR: \n , ] [ % ] interleave ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ PRIVATE>
|
||||||
[ second ] [ [ line-height ] [ min-rows>> ] [ max-rows>> ] tri ] bi* clamp ;
|
[ second ] [ [ line-height ] [ min-rows>> ] [ max-rows>> ] tri ] bi* clamp ;
|
||||||
|
|
||||||
M: line-gadget pref-viewport-dim
|
M: line-gadget pref-viewport-dim
|
||||||
[ pref-dim ] keep
|
[ pref-dim ] [ ] bi
|
||||||
[ line-gadget-width ]
|
[ line-gadget-width ]
|
||||||
[ line-gadget-height ]
|
[ line-gadget-height ]
|
||||||
2bi 2array ;
|
2bi 2array ;
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ PRIVATE>
|
||||||
'[ _ row-value eq? ] with find drop ;
|
'[ _ row-value eq? ] with find drop ;
|
||||||
|
|
||||||
: (update-selected-indices) ( table -- set )
|
: (update-selected-indices) ( table -- set )
|
||||||
[ selection>> value>> dup [ array? not ] [ ] bi and [ 1array ] when ] keep
|
[ selection>> value>> dup { [ array? not ] [ ] } 1&& [ 1array ] when ] keep
|
||||||
'[ _ find-row-index ] map sift unique f assoc-like ;
|
'[ _ find-row-index ] map sift unique f assoc-like ;
|
||||||
|
|
||||||
: initial-selected-indices ( table -- set )
|
: initial-selected-indices ( table -- set )
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ PRIVATE>
|
||||||
pick sizes>> push add-gadget ;
|
pick sizes>> push add-gadget ;
|
||||||
|
|
||||||
M: track remove-gadget
|
M: track remove-gadget
|
||||||
[ [ children>> index ] keep sizes>> delete-nth ] [ call-next-method ] 2bi ;
|
[ [ children>> index ] [ sizes>> ] bi delete-nth ]
|
||||||
|
[ call-next-method ] 2bi ;
|
||||||
|
|
||||||
: clear-track ( track -- ) [ sizes>> delete-all ] [ clear-gadget ] bi ;
|
: clear-track ( track -- ) [ sizes>> delete-all ] [ clear-gadget ] bi ;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
! Copyright (C) 2006, 2009 Slava Pestov.
|
! Copyright (C) 2006, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays definitions kernel ui.commands
|
USING: accessors arrays assocs combinators.short-circuit fry
|
||||||
ui.gestures sequences strings math words generic namespaces
|
kernel linked-assocs namespaces sequences ui.commands words ;
|
||||||
hashtables quotations assocs fry linked-assocs ;
|
|
||||||
IN: ui.operations
|
IN: ui.operations
|
||||||
|
|
||||||
SYMBOL: +keyboard+
|
SYMBOL: +keyboard+
|
||||||
|
|
@ -18,7 +17,7 @@ TUPLE: operation predicate command translator listener? ;
|
||||||
swap >>predicate ;
|
swap >>predicate ;
|
||||||
|
|
||||||
PREDICATE: listener-operation < operation
|
PREDICATE: listener-operation < operation
|
||||||
[ command>> listener-command? ] [ listener?>> ] bi or ;
|
{ [ command>> listener-command? ] [ listener?>> ] } 1|| ;
|
||||||
|
|
||||||
M: operation command-name
|
M: operation command-name
|
||||||
command>> command-name ;
|
command>> command-name ;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
! Copyright (C) 2006, 2009 Slava Pestov.
|
! Copyright (C) 2006, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: debugger classes help help.topics help.crossref help.home
|
USING: accessors arrays assocs classes combinators
|
||||||
kernel models compiler.units assocs words vocabs accessors fry arrays
|
combinators.short-circuit compiler.units debugger fry help
|
||||||
combinators.short-circuit namespaces sequences help.apropos
|
help.apropos help.crossref help.home help.topics kernel models
|
||||||
combinators ui ui.commands ui.gadgets ui.gadgets.panes
|
sequences ui ui.commands ui.gadgets ui.gadgets.borders
|
||||||
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
|
ui.gadgets.buttons ui.gadgets.editors ui.gadgets.glass
|
||||||
ui.gadgets.packs ui.gadgets.editors ui.gadgets.labels
|
ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers
|
||||||
ui.gadgets.status-bar ui.gadgets.glass ui.gadgets.borders
|
ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.viewports
|
||||||
ui.gadgets.viewports ui.tools.common ui.tools.browser.popups
|
ui.gestures ui.tools.browser.history ui.tools.browser.popups
|
||||||
ui.tools.browser.history ;
|
ui.tools.common vocabs ;
|
||||||
IN: ui.tools.browser
|
IN: ui.tools.browser
|
||||||
|
|
||||||
TUPLE: browser-gadget < tool history scroller search-field popup ;
|
TUPLE: browser-gadget < tool history scroller search-field popup ;
|
||||||
|
|
@ -95,8 +95,10 @@ M: browser-gadget focusable-child* search-field>> ;
|
||||||
"help.home" (browser-window) ;
|
"help.home" (browser-window) ;
|
||||||
|
|
||||||
: error-help-window ( error -- )
|
: error-help-window ( error -- )
|
||||||
[ error-help ]
|
{
|
||||||
[ dup tuple? [ class ] [ drop "errors" ] if ] bi or (browser-window) ;
|
[ error-help ]
|
||||||
|
[ dup tuple? [ class ] [ drop "errors" ] if ]
|
||||||
|
} 1|| (browser-window) ;
|
||||||
|
|
||||||
\ browser-window H{ { +nullary+ t } } define-command
|
\ browser-window H{ { +nullary+ t } } define-command
|
||||||
|
|
||||||
|
|
@ -162,4 +164,4 @@ browser-gadget "scrolling"
|
||||||
{ T{ key-down f f "PAGE_DOWN" } com-page-down }
|
{ T{ key-down f f "PAGE_DOWN" } com-page-down }
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
MAIN: browser-window
|
MAIN: browser-window
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
! Copyright (C) 2007, 2009 Slava Pestov.
|
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel quotations accessors fry assocs present math.order
|
USING: accessors arrays assocs combinators.short-circuit
|
||||||
math.vectors arrays locals models.search models.sort models sequences
|
combinators.smart definitions.icons fry kernel locals
|
||||||
vocabs tools.profiler words prettyprint combinators.smart
|
math.order models models.search models.sort present see
|
||||||
definitions.icons see ui ui.commands ui.gadgets ui.gadgets.panes
|
sequences tools.profiler ui.baseline-alignment ui.commands
|
||||||
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
|
ui.gadgets ui.gadgets.borders ui.gadgets.buttons
|
||||||
ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled
|
ui.gadgets.labeled ui.gadgets.labels ui.gadgets.packs
|
||||||
ui.gadgets.packs ui.gadgets.labels ui.gadgets.tabbed
|
ui.gadgets.search-tables ui.gadgets.status-bar
|
||||||
ui.gadgets.status-bar ui.gadgets.borders ui.tools.browser
|
ui.gadgets.tabbed ui.gadgets.tables ui.gadgets.tracks
|
||||||
ui.tools.common ui.baseline-alignment ui.operations ui.images ;
|
ui.gestures ui.images ui.operations ui.tools.browser
|
||||||
|
ui.tools.common vocabs words ;
|
||||||
FROM: models.arrow => <arrow> ;
|
FROM: models.arrow => <arrow> ;
|
||||||
FROM: models.arrow.smart => <smart-arrow> ;
|
FROM: models.arrow.smart => <smart-arrow> ;
|
||||||
FROM: models.product => <product> ;
|
FROM: models.product => <product> ;
|
||||||
|
|
@ -105,9 +106,10 @@ M: method-renderer column-titles drop { "" "Method" "Count" } ;
|
||||||
|
|
||||||
: method-matches? ( method generic class -- ? )
|
: method-matches? ( method generic class -- ? )
|
||||||
[ first ] 2dip
|
[ first ] 2dip
|
||||||
[ drop dup [ subwords memq? ] [ 2drop t ] if ]
|
{
|
||||||
[ nip dup [ swap "method-class" word-prop = ] [ 2drop t ] if ]
|
[ drop dup [ subwords memq? ] [ 2drop t ] if ]
|
||||||
3bi and ;
|
[ nip dup [ swap "method-class" word-prop = ] [ 2drop t ] if ]
|
||||||
|
} 3&& ;
|
||||||
|
|
||||||
: <methods-model> ( profiler -- model )
|
: <methods-model> ( profiler -- model )
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue