 
 (ns ^{:doc    "Utilities for arranging container component layout."
       :author "Denys Lebediev"}
-flatgui.layout
+  flatgui.layout
     (:require [flatgui.base :as fg]
       [flatgui.awt :as awt]
-      [flatgui.util.matrix :as m] [flatgui.util.matrix :as m])
+      [flatgui.util.matrix :as m])
   (:import (java.util.regex Pattern)))
 
 

      ;; TODO
      nil)))

;(fg/defevolverfn :coord-map
; (if-let [layout (map cmd->smile (get-property [:this] :layout))]
;   (let [
;         ;No need in this, should contain rel coords ;cs (get-property [:this] :clip-size)
;         ;w (m/x cs)
;         ;h (m/y cs)
;         ])))

;;; 1. After map-direction is used for elements of each row, each row will
;;; receive it's own set of smile flags. Then map-direction will be used

;  ([cfg stcher bgner sfn ])
;  ([cfg] (map-direction cfg \- \< m/x)))

(declare flattenmap)

(defn flatten-mapper [e]
  (if (coll? e) (flattenmap e) [e]))

(defn flattenmap [coll]
  (mapcat flatten-mapper coll))

(defn flagnestedvec->coordmap [flags]
  (into {} (map (fn [flg] [(:element flg) flg]) (flattenmap flags))))

(fg/defaccessorfn map-direction [component cfg stcher bgner sfn]
  (let [stretches? (fn [element] (true? (and (:flags element) (.contains (:flags element) (str stcher)))))
        flags (map
                #(assoc % :stch-weight (count (filter (fn [f] (= f stcher)) (:flags %))))
                (flattenmap (cfg->flags cfg)))
        total-stch-weight (reduce + (map #(:stch-weight %) flags))
        dir (mapv #(assoc %
                         :min (get-child-minimum-size component (:element %))
