cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=e7842db809cf2543119cf17dff492f2fc241ed82

commit e7842db809cf2543119cf17dff492f2fc241ed82
Author: Subhransu Mohanty <sub.moha...@samsung.com>
Date:   Wed Jul 29 23:14:30 2015 +0200

    radio: add "elm,activate,radio,on" and "elm,activate,radio,off" signal to 
support value change animation.
    
    Summary:
    Currently when user clicks on the radio, and when api value_set() called by
    the developer we emit "elm,state,radio,*" signal. To support value change 
animation when
    user interacts with radio. There is no way to distinguish the action in EDC.
    This "elm,activate,radio,*" is a way which edc can make use to distinguish 
the state change signal
    by the user action or due to api call.
    
    Reviewers: Hermet, raster, cedric
    
    Reviewed By: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2829
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/elm_radio.c | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/src/lib/elm_radio.c b/src/lib/elm_radio.c
index e185da5..a16f16e 100644
--- a/src/lib/elm_radio.c
+++ b/src/lib/elm_radio.c
@@ -46,7 +46,7 @@ static const Elm_Action key_actions[] = {
 };
 
 static void
-_state_set(Evas_Object *obj, Eina_Bool state)
+_state_set(Evas_Object *obj, Eina_Bool state, Eina_Bool activate)
 {
    ELM_RADIO_DATA_GET(obj, sd);
 
@@ -54,9 +54,23 @@ _state_set(Evas_Object *obj, Eina_Bool state)
      {
         sd->state = state;
         if (sd->state)
-          elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
+          {
+             // FIXME: to do animation during state change , we need different 
signal
+             // so that we can distinguish between state change by user or 
state change
+             // by calling state_change() api. Keep both the signal for 
backward compatibility
+             // and only emit "elm,state,radio,on" when activate is false  
when we can break ABI.
+             if (activate) elm_layout_signal_emit(obj, 
"elm,activate,radio,on", "elm");
+             elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
+          }
         else
-          elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
+          {
+             // FIXME: to do animation during state change , we need different 
signal
+             // so that we can distinguish between state change by user or 
state change
+             // by calling state_change() api. Keep both the signal for 
backward compatibility
+             // and only emit "elm,state,radio,off"when activate is false when 
we can break ABI.
+             if (activate) elm_layout_signal_emit(obj, 
"elm,activate,radio,off", "elm");
+             elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
+          }
         if (_elm_config->atspi_mode)
           {
              if (sd->state)
@@ -70,7 +84,7 @@ _state_set(Evas_Object *obj, Eina_Bool state)
 }
 
 static void
-_state_set_all(Elm_Radio_Data *sd)
+_state_set_all(Elm_Radio_Data *sd, Eina_Bool activate)
 {
    const Eina_List *l;
    Eina_Bool disabled = EINA_FALSE;
@@ -83,13 +97,13 @@ _state_set_all(Elm_Radio_Data *sd)
         if (sdc->state) selected = child;
         if (sdc->value == sd->group->value)
           {
-             _state_set(child, EINA_TRUE);
+             _state_set(child, EINA_TRUE, activate);
              if (!sdc->state) disabled = EINA_TRUE;
           }
-        else _state_set(child, EINA_FALSE);
+        else _state_set(child, EINA_FALSE, activate);
      }
 
-   if ((disabled) && (selected)) _state_set(selected, 1);
+   if ((disabled) && (selected)) _state_set(selected, 1, activate);
 }
 
 static void
@@ -105,7 +119,7 @@ _activate(Evas_Object *obj)
         sd->group->value = sd->value;
         if (sd->group->valuep) *(sd->group->valuep) = sd->group->value;
 
-        _state_set_all(sd);
+        _state_set_all(sd, EINA_TRUE);
 
         if (_elm_config->access_mode)
           _elm_access_say(E_("State: On"));
@@ -199,7 +213,7 @@ _elm_radio_elm_widget_theme_apply(Eo *obj, Elm_Radio_Data 
*sd)
    if (sd->state) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
    else elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
 
-   if (sd->state) _state_set(obj, EINA_FALSE);
+   if (sd->state) _state_set(obj, EINA_FALSE, EINA_FALSE);
 
    edje_object_message_signal_process(wd->resize_obj);
 
@@ -349,16 +363,16 @@ _elm_radio_group_add(Eo *obj, Elm_Radio_Data *sd, 
Evas_Object *group)
         sd->group = sdg->group;
         sd->group->radios = eina_list_append(sd->group->radios, obj);
      }
-   if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE);
-   else _state_set(obj, EINA_FALSE);
+   if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE);
+   else _state_set(obj, EINA_FALSE, EINA_FALSE);
 }
 
 EOLIAN static void
 _elm_radio_state_value_set(Eo *obj, Elm_Radio_Data *sd, int value)
 {
    sd->value = value;
-   if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE);
-   else _state_set(obj, EINA_FALSE);
+   if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE);
+   else _state_set(obj, EINA_FALSE, EINA_FALSE);
 }
 
 EOLIAN static int
@@ -373,7 +387,7 @@ _elm_radio_value_set(Eo *obj EINA_UNUSED, Elm_Radio_Data 
*sd, int value)
    if (value == sd->group->value) return;
    sd->group->value = value;
    if (sd->group->valuep) *(sd->group->valuep) = sd->group->value;
-   _state_set_all(sd);
+   _state_set_all(sd, EINA_FALSE);
 }
 
 EOLIAN static int
@@ -391,7 +405,7 @@ _elm_radio_value_pointer_set(Eo *obj EINA_UNUSED, 
Elm_Radio_Data *sd, int *value
         if (*(sd->group->valuep) != sd->group->value)
           {
              sd->group->value = *(sd->group->valuep);
-             _state_set_all(sd);
+             _state_set_all(sd, EINA_FALSE);
           }
      }
    else sd->group->valuep = NULL;

-- 


Reply via email to