]> gitweb.factorcode.org Git - factor.git/commitdiff
comboboxes: improve presentation
authorrazetime <rraghu.11502@gmail.com>
Sat, 4 Nov 2023 04:11:58 +0000 (12:11 +0800)
committerrazetime <rraghu.11502@gmail.com>
Sat, 4 Nov 2023 04:11:58 +0000 (12:11 +0800)
extra/ui/gadgets/comboboxes/comboboxes.factor

index b0a185834ceaece576ad8413ea6a114d9b7d7128..4675ef5f6280e670d3ddaa3ce76510ed6349deac 100644 (file)
@@ -1,15 +1,18 @@
-USING: accessors arrays kernel math.rectangles sequences
-ui.gadgets.controls models.combinators ui.gadgets ui.gadgets.glass
-ui.gadgets.labels ui.gestures ui.tools.common ;
+USING: accessors arrays fonts kernel math.rectangles
+models.arrow models.combinators namespaces sequences ui.gadgets
+ui.gadgets.controls ui.gadgets.glass ui.gadgets.labels
+ui.gestures ui.pens.solid ui.tools.common ui.gadgets.borders ;
 QUALIFIED-WITH: ui.gadgets.tables tbl
 IN: ui.gadgets.comboboxes
 
 TUPLE: combo-table < table spawner ;
 
+: disp-string ( str -- str' ) " ▾ " append " " swap append ;
+
 M: combo-table handle-gesture
     [ call-next-method drop ] 2keep swap T{ button-down } = [
         [ spawner>> ]
-        [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
+        [ tbl:selected-row [ disp-string swap set-control-value ] [ 2drop ] if ]
         [ hide-glass ] tri
     ] [ drop ] if t ;
 
@@ -20,5 +23,6 @@ combobox H{
 } set-gestures
 
 : <combobox> ( options -- combobox )
-    [ first [ combobox new-label ] keep <basic> >>model ] keep
-    <basic> combo-table new-table white-interior [ 1array ] >>quot >>table ;
+    [ first [ combobox new-label ] [ disp-string <basic> ] bi >>model ] keep
+    <basic> combo-table new-table white-interior [ 1array ] >>quot >>table 
+    default-font-foreground-color get <solid> >>boundary ;