Clean up menu code
parent
21f81ab57d
commit
0e1e92ba92
|
@ -34,5 +34,5 @@ IN: ui.gadgets.menus
|
|||
: <operations-menu> ( target hook -- menu )
|
||||
over object-operations <commands-menu> ;
|
||||
|
||||
: show-operations-menu ( gadget target -- )
|
||||
[ ] <operations-menu> show-menu ;
|
||||
: show-operations-menu ( gadget target hook -- )
|
||||
<operations-menu> show-menu ;
|
|
@ -35,12 +35,12 @@ M: presentation ungraft*
|
|||
dup hand-gadget get-global child? [ dup hide-status ] when
|
||||
call-next-method ;
|
||||
|
||||
: show-operations-menu ( presentation -- )
|
||||
: show-presentation-menu ( presentation -- )
|
||||
[ ] [ object>> ] [ dup hook>> curry ] tri
|
||||
<operations-menu> show-menu ;
|
||||
show-operations-menu ;
|
||||
|
||||
presentation H{
|
||||
{ T{ button-down f f 3 } [ show-operations-menu ] }
|
||||
{ T{ button-down f f 3 } [ show-presentation-menu ] }
|
||||
{ T{ mouse-leave } [ [ hide-status ] [ button-update ] bi ] }
|
||||
{ T{ mouse-enter } [ show-mouse-help ] }
|
||||
! Responding to motion too allows nested presentations to
|
||||
|
|
|
@ -25,12 +25,21 @@ TUPLE: search-field < track field ;
|
|||
|
||||
TUPLE: search-table < track table field ;
|
||||
|
||||
! We don't want to delegate all slots, just a few setters
|
||||
PROTOCOL: table-protocol
|
||||
renderer>> (>>renderer)
|
||||
filled-column>> (>>filled-column)
|
||||
selected-value>> (>>selected-value)
|
||||
column-alignment>> (>>column-alignment) ;
|
||||
! A protocol with customizable slots
|
||||
SLOT-PROTOCOL: table-protocol
|
||||
renderer
|
||||
filled-column
|
||||
column-alignment
|
||||
action
|
||||
hook
|
||||
font
|
||||
text-color
|
||||
selection-color
|
||||
focus-border-color
|
||||
mouse-color
|
||||
column-line-color
|
||||
selection-required?
|
||||
selected-value ;
|
||||
|
||||
CONSULT: table-protocol search-table table>> ;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ M: trivial-renderer row-columns drop ;
|
|||
M: object row-value drop ;
|
||||
|
||||
TUPLE: table < gadget
|
||||
renderer filled-column column-alignment action
|
||||
renderer filled-column column-alignment action hook
|
||||
column-widths total-width
|
||||
font text-color selection-color focus-border-color
|
||||
mouse-color column-line-color selection-required?
|
||||
|
@ -30,6 +30,7 @@ focused? ;
|
|||
swap >>model
|
||||
trivial-renderer >>renderer
|
||||
[ drop ] >>action
|
||||
[ ] >>hook
|
||||
f <model> >>selected-value
|
||||
sans-serif-font >>font
|
||||
selection-color >>selection-color
|
||||
|
@ -289,10 +290,10 @@ PRIVATE>
|
|||
2bi
|
||||
] [ hide-mouse-help ] if-mouse-row ;
|
||||
|
||||
: table-operations-menu ( table -- )
|
||||
: show-table-menu ( table -- )
|
||||
[
|
||||
[ nth-row drop ] keep [ renderer>> row-value ] keep
|
||||
swap show-operations-menu
|
||||
tuck [ nth-row drop ] [ renderer>> row-value ] [ hook>> ] tri
|
||||
show-operations-menu
|
||||
] [ drop ] if-mouse-row ;
|
||||
|
||||
table H{
|
||||
|
@ -300,7 +301,7 @@ table H{
|
|||
{ T{ mouse-leave } [ hide-mouse-help ] }
|
||||
{ T{ motion } [ show-mouse-help ] }
|
||||
{ T{ button-down } [ table-button-down ] }
|
||||
{ T{ button-down f f 3 } [ table-operations-menu ] }
|
||||
{ T{ button-down f f 3 } [ show-table-menu ] }
|
||||
{ T{ button-up } [ table-button-up ] }
|
||||
{ T{ gain-focus } [ t >>focused? drop ] }
|
||||
{ T{ lose-focus } [ f >>focused? drop ] }
|
||||
|
|
Loading…
Reference in New Issue