/* vim: set sw=3 ts=3 sts=3 expandtab: */
group {
   name: "ecdb/button";
   alias: "ecdb/combo_item";

   data {
      item: "ecdb/combo_item/minw" 50;
      item: "ecdb/combo_item/minh" 26;
   }
   
   parts {
      part {
         name: "base";
         type: IMAGE;
         mouse_events: 1;
         scale: 1;

         description {
            state: "default" 0.0;
            min: 0 26;
            color: 255 255 255 178;

            image {
               normal: "button_base.png";
               border: 7 7 7 7;
            }
         }
      }

      part {
         name: "button_clip";
         type: RECT;
         mouse_events: 1;

         description {
            state: "default" 0.0;
            color: 255 255 255 255;
   
            rel1 { 
               to: "base"; 
               relative: 0.0 0.0; 
               offset: 3 1; 
            }

            rel2 { 
               to: "base"; 
               relative: 1.0 1.0; 
               offset: -4 -2; 
            }
         }
      }

      part {
         name: "focus_clip";
         type: RECT;
         mouse_events: 1;

         description {
            state: "default" 0.0;
            color: 255 255 255 0;

            rel1 { 
               to: "button"; 
               offset: -1 0; 
            }

            rel2 { 
               to: "button";
               offset: 0 -1; 
            }
         }

         description {
            state: "visible" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 255;
         }
      }

      part {
         name: "focus";
         type: IMAGE;
         mouse_events: 1;
         clip_to: "focus_clip";
         scale: 1;

         description {
            state: "default" 0.0;

            rel1 { 
               to: "focus_clip"; 
            }

            rel2 { 
               to: "focus_clip"; 
            }

            image {
               normal: "focus.png";
               border: 7 7 7 7;
            }
         }
      }

      part {
         name: "button";
         type: IMAGE;
         mouse_events: 1;
         clip_to: "button_clip";
         scale: 1;

         description {
            state: "default" 0.0;
            min: 0 24;

            rel1 {
               to: "button_clip";
            }

            rel2 {
               to: "button_clip";
            }
            
            image {
               normal: "button.png";
               border: 7 7 7 7;
            }
         }

         description {
            state: "disabled" 0.0;
            inherit: "default" 0.0;

            image {
               normal: "button_disabled.png";
               border: 11 11 10 10;
            }
         }
      }

      part {
         name: "shadow";
         type: IMAGE;
         mouse_events: 1;
         clip_to: "button_clip";
         scale: 1;

         description {
            state: "default" 0.0;
            min: 0 24;
            color: 255 255 255 0;
            
            rel1 { 
               to: "button_clip"; 
            }

            rel2 { 
               to: "button_clip"; 
            }
            
            image {
               normal: "button_shadow.png";
               border: 6 6 0 6;
            }
         }

         description {
            state: "clicked" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 255;
         }
      }

      part {
         name: "shadow_overlay";
         type: IMAGE;
         mouse_events: 1;
         clip_to: "button_clip";
         scale: 1;

         description {
            state: "default" 0.0;
            min: 0 24;
            color: 255 255 255 0;

            rel1 { 
               to: "button_clip"; 
            }

            rel2 { 
               to: "button_clip"; 
            }
            
            image {
               normal: "button_shadow_overlay.png";
               border: 6 6 6 13;
            }
         }

         description {
            state: "clicked" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 255;
         }
      }

      part {
         name: "ecdb.label";
         type: TEXT;
         effect: NONE;
         mouse_events: 1;
         scale: 1;
         
         description {
            state: "default" 0.0;
            align: 0.5 0.5;
            color: 60 60 60 255;

            rel1 {
               to: "base";
               relative: 0.0 0.0;
               offset: 8 0;
            }

            rel2 {
               to: "base";
               relative: 1.0 1.0;
               offset: -8 -1;
            }

            text {
               text: "";
               font: "ecdb/default";
               size: 11;
               align: 0.5 0.5;
            }
         }

         description {
            state: "iconized" 0.0;
            inherit: "default" 0.0;
            
            rel1 {
               to_x: "ecdb.swallow.icon";
               relative: 1.0 0.0;
               offset: 5 0;
            }

            rel2 {
               relative: 1.0 1.0;
               offset: -8 -1;
            }

            text {
               align: 0.0 0.5;
            }
         }
      }

      part {
         name: "ecdb.swallow.icon";
         type: SWALLOW;
         mouse_events: 1;
         scale: 1;

         description {
            state: "default" 0.0;
            max: 0 0;
            align: 0.0 0.5;

            rel1 {
               to_x: "button_clip";
               relative: 0.0 0.0;
               offset: 15 0;
            }

            rel2 {
               to: "button_clip";
            }
         }

         description {
            state: "filled" 0.0;
            inherit: "default" 0.0;
            max: 32 32;
            min: 32 32;
         }
      }
   }

   programs {
      program {
         name: "icon_swallow";
         signal: "ecdb,button,icon,swallow";
         source: "ecdb";
         action: STATE_SET "filled" 0.0;
         target: "ecdb.swallow.icon";
      }

      program {
         name: "swallow_text";
         signal: "ecdb,button,icon,swallow";
         source: "ecdb";
         action: STATE_SET "iconized" 0.0;
         target: "ecdb.label";
      }

      program {
         name: "icon_unswallow";
         signal: "ecdb,button,icon,unswallow";
         source: "ecdb";
         action: STATE_SET "default" 0.0;
         target: "ecdb.swallow.icon";
      }

      program {
         name: "unswallow_text";
         signal: "ecdb,button,icon,unswallow";
         source: "ecdb";
         action: STATE_SET "default" 0.0;
         target: "ecdb.label";
      }

      program {
         name: "clicked";
         action: STATE_SET "clicked" 0.0;
         signal: "mouse,down,1";
         source: "*";
         target: "shadow_overlay";
         target: "shadow";
         transition: DECELERATE 0.2;
      }

      program {
         name: "focus_in,mouse";
         signal: "mouse,down,1";
         action: STATE_SET "visible" 0.0;
         source: "*";
         target: "focus_clip";
         transition: DECELERATE 0.5;
      }

      program {
         name: "focus_in,ecdb";
         signal: "ecdb,focus,in";
         action: STATE_SET "visible" 0.0;
         source: "ecdb";
         target: "focus_clip";
         transition: DECELERATE 0.5;
      }

      program {
         name: "unclick";
         signal: "mouse,clicked,1";
         signal: "mouse,up,1";
         action: STATE_SET "default" 0.0;
         source: "*";
         target: "shadow_overlay";
         target: "shadow";
         transition: DECELERATE 0.2;
      }

      program {
         name: "click_emit";
         signal: "mouse,clicked,1";
         source: "*";
         action: SIGNAL_EMIT "ecdb,clicked" "ecdb";
      }

      program {
         name: "focus_out";
         signal: "ecdb,focus,out";
         action: STATE_SET "default" 0.0;
         source: "ecdb";
         target: "focus_clip";
         transition: DECELERATE 0.5;
      }

      program {
         name: "disable";
         signal: "ecdb,disable";
         action: STATE_SET "disabled" 0.0;
         source: "ecdb";
         target: "button";
      }

      program {
         name: "enable";
         signal: "ecdb,enable";
         action: STATE_SET "default" 0.0;
         source: "ecdb";
         target: "button";
      }

      program {
         name: "activate";
         signal: "mouse,down,1";
         action: SIGNAL_EMIT "ecdb,activate" "ecdb";
         source: "*";
      }
   }
}