[actionslider] fix formatting
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 22 Jul 2010 05:51:55 +0000 (14:51 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 22 Jul 2010 05:51:55 +0000 (14:51 +0900)
src/lib/elm_actionslider.c

index 12cf17e..e3e7b85 100644 (file)
@@ -1,4 +1,7 @@
 /*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+/*
  * SLP
  * Copyright (c) 2009 Samsung Electronics, Inc.
  * All rights reserved.
@@ -29,20 +32,20 @@ typedef struct _Widget_Data Widget_Data;
 
 struct _Widget_Data
 {
-       Evas_Object     *as;            // actionslider
-       Evas_Object     *icon;          // an icon for a button or a bar
+   Evas_Object *as;            // actionslider
+   Evas_Object *icon;          // an icon for a button or a bar
 
-       // setting
-       Elm_Actionslider_Magnet_Pos     magnet_position;
-       const char *text_left, *text_right, *text_center;
+   // setting
+   Elm_Actionslider_Magnet_Pos magnet_position;
+   const char *text_left, *text_right, *text_center;
 
-       // status
-       Eina_Bool       mouse_down;
-       Eina_Bool       mouse_hold;
+   // status
+   Eina_Bool   mouse_down;
+   Eina_Bool   mouse_hold;
 
-       // icon animation
-       Ecore_Animator  *icon_animator;
-       double          final_position;
+   // icon animation
+   Ecore_Animator      *icon_animator;
+   double              final_position;
 };
 
 static void _del_hook(Evas_Object *obj);
@@ -66,53 +69,59 @@ static int _icon_animation(void *data);
 static void
 _del_hook(Evas_Object *obj)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
-
-       if(wd->icon) {
-               evas_object_del(wd->icon);
-               wd->icon = NULL;
-       }
-       if (wd->text_left) {
-               eina_stringshare_del(wd->text_left);
-       }
-       if (wd->text_right) {
-               eina_stringshare_del(wd->text_right);
-       }
-       if (wd->text_center) {
-               eina_stringshare_del(wd->text_center);
-       }
-       if(wd->as) {
-               evas_object_smart_member_del(wd->as);
-               evas_object_del(wd->as);
-               wd->as = NULL;
-       }
-       free(wd);
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if(wd->icon) 
+     {
+       evas_object_del(wd->icon);
+       wd->icon = NULL;
+     }
+   if (wd->text_left) 
+     {
+       eina_stringshare_del(wd->text_left);
+     }
+   if (wd->text_right) 
+     {
+       eina_stringshare_del(wd->text_right);
+     }
+   if (wd->text_center) 
+     {
+       eina_stringshare_del(wd->text_center);
+     }
+   if(wd->as) 
+     {
+       evas_object_smart_member_del(wd->as);
+       evas_object_del(wd->as);
+       wd->as = NULL;
+     }
+   free(wd);
 }
 
 static void
 _theme_hook(Evas_Object *obj)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
-
-       if (edje_object_part_swallow_get(wd->as, "elm.swallow.icon") == NULL) {
-               edje_object_part_unswallow(wd->as, wd->icon);
-       }
-
-       _elm_theme_object_set(obj, wd->as, "actionslider", "base", elm_widget_style_get(obj));
-       _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", elm_widget_style_get(obj));
-       edje_object_part_swallow(wd->as, "elm.swallow.icon", wd->icon);
-       edje_object_part_text_set(wd->as, "elm.text.left", wd->text_left);
-       edje_object_part_text_set(wd->as, "elm.text.right", wd->text_right);
-       edje_object_part_text_set(wd->as, "elm.text.center", wd->text_center);
-       edje_object_message_signal_process(wd->as);
-       //edje_object_scale_set(wd->as, elm_widget_scale_get(obj) * _elm_config->scale);
-       _sizing_eval(obj);
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if (edje_object_part_swallow_get(wd->as, "elm.swallow.icon") == NULL) 
+     {
+       edje_object_part_unswallow(wd->as, wd->icon);
+     }
+
+   _elm_theme_object_set(obj, wd->as, "actionslider", "base", elm_widget_style_get(obj));
+   _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", elm_widget_style_get(obj));
+   edje_object_part_swallow(wd->as, "elm.swallow.icon", wd->icon);
+   edje_object_part_text_set(wd->as, "elm.text.left", wd->text_left);
+   edje_object_part_text_set(wd->as, "elm.text.right", wd->text_right);
+   edje_object_part_text_set(wd->as, "elm.text.center", wd->text_center);
+   edje_object_message_signal_process(wd->as);
+   //edje_object_scale_set(wd->as, elm_widget_scale_get(obj) * _elm_config->scale);
+   _sizing_eval(obj);
 }
 
 static void
 _disable_hook(Evas_Object *obj)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
+   Widget_Data *wd = elm_widget_data_get(obj);
 /*
           TODO
    if (elm_widget_disabled_get(obj))
@@ -125,45 +134,49 @@ _disable_hook(Evas_Object *obj)
 static void
 _sizing_eval(Evas_Object *obj)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
-
+   Widget_Data *wd = elm_widget_data_get(obj);
 }
 
 static void
 _sub_del(void *data, Evas_Object *obj, void *event_info)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
-       Evas_Object *sub = event_info;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   Evas_Object *sub = event_info;
 }
 
 static void
 _icon_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
+   Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
 
-       wd->mouse_down = EINA_TRUE;
+   wd->mouse_down = EINA_TRUE;
 }
 
 static void
 _icon_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       Evas_Object *as = (Evas_Object *)data;
-       Widget_Data *wd = elm_widget_data_get(as);
-       double pos = 0.0;
+   Evas_Object *as = (Evas_Object *)data;
+   Widget_Data *wd = elm_widget_data_get(as);
+   double pos = 0.0;
 
-       elm_actionslider_hold(as, EINA_FALSE);
-       if (wd->mouse_down == EINA_FALSE) return;
+   elm_actionslider_hold(as, EINA_FALSE);
+   if (wd->mouse_down == EINA_FALSE) return;
 
-       edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &pos, NULL);
+   edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &pos, NULL);
 
-       if (pos == 0.0) {
-               evas_object_smart_callback_call(as, "position", "left");
-       } else if (pos == 1.0) {
-               evas_object_smart_callback_call(as, "position", "right");
+   if (pos == 0.0) 
+     {
+       evas_object_smart_callback_call(as, "position", "left");
+     } 
+   else if (pos == 1.0) 
+     {
+       evas_object_smart_callback_call(as, "position", "right");
 
-       } else if (pos >= 0.495 && pos <= 0.505) {
-               evas_object_smart_callback_call(as, "position", "center");
-       }
+     } 
+   else if (pos >= 0.495 && pos <= 0.505) 
+     {
+       evas_object_smart_callback_call(as, "position", "center");
+     }
 
        /*
         * TODO
@@ -183,71 +196,90 @@ _icon_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 static void
 _icon_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
-       double position = 0.0;
-
-       wd->mouse_down = EINA_FALSE;
-
-       if (wd->mouse_hold == EINA_FALSE) {
-               if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_LEFT) {
-                       wd->final_position = 0.0;
-               } else if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_RIGHT) {
-                       wd->final_position = 1.0;
-               } else if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_CENTER) {
-                       wd->final_position = 0.5;
-               } else if ( wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_BOTH) {
-                       edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &position, NULL);
-                       if (position <= 0.5) {
-                               wd->final_position = 0.0;
-                       } else {
-                               wd->final_position = 1.0;
-                       }
-               }
-
-               wd->icon_animator = ecore_animator_add(_icon_animation, wd);
-       }
+   Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
+   double position = 0.0;
+
+   wd->mouse_down = EINA_FALSE;
+
+   if (wd->mouse_hold == EINA_FALSE) 
+     {
+       if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_LEFT) 
+         {
+            wd->final_position = 0.0;
+         } 
+       else if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_RIGHT) 
+         {
+            wd->final_position = 1.0;
+         } 
+       else if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_CENTER) 
+         {
+            wd->final_position = 0.5;
+         } 
+       else if ( wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_BOTH) 
+         {
+            edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &position, NULL);
+            if (position <= 0.5) 
+              {
+                 wd->final_position = 0.0;
+              } 
+            else 
+              {
+                 wd->final_position = 1.0;
+              }
+         }
+
+       wd->icon_animator = ecore_animator_add(_icon_animation, wd);
+     }
 }
 
 static int
 _icon_animation(void *data)
 {
-       Widget_Data *wd = (Widget_Data *)data;
-       double cur_position = 0.0, new_position = 0.0;
-       double move_amount = 0.05;
-       Eina_Bool flag_finish_animation = EINA_FALSE;
-
-       edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &cur_position, NULL);
-
-       if (    (wd->final_position == 0.0) ||
-               (wd->final_position == 0.5 && cur_position >= wd->final_position) ) {
-               new_position = cur_position - move_amount;
-               if (new_position <= wd->final_position) {
-                       new_position = wd->final_position;
-                       flag_finish_animation = EINA_TRUE;
-               }
-       } else if (     (wd->final_position == 1.0) ||
-                       (wd->final_position == 0.5 && cur_position < wd->final_position) ) {
-               new_position = cur_position + move_amount;
-               if (new_position >= wd->final_position) {
-                       new_position = wd->final_position;
-                       flag_finish_animation = EINA_TRUE;
-                       /*
-                       // TODO
-                       if (wd->type == ELM_ACTIONSLIDER_TYPE_BAR_GREEN ||
-                               wd->type == ELM_ACTIONSLIDER_TYPE_BAR_RED ) {
-                               edje_object_signal_emit(wd->as, "elm,show,bar,text,center", "elm");
-                       }
-                       */
-               }
-       }
-
-       edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", new_position, 0.5);
-
-       if (flag_finish_animation == EINA_TRUE) {
-               return 0;
-       } else {
-               return 1;
-       }
+   Widget_Data *wd = (Widget_Data *)data;
+   double cur_position = 0.0, new_position = 0.0;
+   double move_amount = 0.05;
+   Eina_Bool flag_finish_animation = EINA_FALSE;
+
+   edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &cur_position, NULL);
+
+   if (        (wd->final_position == 0.0) ||
+        (wd->final_position == 0.5 && cur_position >= wd->final_position) ) 
+     {
+       new_position = cur_position - move_amount;
+       if (new_position <= wd->final_position) 
+         {
+            new_position = wd->final_position;
+            flag_finish_animation = EINA_TRUE;
+         }
+     } 
+   else if (   (wd->final_position == 1.0) ||
+        (wd->final_position == 0.5 && cur_position < wd->final_position) ) 
+     {
+       new_position = cur_position + move_amount;
+       if (new_position >= wd->final_position) 
+         {
+            new_position = wd->final_position;
+            flag_finish_animation = EINA_TRUE;
+            /*
+            // TODO
+            if (wd->type == ELM_ACTIONSLIDER_TYPE_BAR_GREEN ||
+                  wd->type == ELM_ACTIONSLIDER_TYPE_BAR_RED ) {
+                 edje_object_signal_emit(wd->as, "elm,show,bar,text,center", "elm");
+            }
+            */
+         }
+     }
+
+   edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", new_position, 0.5);
+
+   if (flag_finish_animation == EINA_TRUE) 
+     {
+       return 0;
+     } 
+   else 
+     {
+       return 1;
+     }
 }
 
 /**
@@ -261,51 +293,53 @@ _icon_animation(void *data)
 EAPI Evas_Object *
 elm_actionslider_add(Evas_Object *parent)
 {
-       Evas_Object *obj;
-       Evas *e;
-       Widget_Data *wd = NULL;
-
-       wd = ELM_NEW(Widget_Data);
-       e = evas_object_evas_get(parent);
-       if (e == NULL) return NULL;
-       obj = elm_widget_add(e);
-       elm_widget_type_set(obj, "actionslider");
-       elm_widget_sub_object_add(parent, obj);
-       elm_widget_data_set(obj, wd);
-
-       elm_widget_del_hook_set(obj, _del_hook);
-       elm_widget_theme_hook_set(obj, _theme_hook);
-       elm_widget_disable_hook_set(obj, _disable_hook);
-
-       wd->mouse_down = EINA_FALSE;
-       wd->mouse_hold = EINA_FALSE;
-
-       // load background edj
-       wd->as = edje_object_add(e);
-       if(wd->as == NULL) {
-               printf("Cannot load actionslider edj!\n");
-               return NULL;
-       }
-       _elm_theme_object_set(obj, wd->as, "actionslider", "base", "default");
-       elm_widget_resize_object_set(obj, wd->as);
-
-       // load icon
-       wd->icon = edje_object_add(e);
-       if (wd->icon == NULL) {
-               printf("Cannot load acitionslider icon!\n");
-               return NULL;
-       }
-       evas_object_smart_member_add(wd->icon, obj);
-       _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", "default");
-       edje_object_part_swallow(wd->as, "elm.swallow.icon", wd->icon);
-
-       // event callbacks
-       evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
-       evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_DOWN, _icon_down_cb, obj);
-       evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_MOVE, _icon_move_cb, obj);
-       evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_UP, _icon_up_cb, obj);
-
-       return obj;
+   Evas_Object *obj;
+   Evas *e;
+   Widget_Data *wd = NULL;
+
+   wd = ELM_NEW(Widget_Data);
+   e = evas_object_evas_get(parent);
+   if (e == NULL) return NULL;
+   obj = elm_widget_add(e);
+   elm_widget_type_set(obj, "actionslider");
+   elm_widget_sub_object_add(parent, obj);
+   elm_widget_data_set(obj, wd);
+
+   elm_widget_del_hook_set(obj, _del_hook);
+   elm_widget_theme_hook_set(obj, _theme_hook);
+   elm_widget_disable_hook_set(obj, _disable_hook);
+
+   wd->mouse_down = EINA_FALSE;
+   wd->mouse_hold = EINA_FALSE;
+
+   // load background edj
+   wd->as = edje_object_add(e);
+   if(wd->as == NULL) 
+     {
+       printf("Cannot load actionslider edj!\n");
+       return NULL;
+     }
+   _elm_theme_object_set(obj, wd->as, "actionslider", "base", "default");
+   elm_widget_resize_object_set(obj, wd->as);
+
+   // load icon
+   wd->icon = edje_object_add(e);
+   if (wd->icon == NULL) 
+     {
+       printf("Cannot load acitionslider icon!\n");
+       return NULL;
+     }
+   evas_object_smart_member_add(wd->icon, obj);
+   _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", "default");
+   edje_object_part_swallow(wd->as, "elm.swallow.icon", wd->icon);
+
+   // event callbacks
+   evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
+   evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_DOWN, _icon_down_cb, obj);
+   evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_MOVE, _icon_move_cb, obj);
+   evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_UP, _icon_up_cb, obj);
+
+   return obj;
 }
 
 /*
@@ -342,20 +376,27 @@ elm_actionslider_add_with_set(Evas_Object *parent, Elm_Actionslider_Icon_Pos pos
 EAPI void
 elm_actionslider_indicator_pos_set(Evas_Object *obj, Elm_Actionslider_Indicator_Pos pos)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
-       double position = 0.0;
-
-       if (pos == ELM_ACTIONSLIDER_INDICATOR_LEFT) {
-               position = 0.0;
-       } else if (pos == ELM_ACTIONSLIDER_INDICATOR_RIGHT) {
-               position = 1.0;
-       } else if (pos == ELM_ACTIONSLIDER_INDICATOR_CENTER) {
-               position = 0.5;
-       } else {
-               position = 0.0;
-       }
-
-       edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", position, 0.5);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   double position = 0.0;
+
+   if (pos == ELM_ACTIONSLIDER_INDICATOR_LEFT) 
+     {
+       position = 0.0;
+     } 
+   else if (pos == ELM_ACTIONSLIDER_INDICATOR_RIGHT) 
+     {
+       position = 1.0;
+     } 
+   else if (pos == ELM_ACTIONSLIDER_INDICATOR_CENTER) 
+     {
+       position = 0.5;
+     } 
+   else 
+     {
+       position = 0.0;
+     }
+
+   edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", position, 0.5);
 }
 
 /**
@@ -371,9 +412,9 @@ elm_actionslider_indicator_pos_set(Evas_Object *obj, Elm_Actionslider_Indicator_
 EAPI void
 elm_actionslider_magnet_pos_set(Evas_Object *obj, Elm_Actionslider_Magnet_Pos pos)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
+   Widget_Data *wd = elm_widget_data_get(obj);
 
-       wd->magnet_position = pos;
+   wd->magnet_position = pos;
 }
 
 /**
@@ -389,33 +430,42 @@ elm_actionslider_magnet_pos_set(Evas_Object *obj, Elm_Actionslider_Magnet_Pos po
 EAPI int
 elm_actionslider_label_set(Evas_Object *obj, Elm_Actionslider_Label_Pos pos, const char *label)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
-
-       if(label == NULL) {
-               label = "";
-       }
-
-       if (pos == ELM_ACTIONSLIDER_LABEL_RIGHT) {
-               if (wd->text_right) {
-                       eina_stringshare_del(wd->text_right);
-               }
-               wd->text_right = eina_stringshare_add(label);
-               edje_object_part_text_set(wd->as, "elm.text.right", label);
-       } else if (pos == ELM_ACTIONSLIDER_LABEL_LEFT) {
-               if (wd->text_left) {
-                       eina_stringshare_del(wd->text_left);
-               }
-               wd->text_left = eina_stringshare_add(label);
-               edje_object_part_text_set(wd->as, "elm.text.left", label);
-       } else if (pos == ELM_ACTIONSLIDER_LABEL_CENTER) {
-               if (wd->text_center) {
-                       eina_stringshare_del(wd->text_center);
-               }
-               wd->text_center = eina_stringshare_add(label);
-               edje_object_part_text_set(wd->as, "elm.text.center", label);
-       }
-
-       return 0;
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if(label == NULL) 
+     {
+       label = "";
+     }
+
+   if (pos == ELM_ACTIONSLIDER_LABEL_RIGHT) 
+     {
+       if (wd->text_right) 
+         {
+            eina_stringshare_del(wd->text_right);
+         }
+       wd->text_right = eina_stringshare_add(label);
+       edje_object_part_text_set(wd->as, "elm.text.right", label);
+     } 
+   else if (pos == ELM_ACTIONSLIDER_LABEL_LEFT) 
+     {
+       if (wd->text_left) 
+         {
+            eina_stringshare_del(wd->text_left);
+         }
+       wd->text_left = eina_stringshare_add(label);
+       edje_object_part_text_set(wd->as, "elm.text.left", label);
+     } 
+   else if (pos == ELM_ACTIONSLIDER_LABEL_CENTER) 
+     {
+       if (wd->text_center) 
+         {
+            eina_stringshare_del(wd->text_center);
+         }
+       wd->text_center = eina_stringshare_add(label);
+       edje_object_part_text_set(wd->as, "elm.text.center", label);
+     }
+
+   return 0;
 }
 
 /**
@@ -430,9 +480,9 @@ elm_actionslider_label_set(Evas_Object *obj, Elm_Actionslider_Label_Pos pos, con
 EAPI int
 elm_actionslider_hold(Evas_Object *obj, Eina_Bool flag)
 {
-       Widget_Data *wd = elm_widget_data_get(obj);
+   Widget_Data *wd = elm_widget_data_get(obj);
 
-       wd->mouse_hold = flag;
+   wd->mouse_hold = flag;
 
-       return 0;
+   return 0;
 }