[controlbar] bug fix - the selected box of the disabled item don't disappear
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Thu, 3 Mar 2011 02:50:03 +0000 (11:50 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Thu, 3 Mar 2011 02:50:03 +0000 (11:50 +0900)
[scroller] limit the acceleration

src/lib/elm_controlbar.c
src/lib/els_scroller.c

index 6e56643..fa536c0 100644 (file)
@@ -111,7 +111,7 @@ static const char *widtype = NULL;
 static int check_bar_item_number(Widget_Data *wd);
 static void selected_box(Elm_Controlbar_Item * it);
 static void cancel_selected_box(Widget_Data *wd);
-static int pressed_box(Elm_Controlbar_Item * it);
+static Eina_Bool pressed_box(Elm_Controlbar_Item * it);
 static void item_color_set(Elm_Controlbar_Item *item, const char *color_part);
 
 ///////////////////////////////////////////////////////////////////
@@ -918,10 +918,7 @@ cancel_selected_box(Widget_Data *wd)
           }
         else if (item->style == TOOLBAR)
           {
-             if(!item->disable)
-               {
-                  edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
-               }
+             edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
           }
      }
 }
@@ -948,7 +945,7 @@ unpressed_box_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
    return;
 }
 
-static int
+static Eina_Bool 
 pressed_box(Elm_Controlbar_Item * it) 
 {
    Widget_Data * wd = elm_widget_data_get(it->obj);
@@ -956,9 +953,9 @@ pressed_box(Elm_Controlbar_Item * it)
    const Eina_List *l;
    Elm_Controlbar_Item * item;
 
-   if(wd->animating) return EXIT_FAILURE;
+   if(wd->animating) return EINA_FALSE;
 
-   if(it->disable) return EXIT_FAILURE;
+   if(it->disable) return EINA_FALSE;
 
    EINA_LIST_FOREACH(wd->items, l, item)
      {
@@ -970,11 +967,7 @@ pressed_box(Elm_Controlbar_Item * it)
                }
              else if (it->style == TOOLBAR)
                {
-
-                  if(!it->disable) 
-                    {
-                       edje_object_signal_emit(_EDJ(it->base), "elm,state,toolbar_pressed", "elm");
-                    }
+                  edje_object_signal_emit(_EDJ(it->base), "elm,state,toolbar_pressed", "elm");
                }
              evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb, (void *)wd);
 
@@ -982,11 +975,11 @@ pressed_box(Elm_Controlbar_Item * it)
           }
      }
    if (!check)
-      return EXIT_FAILURE;
+      return EINA_FALSE;
 
    wd->pre_item = it;
 
-   return EXIT_SUCCESS;
+   return EINA_TRUE;
 }
 
 static Evas_Object *
index 6c876eb..46b9116 100644 (file)
@@ -1717,15 +1717,10 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
                                 (vel > _elm_config->thumbscroll_momentum_threshold) &&
                                 (!sd->freeze))
                               {
+                                 Evas_Coord cw = 0, ch = 0, px = 0, py = 0;
                                  sd->down.dx = ((double)dx / at);
                                  sd->down.dy = ((double)dy / at);
                                  if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
-                                     ((sd->down.dx < 0) && (sd->down.pdx < 0)))
-                                   sd->down.dx += (double)sd->down.pdx * 1.5; // FIXME: * 1.5 - probably should be config
-                                 if (((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
-                                     ((sd->down.dy < 0) && (sd->down.pdy < 0)))
-                                   sd->down.dy += (double)sd->down.pdy * 1.5; // FIXME: * 1.5 - probably should be config
-                                 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
                                      ((sd->down.dx < 0) && (sd->down.pdx < 0)) ||
                                      ((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
                                      ((sd->down.dy < 0) && (sd->down.pdy < 0)))
@@ -1738,6 +1733,28 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
                                       dt = _elm_config->thumbscroll_friction;
                                     sd->down.extra_time = _elm_config->thumbscroll_friction - dt;
                                   }
+                                 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
+                                     ((sd->down.dx < 0) && (sd->down.pdx < 0)))
+                                   {
+                                      int buf = (int)((double)sd->down.dx * (_elm_config->thumbscroll_friction + sd->down.extra_time) * 2);
+                                      sd->down.dx += (double)sd->down.pdx * 1.5; // FIXME: * 1.5 - probably should be config
+                                      int dest = (int)((double)sd->down.dx * (_elm_config->thumbscroll_friction + sd->down.extra_time));
+                                      if (dest < ((px - cw) + buf))
+                                         sd->down.dx = (int)((double)((px - cw) + buf) / (_elm_config->thumbscroll_friction + sd->down.extra_time));
+                                      else if (dest > (px + buf))
+                                         sd->down.dx = (int)((double)(px + buf) / (_elm_config->thumbscroll_friction + sd->down.extra_time));
+                                   }
+                                 if (((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
+                                     ((sd->down.dy < 0) && (sd->down.pdy < 0)))
+                                   {
+                                      int buf = (int)((double)sd->down.dy * (_elm_config->thumbscroll_friction + sd->down.extra_time) * 2);
+                                      sd->down.dy += (double)sd->down.pdy * 1.5; // FIXME: * 1.5 - probably should be config
+                                      int dest = (int)((double)sd->down.dy * (_elm_config->thumbscroll_friction + sd->down.extra_time));
+                                      if (dest < ((py - ch) + buf))
+                                         sd->down.dy = (int)((double)((py - ch) + buf) / (_elm_config->thumbscroll_friction + sd->down.extra_time));
+                                      else if (dest > (py + buf))
+                                         sd->down.dy = (int)((double)(py + buf) / (_elm_config->thumbscroll_friction + sd->down.extra_time));
+                                   }
                                  else
                                   sd->down.extra_time = 0.0;
                                  sd->down.pdx = sd->down.dx;