]> gitweb.factorcode.org Git - factor.git/commitdiff
recipes: add some terrible @2x icons, cleanup
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 2 Sep 2023 02:40:36 +0000 (19:40 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 2 Sep 2023 02:40:36 +0000 (19:40 -0700)
extra/recipes/icons/back@2x.tiff [new file with mode: 0644]
extra/recipes/icons/hate@2x.tiff [new file with mode: 0644]
extra/recipes/icons/love@2x.tiff [new file with mode: 0644]
extra/recipes/icons/more@2x.tiff [new file with mode: 0644]
extra/recipes/icons/submit@2x.tiff [new file with mode: 0644]
extra/recipes/recipes.factor

diff --git a/extra/recipes/icons/back@2x.tiff b/extra/recipes/icons/back@2x.tiff
new file mode 100644 (file)
index 0000000..751a058
Binary files /dev/null and b/extra/recipes/icons/back@2x.tiff differ
diff --git a/extra/recipes/icons/hate@2x.tiff b/extra/recipes/icons/hate@2x.tiff
new file mode 100644 (file)
index 0000000..28ff96d
Binary files /dev/null and b/extra/recipes/icons/hate@2x.tiff differ
diff --git a/extra/recipes/icons/love@2x.tiff b/extra/recipes/icons/love@2x.tiff
new file mode 100644 (file)
index 0000000..038490f
Binary files /dev/null and b/extra/recipes/icons/love@2x.tiff differ
diff --git a/extra/recipes/icons/more@2x.tiff b/extra/recipes/icons/more@2x.tiff
new file mode 100644 (file)
index 0000000..a3b9d91
Binary files /dev/null and b/extra/recipes/icons/more@2x.tiff differ
diff --git a/extra/recipes/icons/submit@2x.tiff b/extra/recipes/icons/submit@2x.tiff
new file mode 100644 (file)
index 0000000..ddfc9f5
Binary files /dev/null and b/extra/recipes/icons/submit@2x.tiff differ
index 71d6eefdfa54b9060391c972277f996332c879c2..1722c0d1fc3c57981d86d25e3e5d05e0c972cbf0 100644 (file)
@@ -5,57 +5,72 @@ ui.gadgets.controls ui.gadgets.labels ui.gadgets.layout
 ui.gadgets.scrollers ui.pens.solid ;
 IN: recipes
 
-STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ;
-: <recipe> ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
+STORED-TUPLE: recipe
+    { title { VARCHAR 100 } }
+    { votes INTEGER }
+    { txt TEXT }
+    { genre { VARCHAR 100 } } ;
+
+: <recipe> ( title genre text -- recipe )
+    recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
+
 "recipes.db" temp-file <sqlite-db> recipe define-db
-: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
+
+: top-recipes ( offset search -- recipes )
+    <query> T{ recipe } rot >>title >>tuple
     "votes" >>order 30 >>limit swap >>offset get-tuples ;
+
 : top-genres ( -- genres )
     f f top-recipes [ genre>> ] map members 4 index-or-length head-slice ;
 
-: interface ( -- book ) [ 
-     [
-        [ $ TOOLBAR $ ] <hbox> COLOR: AliceBlue <solid> >>interior ,
-        [ "Genres:" <label> , <spacer> $ ALL $ $ GENRES $ ] <hbox>
+: interface ( -- book )
+    [
+        [
+            [ $ TOOLBAR $ ] <hbox> COLOR: AliceBlue <solid> >>interior ,
+            [ "Genres:" <label> , <spacer> $ ALL $ $ GENRES $ ] <hbox>
             { 5 0 } >>gap COLOR: gray <solid> >>interior ,
-        $ RECIPES $
-     ] <vbox> ,
-     [
-        [ "Title:" <label> , $ TITLE $ "Genre:" <label> , $ GENRE $ ] <hbox> ,
-        $ BODY $
-        $ BUTTON $
-     ] <vbox> ,
-  ] <book*> { 350 245 } >>pref-dim ;
-  
-:: recipe-browser ( -- ) [ [
-    interface
-      <table*> :> tbl
-      "okay" <model-border-btn> BUTTON -> :> ok
-      IMG-MODEL-BTN: submit [ store-tuple ] >>value TOOLBAR -> :> submit
-      IMG-MODEL-BTN: love 1 >>value TOOLBAR ->
-      IMG-MODEL-BTN: hate -1 >>value -> 2array merge :> votes
-      IMG-MODEL-BTN: back -> [ -30 ] <$
-      IMG-MODEL-BTN: more -> [ 30 ] <$ 2array merge :> viewed
-      <spacer> <model-field*> ->% 1 :> search
-      submit ok [ [ drop ] ] <$ 2array merge [ drop ] >>value :> quot
-      viewed 0 [ + ] fold search ok t <basic> "all" <model-btn> ALL ->
-      tbl selection>> votes [ [ + ] curry change-votes modify-tuple ] 2$>
+            $ RECIPES $
+        ] <vbox> ,
+        [
+            [ "Title:" <label> , $ TITLE $ "Genre:" <label> , $ GENRE $ ] <hbox> ,
+            $ BODY $
+            $ BUTTON $
+        ] <vbox> ,
+    ] <book*> { 350 245 } >>pref-dim ;
+
+:: <recipe-gadget> ( -- gadget )
+    [
+        interface
+        <table*> :> tbl
+        "okay" <model-border-btn> BUTTON -> :> ok
+        IMG-MODEL-BTN: submit [ store-tuple ] >>value TOOLBAR -> :> submit
+        IMG-MODEL-BTN: love 1 >>value TOOLBAR ->
+        IMG-MODEL-BTN: hate -1 >>value -> 2array merge :> votes
+        IMG-MODEL-BTN: back -> [ -30 ] <$
+        IMG-MODEL-BTN: more -> [ 30 ] <$ 2array merge :> viewed
+        <spacer> <model-field*> ->% 1 :> search
+        submit ok [ [ drop ] ] <$ 2array merge [ drop ] >>value :> quot
+        viewed 0 [ + ] fold search ok t <basic> "all" <model-btn> ALL ->
+        tbl selection>> votes [ [ + ] curry change-votes modify-tuple ] 2$>
         4array merge
         [ drop [ f ] [ "%" dup surround <pattern> ] if-empty top-recipes ] 3fmap :> ups
-      ups [ top-genres [ <model-btn> GENRES -> ] map merge ] bind*
+        ups [ top-genres [ <model-btn> GENRES -> ] map merge ] bind*
         [ text>> T{ recipe } swap >>genre get-tuples ] fmap
-      tbl swap ups 2merge >>model
+        tbl swap ups 2merge >>model
         [ [ title>> ] [ genre>> ] bi 2array ] >>quot
         { "Title" "Genre" } >>column-titles dup <scroller> RECIPES ,% 1 actions>>
-      submit [ "" dup dup <recipe> ] <$ 2array merge
-        { [ [ title>> ] fmap <model-field> TITLE ->% .5 ]
-          [ [ genre>> ] fmap <model-field> GENRE ->% .5 ]
-          [ [ txt>> ] fmap <model-editor> BODY ->% 1 ]
+        submit [ "" dup dup <recipe> ] <$ 2array merge
+        {
+            [ [ title>> ] fmap <model-field> TITLE ->% .5 ]
+            [ [ genre>> ] fmap <model-field> GENRE ->% .5 ]
+            [ [ txt>> ] fmap <model-editor> BODY ->% 1 ]
         } cleave
         [ <recipe> ] 3fmap
-      [ [ 1 ] <$ ]
-      [ quot ok updates #1 [ call( recipe -- ) 0 ] 2fmap ] bi
-      2merge 0 <basic> switch-models >>model
-   ] with-interface "recipes" open-window ] with-ui ;
+        [ [ 1 ] <$ ]
+        [ quot ok updates #1 [ call( recipe -- ) 0 ] 2fmap ] bi
+        2merge 0 <basic> switch-models >>model
+    ] with-interface ;
 
-MAIN: recipe-browser
+MAIN-WINDOW: recipe-browser
+    { { title "Recipes" } }
+    <recipe-gadget> >>gadgets ;