keypad: disable actions when there is no number.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Wed, 11 Jul 2012 18:46:55 +0000 (15:46 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Wed, 11 Jul 2012 18:46:55 +0000 (15:46 -0300)
data/themes/includes/keypad.edc
dialer/keypad.c

index 961c1fd..e7d94fc 100644 (file)
@@ -12,8 +12,12 @@ group {
     *     pressed,<ID>:  key <ID> was pressed
     *     released,<ID>: key <ID> was released
     *     clicked,<ID>:  key <ID> was clicked (press and release in the key)
+    *     enable,<ACTION>:  key <ID> is now clickable
+    *     disable,<ACTION>: key <ID> is now inactive
     *
     * Where <ID> is: numbers 0 to 9, star, hash, save, call or backspace.
+    *
+    * Where <ACTION> is: save, call or backspace.
     */
 
    min: 720 1110;
@@ -293,9 +297,23 @@ group {
 
 #define ACTION_BUTTON(id, img, x0, x1)                                  \
       part {                                                            \
+         name: "clipper."##id;                                          \
+         type: RECT;                                                    \
+         description {                                                  \
+            state: "default" 0.0;                                       \
+            color: 255 255 255 255;                                     \
+         }                                                              \
+         description {                                                  \
+            state: "disabled" 0.0;                                      \
+            inherit: "default" 0.0;                                     \
+            color_class: "disabled";                                    \
+         }                                                              \
+      }                                                                        \
+      part {                                                            \
          name: "button."##id;                                           \
          type: IMAGE;                                                   \
          mouse_events: 1;                                               \
+         clip_to: "clipper."##id;                                       \
          description {                                                  \
             state: "default" 0.0;                                       \
             color: 255 255 255 255;                                     \
@@ -324,6 +342,7 @@ group {
       part {                                                            \
          name: "button.over."##id;                                      \
          type: IMAGE;                                                   \
+         clip_to: "clipper."##id;                                       \
          description {                                                  \
             state: "default" 0.0;                                       \
             color: 255 255 255 0;                                       \
@@ -340,6 +359,24 @@ group {
             visible: 1;                                                 \
          }                                                              \
       }                                                                 \
+      part {                                                            \
+         name: "blocker."##id;                                          \
+         type: RECT;                                                    \
+         mouse_events: 1;                                               \
+         clip_to: "clipper."##id;                                       \
+         description {                                                  \
+            state: "default" 0.0;                                       \
+            color: 0 0 0 0;                                             \
+            visible: 0;                                                 \
+            rel1.to: "button."##id;                                     \
+            rel2.to: "button."##id;                                     \
+         }                                                              \
+         description {                                                  \
+            state: "disabled" 0.0;                                      \
+            inherit: "default" 0.0;                                     \
+            visible: 1;                                                 \
+         }                                                              \
+      }                                                                 \
       programs {                                                        \
          program {                                                      \
             signal: "mouse,up,1";                                       \
@@ -375,6 +412,22 @@ group {
             action: SIGNAL_EMIT "clicked,"##id "keypad";                \
             api: id"_clicked" id" was clicked";                         \
          }                                                              \
+         program {                                                      \
+            signal: "disable,"##id;                                     \
+            source: "keypad";                                           \
+            action: STATE_SET "disabled" 0.0;                           \
+            target: "blocker."##id;                                     \
+            target: "clipper."##id;                                     \
+            api: id"_disable" "disable "##id;                           \
+         }                                                              \
+         program {                                                      \
+            signal: "enable,"##id;                                      \
+            source: "keypad";                                           \
+            action: STATE_SET "default" 0.0;                            \
+            target: "blocker."##id;                                     \
+            target: "clipper."##id;                                     \
+            api: id"_enable" "enable "##id;                             \
+         }                                                              \
       }
 
       ACTION_BUTTON("save",      "add_contact", 0.000000000, 0.333333333);
index c9792a9..3f73cb8 100644 (file)
@@ -37,8 +37,15 @@ static void _number_display(Keypad *ctx)
 
        if ((!src) || (slen < 1)) {
                elm_object_part_text_set(ctx->self, "elm.text.display", "");
+               elm_object_signal_emit(ctx->self, "disable,save", "keypad");
+               elm_object_signal_emit(ctx->self, "disable,call", "keypad");
+               elm_object_signal_emit(ctx->self, "disable,backspace",
+                                       "keypad");
                return;
        }
+       elm_object_signal_emit(ctx->self, "enable,save", "keypad");
+       elm_object_signal_emit(ctx->self, "enable,call", "keypad");
+       elm_object_signal_emit(ctx->self, "enable,backspace", "keypad");
 
        if ((slen <= 4) || (slen > 12))
                goto show_verbatim;
@@ -454,6 +461,10 @@ Evas_Object *keypad_add(Evas_Object *parent) {
                                        _on_clicked, ctx);
 
        elm_object_part_text_set(obj, "elm.text.display", "");
+       elm_object_signal_emit(obj, "disable,save", "keypad");
+       elm_object_signal_emit(obj, "disable,call", "keypad");
+       elm_object_signal_emit(obj, "disable,backspace", "keypad");
+
        elm_object_focus_allow_set(obj, EINA_TRUE);
 
        return obj;