 (ns wines.gui
   (:require [seesaw.dev :as dev]
             [seesaw.core :as ss]
-            [wines.util :refer [parse-json]]))
+            [wines.util :refer [parse-json]]
+            [clojure.pprint :refer [pprint]]))
 
 (defn call-ui []
   (println "Calling ui soon!")
   nil)
 
 (def bg-color "#fdfdfd")
-
 (def max-height 530)
 (def app-height 600)
+(def wine-results-size [370 :by max-height])
+(def wine-properties-size [400 :by (- max-height 30)])
+(def main-search-size [210 :by max-height])
 
 (ss/native!)
 
+
+;;;; TODO: development, mocking. remove!
+(def mocked-body
+  (take 35
+    (cycle
+      (:List
+        (:Products
+          (parse-json
+            (slurp (clojure.java.io/resource "body.seed.json")) "testing"))))))
+
+(def results-model
+  (for [product mocked-body]
+    (let [simpler-product (select-keys product [:Name :Id])]
+      (clojure.string/join
+        " "
+        [(format "%-8d" (:Id simpler-product))
+         (:Name simpler-product)]
+        ))))
+
+;;;;;
+
+
+;; todo: prompt user for api key?
+
+; TODO: why menubar wont show?
+(def main-menu
+  (ss/menubar
+    :items [(ss/menu
+              :text "File"
+              :items [(ss/action
+                        :name "Open..."
+                        :key "menu O"
+                        :handler (fn [e] (println "Open something")))])
+            (ss/menu
+              :text "Edit"
+              :items [(ss/action
+                        :name "Undo"
+                        :key "menu Z"
+                        :handler (fn [e] (println "Undo something")))])
+            (ss/menu
+              :text "Help"
+              :items [(ss/action
+                        :name "About"
+                        :key "menu H"
+                        :handler (fn [e] (println "Show about dialog")))])]))
+
 (def window (ss/frame :title "Wine Finder",
+                      :menubar main-menu
 ;;            :on-close :exit,    ; add this when done...?
 ;;                       :resizable? false  ; todo: resizable false
                       :size [950 :by app-height]

   :icon "http://cache.wine.com/images/logos/80x80_winecom_logo.png"))

(def search-input
  (ss/text ; could replace with ss/input
   :text "Cabernet Sauvignon"
   :editable? true
   :columns 14))

                          :background bg-color
                          :items [search-input search-button] )]
                :background bg-color)
            (ss/horizontal-panel :items [ wine-results wine-properties-table ])]))

(show-window)

(display container)

;; (merge-with + wine-properties-size wine-results-size) ; only if inputs are maps

;; (ss/config! wine-properties :visible? true)

;; (ss/listen window
;;   :component-resized (fn [event] (println event)))
