From 0e1e92ba92934e88878c648f2a99875cf11c5619 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 16 Jan 2009 16:39:32 -0600 Subject: [PATCH] Clean up menu code --- basis/ui/gadgets/menus/menus.factor | 4 ++-- .../presentations/presentations.factor | 6 +++--- .../search-tables/search-tables.factor | 21 +++++++++++++------ basis/ui/gadgets/tables/tables.factor | 11 +++++----- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/basis/ui/gadgets/menus/menus.factor b/basis/ui/gadgets/menus/menus.factor index 4eea4391b6..fd561f4583 100644 --- a/basis/ui/gadgets/menus/menus.factor +++ b/basis/ui/gadgets/menus/menus.factor @@ -34,5 +34,5 @@ IN: ui.gadgets.menus : ( target hook -- menu ) over object-operations ; -: show-operations-menu ( gadget target -- ) - [ ] show-menu ; \ No newline at end of file +: show-operations-menu ( gadget target hook -- ) + show-menu ; \ No newline at end of file diff --git a/basis/ui/gadgets/presentations/presentations.factor b/basis/ui/gadgets/presentations/presentations.factor index f05ea5ae5d..c1efde83ec 100644 --- a/basis/ui/gadgets/presentations/presentations.factor +++ b/basis/ui/gadgets/presentations/presentations.factor @@ -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 - 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 diff --git a/basis/ui/gadgets/search-tables/search-tables.factor b/basis/ui/gadgets/search-tables/search-tables.factor index 5ac7f6bdae..a1c7a09b14 100644 --- a/basis/ui/gadgets/search-tables/search-tables.factor +++ b/basis/ui/gadgets/search-tables/search-tables.factor @@ -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>> ; diff --git a/basis/ui/gadgets/tables/tables.factor b/basis/ui/gadgets/tables/tables.factor index def57b734a..e034b49f77 100644 --- a/basis/ui/gadgets/tables/tables.factor +++ b/basis/ui/gadgets/tables/tables.factor @@ -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 >>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 ] }