history: show item selection.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 3 Aug 2012 20:11:33 +0000 (17:11 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 3 Aug 2012 20:11:33 +0000 (17:11 -0300)
edje group "elm/layout/dialer/history/img" became just an event area,
no visuals in there. This was done so we can change the arrow color
class when item is selected.

added scripts to control selected and missed states.

data/themes/images/bt_arrow_right.png
data/themes/includes/history.edc

index 54d60fd..c01dd98 100644 (file)
Binary files a/data/themes/images/bt_arrow_right.png and b/data/themes/images/bt_arrow_right.png differ
index 9f0f662..0c6a778 100644 (file)
@@ -1,28 +1,22 @@
 group {
    name: "elm/layout/dialer/history/img";
 
-   images.image: "bt_arrow_right.png" COMP;
-
    parts {
       part {
-         name: "call.img.more";
-         type: IMAGE;
+         name: "rect";
+         type: RECT;
          description {
             state: "default" 0.0;
             min: 56 56;
             max: 56 56;
-            color_class: "action";
-            image {
-               normal: "bt_arrow_right.png";
-               scale_hint: STATIC;
-            }
+            color: 0 0 0 0;
          }
       }
    }
    programs {
       program {
          signal: "mouse,clicked,1";
-         source: "call.img.more";
+         source: "rect";
          action: SIGNAL_EMIT "clicked,more" "gui";
       }
    }
@@ -37,6 +31,66 @@ group {
       item: "states" "missed";
    }
 
+   script {
+      public missed;
+      public selected;
+      public not_first; /* can't call it 'first' as globals start as 0 */
+
+      public anim_states() {
+         new m = get_int(missed);
+         new s = get_int(selected);
+
+         if (m) {
+            if (s)
+               run_program(PROGRAM:"show_selected");
+            else
+               run_program(PROGRAM:"show_missed");
+         } else {
+            if (s)
+               run_program(PROGRAM:"show_selected");
+            else
+               run_program(PROGRAM:"show_default");
+         }
+      }
+
+      public set_missed(val) {
+         new m = get_int(missed);
+         new s = get_int(selected);
+
+         if (m == val) return;
+         set_int(missed, val);
+         m = val;
+
+         if (get_int(not_first)) {
+            if (m) {
+               if (s)
+                  run_program(PROGRAM:"animate_selected");
+               else
+                  run_program(PROGRAM:"animate_missed");
+            } else {
+               if (s)
+                  run_program(PROGRAM:"animate_selected");
+               else
+                  run_program(PROGRAM:"animate_default");
+            }
+         } else {
+            set_int(not_first, 1);
+            anim_states();
+         }
+      }
+
+      public set_selected(val) {
+         new s = get_int(selected);
+
+         if (s == val) return;
+         set_int(selected, val);
+
+         anim_states();
+      }
+   }
+
+   images.image: "bt_arrow_right.png" COMP;
+
    parts{
       part {
          name: "bg";
@@ -45,9 +99,15 @@ group {
          mouse_events: 1;
          description {
             state: "default" 0.0;
-            color: 0 0 0 0;
+            color: 255 255 255 0;
+            color_class: "action";
             min: 240 120;
          }
+         description {
+            state: "selected" 0.0;
+            inherit: "default" 0.0;
+            color: 255 255 255 255;
+         }
       }
       part {
          name: "text.call.name";
@@ -81,6 +141,11 @@ group {
             inherit: "default" 0.0;
             color_class: "caution";
          }
+         description {
+            state: "selected" 0.0;
+            inherit: "default" 0.0;
+            color_class: "bg";
+         }
       }
 
       part {
@@ -114,6 +179,11 @@ group {
             inherit: "default" 0.0;
             color_class: "caution";
          }
+         description {
+            state: "selected" 0.0;
+            inherit: "default" 0.0;
+            color_class: "bg";
+         }
       }
 
       part {
@@ -148,6 +218,36 @@ group {
             inherit: "default" 0.0;
             color_class: "caution";
          }
+         description {
+            state: "selected" 0.0;
+            inherit: "default" 0.0;
+            color_class: "bg";
+         }
+      }
+
+      part {
+         name: "call.img.more";
+         type: IMAGE;
+         mouse_events: 0;
+         description {
+            state: "default" 0.0;
+            rel1.to: "call.swallow.more";
+            rel2.to: "call.swallow.more";
+            color_class: "action";
+            image {
+               normal: "bt_arrow_right.png";
+               scale_hint: STATIC;
+            }
+         }
+         description {
+            state: "missed" 0.0;
+            inherit: "default" 0.0;
+         }
+         description {
+            state: "selected" 0.0;
+            inherit: "default" 0.0;
+            color_class: "bg";
+         }
       }
 
       part {
@@ -174,19 +274,89 @@ group {
       program {
          signal: "elm,state,missed,active";
          source: "elm";
+         script {
+            set_missed(1);
+         }
+      }
+      program {
+         signal: "elm,state,missed,passive";
+         source: "elm";
+         script {
+            set_missed(0);
+         }
+      }
+      program {
+         signal:  "elm,state,selected";
+         source:  "elm";
+         script {
+            set_selected(1);
+         }
+      }
+      program {
+         signal:  "elm,state,unselected";
+         source:  "elm";
+         script {
+            set_selected(0);
+         }
+      }
+
+      program {
+         name: "show_missed";
          action: STATE_SET "missed" 0.0;
+         target: "bg";
+         target: "text.call.name";
+         target: "text.call.time";
+         target: "text.call.type";
+         target: "call.img.more";
+      }
+      program {
+         name: "show_default";
+         action: STATE_SET "default" 0.0;
+         target: "bg";
+         target: "text.call.name";
+         target: "text.call.time";
+         target: "text.call.type";
+         target: "call.img.more";
+      }
+      program {
+         name: "show_selected";
+         action: STATE_SET "selected" 0.0;
+         target: "bg";
          target: "text.call.name";
          target: "text.call.time";
          target: "text.call.type";
+         target: "call.img.more";
       }
 
       program {
-         signal: "elm,state,missed,passive";
-         source: "elm";
+         name: "animate_missed";
+         action: STATE_SET "missed" 0.0;
+         transition: DECELERATE 0.1;
+         target: "bg";
+         target: "text.call.name";
+         target: "text.call.time";
+         target: "text.call.type";
+         target: "call.img.more";
+      }
+      program {
+         name: "animate_default";
          action: STATE_SET "default" 0.0;
+         transition: DECELERATE 0.1;
+         target: "bg";
+         target: "text.call.name";
+         target: "text.call.time";
+         target: "text.call.type";
+         target: "call.img.more";
+      }
+      program {
+         name: "animate_selected";
+         action: STATE_SET "selected" 0.0;
+         transition: DECELERATE 0.1;
+         target: "bg";
          target: "text.call.name";
          target: "text.call.time";
          target: "text.call.type";
+         target: "call.img.more";
       }
    }
 }