Re: [Sawfish] 2 new blue styles for StyleTab

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


Hi,

On Sat, 27 Aug 2011 09:20:12 +0200
wrote Christopher Roy Bratusek <nano@xxxxxxxxxxxxx>:

>Alternatively StyleTab may use recolor-image like in Crux theme and let the 
>user choose the color? But this would involve additional tasks in theme.jl.

Ok now we can recolor StyleTab. But if you change the size of the
titlebar or buttons the foreground will not scale and redraw correct
(read comment in theme.jl) and i have no idea how to fix it. I have
rename style DarkColor in Default and remove all other styles (will
readd later if redraw ready but it take some time). Settings from prev
StyleTab will not work so you need to set your custom settings for
Styletab.

The patch is for the theming-1.9 branch.

Download image here:
http://mitglied.multimania.de/fuchur2004/Default.tar.bz2

-- 
Regards,
Fuchur

GPG Fingerprint: CA3B 8204 5B3E 6D48 6D53  C116 E5BC 70D5 B8D7 B2B0
--- theme.jl.orgi	2011-09-23 14:38:16.000000000 +0200
+++ theme.jl	2011-09-23 14:19:06.000000000 +0200
@@ -3,13 +3,18 @@
 (define theme-name 'StyleTab)
 
 ;;need hash tables for icon cache 
-
 (require 'rep.data.tables)
 
+;; recolor imanges
+(require 'sawfish.wm.util.recolor-image)
+
 ;; Defcustom and defgroup
 (defgroup StyleTab:group "StyleTab"
   :group appearance)
 
+(defgroup StyleTab:color-group "colors"
+  :group (appearance StyleTab:group))
+
 (defgroup StyleTab:top-buttons-group "Top Titlebar Buttons"
   :group (appearance StyleTab:group))
 
@@ -22,45 +27,259 @@
 (defgroup StyleTab:right-buttons-group "Right Titlebar Buttons"
   :group (appearance StyleTab:group))
 
-(defcustom styletab:style 'Dark "Frame and button style."
+(defcustom styletab-c:do-reload nil "Do reload. Will reload the theme if switch on/off.
+Essential if you change the title hight or botton size.
+Fix/hack for foreground button, but makes botton ugly."
   :group (appearance StyleTab:group)
-  :options (BlueGlass BlueDarker Reduce Dark DarkColor Silver SilverColor Smoothly)
-  :type symbol)
+  :type boolean)
 
-(defcustom styletab:titlebar-place 'top "Titlebar default place."
+(defcustom styletab-c:styles 'Default "Frame and button style."
   :group (appearance StyleTab:group)
-  :options (top bottom left right)
-  :type symbol)
+  :type symbol
+  :options (Default))
+;;  :options (Default Reduce Glass WixDa Smoothly)
 
-(defcustom styletab:title-dimension 24 "Height of title border. "
+(defcustom styletab-c:titlebar-place 'top "Titlebar default place."
+  :group (appearance StyleTab:group)
+  :type symbol
+  :options (top bottom left right))
+
+(defcustom styletab-c:title-dimension 24 "Height of title border. "
   :group (appearance StyleTab:group)
   :type number
   :range (16 . 32))
 
-(defcustom styletab:borders-dimension 4 "Width of window border."
+(defcustom styletab-c:borders-dimension 4 "Width of window border."
   :group (appearance StyleTab:group)
   :type number
   :range (0 . 10))
 
-(defcustom styletab:custom-button-width nil "Customize buttons width."
+(defcustom styletab-c:custom-button-width nil "Customize buttons width."
   :group (appearance StyleTab:group)
   :type boolean)
 
-(defcustom styletab:button-width 0 "Width of Buttons."
+(defcustom styletab-c:button-width 0 "Width of Buttons."
   :group (appearance StyleTab:group)
   :type number
-  :depends styletab:custom-button-width
+  :depends styletab-c:custom-button-width
   :range (-4 . 4))
 
+(defcustom styletab-c:proposals 'Pink "Proposals."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type symbol
+  :options (Brown Dark Darkblue Blue Pink Green)
+  :after-set (lambda () (color-changed)))
+
+(defcustom styletab-c:hightlight-tabbar nil "Also hightlighted tabbars."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :after-set (lambda () (botton-color-changed recolor-tab)))
+
+(defcustom styletab-c:custom-frame-colors nil "Customize frame color/brightness."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :after-set (lambda () (color-changed)))
+
+(defcustom styletab-c:focus-frame-color (get-color "#780000")
+  "Focus frame color."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type color
+  :depends styletab-c:custom-frame-colors
+  :after-set (lambda () (color-changed)))
+
+(defcustom styletab-c:unfocus-frame-color (get-color "#780000")
+  "Inactive frame color"
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type color
+  :depends styletab-c:custom-frame-colors
+  :after-set (lambda () (color-changed)))
+
+(defcustom styletab-c:inactive-dimout 2 "Dimout inactive frame."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :depends styletab-c:custom-frame-colors
+  :type number
+  :range (0 . 5)
+  :after-set (lambda () (color-changed)))
+
+(defcustom styletab-c:active-hightlight-brighten 2 "Focus window brightness mouse over buttons."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :depends styletab-c:custom-frame-colors
+  :type number
+  :range (-5 . 5)
+  :after-set (lambda () (bright-changed)))
+
+(defcustom styletab-c:inactive-hightlight-brighten 2 "Inactive windows brightness mouse over buttons."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type number
+  :depends styletab-c:custom-frame-colors
+  :range (-5 . 5)
+  :after-set (lambda () (bright-changed)))
+
+(defcustom styletab-c:hightlight-close nil
+  "Hightlighted close button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-close-button)))
+
+(defcustom styletab-c:hightlight-close-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-close
+  :after-set (lambda () (botton-color-changed recolor-close-button)))
+
+(defcustom styletab-c:hightlight-maximize nil
+  "Hightlighted maximize button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-maximize-button)))
+
+(defcustom styletab-c:hightlight-maximize-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-maximize
+  :after-set (lambda () (botton-color-changed recolor-maximize-button)))
+
+(defcustom styletab-c:hightlight-iconify nil
+  "Hightlighted minimize button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-iconify-button)))
+
+(defcustom styletab-c:hightlight-iconify-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-iconify
+  :after-set (lambda () (botton-color-changed recolor-iconify-button)))
+
+(defcustom styletab-c:hightlight-shade nil
+  "Hightlighted shade button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-shade-button)))
+
+(defcustom styletab-c:hightlight-shade-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-shade
+  :after-set (lambda () (botton-color-changed recolor-shade-button)))
+
+(defcustom styletab-c:hightlight-sticky nil
+  "Hightlighted sticky button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-sticky-button)))
+
+(defcustom styletab-c:hightlight-sticky-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-sticky
+  :after-set (lambda () (botton-color-changed recolor-sticky-button)))
+
+(defcustom styletab-c:hightlight-menu nil
+  "Hightlighted menu button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-menu-button)))
+
+(defcustom styletab-c:hightlight-menu-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-menu
+  :after-set (lambda () (botton-color-changed recolor-menu-button)))
+
+(defcustom styletab-c:hightlight-frame-type nil
+  "Hightlighted frame type button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-frame-type-button)))
+
+(defcustom styletab-c:hightlight-frame-type-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-frame-type
+  :after-set (lambda () (botton-color-changed recolor-frame-type-button)))
+
+(defcustom styletab-c:hightlight-lock nil
+  "Hightlighted lock button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-lock-button)))
+
+(defcustom styletab-c:hightlight-lock-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-lock
+  :after-set (lambda () (botton-color-changed recolor-lock-button)))
+
+(defcustom styletab-c:hightlight-move-resize nil
+  "Hightlighted move/resize button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-move-resize-button)))
+
+(defcustom styletab-c:hightlight-move-resize-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-move-resize
+  :after-set (lambda () (botton-color-changed recolor-move-resize-button)))
+
+(defcustom styletab-c:hightlight-raise-lower nil
+  "Hightlighted raise/lower button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-raise-lower-button)))
+
+(defcustom styletab-c:hightlight-raise-lower-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-raise-lower
+  :after-set (lambda () (botton-color-changed recolor-raise-lower-button)))
+
+(defcustom styletab-c:hightlight-next nil
+  "Hightlighted next workspace button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-next-button)))
+
+(defcustom styletab-c:hightlight-next-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-next
+  :after-set (lambda () (botton-color-changed recolor-next-button)))
+
+(defcustom styletab-c:hightlight-prev nil
+  "Hightlighted previous workspace button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-prev-button)))
+
+(defcustom styletab-c:hightlight-prev-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-prev
+  :after-set (lambda () (botton-color-changed recolor-prev-button)))
+
+(defcustom styletab-c:hightlight-rename nil
+  "Hightlighted rename button."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type (optional color)
+  :after-set (lambda () (botton-color-changed recolor-rename-button)))
+
+(defcustom styletab-c:hightlight-rename-all nil "Always use."
+  :group (appearance StyleTab:group StyleTab:color-group)
+  :type boolean
+  :depends styletab-c:hightlight-rename
+  :after-set (lambda () (botton-color-changed recolor-rename-button)))
+
 (mapc
  (lambda (arg)
    (let ((type-list ;; ":type" in defcustom
           (append '(v-and)
                   (make-list 10
-			     ;; Here, `list' is necessary. If you
-			     ;; replace it with a quote, the configurator
-			     ;; crashes.
-                             (list 'h-and '(choice \(none\) close menu maximize minimize shade sticky space send-to-prev 
+                             ;; Here, `list' is necessary. If you
+                             ;; replace it with a quote, the configurator
+                             ;; crashes.
+                             (list 'h-and '(choice \(none\) close menu maximize minimize shade sticky space send-to-prev
                                                    send-to-next lock raise-lower move-resize rename frame-type)
                                    '(boolean "Also show in transients"))))))
      (eval
@@ -69,141 +288,160 @@
           ,(cadr arg) ;; default value
           ,(caddr arg) ;; doc
           :group
-         ,`(appearance StyleTab:group
-                       ,(cadddr arg))
-         :type ,type-list
-         ))))) ;; end of lambda
+          ,`(appearance StyleTab:group
+                        ,(cadddr arg))
+          :type ,type-list
+          ))))) ;; end of lambda
  '( ;; list to pass to mapc
-   (styletab:top-left-buttons
+   (styletab-c:top-left-buttons
     '((menu t) (sticky nil) (shade nil))
     "Top Titlebar Left Buttons (from left to right) \\top"
     StyleTab:top-buttons-group)
-   (styletab:top-right-buttons
+   (styletab-c:top-right-buttons
     '((close t) (maximize t) (minimize nil))
     "Top Titlebar Right Buttons (from right to left) \\top"
     StyleTab:top-buttons-group)
-   (styletab:bottom-left-buttons
+   (styletab-c:bottom-left-buttons
     '((menu t) (sticky nil) (shade nil))
     "Bottom Titlebar Left Buttons (from left to right) \\top"
     StyleTab:bottom-buttons-group)
-   (styletab:bottom-right-buttons
+   (styletab-c:bottom-right-buttons
     '((close t) (maximize t) (minimize nil))
     "Bottom Titlebar Right Buttons (from right to left) \\top"
     StyleTab:bottom-buttons-group)
-   (styletab:left-top-buttons
+   (styletab-c:left-top-buttons
     '((close t) (maximize t) (minimize nil))
     "Left Titlebar Top Buttons (from top to bottom) \\top"
     StyleTab:left-buttons-group)
-   (styletab:left-bottom-buttons
+   (styletab-c:left-bottom-buttons
     '((menu t) (sticky nil) (shade nil))
     "Left Titlebar Bottom Buttons (from bottom to top) \\top"
     StyleTab:left-buttons-group)
-   (styletab:right-top-buttons
+   (styletab-c:right-top-buttons
     '((close t) (maximize t) (minimize nil))
     "Right Titlebar Top Buttons (from top to bottom) \\top"
     StyleTab:right-buttons-group)
-   (styletab:right-bottom-buttons
+   (styletab-c:right-bottom-buttons
     '((menu t) (sticky nil) (shade nil))
     "Right Titlebar Bottom Buttons (from bottom to top) \\top"
-    StyleTab:right-buttons-group)
-   ))
+    StyleTab:right-buttons-group)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 ;;; styles settings 
 
-;;(define styletab-style styletab:style)
-
-(define title-colors-images
+(define proposals-colors
   (lambda ()
-      (case styletab:style
-	    ((BlueGlass) (title-colors-blueglass))
-	    ((BlueDarker) (title-colors-bluedarker))
-            ((Reduce) (title-colors-reduce))
-            ((Dark) (title-colors-dark))
-            ((DarkColor) (title-colors-dark))
-            ((Silver) (title-colors-silver))
-            ((SilverColor) (title-colors-silver))
-            ((Smoothly) (title-colors-smoothly)))))
+    (case styletab-c:proposals
+          ;; format "color" "dimout inactive frame" "brighte mouse over button active" "brighte mouse over button inactive"
+          ((Dark) (list "#000033" '40 '100 '100))
+          ((Darkblue) (list "#00006E" '30 '70 '70))
+          ((Brown) (list "#780000" '40 '40 '50))
+          ((Blue) (list "#0000B4" '30 '40 '50))
+          ((Pink) (list "#7F0081" '50 '50 '50))
+          ((Green) (list "#006400" '30 '60 '60)))))
 
-(define title-colors-blueglass
+(define title-colors-images
   (lambda ()
-    `((focused . "#E5E5E5") (highlighted . "#FDFDFD") (clicked . "#FDFDFD") (inactive . "#2B2B2B") (inactive-highlighted . "#000000")
-      (inactive-clicked . "#000000"))))
+    (case styletab-c:styles
+          ((Default) (title-colors-default))
+          ((Reduce) (title-colors-reduce))
+          ((Glass) (title-colors-glass))
+          ((WixDa) (title-colors-wixda))
+          ((Smoothly) (title-colors-smoothly)))))
 
-(define title-colors-bluedarker
+(define title-colors-default
   (lambda ()
-    `((focused . "#E5E5E5") (highlighted . "#FDFDFD") (clicked . "#FDFDFD") (inactive . "#B8B8B8") (inactive-highlighted . "#CFCFCF")
-      (inactive-clicked . "#CFCFCF"))))
+    `((focused . "#F2F2F2") (highlighted . "#FEFEFE") (clicked . "#FEFEFE") (inactive . "#CBCBCB") (inactive-highlighted . "#D8D8D8")
+      (inactive-clicked . "#D8D8D8"))))
 
 (define title-colors-reduce
   (lambda ()
     `((focused . "#E5E5E5") (highlighted . "#FDFDFD") (clicked . "#FDFDFD") (inactive . "#B1B1B1") (inactive-highlighted . "#CBCBCB")
       (inactive-clicked . "#CBCBCB"))))
 
-(define title-colors-dark
-  (lambda ()
-    `((focused . "#F2F2F2") (highlighted . "#FEFEFE") (clicked . "#FEFEFE") (inactive . "#CBCBCB") (inactive-highlighted . "#D8D8D8")
-      (inactive-clicked . "#D8D8D8"))))
-
-(define title-colors-smoothly
+(define title-colors-glass
   (lambda ()
-    `((focused . "#000000") (highlighted . "#333333") (clicked . "#333333") (inactive . "#666666") (inactive-highlighted . "#777777")
-      (inactive-clicked . "#777777"))))
+    `((focused . "#E5E5E5") (highlighted . "#FDFDFD") (clicked . "#FDFDFD") (inactive . "#2B2B2B") (inactive-highlighted . "#000000")
+      (inactive-clicked . "#000000"))))
 
-(define title-colors-silver
+(define title-colors-wixda
   (lambda ()
     `((focused . "#000000") (highlighted . "#333333") (clicked . "#333333") (inactive . "#4C4C4C") (inactive-highlighted . "#666666")
       (inactive-clicked . "#666666"))))
 
+(define title-colors-smoothly
+  (lambda ()
+    `((focused . "#000000") (highlighted . "#333333") (clicked . "#333333") (inactive . "#666666") (inactive-highlighted . "#777777")
+      (inactive-clicked . "#777777"))))
 
 (define button-width-custom
   (lambda ()
-    (if (eq styletab:custom-button-width t)
+    (if (eq styletab-c:custom-button-width t)
         (button-width-set)
-      (case styletab:style
-	    ((BlueGlass) (button-width-blueglass))
-            ((BlueDarker) (button-width-blueglass))
+      (case styletab-c:styles
+            ((Default) (button-width-default))
             ((Reduce) (button-width-reduce))
-            ((Dark) (button-width-dark))
-            ((DarkColor) (button-width-dark))
-            ((Silver) (button-width-silver))
-            ((SilverColor) (button-width-silver))
+            ((Glass) (button-width-glass))
+            ((WixDa) (button-width-wixda))
             ((Smoothly) (button-width-smoothly))))))
 
 (define button-width-add
   (lambda ()
-    (if (eq styletab:custom-button-width nil)
+    (if (eq styletab-c:custom-button-width nil)
         (button-width-zero)
-      (case styletab:style
-	    ((BlueGlass) (button-width-blueglass))
-            ((BlueDarker) (button-width-blueglass))
+      (case styletab-c:styles
+            ((Default) (button-width-default))
             ((Reduce) (button-width-reduce))
-            ((Dark) (button-width-dark))
-            ((DarkColor) (button-width-dark))
-            ((Silver) (button-width-silver))
-            ((SilverColor) (button-width-silver))
+            ((Glass) (button-width-glass))
+            ((WixDa) (button-width-wixda))
             ((Smoothly) (button-width-smoothly))))))
 
-(define button-width-set (lambda () (+ styletab:button-width (button-width-add))))
+(define button-width-set (lambda () (+ styletab-c:button-width (button-width-add))))
 (define button-width-zero (lambda () 0))
+(define button-width-default (lambda () 8))
 (define button-width-reduce (lambda () 0))
-(define button-width-blueglass (lambda () 0))
-(define button-width-dark (lambda () 8))
-(define button-width-silver (lambda () -4))
+(define button-width-glass (lambda () 0))
+(define button-width-wixda (lambda () -4))
 (define button-width-smoothly (lambda () 0))
 
+;; end of tabtext
 (define tabbar-right-edge-width
   (lambda ()
-    (case styletab:style
-	  ((BlueGlass) 3)
-          ((BlueDarker) 3)
+    (case styletab-c:styles
+          ((Default) 3)
           ((Reduce) 6)
-          ((Dark) 3)
-          ((DarkColor) 3)
-          ((Silver) 3)
-          ((SilverColor) 3)
+          ((Glass) 3)
+          ((WixDa) 3)
           ((Smoothly) 3))))
 
+;; edge of first buttons left/right
+(define button-left-edge
+  (lambda ()
+    (case styletab-c:styles
+          ((Default) 1)
+          ((Reduce) 1)
+          ((Glass) 1)
+          ((WixDa) 1)
+          ((Smoothly) 1))))
+
+(define button-right-edge
+  (lambda ()
+    (case styletab-c:styles
+          ((Default) 2)
+          ((Reduce) 2)
+          ((Glass) 1)
+          ((WixDa) 1)
+          ((Smoothly) 3))))
+
+(define icon-edge
+  (lambda ()
+    (case styletab-c:styles
+          ((Default) 2)
+          ((Reduce) 2)
+          ((Glass) 1)
+          ((WixDa) 1)
+          ((Smoothly) 2))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 ;;; frame-class, keys bindings
 
@@ -212,7 +450,7 @@
         (wins (tab-group-window-index (current-event-window)))
         pos-x pos-y fdim framew framehigh dim-x dim-y current-title type)
     (if (not (window-get w 'title-position))
-        (case styletab:titlebar-place
+        (case styletab-c:titlebar-place
               ((top) (setq current-title 'top))
               ((bottom) (setq current-title 'bottom))
               ((left) (setq current-title 'left))
@@ -224,7 +462,7 @@
     (setq dim-x (car (window-dimensions w)))
     (setq dim-y (cdr (window-dimensions w)))
     (setq fdim (window-frame-dimensions w))
-    (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab:title-dimension)) 3))
+    (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab-c:title-dimension)) 3))
 
     (when (not (eq type 'unframed))
       (if (window-get w 'shaded) (unshade-window w))
@@ -234,21 +472,21 @@
                 (if (eq current-title 'top)
                     (setq dest 'bottom)
                   (setq dest 'top))
-                (when (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
-                  (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
+                (when (>= (+ pos-y dim-y styletab-c:title-dimension framew) (screen-height))
+                  (setq pos-y (- (screen-height) dim-y styletab-c:title-dimension framew)))
                 (when (<= pos-y 0) (setq pos-y 0)))
             ;; To left or right
             (if (or (eq (window-get w 'type) 'default)
                     (eq (window-get w 'type) 'transient))
-                (setq framehigh (+ (- styletab:title-dimension (* styletab:borders-dimension 2)) framew))
-              (setq framehigh (+ styletab:title-dimension framew)))
+                (setq framehigh (+ (- styletab-c:title-dimension (* styletab-c:borders-dimension 2)) framew))
+              (setq framehigh (+ styletab-c:title-dimension framew)))
             (setq dim-x (- dim-x framehigh))
             (setq dim-y (+ dim-y framehigh))
             (when (and (eq dest 'left) (<= pos-x 0))
               (setq pos-x 0))
             (when (and (eq dest 'right)
                        (>= (+ pos-x dim-x framehigh framew framew) (screen-width)))
-              (setq pos-x (- (screen-width) dim-x styletab:title-dimension framew))))
+              (setq pos-x (- (screen-width) dim-x styletab-c:title-dimension framew))))
         ;; vert
         (if (eq dest 'opposite)
             (progn
@@ -256,18 +494,18 @@
                   (progn
                     (setq dest 'right)
                     (when (>= (+ pos-x dim-x) (screen-width))
-                      (setq pos-x (- (screen-width) dim-x styletab:title-dimension framew))))
+                      (setq pos-x (- (screen-width) dim-x styletab-c:title-dimension framew))))
                 (setq dest 'left)
                 (when (<= pos-x 0) (setq pos-x 0))))
           ;; To top or bottom
           (if (or (eq (window-get w 'type) 'default)
                   (eq (window-get w 'type) 'transient))
-              (setq framehigh (- styletab:title-dimension (* styletab:borders-dimension 2)))
-            (setq framehigh styletab:title-dimension))
+              (setq framehigh (- styletab-c:title-dimension (* styletab-c:borders-dimension 2)))
+            (setq framehigh styletab-c:title-dimension))
           (setq dim-x (+ dim-x framehigh framew))
           (setq dim-y (- dim-y framehigh framew))
-          (when (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
-            (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
+          (when (>= (+ pos-y dim-y styletab-c:title-dimension framew) (screen-height))
+            (setq pos-y (- (screen-height) dim-y styletab-c:title-dimension framew)))
           (when (<= pos-y 0) (setq pos-y 0))))
 
       (mapcar (lambda (w)
@@ -282,7 +520,7 @@
   "Move tab-bar to top."
   (let ((w (current-event-window)))
     (if (not (window-get w 'title-position))
-        (window-put w 'title-position styletab:titlebar-place))
+        (window-put w 'title-position styletab-c:titlebar-place))
     (if (or (eq (window-get w 'title-position) 'left)
             (eq (window-get w 'title-position) 'right))
         (rotate-tab 'vert 'top))
@@ -293,7 +531,7 @@
   "Move tab-bar to bottom."
   (let ((w (current-event-window)))
     (if (not (window-get w 'title-position))
-        (window-put w 'title-position styletab:titlebar-place))
+        (window-put w 'title-position styletab-c:titlebar-place))
     (if (or (eq (window-get w 'title-position) 'left)
             (eq (window-get w 'title-position) 'right))
         (rotate-tab 'vert 'bottom))
@@ -304,7 +542,7 @@
   "Move tab-bar to left."
   (let ((w (current-event-window)))
     (if (not (window-get w 'title-position))
-        (window-put w 'title-position styletab:titlebar-place))
+        (window-put w 'title-position styletab-c:titlebar-place))
     (if (or (eq (window-get w 'title-position) 'top)
             (eq (window-get w 'title-position) 'bottom))
         (rotate-tab 'horiz 'left))
@@ -315,7 +553,7 @@
   "Move tab-bar to right."
   (let ((w (current-event-window)))
     (if (not (window-get w 'title-position))
-        (window-put w 'title-position styletab:titlebar-place))
+        (window-put w 'title-position styletab-c:titlebar-place))
     (if (or (eq (window-get w 'title-position) 'top)
             (eq (window-get w 'title-position) 'bottom))
         (rotate-tab 'horiz 'right))
@@ -323,10 +561,10 @@
         (rotate-tab 'vert 'opposite))))
 
 (define (tabbartoggle)
-  " Move tab-bar to the opposite side. (Swap top & bottom, or left & right)"
+  "Move tab-bar to the opposite side. (Swap top & bottom, or left & right)"
   (let ((w (current-event-window)))
     (if (not (window-get w 'title-position))
-        (window-put w 'title-position styletab:titlebar-place))
+        (window-put w 'title-position styletab-c:titlebar-place))
     (if (or (eq (window-get w 'title-position) 'top)
             (eq (window-get w 'title-position) 'bottom))
         (rotate-tab 'horiz 'opposite)
@@ -350,13 +588,12 @@
              "Button2-Off" 'tabbar-toggle
              "Button3-Off" 'tabbar-to-bottom))
 
-
 (define (f-type dest)
   (let ((w (current-event-window))
         (wins (tab-group-window-index (current-event-window)))
         pos-x pos-y dim-x dim-y cur new current-title)
     (if (not (window-get w 'title-position))
-        (case styletab:titlebar-place
+        (case styletab-c:titlebar-place
               ((top) (setq current-title 'top))
               ((bottom) (setq current-title 'bottom))
               ((left) (setq current-title 'left))
@@ -376,30 +613,30 @@
       (when (or (eq cur 'shaped)
                 (eq cur 'utility))
         (setq new 'default)
-        (setq dim-x (- dim-x (* styletab:borders-dimension 2)))
-        (setq dim-y (- dim-y styletab:borders-dimension))
+        (setq dim-x (- dim-x (* styletab-c:borders-dimension 2)))
+        (setq dim-y (- dim-y styletab-c:borders-dimension))
         (when (not (or (eq current-title 'top)
                        (eq current-title 'bottom)))
-          (setq dim-x (+ dim-x styletab:borders-dimension))
-          (setq dim-y (- dim-y styletab:borders-dimension))))
+          (setq dim-x (+ dim-x styletab-c:borders-dimension))
+          (setq dim-y (- dim-y styletab-c:borders-dimension))))
       (when (eq cur 'shaped-transient)
         (setq new 'transient)
-        (setq dim-x (- dim-x (* styletab:borders-dimension 2)))
-        (setq dim-y (- dim-y styletab:borders-dimension))
+        (setq dim-x (- dim-x (* styletab-c:borders-dimension 2)))
+        (setq dim-y (- dim-y styletab-c:borders-dimension))
         (when (not (or (eq current-title 'top)
                        (eq current-title 'bottom)))
-          (setq dim-x (+ dim-x styletab:borders-dimension))
-          (setq dim-y (- dim-y styletab:borders-dimension))))
+          (setq dim-x (+ dim-x styletab-c:borders-dimension))
+          (setq dim-y (- dim-y styletab-c:borders-dimension))))
       (when (eq cur 'unframed)
         (setq new 'default)
         (when (or (eq current-title 'top)
                   (eq current-title 'bottom))
-          (setq dim-x (- dim-x (* styletab:borders-dimension 2)))
-          (setq dim-y (- dim-y styletab:borders-dimension styletab:title-dimension)))
+          (setq dim-x (- dim-x (* styletab-c:borders-dimension 2)))
+          (setq dim-y (- dim-y styletab-c:borders-dimension styletab-c:title-dimension)))
         (when (not (or (eq current-title 'top)
                        (eq current-title 'bottom)))
-          (setq dim-y (- dim-y (* styletab:borders-dimension 2)))
-          (setq dim-x (- dim-x styletab:borders-dimension styletab:title-dimension)))))
+          (setq dim-y (- dim-y (* styletab-c:borders-dimension 2)))
+          (setq dim-x (- dim-x styletab-c:borders-dimension styletab-c:title-dimension)))))
 
     (when (eq dest 'sha-tra)
       (if (or (eq cur 'shaped)
@@ -408,26 +645,26 @@
         (setq new 'shaped))
       (when (eq cur 'default)
         (setq new 'shaped)
-        (setq dim-x (+ dim-x (* styletab:borders-dimension 2)))
-        (setq dim-y (+ dim-y styletab:borders-dimension))
+        (setq dim-x (+ dim-x (* styletab-c:borders-dimension 2)))
+        (setq dim-y (+ dim-y styletab-c:borders-dimension))
         (when (not (or (eq current-title 'top)
                        (eq current-title 'bottom)))
-          (setq dim-x (- dim-x styletab:borders-dimension))
-          (setq dim-y (+ dim-y styletab:borders-dimension))))
+          (setq dim-x (- dim-x styletab-c:borders-dimension))
+          (setq dim-y (+ dim-y styletab-c:borders-dimension))))
       (when (eq cur 'transient)
         (setq new 'shaped-transient)
-        (setq dim-x (+ dim-x (* styletab:borders-dimension 2)))
-        (setq dim-y (+ dim-y styletab:borders-dimension))
+        (setq dim-x (+ dim-x (* styletab-c:borders-dimension 2)))
+        (setq dim-y (+ dim-y styletab-c:borders-dimension))
         (when (not (or (eq current-title 'top)
                        (eq current-title 'bottom)))
-          (setq dim-x (- dim-x styletab:borders-dimension))
-          (setq dim-y (+ dim-y styletab:borders-dimension))))
+          (setq dim-x (- dim-x styletab-c:borders-dimension))
+          (setq dim-y (+ dim-y styletab-c:borders-dimension))))
       (when (eq cur 'unframed)
         (setq new 'shaped)
         (if (or (eq current-title 'top)
                 (eq current-title 'bottom))
-            (setq dim-y (- dim-y styletab:title-dimension))
-          (setq dim-x (- dim-x styletab:title-dimension)))))
+            (setq dim-y (- dim-y styletab-c:title-dimension))
+          (setq dim-x (- dim-x styletab-c:title-dimension)))))
 
     (when (eq dest 'unf-def)
       (when (or (eq cur 'default)
@@ -435,26 +672,26 @@
         (setq new 'unframed)
         (when (or (eq current-title 'top)
                   (eq current-title 'bottom))
-          (setq dim-x (+ dim-x (* styletab:borders-dimension 2)))
-          (setq dim-y (+ dim-y styletab:borders-dimension styletab:title-dimension)))
+          (setq dim-x (+ dim-x (* styletab-c:borders-dimension 2)))
+          (setq dim-y (+ dim-y styletab-c:borders-dimension styletab-c:title-dimension)))
         (when (not (or (eq current-title 'top)
                        (eq current-title 'bottom)))
-          (setq dim-y (+ dim-y (* styletab:borders-dimension 2)))
-          (setq dim-x (+ dim-x styletab:borders-dimension styletab:title-dimension))))
+          (setq dim-y (+ dim-y (* styletab-c:borders-dimension 2)))
+          (setq dim-x (+ dim-x styletab-c:borders-dimension styletab-c:title-dimension))))
       (when (or (eq cur 'shaped)
                 (eq cur 'shaped-transient)
                 (eq cur 'utility))
         (setq new 'unframed)
         (if (or (eq current-title 'top)
                 (eq current-title 'bottom))
-            (setq dim-y (+ dim-y styletab:title-dimension))
-          (setq dim-x (+ dim-x styletab:title-dimension))))
+            (setq dim-y (+ dim-y styletab-c:title-dimension))
+          (setq dim-x (+ dim-x styletab-c:title-dimension))))
       (when (eq cur 'unframed)
         (setq new 'shaped-transient)
         (if (or (eq current-title 'top)
                 (eq current-title 'bottom))
-            (setq dim-y (- dim-y styletab:title-dimension))
-          (setq dim-x (- dim-x styletab:title-dimension)))))
+            (setq dim-y (- dim-y styletab-c:title-dimension))
+          (setq dim-x (- dim-x styletab-c:title-dimension)))))
     (when (not (eq cur new))
       (mapcar (lambda (w)
                 (window-put w 'type new)
@@ -462,7 +699,6 @@
                 (move-window-to w pos-x pos-y)
                 (resize-window-to w dim-x dim-y)) wins))))
 
-
 (define (set-frame-default-and-default/transient)
   "Set frametype to `default' and toggle transient-ness with resize."
   (f-type 'def-tra))
@@ -486,473 +722,539 @@
              "Button3-Off" 'set-frame-shaped-and-shaped/shaped-transient-toggle))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
-;;; make images 
+;;; make images/recolor 
 
 ;; button/icon table
-;;
-(define styletab-icon-cache (make-weak-table eq-hash eq))
+(define styletab-c-icon-cache (make-weak-table eq-hash eq))
 
 ;; frames/title table
-;;
-(define styletab-frame-cache (make-weak-table eq-hash eq))
+(define styletab-c-frame-cache (make-weak-table eq-hash eq))
 
 (define (window-icon w)
-  (or (table-ref styletab-icon-cache w)
+  (or (table-ref styletab-c-icon-cache w)
       (let ((icon (window-icon-image w)))
         (if icon
-            (let ((scaled (scale-image icon (- styletab:title-dimension 7) (- styletab:title-dimension 7))))
-              (table-set styletab-icon-cache w scaled)
+            (let ((scaled (scale-image icon (- styletab-c:title-dimension 7) (- styletab-c:title-dimension 7))))
+              (table-set styletab-c-icon-cache w scaled)
               scaled)
-          (scale-image top-frame-icon-title-images (- styletab:title-dimension 7) (- styletab:title-dimension 7))))))
+          (scale-image top-frame-icon-title-images (- styletab-c:title-dimension 7) (- styletab-c:title-dimension 7))))))
 
-(define top-frame-icon-title-images 
-  (make-image (concat (symbol-name  styletab:style) "/" "top-frame-icon-title-images-f.png")))
+(defun brighten-color (color percentage)
+  (let* ((red (car (color-rgb color)))
+         (green (cadr (color-rgb color)))
+         (blue (car (cddr (color-rgb color))))
+         (red-delta (quotient (* red percentage) 100))
+         (green-delta (quotient (* green percentage) 100))
+         (blue-delta (quotient (* blue percentage) 100)))
+    (get-color-rgb (min (+ red-delta red) 65535)
+                   (min (+ green-delta green) 65535)
+                   (min (+ blue-delta blue) 65535))))
 
-(define (get-frame-image img)
+(defun darken-color (color percentage)
+  (let* ((red (car (color-rgb color)))
+         (green (cadr (color-rgb color)))
+         (blue (car (cddr (color-rgb color))))
+         (red-delta (quotient (* red percentage) 100))
+         (green-delta (quotient (* green percentage) 100))
+         (blue-delta (quotient (* blue percentage) 100)))
+    (get-color-rgb (max (- red red-delta) 0)
+                   (max (- green green-delta) 0)
+                   (max (- blue blue-delta) 0))))
+
+(defun do-recolor (img color)
+  (let* ((recolorer
+          (make-image-recolorer color
+                                #:zero-channel blue-channel
+                                #:index-channel green-channel)))
+    (recolorer img)))
+
+(define (get-recolor-dark dimout color)
+  (darken-color color dimout))
+
+(define (get-recolor-bright bright color)
+  (brighten-color color bright))
+
+(define (do-make-image img)
   (or
-   (table-ref styletab-frame-cache img)
+   (table-ref styletab-c-frame-cache img)
    (let ((image
           (make-image img)))
-     (table-set styletab-frame-cache img image)
+     (table-set styletab-c-frame-cache img image)
      image)))
 
 (define make-border-image
   (lambda (w)
-    `((focused . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-f.png")))
-      (inactive . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-i.png"))))))
+    `((focused . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-f.png")))
+      (inactive . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-f.png")))))) 
 
-(define top-border-images 
-  (lambda (w) (make-border-image (concat w "-frame-top-border"))))
-(define top-left-corner-images 
-  (lambda (w) (make-border-image (concat w "-frame-top-left-corner"))))
-(define top-left-corner-shaped-images 
-  (lambda (w) (make-border-image (concat w "-frame-top-left-corner-shaped"))))
+(define make-tab-image
+  (lambda (w)
+    `((focused . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-f.png")))
+      (highlighted . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-f.png")))
+      (inactive . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-i.png")))
+      (inactive-highlighted . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-i.png"))))))
+
+(define make-base-button-image
+  (lambda (w)
+    `((focused . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-button-f.png")))
+      (highlighted . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-button-f.png")))
+      (clicked . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-button-c.png")))
+      (inactive . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-button-f.png")))
+      (inactive-highlighted . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-button-f.png")))
+      (inactive-clicked . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-button-c.png"))))))
+
+;; Scale foreground botton here.
+;; I have no idea how to scale
+;; a botton after the botton was 
+;; create with make-image, (scale-image
+;; then not work like recolor-image)
+;; so theme or sawfish must restart/reload 
+;; if titel or botton sitz change but it
+;; makes the forground ugly
+(define scale-w nil)
+(define scale-h nil)
+(define make-hight-button-image
+  (lambda (w x)
+    (if (or (= w '"top")
+            (= w '"bottom"))
+        (progn (setq scale-w (+ styletab-c:title-dimension (button-width-custom)))
+               (setq scale-h (- styletab-c:title-dimension 4)))
+      (progn (setq scale-w (- styletab-c:title-dimension 4))
+             (setq scale-h (+ styletab-c:title-dimension (button-width-custom)))))
+    `((focused . ,(scale-image (do-make-image (concat (symbol-name styletab-c:styles) 
+                                                                  "/" w "-frame-" x "-button-f.png")) scale-w scale-h))
+      (highlighted . ,(scale-image (do-make-image (concat (symbol-name styletab-c:styles) 
+                                                                      "/" w "-frame-" x "-button-f.png")) scale-w scale-h))
+      (clicked . ,(scale-image (do-make-image (concat (symbol-name styletab-c:styles) 
+                                                                  "/" w "-frame-" x "-button-c.png")) scale-w scale-h))
+      (inactive . ,(scale-image (do-make-image (concat (symbol-name styletab-c:styles) 
+                                                                   "/" w "-frame-" x "-button-i.png")) scale-w scale-h))
+      (inactive-highlighted . ,(scale-image (do-make-image (concat (symbol-name styletab-c:styles) 
+                                                                               "/" w "-frame-" x "-button-ih.png")) scale-w scale-h))
+      (inactive-clicked . ,(scale-image (do-make-image (concat (symbol-name styletab-c:styles) 
+                                                                           "/" w "-frame-" x "-button-ic.png")) scale-w scale-h)))))
+;;(define make-hight-button-image
+;;  (lambda (w x)
+;;    `((focused . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-" x "-button-f.png")))
+;;      (highlighted . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-" x "-button-f.png")))
+;;      (clicked . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-" x "-button-c.png")))
+;;      (inactive . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-" x "-button-i.png")))
+;;      (inactive-highlighted . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-" x "-button-ih.png")))
+;;      (inactive-clicked . ,(do-make-image (concat (symbol-name styletab-c:styles) "/" w "-frame-" x "-button-ic.png"))))))
+
+;; frames/tabbar
+(define top-frame-icon-title-images 
+  (do-make-image (concat (symbol-name styletab-c:styles) "/" "top-frame-icon-title-images-f.png")))
+
+(define tabbar-horizontal-images
+  (mapcar (lambda (w)  (mapcar (lambda (x) (make-tab-image 
+                                            (concat x "-" w))) (list "top" "bottom"))) (list "frame-tab-left-icon" "frame-tab" "frame-tab-right")))
+(define tabbar-vertical-images
+  (mapcar (lambda (w)  (mapcar (lambda (x) (make-tab-image 
+                                            (concat x "-" w))) (list "left" "right"))) (list "frame-tab-top" "frame-tab" "frame-tab-bottom-icon")))
+(define title-cursor-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-title-cursor"))) (list "top" "bottom" "left" "right")))
+(define title-nocursor-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-title-nocursor"))) (list "top" "bottom" "left" "right")))
+(define top-border-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-top-border"))) (list "bottom" "left" "right")))
+(define top-left-corner-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-top-left-corner"))) (list "top" "bottom" "left" "right")))
 (define top-right-corner-images
-  (lambda (w) (make-border-image (concat w "-frame-top-right-corner"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-top-right-corner"))) (list "top" "bottom" "left" "right")))
+(define top-left-corner-shaped-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-top-left-corner-shaped"))) (list "top" "left")))
 (define top-right-corner-shaped-images
-  (lambda (w) (make-border-image (concat w "-frame-top-right-corner-shaped"))))
-(define tab-left-icon-images 
-  (lambda (w) (make-border-image (concat w "-frame-tab-left-icon"))))
-(define tab-images 
-  (lambda (w) (make-border-image (concat w "-frame-tab"))))
-(define tab-right-images 
-  (lambda (w) (make-border-image (concat w "-frame-tab-right"))))
-(define tab-bottom-icon-images
-  (lambda (w) (make-border-image (concat w "-frame-tab-bottom-icon"))))
-(define tab-top-images
-  (lambda (w) (make-border-image (concat w "-frame-tab-top"))))
-(define title-images 
-  (lambda (w) (make-border-image (concat w "-frame-title"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-top-right-corner-shaped"))) (list "top" "right")))
+(define title-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-title"))) (list "top" "bottom" "left" "right")))
 (define left-border-images
-  (lambda (w) (make-border-image (concat w "-frame-left-border"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-left-border"))) (list "top" "bottom" "right")))
 (define right-border-images
-  (lambda (w) (make-border-image (concat w "-frame-right-border"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-right-border"))) (list "top" "bottom" "left")))
 (define bottom-left-corner-images
-  (lambda (w) (make-border-image (concat w "-frame-bottom-left-corner"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-bottom-left-corner"))) (list "top" "bottom" "left" "right")))
 (define bottom-border-images
-  (lambda (w) (make-border-image (concat w "-frame-bottom-border"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-bottom-border"))) (list "top" "left" "right")))
 (define bottom-right-corner-images
-  (lambda (w) (make-border-image (concat w "-frame-bottom-right-corner"))))
-(define bottom-border-cursor-images
-  (lambda (w) (make-border-image (concat w "-frame-bottom-border-cursor"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-bottom-right-corner"))) (list "top" "bottom" "left" "right")))
 (define bottom-left-corner-shaped-images
-  (lambda (w) (make-border-image (concat w "-frame-bottom-left-corner-shaped"))))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-bottom-left-corner-shaped"))) (list "bottom" "left")))
 (define bottom-right-corner-shaped-images
-  (lambda (w) (make-border-image (concat w "-frame-bottom-right-corner-shaped"))))
-
-(define make-button-image
-  (lambda (w)
-    `((focused . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-f.png")))
-      (highlighted . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-h.png")))
-      (clicked . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-c.png")))
-      (inactive . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-i.png")))
-      (inactive-highlighted . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-ih.png")))
-      (inactive-clicked . ,(get-frame-image (concat (symbol-name  styletab:style) "/" w "-ic.png"))))))
-
-(define button-images
-  (lambda (w x) (make-button-image (concat w "-frame-" x "-button"))))
-
-(define top-frame-shade-button-images (make-button-image "top-frame-shade-button"))
-(define bottom-frame-shade-button-images (make-button-image "bottom-frame-shade-button"))
-(define left-frame-shade-button-images (make-button-image "left-frame-shade-button"))
-(define right-frame-shade-button-images (make-button-image "right-frame-shade-button"))
-(define top-frame-unshade-button-images (make-button-image "top-frame-unshade-button"))
-(define bottom-frame-unshade-button-images (make-button-image "bottom-frame-unshade-button"))
-(define left-frame-unshade-button-images (make-button-image "left-frame-unshade-button"))
-(define right-frame-unshade-button-images (make-button-image "right-frame-unshade-button"))
-(define top-frame-sticky-button-images (make-button-image "top-frame-sticky-button"))
-(define bottom-frame-sticky-button-images (make-button-image "bottom-frame-sticky-button"))
-(define left-frame-sticky-button-images (make-button-image "left-frame-sticky-button"))
-(define right-frame-sticky-button-images (make-button-image "right-frame-sticky-button"))
-(define top-frame-unsticky-button-images (make-button-image "top-frame-unsticky-button"))
-(define bottom-frame-unsticky-button-images (make-button-image "bottom-frame-unsticky-button"))
-(define left-frame-unsticky-button-images (make-button-image "left-frame-unsticky-button"))
-(define right-frame-unsticky-button-images (make-button-image "right-frame-unsticky-button"))
-(define top-frame-maximize-button-images (make-button-image "top-frame-maximize-button"))
-(define bottom-frame-maximize-button-images (make-button-image "bottom-frame-maximize-button"))
-(define left-frame-maximize-button-images (make-button-image "left-frame-maximize-button"))
-(define right-frame-maximize-button-images (make-button-image "right-frame-maximize-button"))
-(define top-frame-unmaximize-button-images (make-button-image "top-frame-unmaximize-button"))
-(define bottom-frame-unmaximize-button-images (make-button-image "bottom-frame-unmaximize-button"))
-(define left-frame-unmaximize-button-images (make-button-image "left-frame-unmaximize-button"))
-(define right-frame-unmaximize-button-images (make-button-image "right-frame-unmaximize-button"))
-(define top-frame-lock-button-images (make-button-image "top-frame-lock-button"))
-(define bottom-frame-lock-button-images (make-button-image "bottom-frame-lock-button"))
-(define left-frame-lock-button-images (make-button-image "left-frame-lock-button"))
-(define right-frame-lock-button-images (make-button-image "right-frame-lock-button"))
-(define top-frame-unlock-button-images (make-button-image "top-frame-unlock-button"))
-(define bottom-frame-unlock-button-images (make-button-image "bottom-frame-unlock-button"))
-(define left-frame-unlock-button-images (make-button-image "left-frame-unlock-button"))
-(define right-frame-unlock-button-images (make-button-image "right-frame-unlock-button"))
-(define top-frame-prev-button-images (make-button-image "top-frame-prev-button"))
-(define bottom-frame-prev-button-images (make-button-image "bottom-frame-prev-button"))
-(define left-frame-prev-button-images (make-button-image "left-frame-prev-button"))
-(define right-frame-prev-button-images (make-button-image "right-frame-prev-button"))
-(define top-frame-prev-last-button-images (make-button-image "top-frame-prev-last-button"))
-(define bottom-frame-prev-last-button-images (make-button-image "bottom-frame-prev-last-button"))
-(define left-frame-prev-last-button-images (make-button-image "left-frame-prev-last-button"))
-(define right-frame-prev-last-button-images (make-button-image "right-frame-prev-last-button"))
-(define top-frame-next-button-images (make-button-image "top-frame-next-button"))
-(define bottom-frame-next-button-images (make-button-image "bottom-frame-next-button"))
-(define left-frame-next-button-images (make-button-image "left-frame-next-button"))
-(define right-frame-next-button-images (make-button-image "right-frame-next-button"))
-(define top-frame-next-last-button-images (make-button-image "top-frame-next-last-button"))
-(define bottom-frame-next-last-button-images (make-button-image "bottom-frame-next-last-button"))
-(define left-frame-next-last-button-images (make-button-image "left-frame-next-last-button"))
-(define right-frame-next-last-button-images (make-button-image "right-frame-next-last-button"))
-(define top-frame-raise-lower-button-images (make-button-image "top-frame-raise-lower-button"))
-(define bottom-frame-raise-lower-button-images (make-button-image "bottom-frame-raise-lower-button"))
-(define left-frame-raise-lower-button-images (make-button-image "left-frame-raise-lower-button"))
-(define right-frame-raise-lower-button-images (make-button-image "right-frame-raise-lower-button"))
-(define top-frame-ontop-button-images (make-button-image "top-frame-ontop-button"))
-(define bottom-frame-ontop-button-images (make-button-image "bottom-frame-ontop-button"))
-(define left-frame-ontop-button-images (make-button-image "left-frame-ontop-button"))
-(define right-frame-ontop-button-images (make-button-image "right-frame-ontop-button"))
-(define top-frame-unontop-button-images (make-button-image "top-frame-unontop-button"))
-(define bottom-frame-unontop-button-images (make-button-image "bottom-frame-unontop-button"))
-(define left-frame-unontop-button-images (make-button-image "left-frame-unontop-button"))
-(define right-frame-unontop-button-images (make-button-image "right-frame-unontop-button"))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
-;;; buttons, colors settings 
-
-(define top-frame-sticky-image-set
-  (lambda (w)
-    (if (window-get w 'sticky)
-        top-frame-unsticky-button-images
-      top-frame-sticky-button-images)))
-
-(define bottom-frame-sticky-image-set
-  (lambda (w)
-    (if (window-get w 'sticky)
-        bottom-frame-unsticky-button-images
-      bottom-frame-sticky-button-images)))
-
-(define left-frame-sticky-image-set
-  (lambda (w)
-    (if (window-get w 'sticky)
-        left-frame-unsticky-button-images
-      left-frame-sticky-button-images)))
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-bottom-right-corner-shaped"))) (list "bottom" "right")))
 
-(define right-frame-sticky-image-set
-  (lambda (w)
-    (if (window-get w 'sticky)
-        right-frame-unsticky-button-images
-      right-frame-sticky-button-images)))
+;; buttons
+(define base-button-images
+  (mapcar (lambda (w) (make-base-button-image w)) (list "top" "bottom" "left" "right")))
+(define space-button-images
+  (mapcar (lambda (w) (make-border-image (concat w "-frame-title"))) (list "top" "bottom" "left" "right")))
+(define close-button-images
+  (mapcar (lambda (w) (make-hight-button-image w "close")) (list "top" "bottom" "left" "right")))
+(define menu-button-images
+  (mapcar (lambda (w) (make-hight-button-image w "menu")) (list "top" "bottom" "left" "right")))
+(define iconify-button-images
+  (mapcar (lambda (w) (make-hight-button-image w "iconify")) (list "top" "bottom" "left" "right")))
+(define move-resize-button-images
+  (mapcar (lambda (w) (make-hight-button-image w "move-resize")) (list "top" "bottom" "left" "right")))
+(define rename-button-images
+  (mapcar (lambda (w) (make-hight-button-image w "rename")) (list "top" "bottom" "left" "right")))
+(define frame-type-button-images
+  (mapcar (lambda (w) (make-hight-button-image w "frame-type")) (list "top" "bottom" "left" "right")))
+(define maximize-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "maximize" "unmaximize")))
+(define shade-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "shade" "unshade")))
+(define sticky-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "sticky" "unsticky")))
+(define lock-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "lock" "unlock")))
+(define prev-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "prev" "prev-last")))
+(define next-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "next" "next-last")))
+(define raise-lower-button-images 
+  (mapcar (lambda (w) (mapcar (lambda (x) (make-hight-button-image x w)) (list "top" "bottom" "left" "right"))) (list "raise-lower" "ontop" "unontop")))
 
-(define top-frame-shade-image-set
-  (lambda (w)
-    (if (window-get w 'shaded)
-        top-frame-unshade-button-images
-      top-frame-shade-button-images)))
+(define (recolor-base)
+  (mapcar (lambda (w)
+            (mapcar (lambda (x)
+                      (do-recolor (cdr (nth 0 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-dark 0 styletab-c:focus-frame-color)
+                                    (get-recolor-dark 0 (get-color (nth 0 (proposals-colors))))))
+                      (do-recolor (cdr (nth 1 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-dark (* styletab-c:inactive-dimout 20) styletab-c:unfocus-frame-color)
+                                    (get-recolor-dark (nth 1 (proposals-colors)) (get-color (nth 0 (proposals-colors))))))) w))
+          (list title-cursor-images title-nocursor-images top-border-images top-left-corner-images top-right-corner-images
+                top-left-corner-shaped-images top-right-corner-shaped-images title-images left-border-images right-border-images
+                bottom-left-corner-images bottom-border-images bottom-right-corner-images bottom-left-corner-shaped-images
+                bottom-right-corner-shaped-images space-button-images))
 
-(define bottom-frame-shade-image-set
-  (lambda (w)
-    (if (window-get w 'shaded)
-        bottom-frame-unshade-button-images
-      bottom-frame-shade-button-images)))
+  (mapcar (lambda (w)
+            (mapcar (lambda (x)
+                      (mapcar (lambda (y)
+                                (do-recolor (cdr (nth y x))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-dark 0 styletab-c:focus-frame-color)
+                                              (get-recolor-dark 0 (get-color (nth 0 (proposals-colors)))))))
+                              (list '0 '1 '2))
+                      (mapcar (lambda (y)
+                                (do-recolor (cdr (nth y x))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-dark (* styletab-c:inactive-dimout 20) styletab-c:unfocus-frame-color)
+                                              (get-recolor-dark (nth 1 (proposals-colors)) (get-color (nth 0 (proposals-colors)))))))
+                              (list '3 '4 '5))) w))
+          (list base-button-images)))
 
-(define left-frame-shade-image-set
-  (lambda (w)
-    (if (window-get w 'shaded)
-        left-frame-unshade-button-images
-      left-frame-shade-button-images)))
+(define (recolor-tab)
+  (mapcar (lambda (w)
+            (mapcar (lambda (x)
+                      (mapcar (lambda (y)
+                                (do-recolor (cdr (nth 0 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-dark 0 styletab-c:focus-frame-color)
+                                              (get-recolor-dark 0 (get-color (nth 0 (proposals-colors))))))
+                                (do-recolor (cdr (nth 1 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-bright (if (eq styletab-c:hightlight-tabbar t) 
+                                                                        (/ (* styletab-c:active-hightlight-brighten 20) 2)
+                                                                      0)
+                                                                    styletab-c:focus-frame-color)
+                                              (get-recolor-bright (if (eq styletab-c:hightlight-tabbar t) 
+                                                                      (/ (nth 2 (proposals-colors)) 2)
+                                                                    0)
+                                                                  (get-color (nth 0 (proposals-colors))))))
+                                (do-recolor (cdr (nth 2 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-dark (* styletab-c:inactive-dimout 20) styletab-c:unfocus-frame-color)
+                                              (get-recolor-dark (nth 1 (proposals-colors)) (get-color (nth 0 (proposals-colors))))))
+                                (do-recolor (cdr (nth 3 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-bright 
+                                                 (if (eq styletab-c:hightlight-tabbar t) 
+                                                     (- (/ (* styletab-c:inactive-hightlight-brighten 20) 2) (* styletab-c:inactive-dimout 20))
+                                                   (- (* styletab-c:inactive-dimout 20)))
+                                                 styletab-c:unfocus-frame-color)
+                                              (get-recolor-bright (if (eq styletab-c:hightlight-tabbar t) 
+                                                                      (- (/ (nth 3 (proposals-colors)) 2) (nth 1 (proposals-colors)))
+                                                                    (- (nth 1 (proposals-colors))))
+                                                                  (get-color (nth 0 (proposals-colors))))))) x)) w)) 
+          (list tabbar-horizontal-images tabbar-vertical-images)))
 
-(define right-frame-shade-image-set
-  (lambda (w)
-    (if (window-get w 'shaded)
-        right-frame-unshade-button-images
-      right-frame-shade-button-images)))
+(define (recolor-botton-static-sing button color always)
+  (mapcar (lambda (w)
+            (mapcar (lambda (x)
+                      (do-recolor (cdr (nth 0 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-dark 0 (if (and always color) color styletab-c:focus-frame-color))
+                                    (get-recolor-dark 0 (if (and always color) color (get-color (nth 0 (proposals-colors)))))))
+                      (do-recolor (cdr (nth 1 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-bright (* styletab-c:active-hightlight-brighten 20) (if color color styletab-c:focus-frame-color))
+                                    (get-recolor-bright (nth 2 (proposals-colors)) (if color color (get-color (nth 0 (proposals-colors)))))))
+                      (do-recolor (cdr (nth 2 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-bright (* styletab-c:active-hightlight-brighten 20) (if color color styletab-c:focus-frame-color))
+                                    (get-recolor-bright (nth 2 (proposals-colors)) (if color color (get-color (nth 0 (proposals-colors)))))))
+                      (do-recolor (cdr (nth 3 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-dark (* styletab-c:inactive-dimout 20) (if (and always color) color styletab-c:unfocus-frame-color))
+                                    (get-recolor-dark (nth 1 (proposals-colors)) (if (and always color) color (get-color (nth 0 (proposals-colors)))))))
+                      (do-recolor (cdr (nth 4 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-bright (- (* styletab-c:inactive-hightlight-brighten 20) (* styletab-c:inactive-dimout 20))
+                                                          (if color color styletab-c:unfocus-frame-color))
+                                    (get-recolor-bright (- (nth 3 (proposals-colors)) (nth 1 (proposals-colors)))
+                                                        (if color color (get-color (nth 0 (proposals-colors)))))))
+                      (do-recolor (cdr (nth 5 x))
+                                  (if (eq styletab-c:custom-frame-colors t)
+                                      (get-recolor-bright (- (* styletab-c:inactive-hightlight-brighten 20) (* styletab-c:inactive-dimout 20))
+                                                          (if color color styletab-c:unfocus-frame-color))
+                                    (get-recolor-bright (- (nth 3 (proposals-colors)) (nth 1 (proposals-colors)))
+                                                        (if color color (get-color (nth 0 (proposals-colors)))))))) w))
+          (list button)))
 
-(define top-frame-maximize-image-set
-  (lambda (w)
-    (if (window-get w 'unmaximized-geometry)
-        top-frame-unmaximize-button-images
-      top-frame-maximize-button-images)))
+(define (recolor-botton-dynamic-sing button color always)
+  (mapcar (lambda (w)
+            (mapcar (lambda (x)
+                      (mapcar (lambda (y)
+                                (do-recolor (cdr (nth 0 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-dark 0 (if (and always color) color styletab-c:focus-frame-color))
+                                              (get-recolor-dark 0 (if (and always color) color (get-color (nth 0 (proposals-colors)))))))
+                                (do-recolor (cdr (nth 1 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-bright (* styletab-c:active-hightlight-brighten 20) 
+                                                                    (if color color styletab-c:focus-frame-color))
+                                              (get-recolor-bright (nth 2 (proposals-colors)) (if color color (get-color (nth 0 (proposals-colors)))))))
+                                (do-recolor (cdr (nth 2 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-bright (* styletab-c:active-hightlight-brighten 20) 
+                                                                    (if color color styletab-c:focus-frame-color))
+                                              (get-recolor-bright (nth 2 (proposals-colors)) (if color color (get-color (nth 0 (proposals-colors)))))))
+                                (do-recolor (cdr (nth 3 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-dark (* styletab-c:inactive-dimout 20) 
+                                                                  (if (and always color) color styletab-c:unfocus-frame-color))
+                                              (get-recolor-dark (nth 1 (proposals-colors)) 
+                                                                (if (and always color) color (get-color (nth 0 (proposals-colors)))))))
+                                (do-recolor (cdr (nth 4 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-bright (- (* styletab-c:inactive-hightlight-brighten 20) (* styletab-c:inactive-dimout 20))
+                                                                    (if color color styletab-c:unfocus-frame-color))
+                                              (get-recolor-bright (- (nth 3 (proposals-colors)) (nth 1 (proposals-colors)))
+                                                                  (if color color (get-color (nth 0 (proposals-colors)))))))
+                                (do-recolor (cdr (nth 5 y))
+                                            (if (eq styletab-c:custom-frame-colors t)
+                                                (get-recolor-bright (- (* styletab-c:inactive-hightlight-brighten 20) (* styletab-c:inactive-dimout 20))
+                                                                    (if color color styletab-c:unfocus-frame-color))
+                                              (get-recolor-bright (- (nth 3 (proposals-colors)) (nth 1 (proposals-colors)))
+                                                                  (if color color (get-color (nth 0 (proposals-colors)))))))) x)) w))
+          (list button)))
 
-(define bottom-frame-maximize-image-set
-  (lambda (w)
-    (if (window-get w 'unmaximized-geometry)
-        bottom-frame-unmaximize-button-images
-      bottom-frame-maximize-button-images)))
+(define (recolor-close-button)
+  (recolor-botton-static-sing close-button-images styletab-c:hightlight-close (if (eq styletab-c:hightlight-close-all t) t)))
+(define (recolor-menu-button)
+  (recolor-botton-static-sing menu-button-images styletab-c:hightlight-menu (if (eq styletab-c:hightlight-menu-all t) t)))
+(define (recolor-iconify-button)
+  (recolor-botton-static-sing iconify-button-images styletab-c:hightlight-iconify (if (eq styletab-c:hightlight-iconify-all t) t)))
+(define (recolor-move-resize-button)
+  (recolor-botton-static-sing move-resize-button-images styletab-c:hightlight-move-resize (if (eq styletab-c:hightlight-move-resize-all t) t)))
+(define (recolor-rename-button)
+  (recolor-botton-static-sing rename-button-images styletab-c:hightlight-rename (if (eq styletab-c:hightlight-rename-all t) t)))
+(define (recolor-frame-type-button)
+  (recolor-botton-static-sing frame-type-button-images styletab-c:hightlight-frame-type (if (eq styletab-c:hightlight-frame-type-all t) t)))
+(define (recolor-maximize-button)
+  (recolor-botton-dynamic-sing maximize-button-images styletab-c:hightlight-maximize (if (eq styletab-c:hightlight-maximize-all t) t)))
+(define (recolor-shade-button)
+  (recolor-botton-dynamic-sing shade-button-images styletab-c:hightlight-shade (if (eq styletab-c:hightlight-shade-all t) t)))
+(define (recolor-sticky-button)
+  (recolor-botton-dynamic-sing sticky-button-images styletab-c:hightlight-sticky (if (eq styletab-c:hightlight-sticky-all t) t)))
+(define (recolor-lock-button)
+  (recolor-botton-dynamic-sing lock-button-images styletab-c:hightlight-lock (if (eq styletab-c:hightlight-lock-all t) t)))
+(define (recolor-prev-button)
+  (recolor-botton-dynamic-sing prev-button-images styletab-c:hightlight-prev (if (eq styletab-c:hightlight-prev-all t) t)))
+(define (recolor-next-button)
+  (recolor-botton-dynamic-sing next-button-images styletab-c:hightlight-next (if (eq styletab-c:hightlight-next-all t) t)))
+(define (recolor-raise-lower-button)
+  (recolor-botton-dynamic-sing raise-lower-button-images styletab-c:hightlight-raise-lower (if (eq styletab-c:hightlight-raise-lower-all t) t)))
 
-(define left-frame-maximize-image-set
-  (lambda (w)
-    (if (window-get w 'unmaximized-geometry)
-        left-frame-unmaximize-button-images
-      left-frame-maximize-button-images)))
+(define (recolor-all-buttons)
+  (recolor-close-button) (recolor-menu-button) (recolor-iconify-button) (recolor-move-resize-button) (recolor-rename-button) 
+  (recolor-frame-type-button) (recolor-maximize-button) (recolor-shade-button) (recolor-sticky-button) (recolor-lock-button)
+  (recolor-prev-button) (recolor-next-button) (recolor-raise-lower-button))
 
-(define right-frame-maximize-image-set
-  (lambda (w)
-    (if (window-get w 'unmaximized-geometry)
-        right-frame-unmaximize-button-images
-      right-frame-maximize-button-images)))
+(define (recolor-all)
+  (recolor-base) (recolor-tab) (recolor-all-buttons))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;; frames classes
 (defmacro window-in-workspace-p (w space)
   `(memq ,space (window-get ,w 'workspaces)))
 
 (define (get-first-workspace) 1)
 
-(define top-frame-prev-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-first-workspace) 1))
-            (window-get w 'sticky))
-        top-frame-prev-last-button-images
-      top-frame-prev-button-images)))
-
-(define bottom-frame-prev-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-first-workspace) 1))
-            (window-get w 'sticky))
-        bottom-frame-prev-last-button-images
-      bottom-frame-prev-button-images)))
-
-(define left-frame-prev-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-first-workspace) 1))
-            (window-get w 'sticky))
-        left-frame-prev-last-button-images
-      left-frame-prev-button-images)))
-
-(define right-frame-prev-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-first-workspace) 1))
-            (window-get w 'sticky))
-        right-frame-prev-last-button-images
-      right-frame-prev-button-images)))
-
 (define (get-last-workspace)
   (aref
    (nth 2 (get-x-property 'root '_NET_NUMBER_OF_DESKTOPS)) 0))
 
-(define top-frame-next-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-last-workspace) 1))
-            (window-get w 'sticky))
-        top-frame-next-last-button-images
-      top-frame-next-button-images)))
-
-(define bottom-frame-next-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-last-workspace) 1))
-            (window-get w 'sticky))
-        bottom-frame-next-last-button-images
-      bottom-frame-next-button-images)))
-
-(define left-frame-next-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-last-workspace) 1))
-            (window-get w 'sticky))
-        left-frame-next-last-button-images
-      left-frame-next-button-images)))
-
-(define right-frame-next-image-set
-  (lambda (w)
-    (if (or (window-in-workspace-p w (- (get-last-workspace) 1))
-            (window-get w 'sticky))
-        right-frame-next-last-button-images
-      right-frame-next-button-images)))
-
-(define top-frame-lock-image-set
-  (lambda (w)
-    (if (window-get w 'fixed-position)
-        top-frame-unlock-button-images
-      top-frame-lock-button-images)))
-
-(define bottom-frame-lock-image-set
-  (lambda (w)
-    (if (window-get w 'fixed-position)
-        bottom-frame-unlock-button-images
-      bottom-frame-lock-button-images)))
-
-(define left-frame-lock-image-set
-  (lambda (w)
-    (if (window-get w 'fixed-position)
-        left-frame-unlock-button-images
-      left-frame-lock-button-images)))
-
-(define right-frame-lock-image-set
-  (lambda (w)
-    (if (window-get w 'fixed-position)
-        right-frame-unlock-button-images
-      right-frame-lock-button-images)))
-
-(define top-frame-raise-lower-image-set
-  (lambda (w)
-    (if (= (window-get w 'depth) 0)
-        top-frame-raise-lower-button-images
-      (if (> (window-get w 'depth) 0)
-          top-frame-ontop-button-images
-        top-frame-unontop-button-images))))
-
-(define bottom-frame-raise-lower-image-set
-  (lambda (w)
-    (if (= (window-get w 'depth) 0)
-        bottom-frame-raise-lower-button-images
-      (if (> (window-get w 'depth) 0)
-          bottom-frame-ontop-button-images
-        bottom-frame-unontop-button-images))))
-
-(define left-frame-raise-lower-image-set
-  (lambda (w)
-    (if (= (window-get w 'depth) 0)
-        left-frame-raise-lower-button-images
-      (if (> (window-get w 'depth) 0)
-          left-frame-ontop-button-images
-        left-frame-unontop-button-images))))
-
-(define right-frame-raise-lower-image-set
-  (lambda (w)
-    (if (= (window-get w 'depth) 0)
-        right-frame-raise-lower-button-images
-      (if (> (window-get w 'depth) 0)
-          right-frame-ontop-button-images
-        right-frame-unontop-button-images))))
-
 (define frame-width
   (lambda (w)
     (if (or (eq (window-type w) 'default)
 			(eq (window-type w) 'transient))
-        styletab:borders-dimension
+        styletab-c:borders-dimension
       0)))
 
 (define frame-edge
   (lambda (w)
     (if (or (eq (window-type w) 'default)
             (eq (window-type w) 'transient))
-        (- styletab:borders-dimension)
+        (- styletab-c:borders-dimension)
       0)))
 
-(define title-height (lambda (w) styletab:title-dimension)) 
-(define title-height-s (lambda (w) (- styletab:title-dimension 2)))
-(define title-edge (lambda (w) (- styletab:title-dimension)))
-(define title-edge-s (lambda (w) (- (- styletab:title-dimension 2))))
-(define top-frame-button-width (lambda (w) (+ styletab:title-dimension (button-width-custom))))
-(define bottom-frame-button-width (lambda (w) (+ styletab:title-dimension (button-width-custom))))
-(define left-frame-button-height (lambda (w) (+ styletab:title-dimension (button-width-custom))))
-(define right-frame-button-height (lambda (w) (+ styletab:title-dimension (button-width-custom))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
-;;; frames 
+(define title-height (lambda (w) styletab-c:title-dimension)) 
+(define title-height-s (lambda (w) (- styletab-c:title-dimension 4)))
+(define title-edge (lambda (w) (- styletab-c:title-dimension)))
+(define title-edge-s (lambda (w) (- (- styletab-c:title-dimension 2))))
+(define top-frame-button-width (lambda (w) (+ styletab-c:title-dimension (button-width-custom))))
+(define bottom-frame-button-width (lambda (w) (+ styletab-c:title-dimension (button-width-custom))))
+(define left-frame-button-height (lambda (w) (+ styletab-c:title-dimension (button-width-custom))))
+(define right-frame-button-height (lambda (w) (+ styletab-c:title-dimension (button-width-custom))))
 
-(define top-frame-default-border-corner-group 
-  `(((class . top-left-corner)
-     (background . ,(top-left-corner-images "top"))
+(define top-frame-default-border-corner-group
+  `(((class . title)
+     (background . ,(nth 0 title-images))
+     (left-edge . 0)
+     (top-edge . ,title-edge-s)
+     (height . ,title-height-s)
+     (width . ,button-left-edge))
+    ((class . top-left-corner)
+     (background . ,(nth 0 top-left-corner-images))
      (left-edge . ,frame-edge)
      (top-edge . ,title-edge)
      (height . ,title-height)
      (width . ,frame-width))
-	((class . top-right-corner)
-     (background . ,(top-right-corner-images "top"))
+    ((class . top-right-corner)
+     (background . ,(nth 0 top-right-corner-images))
      (top-edge . ,title-edge)
      (right-edge . ,frame-edge)
      (height . ,title-height)
      (width . ,frame-width))
     ((class . title)
-     (background . ,(title-images "top"))
+     (background . ,(nth 0 title-images))
      (right-edge . 0)
      (top-edge . ,title-edge-s)
      (height . ,title-height-s)
-     (width . 2))))
+     (width . ,button-right-edge))))
 
 (define bottom-frame-default-border-corner-group
-  `(((class . bottom-left-corner)
-     (background . ,(bottom-left-corner-images "bottom"))
+  `(((class . title)
+     (background . ,(nth 1 title-images))
+     (left-edge . 0)
+     (bottom-edge . ,title-edge-s)
+     (height . ,title-height-s)
+     (width . ,button-left-edge))
+    ((class . bottom-left-corner)
+     (background . ,(nth 1 bottom-left-corner-images))
      (left-edge . ,frame-edge)
      (bottom-edge . ,title-edge)
      (height . ,title-height)
      (width . ,frame-width))
     ((class . bottom-right-corner)
-     (background . ,(bottom-right-corner-images "bottom"))
+     (background . ,(nth 1 bottom-right-corner-images))
      (bottom-edge . ,title-edge)
      (right-edge . ,frame-edge)
      (height . ,title-height)
      (width . ,frame-width))
     ((class . title)
-     (background . ,(title-images "bottom"))
+     (background . ,(nth 1 title-images))
      (right-edge . 0)
-     (bottom-edge . ,title-edge)
+     (bottom-edge . ,title-edge-s)
      (height . ,title-height-s)
-     (width . 2))))
+     (width . ,button-right-edge))))
 
 (define left-frame-default-border-corner-group
-  `(((class . bottom-left-corner)
-     (background . ,(bottom-left-corner-images "left"))
+  `(((class . title)
+     (background . ,(nth 2 title-images))
+     (top-edge . 0)
+     (left-edge . ,title-edge-s)
+     (height . ,button-right-edge)
+     (width . ,title-height-s))
+    ((class . bottom-left-corner)
+     (background . ,(nth 2 bottom-left-corner-images))
      (bottom-edge . ,frame-edge)
      (left-edge . ,title-edge)
      (height . ,frame-width)
      (width . ,title-height))
     ((class . top-left-corner)
-     (background . ,(top-left-corner-images "left"))
+     (background . ,(nth 2 top-left-corner-images))
      (top-edge . ,frame-edge)
      (left-edge . ,title-edge)
      (height . ,frame-width)
-     (width . ,title-height))))
+     (width . ,title-height))
+    ((class . title)
+     (background . ,(nth 2 title-images))
+     (bottom-edge . 0)
+     (left-edge . ,title-edge-s)
+     (height . ,button-left-edge)
+     (width . ,title-height-s))))
 
 (define right-frame-default-border-corner-group
-  `(((class . bottom-right-corner)
-     (background . ,(bottom-right-corner-images "right"))
+  `(((class . title)
+     (background . ,(nth 3 title-images))
+     (top-edge . 0)
+     (right-edge . ,title-edge-s)
+     (height . ,button-left-edge)
+     (width . ,title-height-s))
+    ((class . bottom-right-corner)
+     (background . ,(nth 3 bottom-right-corner-images))
      (bottom-edge . ,frame-edge)
      (right-edge . ,title-edge)
      (height . ,frame-width)
      (width . ,title-height))
     ((class . top-right-corner)
-     (background . ,(top-right-corner-images "right"))
+     (background . ,(nth 3 top-right-corner-images))
      (top-edge . ,frame-edge)
      (right-edge . ,title-edge)
      (height . ,frame-width)
-     (width . ,title-height))))
+     (width . ,title-height))
+    ((class . title)
+     (background . ,(nth 3 title-images))
+     (bottom-edge . 0)
+     (right-edge . ,title-edge-s)
+     (height . ,button-right-edge)
+     (width . ,title-height-s))))
 
 (define top-frame-border-group
   `(((class . left-border)
-     (background . ,(left-border-images "top"))
+     (background . ,(nth 0 left-border-images))
      (cursor . sb_h_double_arrow)
      (left-edge . ,frame-edge)
      (top-edge . 0)
      (width . ,frame-width)
      (bottom-edge . 0))
 	((class . bottom-left-corner)
-     (background . ,(bottom-left-corner-images "top"))
+     (background . ,(nth 0 bottom-left-corner-images))
      (left-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width)
      (bottom-edge . ,frame-edge))
 	((class . bottom-border)
-     (background . ,(bottom-border-images "top"))
+     (background . ,(nth 0 bottom-border-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (right-edge . 0)
      (height . ,frame-width)
      (bottom-edge . ,frame-edge))
 	((class . bottom-right-corner)
-     (background . ,(bottom-right-corner-images "top"))
+     (background . ,(nth 0 bottom-right-corner-images))
      (right-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width)
      (bottom-edge . ,frame-edge))
 	((class . right-border)
-     (background . ,(right-border-images "top"))
+     (background . ,(nth 0 right-border-images))
      (cursor . sb_h_double_arrow)
      (top-edge . 0)
      (right-edge . ,frame-edge)
@@ -961,33 +1263,33 @@
 
 (define bottom-frame-border-group
   `(((class . left-border)
-     (background . ,(left-border-images "bottom"))
+     (background . ,(nth 1 left-border-images))
      (cursor . sb_h_double_arrow)
      (left-edge . ,frame-edge)
      (bottom-edge . 0)
      (width . ,frame-width)
      (top-edge . 0))
     ((class . top-left-corner)
-     (background . ,(top-left-corner-images "bottom"))
+     (background . ,(nth 1 top-left-corner-images))
      (left-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width)
      (top-edge . ,frame-edge))
     ((class . top-border)
-     (background . ,(top-border-images "bottom"))
+     (background . ,(nth 0 top-border-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (right-edge . 0)
      (height . ,frame-width)
      (top-edge . ,frame-edge))
     ((class . top-right-corner)
-     (background . ,(top-right-corner-images "bottom"))
+     (background . ,(nth 1 top-right-corner-images))
      (right-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width)
      (top-edge . ,frame-edge))
     ((class . right-border)
-     (background . ,(right-border-images "bottom"))
+     (background . ,(nth 1 right-border-images))
      (cursor . sb_h_double_arrow)
      (bottom-edge . 0)
      (right-edge . ,frame-edge)
@@ -996,33 +1298,33 @@
 
 (define left-frame-border-group
   `(((class . bottom-border)
-     (background . ,(bottom-border-images "left"))
+     (background . ,(nth 1 bottom-border-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (right-edge . 0)
      (height . ,frame-width)
      (bottom-edge . ,frame-edge))
     ((class . bottom-right-corner)
-     (background . ,(bottom-right-corner-images "left"))
+     (background . ,(nth 2 bottom-right-corner-images))
      (right-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width)
      (bottom-edge . ,frame-edge))
     ((class . right-border)
-     (background . ,(right-border-images "left"))
+     (background . ,(nth 2 right-border-images))
      (cursor . sb_h_double_arrow)
      (top-edge . 0)
      (right-edge . ,frame-edge)
      (width . ,frame-width)
      (bottom-edge . 0))
     ((class . top-right-corner)
-     (background . ,(top-right-corner-images "left"))
+     (background . ,(nth 2 top-right-corner-images))
      (top-edge . ,frame-edge)
      (right-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width))
     ((class . top-border)
-     (background . ,(top-border-images "left"))
+     (background . ,(nth 1 top-border-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (right-edge . 0)
@@ -1031,33 +1333,33 @@
 
 (define right-frame-border-group
   `(((class . bottom-border)
-     (background . ,(bottom-border-images "right"))
+     (background . ,(nth 2 bottom-border-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (right-edge . 0)
      (height . ,frame-width)
      (bottom-edge . ,frame-edge))
     ((class . bottom-left-corner)
-     (background . ,(bottom-left-corner-images "right"))
+     (background . ,(nth 3 bottom-left-corner-images))
      (left-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width)
      (bottom-edge . ,frame-edge))
     ((class . left-border)
-     (background . ,(left-border-images "right"))
+     (background . ,(nth 2 left-border-images))
      (cursor . sb_h_double_arrow)
      (top-edge . 0)
      (left-edge . ,frame-edge)
      (width . ,frame-width)
      (bottom-edge . 0))
     ((class . top-left-corner)
-     (background . ,(top-left-corner-images "right"))
+     (background . ,(nth 3 top-left-corner-images))
      (top-edge . ,frame-edge)
      (left-edge . ,frame-edge)
      (height . ,frame-width)
      (width . ,frame-width))
     ((class . top-border)
-     (background . ,(top-border-images "right"))
+     (background . ,(nth 2 top-border-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (right-edge . 0)
@@ -1066,68 +1368,81 @@
 
 (define top-frame-title-group
   `(((class . top-border)
-     (background . ,(top-border-images "top"))
+     (background . ,(nth 0 title-cursor-images))
      (cursor . sb_v_double_arrow)
      (left-edge . 0)
      (top-edge . ,title-edge)
      (right-edge . 0)
      (height . 2))
     ((class . tabbar-horizontal)
-     (x-justify . ,(lambda (w) (- styletab:title-dimension 12)))
+     (x-justify . ,(lambda (w) (- styletab-c:title-dimension 12)))
      (y-justify . center)
-     (background . ,(tab-images "top"))
+     (background . ,(nth 0 (nth 1 tabbar-horizontal-images)))
      (foreground . ,title-colors-images)
      (top-edge . ,title-edge-s)
      (height . ,title-height-s)
      (text . ,window-name))
     ((class . tabbar-horizontal-left-edge)
      (foreground . ,(lambda (w) (window-icon w)))
-     (background . ,(tab-left-icon-images "top"))
+     (background . ,(nth 0 (nth 0 tabbar-horizontal-images)))
      (cursor . hand2)
      (top-edge . ,title-edge-s)
      (height . ,title-height-s)
-     (width . ,title-height-s)
+     (width . ,(lambda (w) (+ 2 (title-height-s w))))
      (y-justify . 2)
-     (x-justify . 5))
+     (x-justify . ,(lambda (w) (+ 3 (icon-edge w)))))
     ((class . tabbar-horizontal-right-edge)
-     (background . ,(tab-right-images "top"))
+     (background . ,(nth 0 (nth 2 tabbar-horizontal-images)))
      (width . ,tabbar-right-edge-width)
      (height . ,title-height-s)
-     (top-edge . ,title-edge-s))))
+     (top-edge . ,title-edge-s))
+    ((class . title)
+     (background . ,(nth 0 title-nocursor-images))
+     (left-edge . 0)
+     (top-edge . -2)
+     (right-edge . 0)
+     (height . 2))))
 
 (define bottom-frame-title-group
   `(((class . title)
-     (background . ,(bottom-border-images "bottom"))
+     (background . ,(nth 1 title-nocursor-images))
      (left-edge . 0)
      (bottom-edge . -2)
      (right-edge . 0)
      (height . 2))
     ((class . tabbar-horizontal)
-     (x-justify . ,(lambda (w) (- styletab:title-dimension 12)))
+     (x-justify . ,(lambda (w) (- styletab-c:title-dimension 12)))
      (y-justify . center)
-     (background . ,(tab-images "bottom"))
+     (background . ,(nth 0 (nth 1 tabbar-horizontal-images)))
      (foreground . ,title-colors-images)
-     (bottom-edge . ,title-edge)
+     (bottom-edge . ,title-edge-s)
      (height . ,title-height-s)
      (text . ,window-name))
     ((class . tabbar-horizontal-left-edge)
      (foreground . ,(lambda (w) (window-icon w)))
-     (background . ,(tab-left-icon-images "bottom"))
+     (background . ,(nth 0 (nth 0 tabbar-horizontal-images)))
      (cursor . hand2)
-     (bottom-edge . ,title-edge)
+     (bottom-edge . ,title-edge-s)
      (height . ,title-height-s)
-     (width . ,title-height-s)
+     (width . ,(lambda (w) (+ 2 (title-height-s w))))
      (y-justify . 2)
-     (x-justify . 5))
+     (x-justify . ,(lambda (w) (+ 3 (icon-edge w)))))
     ((class . tabbar-horizontal-right-edge)
-     (background . ,(tab-right-images "bottom"))
+     (background . ,(nth 0 (nth 2 tabbar-horizontal-images)))
      (width . ,tabbar-right-edge-width)
      (height . ,title-height-s)
-     (bottom-edge . ,title-edge))))
+     (bottom-edge . ,title-edge-s))
+    ((class . bottom-border)
+     (background . ,(nth 1 title-cursor-images))
+     (cursor . sb_v_double_arrow)
+     (left-edge . 0)
+     (bottom-edge . ,title-edge)
+     (right-edge . 0)
+     (height . 2))))
 
 (define left-frame-title-group
   `(((class . left-border)
-     (background . ,(left-border-images "left"))
+     (background . ,(nth 2 title-cursor-images))
      (cursor . sb_h_double_arrow)
      (top-edge . 0)
      (left-edge . ,title-edge)
@@ -1135,31 +1450,37 @@
      (width . 2))
     ((class . tabbar-vertical-top-edge)
      (foreground . ,(lambda (w) (window-icon w)))
-     (background . ,(tab-top-images "left"))
+     (background . ,(nth 0 (nth 0 tabbar-vertical-images)))
      (cursor . hand2)
-     (height . ,title-height-s)
+     (height . ,(lambda (w) (+ 2 (title-height-s w))))
      (width . ,title-height-s)
      (left-edge . ,title-edge-s)
-     (y-justify . 4)
+     (y-justify . ,(lambda (w) (+ 2 (icon-edge w))))
      (x-justify . 2))
     ((class . tabbar-vertical)
      (x-justify . 12)
      (y-justify . center)
-     (background . ,(tab-images "left"))
+     (background . ,(nth 0 (nth 1 tabbar-vertical-images)))
      (left-edge . ,title-edge-s)
      (width . ,title-height-s))
     ((class . tabbar-vertical-bottom-edge)
      (foreground . ,(lambda (w) (window-icon w)))
-     (background . ,(tab-bottom-icon-images "left"))
+     (background . ,(nth 0 (nth 2 tabbar-vertical-images)))
      (left-edge . ,title-edge-s)
      (height . ,title-height-s)
      (width . ,title-height-s)
-     (y-justify . 1)
-     (x-justify . 2))))
+     (y-justify . ,(lambda (w) (- (+ 0 (icon-edge w)))))
+     (x-justify . 2))
+    ((class . title)
+     (background . ,(nth 2 title-nocursor-images))
+     (top-edge . 0)
+     (left-edge . -2)
+     (bottom-edge . 0)
+     (width . 2))))
 
 (define right-frame-title-group
   `(((class . right-border)
-     (background . ,(right-border-images "right"))
+     (background . ,(nth 3 title-cursor-images))
      (cursor . sb_h_double_arrow)
      (top-edge . 0)
      (right-edge . ,title-edge)
@@ -1167,40 +1488,38 @@
      (width . 2))
     ((class . tabbar-vertical-top-edge)
      (foreground . ,(lambda (w) (window-icon w)))
-     (background . ,(tab-top-images "right"))
+     (background . ,(nth 1 (nth 0 tabbar-vertical-images)))
      (cursor . hand2)
-     (height . ,title-height-s)
+     (height . ,(lambda (w) (+ 2 (title-height-s w))))
      (width . ,title-height-s)
      (right-edge . ,title-edge-s)
-     (y-justify . 4)
-     (x-justify . 4))
+     (y-justify . ,(lambda (w) (+ 2 (icon-edge w))))
+     (x-justify . 2))
     ((class . tabbar-vertical)
      (x-justify . 12)
      (y-justify . center)
-     (background . ,(tab-images "right"))
+     (background . ,(nth 1 (nth 1 tabbar-vertical-images)))
      (right-edge . ,title-edge-s)
      (width . ,title-height-s))
     ((class . tabbar-vertical-bottom-edge)
      (foreground . ,(lambda (w) (window-icon w)))
-     (background . ,(tab-bottom-icon-images "right"))
+     (background . ,(nth 1 (nth 2 tabbar-vertical-images)))
      (right-edge . ,title-edge-s)
      (height . ,title-height-s)
      (width . ,title-height-s)
-     (y-justify . 1)
-     (x-justify . 4))))
-
-(define bottom-frame-title-cursor-images
-  `(((class . bottom-border)
-     (background . ,(bottom-border-cursor-images "bottom"))
-     (cursor . sb_v_double_arrow)
-     (left-edge . 0)
-     (bottom-edge . ,title-edge)
-     (right-edge . 0)
-     (height . 2))))
+     (y-justify . ,(lambda (w) (- (+ 0 (icon-edge w)))))
+     (x-justify . 2))
+    ((class . title)
+     (background . ,(nth 3 title-nocursor-images))
+     (top-edge . 0)
+     (right-edge . -2)
+     (bottom-edge . 0)
+     (width . 2))))
 
 (define top-frame-close-button
   `((class . close-button)
-    (background . ,(button-images "top" "close"))
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(nth 0 close-button-images))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1208,15 +1527,17 @@
 
 (define bottom-frame-close-button
   `((class . close-button)
-    (background . ,(button-images "bottom" "close"))
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(nth 1 close-button-images))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-close-button
   `((class . close-button)
-    (background . ,(button-images "left" "close"))
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(nth 2 close-button-images))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1224,7 +1545,8 @@
 
 (define right-frame-close-button
   `((class . close-button)
-    (background . ,(button-images "right" "close"))
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(nth 3 close-button-images))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1232,7 +1554,8 @@
 
 (define top-frame-menu-button
   `((class . menu-button)
-    (background . ,(button-images "top" "menu"))
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(nth 0 menu-button-images))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1240,15 +1563,17 @@
 
 (define bottom-frame-menu-button
   `((class . menu-button)
-    (background . ,(button-images "bottom" "menu"))
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(nth 1 menu-button-images))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-menu-button
   `((class . menu-button)
-    (background . ,(button-images "left" "menu"))
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(nth 2 menu-button-images))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1256,7 +1581,8 @@
 
 (define right-frame-menu-button
   `((class . menu-button)
-    (background . ,(button-images "right" "menu"))
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(nth 3 menu-button-images))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1264,7 +1590,8 @@
 
 (define top-frame-iconify-button
   `((class . iconify-button)
-    (background . ,(button-images "top" "iconify"))
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(nth 0 iconify-button-images))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1272,15 +1599,17 @@
 
 (define bottom-frame-iconify-button
   `((class . iconify-button)
-    (background . ,(button-images "bottom" "iconify"))
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(nth 1 iconify-button-images))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-iconify-button
   `((class . iconify-button)
-    (background . ,(button-images "left" "iconify"))
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(nth 2 iconify-button-images))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1288,7 +1617,8 @@
 
 (define right-frame-iconify-button
   `((class . iconify-button)
-    (background . ,(button-images "right" "iconify"))
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(nth 3 iconify-button-images))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1296,7 +1626,9 @@
 
 (define top-frame-maximize-button
   `((class . maximize-button)
-    (background . ,top-frame-maximize-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'unmaximized-geometry) 
+                                   (nth 0 (nth 1 maximize-button-images)) (nth 0 (nth 0 maximize-button-images)))))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1304,15 +1636,19 @@
 
 (define bottom-frame-maximize-button
   `((class . maximize-button)
-    (background . ,bottom-frame-maximize-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'unmaximized-geometry) 
+                                   (nth 1 (nth 1 maximize-button-images)) (nth 1 (nth 0 maximize-button-images)))))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-maximize-button
   `((class . maximize-button)
-    (background . ,left-frame-maximize-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'unmaximized-geometry) 
+                                   (nth 2 (nth 1 maximize-button-images)) (nth 2 (nth 0 maximize-button-images)))))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1320,7 +1656,9 @@
 
 (define right-frame-maximize-button
   `((class . maximize-button)
-    (background . ,right-frame-maximize-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'unmaximized-geometry) 
+                                   (nth 3 (nth 1 maximize-button-images)) (nth 3 (nth 0 maximize-button-images)))))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1328,7 +1666,8 @@
 
 (define top-frame-shade-button
   `((class . shade-button)
-    (background . ,top-frame-shade-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'shaded) (nth 0 (nth 1 shade-button-images)) (nth 0 (nth 0 shade-button-images)))))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1336,15 +1675,17 @@
 
 (define bottom-frame-shade-button
   `((class . shade-button)
-    (background . ,bottom-frame-shade-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'shaded) (nth 1 (nth 1 shade-button-images)) (nth 1 (nth 0 shade-button-images)))))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-shade-button
   `((class . shade-button)
-    (background . ,left-frame-shade-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'shaded) (nth 2 (nth 1 shade-button-images)) (nth 2 (nth 0 shade-button-images)))))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1352,7 +1693,8 @@
 
 (define right-frame-shade-button
   `((class . shade-button)
-    (background . ,right-frame-shade-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'shaded) (nth 3 (nth 1 shade-button-images)) (nth 3 (nth 0 shade-button-images)))))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1360,7 +1702,8 @@
 
 (define top-frame-sticky-button
   `((class . sticky-button)
-    (background . ,top-frame-sticky-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'sticky) (nth 0 (nth 1 sticky-button-images)) (nth 0 (nth 0 sticky-button-images)))))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1368,15 +1711,17 @@
 
 (define bottom-frame-sticky-button
   `((class . sticky-button)
-    (background . ,bottom-frame-sticky-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'sticky) (nth 1 (nth 1 sticky-button-images)) (nth 1 (nth 0 sticky-button-images)))))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-sticky-button
   `((class . sticky-button)
-    (background . ,left-frame-sticky-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'sticky) (nth 2 (nth 1 sticky-button-images)) (nth 2 (nth 0 sticky-button-images)))))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1384,7 +1729,8 @@
 
 (define right-frame-sticky-button
   `((class . sticky-button)
-    (background . ,right-frame-sticky-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'sticky) (nth 3 (nth 1 sticky-button-images)) (nth 3 (nth 0 sticky-button-images)))))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1392,35 +1738,37 @@
 
 (define top-frame-space-button
   `((class . title)
-    (background . ,(title-images "top"))
+    (background . ,(nth 0 space-button-images))
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,top-frame-button-width)))
 
 (define bottom-frame-space-button
   `((class . title)
-    (background . ,(title-images "bottom"))
-    (bottom-edge . ,title-edge)
+    (background . ,(nth 1 space-button-images))
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-space-button
   `((class . title)
-    (background . ,(title-images "left"))
+    (background . ,(nth 2 space-button-images))
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
     (width . ,title-height-s)))
 
 (define right-frame-space-button
   `((class . title)
-    (background . ,(title-images "right"))
+    (background . ,(nth 3 space-button-images))
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
     (width . ,title-height-s)))
 
 (define top-frame-prev-button
   `((class . previous-workspace-button)
-    (background . ,top-frame-prev-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-first-workspace) 1)) (window-get w 'sticky))
+                                   (nth 0 (nth 1 prev-button-images)) (nth 0 (nth 0 prev-button-images)))))    
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1428,15 +1776,19 @@
 
 (define bottom-frame-prev-button
   `((class . previous-workspace-button)
-    (background . ,bottom-frame-prev-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-first-workspace) 1)) (window-get w 'sticky))
+                                   (nth 1 (nth 1 prev-button-images)) (nth 1 (nth 0 prev-button-images)))))    
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-prev-button
   `((class . previous-workspace-button)
-    (background . ,left-frame-prev-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-first-workspace) 1)) (window-get w 'sticky))
+                                   (nth 2 (nth 1 prev-button-images)) (nth 2 (nth 0 prev-button-images)))))    
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1444,7 +1796,9 @@
 
 (define right-frame-prev-button
   `((class . previous-workspace-button)
-    (background . ,right-frame-prev-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-first-workspace) 1)) (window-get w 'sticky))
+                                   (nth 3 (nth 1 prev-button-images)) (nth 3 (nth 0 prev-button-images)))))    
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1452,7 +1806,9 @@
 
 (define top-frame-next-button
   `((class . next-workspace-button)
-    (background . ,top-frame-next-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-last-workspace) 1)) (window-get w 'sticky))
+                                   (nth 0 (nth 1 next-button-images)) (nth 0 (nth 0 next-button-images)))))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1460,15 +1816,19 @@
 
 (define bottom-frame-next-button
   `((class . next-workspace-button)
-    (background . ,bottom-frame-next-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-last-workspace) 1)) (window-get w 'sticky))
+                                   (nth 1 (nth 1 next-button-images)) (nth 1 (nth 0 next-button-images)))))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-next-button
   `((class . next-workspace-button)
-    (background . ,left-frame-next-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-last-workspace) 1)) (window-get w 'sticky))
+                                   (nth 2 (nth 1 next-button-images)) (nth 2 (nth 0 next-button-images)))))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1476,7 +1836,9 @@
 
 (define right-frame-next-button
   `((class . next-workspace-button)
-    (background . ,right-frame-next-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (or (window-in-workspace-p w (- (get-last-workspace) 1)) (window-get w 'sticky))
+                                   (nth 3 (nth 1 next-button-images)) (nth 3 (nth 0 next-button-images)))))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1484,7 +1846,8 @@
 
 (define top-frame-lock-button
   `((class . lock-button)
-    (background . ,top-frame-lock-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'fixed-position) (nth 0 (nth 1 lock-button-images)) (nth 0 (nth 0 lock-button-images)))))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1492,15 +1855,17 @@
 
 (define bottom-frame-lock-button
   `((class . lock-button)
-    (background . ,bottom-frame-lock-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'fixed-position) (nth 1 (nth 1 lock-button-images)) (nth 1 (nth 0 lock-button-images)))))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-lock-button
   `((class . lock-button)
-    (background . ,left-frame-lock-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'fixed-position) (nth 2 (nth 1 lock-button-images)) (nth 2 (nth 0 lock-button-images)))))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1508,7 +1873,8 @@
 
 (define right-frame-lock-button
   `((class . lock-button)
-    (background . ,right-frame-lock-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (window-get w 'fixed-position) (nth 3 (nth 1 lock-button-images)) (nth 3 (nth 0 lock-button-images)))))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1516,7 +1882,9 @@
 
 (define top-frame-raise-lower-button
   `((class . raise-lower-button)
-    (background . ,top-frame-raise-lower-image-set)
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(lambda (w) (if (= (window-get w 'depth) 0) (nth 0 (nth 0 raise-lower-button-images)) 
+                                 (if (> (window-get w 'depth) 0) (nth 0 (nth 1 raise-lower-button-images)) (nth 0 (nth 2 raise-lower-button-images))))))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1524,15 +1892,19 @@
 
 (define bottom-frame-raise-lower-button
   `((class . raise-lower-button)
-    (background . ,bottom-frame-raise-lower-image-set)
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(lambda (w) (if (= (window-get w 'depth) 0) (nth 1 (nth 0 raise-lower-button-images)) 
+                                 (if (> (window-get w 'depth) 0) (nth 1 (nth 1 raise-lower-button-images)) (nth 1 (nth 2 raise-lower-button-images))))))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-raise-lower-button
   `((class . raise-lower-button)
-    (background . ,left-frame-raise-lower-image-set)
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(lambda (w) (if (= (window-get w 'depth) 0) (nth 2 (nth 0 raise-lower-button-images)) 
+                                 (if (> (window-get w 'depth) 0) (nth 2 (nth 1 raise-lower-button-images)) (nth 2 (nth 2 raise-lower-button-images))))))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1540,7 +1912,9 @@
 
 (define right-frame-raise-lower-button
   `((class . raise-lower-button)
-    (background . ,right-frame-raise-lower-image-set)
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(lambda (w) (if (= (window-get w 'depth) 0) (nth 3 (nth 0 raise-lower-button-images)) 
+                                 (if (> (window-get w 'depth) 0) (nth 3 (nth 1 raise-lower-button-images)) (nth 3 (nth 2 raise-lower-button-images))))))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1548,7 +1922,8 @@
 
 (define  top-frame-move-resize-button
   `((class . move-resize-button)
-    (background . ,(button-images "top" "move-resize"))
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(nth 0 move-resize-button-images))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1556,15 +1931,17 @@
 
 (define  bottom-frame-move-resize-button
   `((class . move-resize-button)
-    (background . ,(button-images "bottom" "move-resize"))
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(nth 1 move-resize-button-images))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define  left-frame-move-resize-button
   `((class . move-resize-button)
-    (background . ,(button-images "left" "move-resize"))
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(nth 2 move-resize-button-images))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1572,7 +1949,8 @@
 
 (define  right-frame-move-resize-button
   `((class . move-resize-button)
-    (background . ,(button-images "right" "move-resize"))
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(nth 3 move-resize-button-images))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1580,7 +1958,8 @@
 
 (define top-frame-rename-button
   `((class . rename-button)
-    (background . ,(button-images "top" "rename"))
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(nth 0 rename-button-images))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1588,15 +1967,17 @@
 
 (define bottom-frame-rename-button
   `((class . rename-button)
-    (background . ,(button-images "bottom" "rename"))
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(nth 1 rename-button-images))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-rename-button
   `((class . rename-button)
-    (background . ,(button-images "left" "rename"))
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(nth 2 rename-button-images))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1604,7 +1985,8 @@
 
 (define right-frame-rename-button
   `((class . rename-button)
-    (background . ,(button-images "right" "rename"))
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(nth 3 rename-button-images))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
@@ -1612,7 +1994,8 @@
 
 (define top-frame-frame-type-button
   `((class . frame-type-button)
-    (background . ,(button-images "top" "frame-type"))
+    (background . ,(nth 0 base-button-images))
+    (foreground . ,(nth 0 frame-type-button-images))
     (cursor . hand2)
     (top-edge . ,title-edge-s)
     (height . ,title-height-s)
@@ -1620,15 +2003,17 @@
 
 (define bottom-frame-frame-type-button
   `((class . frame-type-button)
-    (background . ,(button-images "bottom" "frame-type"))
+    (background . ,(nth 1 base-button-images))
+    (foreground . ,(nth 1 frame-type-button-images))
     (cursor . hand2)
-    (bottom-edge . ,title-edge)
+    (bottom-edge . ,title-edge-s)
     (height . ,title-height-s)
     (width . ,bottom-frame-button-width)))
 
 (define left-frame-frame-type-button
   `((class . frame-type-button)
-    (background . ,(button-images "left" "frame-type"))
+    (background . ,(nth 2 base-button-images))
+    (foreground . ,(nth 2 frame-type-button-images))
     (cursor . hand2)
     (left-edge . ,title-edge-s)
     (height . ,left-frame-button-height)
@@ -1636,83 +2021,120 @@
 
 (define right-frame-frame-type-button
   `((class . frame-type-button)
-    (background . ,(button-images "right" "frame-type"))
+    (background . ,(nth 3 base-button-images))
+    (foreground . ,(nth 3 frame-type-button-images))
     (cursor . hand2)
     (right-edge . ,title-edge-s)
     (height . ,right-frame-button-height)
     (width . ,title-height-s)))
 
 (define top-frame-shaped-border-corner-group
-  `(((class . top-left-corner)
-     (background . ,(top-left-corner-shaped-images "top"))
+  `(((class . title)
+     (background . ,(nth 0 title-images))
+     (left-edge . 0)
+     (top-edge . ,title-edge-s)
+     (height . ,title-height-s)
+     (width . ,button-left-edge))
+    ((class . top-left-corner)
+     (background . ,(nth 0 top-left-corner-shaped-images))
      (cursor . sb_h_double_arrow)
      (left-edge . ,frame-edge)
      (top-edge . ,title-edge)
      (height . ,title-height)
      (width . ,frame-width))
-	((class . top-right-corner)
-     (background . ,(top-right-corner-shaped-images "top"))
+    ((class . top-right-corner)
+     (background . ,(nth 0 top-right-corner-shaped-images))
      (cursor . sb_h_double_arrow)
      (top-edge . ,title-edge)
      (right-edge . ,frame-edge)
      (height . ,title-height)
      (width . ,frame-width))
     ((class . title)
-     (background . ,(title-images "top"))
+     (background . ,(nth 0 title-images))
      (right-edge . 0)
      (top-edge . ,title-edge-s)
      (height . ,title-height-s)
-     (width . 2))))
+     (width . ,button-right-edge))))
 
 (define bottom-frame-shaped-border-corner-group
-  `(((class . bottom-left-corner)
-     (background . ,(bottom-left-corner-shaped-images "bottom"))
+  `(((class . title)
+     (background . ,(nth 1 title-images))
+     (left-edge . 0)
+     (bottom-edge . ,title-edge-s)
+     (height . ,title-height-s)
+     (width . ,button-left-edge))
+    ((class . bottom-left-corner)
+     (background . ,(nth 0 bottom-left-corner-shaped-images))
      (cursor . sb_h_double_arrow)
      (left-edge . ,frame-edge)
      (bottom-edge . ,title-edge)
      (height . ,title-height)
      (width . ,frame-width))
     ((class . bottom-right-corner)
-     (background . ,(bottom-right-corner-shaped-images "bottom"))
+     (background . ,(nth 0 bottom-right-corner-shaped-images))
      (cursor . sb_h_double_arrow)
      (bottom-edge . ,title-edge)
      (right-edge . ,frame-edge)
      (height . ,title-height)
      (width . ,frame-width))
     ((class . title)
-     (background . ,(title-images "bottom"))
+     (background . ,(nth 1 title-images))
      (right-edge . 0)
-     (bottom-edge . ,title-edge)
+     (bottom-edge . ,title-edge-s)
      (height . ,title-height-s)
-     (width . 2))))
+     (width . ,button-right-edge))))
 
 (define left-frame-shaped-border-corner-group
-  `(((class . bottom-left-corner)
-     (background . ,(bottom-left-corner-shaped-images "left"))
+  `(((class . title)
+     (background . ,(nth 2 title-images))
+     (top-edge . 0)
+     (left-edge . ,title-edge-s)
+     (height . ,button-right-edge)
+     (width . ,title-height-s))
+    ((class . bottom-left-corner)
+     (background . ,(nth 1 bottom-left-corner-shaped-images))
      (bottom-edge . ,frame-edge)
      (left-edge . ,title-edge)
      (height . ,frame-width)
      (width . ,title-height))
     ((class . top-left-corner)
-     (background . ,(top-left-corner-shaped-images "left"))
+     (background . ,(nth 1 top-left-corner-shaped-images))
      (top-edge . ,frame-edge)
      (left-edge . ,title-edge)
      (height . ,frame-width)
-     (width . ,title-height))))
+     (width . ,title-height))
+    ((class . title)
+     (background . ,(nth 2 title-images))
+     (bottom-edge . 0)
+     (left-edge . ,title-edge-s)
+     (height . ,button-left-edge)
+     (width . ,title-height-s))))
 
 (define right-frame-shaped-border-corner-group
-  `(((class . bottom-right-corner)
-     (background . ,(bottom-right-corner-shaped-images "right"))
+  `(((class . title)
+     (background . ,(nth 3 title-images))
+     (top-edge . 0)
+     (right-edge . ,title-edge-s)
+     (height . ,button-left-edge)
+     (width . ,title-height-s))
+    ((class . bottom-right-corner)
+     (background . ,(nth 1 bottom-right-corner-shaped-images))
      (bottom-edge . ,frame-edge)
      (right-edge . ,title-edge)
      (height . ,frame-width)
      (width . ,title-height))
     ((class . top-right-corner)
-     (background . ,(top-right-corner-shaped-images "right"))
+     (background . ,(nth 1 top-right-corner-shaped-images))
      (top-edge . ,frame-edge)
      (right-edge . ,title-edge)
      (height . ,frame-width)
-     (width . ,title-height))))
+     (width . ,title-height))
+    ((class . title)
+     (background . ,(nth 3 title-images))
+     (bottom-edge . 0)
+     (right-edge . ,title-edge-s)
+     (height . ,button-right-edge)
+     (width . ,title-height-s))))
 
 (define top-button-alist
   `((close  . ,top-frame-close-button)
@@ -1789,26 +2211,35 @@
 (define shaped-frame nil)
 (define transient-frame nil)
 (define shaped-transient-frame nil)
+(define button-alist nil)
+(define current-title styletab-c:titlebar-place)
+(define top-normal-buttons-left nil)
+(define top-transient-buttons-left nil)
+(define top-normal-buttons-right nil)
+(define top-transient-buttons-right nil)
+(define bottom-normal-buttons-left nil)
+(define bottom-transient-buttons-left nil)
+(define bottom-normal-buttons-right nil)
+(define bottom-transient-buttons-right nil)
+(define left-normal-buttons-top nil)
+(define left-transient-buttons-top nil)
+(define left-normal-buttons-bottom nil)
+(define left-transient-buttons-bottom nil)
+(define right-normal-buttons-top nil)
+(define right-transient-buttons-top nil)
+(define right-normal-buttons-bottom nil)
+(define right-transient-buttons-bottom nil)
+(define top-tab-adjustments nil)
+(define bottom-tab-adjustments nil)
+(define left-tab-adjustments nil)
+(define right-tab-adjustments nil)
 
-;; first run use top title
-;;
-(define current-title 'top)
-
-(define create-frames
+(define make-buttons
   ;; ripped from Anonymous
-  ;;
   (lambda ()
     (let* (
-           (button-alist
-            (case current-title
-                  ((top) top-button-alist)
-                  ((bottom) bottom-button-alist)
-                  ((left) left-button-alist)
-                  ((right) right-button-alist)))
-
            ;; turns one cons cell (btn-name . show-in-transients) into a button
            ;; definition, adding the button position
-           ;;
            (make-button
             (lambda (is-trans btn edge pos)
               (let ((btn-def  (cdr (assq (car btn) button-alist)))
@@ -1819,7 +2250,6 @@
 
            ;; turns the list of cons cells (btn-name . show-in-transients) into
            ;; a list of button definitions, adding the button positions
-           ;;
            (make-button-list
             (lambda (is-trans btn-list edge pos-start pos-inc)
               (let loop ((rest btn-list) (pos pos-start) (result ()))
@@ -1830,195 +2260,212 @@
                         (loop (cdr rest) pos result)
                       (loop (cdr rest) (+ pos pos-inc) (append (list new-btn) result))))))))
 
-		   (top-frame-normal-buttons-left 
-            (make-button-list nil styletab:top-left-buttons 'left-edge  0 (+ styletab:title-dimension (button-width-custom))))
+
+           (top-frame-normal-buttons-left
+            (setq button-alist top-button-alist)
+            (make-button-list nil styletab-c:top-left-buttons 'left-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
            (top-frame-normal-buttons-right
-            (make-button-list nil styletab:top-right-buttons 'right-edge 0 (+ styletab:title-dimension (button-width-custom))))
+            (make-button-list nil styletab-c:top-right-buttons 'right-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
            (top-frame-transient-buttons-left
-            (make-button-list t styletab:top-left-buttons 'left-edge  0 (+ styletab:title-dimension (button-width-custom))))
+            (make-button-list t styletab-c:top-left-buttons 'left-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
            (top-frame-transient-buttons-right
-            (make-button-list t styletab:top-right-buttons 'right-edge 0 (+ styletab:title-dimension (button-width-custom))))
+            (make-button-list t styletab-c:top-right-buttons 'right-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
 
            (bottom-frame-normal-buttons-left 
-            (make-button-list nil styletab:bottom-left-buttons 'left-edge  0 (+ styletab:title-dimension (button-width-custom))))
+            (setq button-alist bottom-button-alist)
+            (make-button-list nil styletab-c:bottom-left-buttons 'left-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
            (bottom-frame-normal-buttons-right
-            (make-button-list nil styletab:bottom-right-buttons 'right-edge 0 (+ styletab:title-dimension (button-width-custom))))
+            (make-button-list nil styletab-c:bottom-right-buttons 'right-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
            (bottom-frame-transient-buttons-left
-            (make-button-list t styletab:bottom-left-buttons 'left-edge  0 (+ styletab:title-dimension (button-width-custom))))
+            (make-button-list t styletab-c:bottom-left-buttons 'left-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
            (bottom-frame-transient-buttons-right
-            (make-button-list t styletab:bottom-right-buttons 'right-edge 0 (+ styletab:title-dimension (button-width-custom))))
+            (make-button-list t styletab-c:bottom-right-buttons 'right-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
 
-           (left-frame-normal-buttons-left 
-            (make-button-list nil styletab:left-bottom-buttons 'bottom-edge  0 (+ styletab:title-dimension (button-width-custom))))
-           (left-frame-normal-buttons-right
-            (make-button-list nil styletab:left-top-buttons 'top-edge 0 (+ styletab:title-dimension (button-width-custom))))
-           (left-frame-transient-buttons-left
-            (make-button-list t styletab:left-bottom-buttons 'bottom-edge  0 (+ styletab:title-dimension (button-width-custom))))
-           (left-frame-transient-buttons-right
-            (make-button-list t styletab:left-top-buttons 'top-edge 0 (+ styletab:title-dimension (button-width-custom))))
+           (left-frame-normal-buttons-bottom 
+            (setq button-alist left-button-alist)
+            (make-button-list nil styletab-c:left-bottom-buttons 'bottom-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
+           (left-frame-normal-buttons-top
+            (make-button-list nil styletab-c:left-top-buttons 'top-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
+           (left-frame-transient-buttons-bottom
+            (make-button-list t styletab-c:left-bottom-buttons 'bottom-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
+           (left-frame-transient-buttons-top
+            (make-button-list t styletab-c:left-top-buttons 'top-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
 
-           (right-frame-normal-buttons-left 
-            (make-button-list nil styletab:right-bottom-buttons 'bottom-edge  0 (+ styletab:title-dimension (button-width-custom))))
-           (right-frame-normal-buttons-right
-            (make-button-list nil styletab:right-top-buttons 'top-edge 0 (+ styletab:title-dimension (button-width-custom))))
-           (right-frame-transient-buttons-left
-            (make-button-list t styletab:right-bottom-buttons 'bottom-edge  0 (+ styletab:title-dimension (button-width-custom))))
-           (right-frame-transient-buttons-right
-            (make-button-list t styletab:right-top-buttons 'top-edge 0 (+ styletab:title-dimension (button-width-custom)))))
+           (right-frame-normal-buttons-bottom 
+            (setq button-alist right-button-alist)
+            (make-button-list nil styletab-c:right-bottom-buttons 'bottom-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
+           (right-frame-normal-buttons-top
+            (make-button-list nil styletab-c:right-top-buttons 'top-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom))))
+           (right-frame-transient-buttons-bottom
+            (make-button-list t styletab-c:right-bottom-buttons 'bottom-edge (button-right-edge) (+ styletab-c:title-dimension (button-width-custom))))
+           (right-frame-transient-buttons-top
+            (make-button-list t styletab-c:right-top-buttons 'top-edge (button-left-edge) (+ styletab-c:title-dimension (button-width-custom)))))
 
-      (require 'sawfish.wm.tabs.tab)
-      (when (eq current-title 'top)
-        (let ((top-left-d-w 11)
-              (top-right-d-w (tabbar-right-edge-width))
-              (top-left-m
-               (if (numberp (cdr (car (car top-frame-normal-buttons-left))))
-                   (+ (cdr (car (car top-frame-normal-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (top-right-m
-               (if (numberp (cdr (car (car top-frame-normal-buttons-right))))
-                   (+ (cdr (car (car top-frame-normal-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (top-left-m-t
-               (if (numberp (cdr (car (car top-frame-transient-buttons-left))))
-                   (+ (cdr (car (car top-frame-transient-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (top-right-m-t
-               (if (numberp (cdr (car (car top-frame-transient-buttons-right))))
-                   (+ (cdr (car (car top-frame-transient-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0)))
-          (set-tab-adjustments #:theme-left-dec-width top-left-d-w #:theme-right-dec-width top-right-d-w #:theme-left-margin top-left-m
-                               #:theme-right-margin top-right-m #:theme-left-margin-transient top-left-m-t
-                               #:theme-right-margin-transient top-right-m-t)
-	  (update-title-x-offsets '(11 . 0)))
-        (setq normal-frame
-              (append top-frame-default-border-corner-group top-frame-title-group top-frame-normal-buttons-left 
-                      top-frame-border-group top-frame-normal-buttons-right))
-        (setq shaped-frame
-              (append top-frame-shaped-border-corner-group top-frame-title-group top-frame-normal-buttons-left 
-                      top-frame-normal-buttons-right))
-        (setq transient-frame
-              (append top-frame-default-border-corner-group top-frame-title-group top-frame-transient-buttons-left 
-                      top-frame-border-group top-frame-transient-buttons-right))
-        (setq shaped-transient-frame
-              (append top-frame-shaped-border-corner-group top-frame-title-group top-frame-transient-buttons-left
-                      top-frame-transient-buttons-right)))
+      (let ((top-left-d-w 11)
+            (top-right-d-w (tabbar-right-edge-width))
+            (top-left-m
+             (if (numberp (cdr (car (car top-frame-normal-buttons-left))))
+                 (+ (cdr (car (car top-frame-normal-buttons-left))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (top-right-m
+             (if (numberp (cdr (car (car top-frame-normal-buttons-right))))
+                 (+ (cdr (car (car top-frame-normal-buttons-right))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (top-left-m-t
+             (if (numberp (cdr (car (car top-frame-transient-buttons-left))))
+                 (+ (cdr (car (car top-frame-transient-buttons-left))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (top-right-m-t
+             (if (numberp (cdr (car (car top-frame-transient-buttons-right))))
+                 (+ (cdr (car (car top-frame-transient-buttons-right))) (+ styletab-c:title-dimension (button-width-custom))) 0)))
+        (setq top-normal-buttons-left top-frame-normal-buttons-left)
+        (setq top-transient-buttons-left top-frame-transient-buttons-left)
+        (setq top-normal-buttons-right top-frame-normal-buttons-right)
+        (setq top-transient-buttons-right top-frame-transient-buttons-right)
+        (setq top-tab-adjustments (list top-left-d-w top-right-d-w top-left-m top-right-m top-left-m-t top-right-m-t)))
 
-      (when (eq current-title 'bottom)
-        (let ((bottom-left-d-w 11)
-              (bottom-right-d-w (tabbar-right-edge-width))
-              (bottom-left-m
-               (if (numberp (cdr (car (car bottom-frame-normal-buttons-left))))
-                   (+ (cdr (car (car bottom-frame-normal-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (bottom-right-m
-               (if (numberp (cdr (car (car bottom-frame-normal-buttons-right))))
-                   (+ (cdr (car (car bottom-frame-normal-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (bottom-left-m-t
-               (if (numberp (cdr (car (car bottom-frame-transient-buttons-left))))
-                   (+ (cdr (car (car bottom-frame-transient-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (bottom-right-m-t
-               (if (numberp (cdr (car (car bottom-frame-transient-buttons-right))))
-                   (+ (cdr (car (car bottom-frame-transient-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0)))
-          (set-tab-adjustments #:theme-left-dec-width bottom-left-d-w #:theme-right-dec-width bottom-right-d-w #:theme-left-margin bottom-left-m
-                               #:theme-right-margin bottom-right-m #:theme-left-margin-transient bottom-left-m-t
-                               #:theme-right-margin-transient bottom-right-m-t)
-	  (update-title-x-offsets '(11 . 0)))
-        (setq normal-frame
-              (append bottom-frame-default-border-corner-group bottom-frame-title-group bottom-frame-normal-buttons-left 
-                      bottom-frame-border-group bottom-frame-normal-buttons-right bottom-frame-title-cursor-images))
-        (setq shaped-frame
-              (append bottom-frame-shaped-border-corner-group bottom-frame-title-group bottom-frame-normal-buttons-left 
-                      bottom-frame-normal-buttons-right bottom-frame-title-cursor-images))
-        (setq transient-frame
-              (append bottom-frame-default-border-corner-group bottom-frame-title-group bottom-frame-transient-buttons-left
-                      bottom-frame-border-group bottom-frame-transient-buttons-right bottom-frame-title-cursor-images))
-        (setq shaped-transient-frame
-              (append bottom-frame-shaped-border-corner-group bottom-frame-title-group bottom-frame-transient-buttons-left 
-                      bottom-frame-transient-buttons-right bottom-frame-title-cursor-images)))
-      
-      (when (eq current-title 'left)
-        (let ((left-left-d-w 11)
-              (left-right-d-w (- styletab:title-dimension 2))
-              (left-left-m
-               (if (numberp (cdr (car (car left-frame-normal-buttons-left))))
-                   (+ (cdr (car (car left-frame-normal-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (left-right-m
-               (if (numberp (cdr (car (car left-frame-normal-buttons-right))))
-                   (+ (cdr (car (car left-frame-normal-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (left-left-m-t
-               (if (numberp (cdr (car (car left-frame-transient-buttons-left))))
-                   (+ (cdr (car (car left-frame-transient-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (left-right-m-t
-               (if (numberp (cdr (car (car left-frame-transient-buttons-right))))
-                   (+ (cdr (car (car left-frame-transient-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0)))
-          (set-tab-adjustments #:theme-left-dec-width left-left-d-w #:theme-right-dec-width left-right-d-w #:theme-left-margin left-left-m
-                               #:theme-right-margin left-right-m #:theme-left-margin-transient left-left-m-t
-                               #:theme-right-margin-transient left-right-m-t)
-	  (update-title-x-offsets '(11 . -11)))
-        (setq normal-frame
-              (append left-frame-title-group left-frame-normal-buttons-left left-frame-default-border-corner-group 
-                      left-frame-border-group left-frame-normal-buttons-right))
-        (setq shaped-frame
-              (append left-frame-title-group left-frame-normal-buttons-left left-frame-shaped-border-corner-group 
-                      left-frame-normal-buttons-right))
-        (setq transient-frame
-              (append left-frame-title-group left-frame-transient-buttons-left left-frame-default-border-corner-group 
-                      left-frame-border-group left-frame-transient-buttons-right))
-        (setq shaped-transient-frame
-              (append left-frame-title-group left-frame-transient-buttons-left left-frame-shaped-border-corner-group 
-                      left-frame-transient-buttons-right)))
+      (let ((bottom-left-d-w 11)
+            (bottom-right-d-w (tabbar-right-edge-width))
+            (bottom-left-m
+             (if (numberp (cdr (car (car bottom-frame-normal-buttons-left))))
+                 (+ (cdr (car (car bottom-frame-normal-buttons-left))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (bottom-right-m
+             (if (numberp (cdr (car (car bottom-frame-normal-buttons-right))))
+                 (+ (cdr (car (car bottom-frame-normal-buttons-right))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (bottom-left-m-t
+             (if (numberp (cdr (car (car bottom-frame-transient-buttons-left))))
+                 (+ (cdr (car (car bottom-frame-transient-buttons-left))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (bottom-right-m-t
+             (if (numberp (cdr (car (car bottom-frame-transient-buttons-right))))
+                 (+ (cdr (car (car bottom-frame-transient-buttons-right))) (+ styletab-c:title-dimension (button-width-custom))) 0)))
+        (setq bottom-normal-buttons-left bottom-frame-normal-buttons-left)
+        (setq bottom-transient-buttons-left bottom-frame-transient-buttons-left)
+        (setq bottom-normal-buttons-right bottom-frame-normal-buttons-right)
+        (setq bottom-transient-buttons-right bottom-frame-transient-buttons-right)
+        (setq bottom-tab-adjustments (list bottom-left-d-w bottom-right-d-w bottom-left-m bottom-right-m bottom-left-m-t bottom-right-m-t)))
       
-      (when (eq current-title 'right)
-        (let ((right-left-d-w 11)
-              (right-right-d-w (- styletab:title-dimension 2))
-              (right-left-m
-               (if (numberp (cdr (car (car right-frame-normal-buttons-left))))
-                   (+ (cdr (car (car right-frame-normal-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (right-right-m
-               (if (numberp (cdr (car (car right-frame-normal-buttons-right))))
-                   (+ (cdr (car (car right-frame-normal-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (right-left-m-t
-               (if (numberp (cdr (car (car right-frame-transient-buttons-left))))
-                   (+ (cdr (car (car right-frame-transient-buttons-left))) (+ styletab:title-dimension (button-width-custom))) 0))
-              (right-right-m-t
-               (if (numberp (cdr (car (car right-frame-transient-buttons-right))))
-                   (+ (cdr (car (car right-frame-transient-buttons-right))) (+ styletab:title-dimension (button-width-custom))) 0)))
-          (set-tab-adjustments #:theme-left-dec-width right-left-d-w #:theme-right-dec-width right-right-d-w #:theme-left-margin right-left-m
-                               #:theme-right-margin right-right-m #:theme-left-margin-transient right-left-m-t
-                               #:theme-right-margin-transient right-right-m-t)
-	  (update-title-x-offsets '(11 . -11)))
-        (setq normal-frame
-              (append right-frame-title-group right-frame-normal-buttons-left right-frame-default-border-corner-group 
-                      right-frame-border-group right-frame-normal-buttons-right))
-        (setq shaped-frame
-              (append right-frame-title-group right-frame-normal-buttons-left right-frame-shaped-border-corner-group 
-                      right-frame-normal-buttons-right))
-        (setq transient-frame
-              (append right-frame-title-group right-frame-transient-buttons-left right-frame-default-border-corner-group 
-                      right-frame-border-group right-frame-transient-buttons-right))
-        (setq shaped-transient-frame
-              (append right-frame-title-group right-frame-transient-buttons-left right-frame-shaped-border-corner-group 
-                      right-frame-transient-buttons-right))))))
+      (let ((left-left-d-w 11)
+            (left-right-d-w (- styletab-c:title-dimension 2))
+            (left-left-m
+             (if (numberp (cdr (car (car left-frame-normal-buttons-bottom))))
+                 (+ (cdr (car (car left-frame-normal-buttons-bottom))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (left-right-m
+             (if (numberp (cdr (car (car left-frame-normal-buttons-top))))
+                 (+ (cdr (car (car left-frame-normal-buttons-top))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (left-left-m-t
+             (if (numberp (cdr (car (car left-frame-transient-buttons-bottom))))
+                 (+ (cdr (car (car left-frame-transient-buttons-bottom))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (left-right-m-t
+             (if (numberp (cdr (car (car left-frame-transient-buttons-top))))
+                 (+ (cdr (car (car left-frame-transient-buttons-top))) (+ styletab-c:title-dimension (button-width-custom))) 0)))
+        (setq left-normal-buttons-top left-frame-normal-buttons-top)
+        (setq left-transient-buttons-top left-frame-transient-buttons-top)
+        (setq left-normal-buttons-bottom left-frame-normal-buttons-bottom)
+        (setq left-transient-buttons-bottom left-frame-transient-buttons-bottom)
+        (setq left-tab-adjustments (list left-left-d-w left-right-d-w left-left-m left-right-m left-left-m-t left-right-m-t)))
 
-(create-frames)
+      (let ((right-left-d-w 11)
+            (right-right-d-w (- styletab-c:title-dimension 2))
+            (right-left-m
+             (if (numberp (cdr (car (car right-frame-normal-buttons-bottom))))
+                 (+ (cdr (car (car right-frame-normal-buttons-bottom))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (right-right-m
+             (if (numberp (cdr (car (car right-frame-normal-buttons-top))))
+                 (+ (cdr (car (car right-frame-normal-buttons-top))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (right-left-m-t
+             (if (numberp (cdr (car (car right-frame-transient-buttons-bottom))))
+                 (+ (cdr (car (car right-frame-transient-buttons-bottom))) (+ styletab-c:title-dimension (button-width-custom))) 0))
+            (right-right-m-t
+             (if (numberp (cdr (car (car right-frame-transient-buttons-top))))
+                 (+ (cdr (car (car right-frame-transient-buttons-top))) (+ styletab-c:title-dimension (button-width-custom))) 0)))
+        (setq right-normal-buttons-top right-frame-normal-buttons-top)
+        (setq right-transient-buttons-top right-frame-transient-buttons-top)
+        (setq right-normal-buttons-bottom right-frame-normal-buttons-bottom)
+        (setq right-transient-buttons-bottom right-frame-transient-buttons-bottom)
+        (setq right-tab-adjustments (list right-left-d-w right-right-d-w right-left-m right-right-m right-left-m-t right-right-m-t))))))
 
-;; At last! We create the actual theme
-;;
-(add-frame-style theme-name
-                 (lambda (w type)
-                   (case type
-                         ((default)             normal-frame)
-                         ((shaped)              shaped-frame)
-                         ((transient)           transient-frame)
-                         ((shaped-transient)    shaped-transient-frame)
-                         ((utility)             normal-frame)
-                         ((shaded-utility)      normal-frame)
-                         ((unframed)            nil-frame))))
+(define make-frame
+  (lambda ()
+    (require 'sawfish.wm.tabs.tab)
+    (when (eq current-title 'top)
+      (update-title-x-offsets `(,(- styletab-c:title-dimension 12) . 0))
+      (set-tab-adjustments #:theme-left-dec-width (nth 0 top-tab-adjustments) #:theme-right-dec-width (nth 1 top-tab-adjustments)
+                           #:theme-left-margin (nth 2 top-tab-adjustments) #:theme-right-margin (nth 3 top-tab-adjustments)
+                           #:theme-left-margin-transient (nth 4 top-tab-adjustments) #:theme-right-margin-transient (nth 5 top-tab-adjustments))
+      (setq normal-frame
+            (append top-frame-title-group top-frame-default-border-corner-group top-normal-buttons-left
+                    top-frame-border-group top-normal-buttons-right))
+      (setq shaped-frame
+            (append top-frame-title-group top-frame-shaped-border-corner-group top-normal-buttons-left
+                    top-normal-buttons-right))
+      (setq transient-frame
+            (append top-frame-title-group top-frame-default-border-corner-group top-transient-buttons-left
+                    top-frame-border-group top-transient-buttons-right))
+      (setq shaped-transient-frame
+            (append top-frame-title-group top-frame-shaped-border-corner-group top-transient-buttons-left
+                    top-transient-buttons-right)))
+
+    (when (eq current-title 'bottom)
+      (update-title-x-offsets `(,(- styletab-c:title-dimension 12) . 0))
+      (set-tab-adjustments #:theme-left-dec-width (nth 0 bottom-tab-adjustments) #:theme-right-dec-width (nth 1 bottom-tab-adjustments)
+                           #:theme-left-margin (nth 2 bottom-tab-adjustments) #:theme-right-margin (nth 3 bottom-tab-adjustments)
+                           #:theme-left-margin-transient (nth 4 bottom-tab-adjustments) #:theme-right-margin-transient (nth 5 bottom-tab-adjustments))
+      (setq normal-frame
+            (append bottom-frame-title-group bottom-frame-default-border-corner-group bottom-normal-buttons-left
+                    bottom-frame-border-group bottom-normal-buttons-right))
+      (setq shaped-frame
+            (append bottom-frame-title-group bottom-frame-shaped-border-corner-group bottom-normal-buttons-left
+                    bottom-normal-buttons-right))
+      (setq transient-frame
+            (append bottom-frame-title-group bottom-frame-default-border-corner-group bottom-transient-buttons-left
+                    bottom-frame-border-group bottom-transient-buttons-right))
+      (setq shaped-transient-frame
+            (append bottom-frame-title-group bottom-frame-shaped-border-corner-group bottom-transient-buttons-left
+                    bottom-transient-buttons-right)))
+
+    (when (eq current-title 'left)
+      (update-title-x-offsets '(11 . -11))
+      (set-tab-adjustments #:theme-left-dec-width (nth 0 left-tab-adjustments) #:theme-right-dec-width (nth 1 left-tab-adjustments)
+                           #:theme-left-margin (nth 2 left-tab-adjustments) #:theme-right-margin (nth 3 left-tab-adjustments)
+                           #:theme-left-margin-transient (nth 4 left-tab-adjustments) #:theme-right-margin-transient (nth 5 left-tab-adjustments))
+      (setq normal-frame
+            (append left-frame-title-group left-normal-buttons-bottom left-frame-default-border-corner-group
+                    left-frame-border-group left-normal-buttons-top))
+      (setq shaped-frame
+            (append left-frame-title-group left-normal-buttons-bottom left-frame-shaped-border-corner-group
+                    left-normal-buttons-top))
+      (setq transient-frame
+            (append left-frame-title-group left-transient-buttons-bottom left-frame-default-border-corner-group
+                    left-frame-border-group left-transient-buttons-top))
+      (setq shaped-transient-frame
+            (append left-frame-title-group left-transient-buttons-bottom left-frame-shaped-border-corner-group
+                    left-transient-buttons-top)))
+
+    (when (eq current-title 'right)
+      (update-title-x-offsets '(11 . -11))
+      (set-tab-adjustments #:theme-left-dec-width (nth 0 right-tab-adjustments) #:theme-right-dec-width (nth 1 right-tab-adjustments)
+                           #:theme-left-margin (nth 2 right-tab-adjustments) #:theme-right-margin (nth 3 right-tab-adjustments)
+                           #:theme-left-margin-transient (nth 4 right-tab-adjustments) #:theme-right-margin-transient (nth 5 right-tab-adjustments))
+      (setq normal-frame
+            (append right-frame-title-group right-normal-buttons-bottom right-frame-default-border-corner-group
+                    right-frame-border-group right-normal-buttons-top))
+      (setq shaped-frame
+            (append right-frame-title-group right-normal-buttons-bottom right-frame-shaped-border-corner-group
+                    right-normal-buttons-top))
+      (setq transient-frame
+            (append right-frame-title-group right-transient-buttons-bottom right-frame-default-border-corner-group
+                    right-frame-border-group right-transient-buttons-top))
+      (setq shaped-transient-frame
+            (append right-frame-title-group right-transient-buttons-bottom right-frame-shaped-border-corner-group
+                    right-transient-buttons-top)))))
 
 (define (current-title-w w)
   (if (not (window-get w 'title-position))
-      (case styletab:titlebar-place
+      (case styletab-c:titlebar-place
             ((top) (setq current-title 'top))
             ((bottom) (setq current-title 'bottom))
             ((left) (setq current-title 'left))
             ((right) (setq current-title 'right)))
     (setq current-title (window-get w 'title-position)))
-  (create-frames))
+  (make-buttons)
+  (make-frame))
 
 (define (create-frames-only w)
   (when (eq (window-get w 'current-frame-style) theme-name)
@@ -2031,8 +2478,14 @@
        (current-title-w w)
        (reframe-window w)))))
 
+(define reframe-buttons
+  (lambda ()
+    (make-buttons)
+    (reframe-windows theme-name)))
+
 (define reframe-all
   (lambda ()
+    (make-frame)
     (reframe-windows theme-name)))
 
 (define (reframe-one w)
@@ -2041,36 +2494,69 @@
       (current-title-w w)
       (rebuild-frame w))))
 
-;; also reset icon cache
-;;
-(define clear-cache-reframe
+;; reframe-all and reset icon cache
+(define clear-icon-cache-reframe
   (lambda ()
-    (setq styletab-icon-cache (make-weak-table eq-hash eq))
+    (setq styletab-c-icon-cache (make-weak-table eq-hash eq))
     (reframe-all)))
 
-;; also reset all cache 
-;;
+;; reload-frame-style and reset icon and frame cache 
 (define (clear-cache-reload-frame-style)
-  (setq styletab-icon-cache (make-weak-table eq-hash eq))
-  (setq styletab-frame-cache (make-weak-table eq-hash eq))
+  (setq styletab-c-icon-cache (make-weak-table eq-hash eq))
+  (setq styletab-c-frame-cache (make-weak-table eq-hash eq))
   (reload-frame-style theme-name))
 
-(call-after-state-changed '(sticky fixed-position stacking) reframe-one)
+(define (bright-changed)
+  (recolor-tab)
+  (recolor-all-buttons)
+  (reframe-windows-with-style theme-name))
+
+(define (color-changed)
+  (recolor-all)
+  (reframe-windows-with-style theme-name))
+
+(define (botton-color-changed botton)
+  (botton)
+  (reframe-windows theme-name))
+
+(define (initialize-theme)
+  (recolor-all)
+  (make-buttons)
+  (make-frame)
+  (reframe-windows-with-style theme-name))
+
+(initialize-theme)
+
+;; At last! We create the actual theme
+(add-frame-style theme-name
+                 (lambda (w type)
+                   (case type
+                         ((default)             normal-frame)
+                         ((shaped)              shaped-frame)
+                         ((transient)           transient-frame)
+                         ((shaped-transient)    shaped-transient-frame)
+                         ((utility)             normal-frame)
+                         ((shaded-utility)      normal-frame)
+                         ((unframed)            nil-frame))))
+
+
+(call-after-state-changed '(sticky fixed-position stacking maximized) reframe-one)
 (call-after-state-changed '(title-position) create-frames-only)
 (add-hook 'remove-from-workspace-hook reframe-one)
 
-(custom-set-property 'styletab:custom-colors ':after-set reframe-all)
-(custom-set-property 'styletab:style ':after-set clear-cache-reload-frame-style)
-(custom-set-property 'styletab:title-dimension ':after-set clear-cache-reframe)
-(custom-set-property 'styletab:custom-button-width ':after-set clear-cache-reframe)
-(custom-set-property 'styletab:button-width ':after-set clear-cache-reframe)
-(custom-set-property 'styletab:borders-dimension ':after-set reframe-all)
-(custom-set-property 'styletab:titlebar-place ':after-set reframe-all)
-(custom-set-property 'styletab:top-left-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:top-right-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:bottom-left-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:bottom-right-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:left-top-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:left-bottom-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:right-top-buttons ':after-set reframe-all)
-(custom-set-property 'styletab:right-bottom-buttons ':after-set reframe-all)
+;;(custom-set-property 'styletab-c:styles ':after-set clear-cache-reload-frame-style)
+(custom-set-property 'styletab-c:title-dimension ':after-set clear-icon-cache-reframe)
+(custom-set-property 'styletab-c:custom-button-width ':after-set clear-icon-cache-reframe)
+(custom-set-property 'styletab-c:button-width ':after-set clear-icon-cache-reframe)
+(custom-set-property 'styletab-c:borders-dimension ':after-set reframe-all)
+(custom-set-property 'styletab-c:titlebar-place ':after-set reframe-all)
+(custom-set-property 'styletab-c:top-left-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:top-right-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:bottom-left-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:bottom-right-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:left-top-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:left-bottom-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:right-top-buttons ':after-set reframe-buttons)
+(custom-set-property 'styletab-c:right-bottom-buttons ':after-set reframe-buttons)
+
+(custom-set-property 'styletab-c:do-reload ':after-set clear-cache-reload-frame-style)

Attachment: Bildschirmfoto-Sawfish-Einstellungen.png
Description: PNG image

Attachment: signature.asc
Description: PGP signature



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/