]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.comboboxes: restore from unmaintained
authorAlexander Ilin <alex.ilin@protonmail.com>
Fri, 1 Sep 2023 21:36:51 +0000 (23:36 +0200)
committerAlexander Ilin <alex.ilin@protonmail.com>
Fri, 1 Sep 2023 22:08:58 +0000 (00:08 +0200)
extra/ui/gadgets/comboboxes/authors.txt [new file with mode: 0644]
extra/ui/gadgets/comboboxes/comboboxes.factor [new file with mode: 0644]
extra/ui/gadgets/comboboxes/summary.txt [new file with mode: 0644]

diff --git a/extra/ui/gadgets/comboboxes/authors.txt b/extra/ui/gadgets/comboboxes/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/extra/ui/gadgets/comboboxes/comboboxes.factor b/extra/ui/gadgets/comboboxes/comboboxes.factor
new file mode 100644 (file)
index 0000000..a2a7585
--- /dev/null
@@ -0,0 +1,22 @@
+USING: accessors arrays kernel math.rectangles sequences
+ui.gadgets.controls models.combinators ui.gadgets ui.gadgets.glass
+ui.gadgets.labels ui.gestures ;
+QUALIFIED-WITH: ui.gadgets.tables tbl
+IN: ui.gadgets.comboboxes
+
+TUPLE: combo-table < table spawner ;
+
+M: combo-table handle-gesture [ call-next-method drop ] 2keep swap
+   T{ button-up } = [
+      [ spawner>> ]
+      [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
+      [ hide-glass ] tri
+   ] [ drop ] if t ;
+
+TUPLE: combobox < label-control table ;
+combobox H{
+   { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
+} set-gestures
+
+: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
+    <basic> combo-table new-table [ 1array ] >>quot >>table ;
diff --git a/extra/ui/gadgets/comboboxes/summary.txt b/extra/ui/gadgets/comboboxes/summary.txt
new file mode 100644 (file)
index 0000000..0f2ce2b
--- /dev/null
@@ -0,0 +1 @@
+Combo boxes have a model choosen from a list of options
\ No newline at end of file