elm_panel: set hidden property when panel is close/open 83/130183/1
authorJEONGHYUN YUN <jh0506.yun@samsung.com>
Thu, 16 Mar 2017 08:38:18 +0000 (17:38 +0900)
committerJaeun Choi <jaeun12.choi@samsung.com>
Fri, 19 May 2017 07:00:39 +0000 (16:00 +0900)
Summary:
elm_panel has a property named hidden which stores open/close status.
This is updated when:
  1.bring_in animation is done(anim_stop_cb).
  2.mouse_up on panel.
  3.API is called. (elm_panel_toggle, elm_panel_hidden_set)
In case 3, API changes hidden, and starts bring_in animation which will call anim_stop_cb() which will update hidden again.
If bring_in animation is canceled (eg: sizing_eval), anim_stop_cb will be called and calculate hidden status
which will not guarantee updated hidden state by APIs.

Test Plan:
1.Call any APIs which will call elm_layout_sizing_eval(panel) right after calling elm_panel_toggle()/elm_panel_hidden_set().
2.Delete content of panel during "toggled" cb.

Reviewers: jpeg, eunue, cedric

Differential Revision: https://phab.enlightenment.org/D4704

@tizen_fix

Change-Id: I8e0a97910de8bbc0920dd0260e3b81bc1793827e
Signed-off-by: JEONGHYUN YUN <jh0506.yun@samsung.com>
src/lib/elm_panel.c

index ae8a45bcc324dd29114d369c29f33931c1c31598..cf0c20fc344565ed29409a2c57abacbec579b247 100644 (file)
@@ -216,7 +216,9 @@ EOLIAN static Elm_Theme_Apply
 _elm_panel_elm_widget_theme_apply(Eo *obj, Elm_Panel_Data *sd)
 {
    const char *str;
-   int w, h;
+   // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+   //int w, h;
+   //
    Evas_Coord minw = 0, minh = 0;
 
    Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED;
@@ -234,9 +236,11 @@ _elm_panel_elm_widget_theme_apply(Eo *obj, Elm_Panel_Data *sd)
         elm_widget_theme_object_set(obj, sd->scr_edje, "scroller", "panel",
                                     elm_widget_style_get(obj));
         _scrollable_layout_theme_set(obj, sd);
-        evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+        // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+        /*evas_object_geometry_get(obj, NULL, NULL, &w, &h);
         if (!sd->hidden) _drawer_open(obj, w, h, EINA_FALSE);
-        else _drawer_close(obj, w, h, EINA_FALSE);
+        else _drawer_close(obj, w, h, EINA_FALSE);*/
+        //
         handler_size = edje_object_data_get(sd->scr_edje, "handler_size");
         if (handler_size)
           sd->handler_size = (int) (elm_object_scale_get(obj)) * (atoi(handler_size));
@@ -514,16 +518,21 @@ static Eina_Bool
 _state_sync(Evas_Object *obj)
 {
    ELM_PANEL_DATA_GET(obj, sd);
-   Evas_Object *ao;
+   // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+   /*Evas_Object *ao;
    Evas_Coord pos, panel_size, w, h;
-   Eina_Bool open = EINA_FALSE, horizontal = EINA_FALSE;
+   Eina_Bool open = EINA_FALSE, horizontal = EINA_FALSE;*/
+   Evas_Coord pos, panel_size, w, h, threshold;
+   Eina_Bool horizontal = EINA_FALSE, reverse = EINA_FALSE;
+   //
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
 
    if (!evas_object_visible_get(sd->bx)) return EINA_TRUE;
 
    switch (sd->orient)
      {
-      case ELM_PANEL_ORIENT_TOP:
+      // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+      /*case ELM_PANEL_ORIENT_TOP:
          if (h <= 0) return EINA_TRUE;
 
          panel_size = h * sd->content_size_ratio;
@@ -585,10 +594,22 @@ _state_sync(Evas_Object *obj)
               else if (pos == 0) open = EINA_FALSE;
               else return EINA_FALSE;
            }
-         break;
+         break;*/
+       case ELM_PANEL_ORIENT_BOTTOM:
+          reverse = EINA_TRUE;
+       case ELM_PANEL_ORIENT_TOP:
+          break;
+
+       case ELM_PANEL_ORIENT_RIGHT:
+          reverse = EINA_TRUE;
+       case ELM_PANEL_ORIENT_LEFT:
+          horizontal = EINA_TRUE;
+          break;
+       //
      }
 
-   if (open)
+   // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+   /*if (open)
      {
         if (sd->hidden)
           {
@@ -638,7 +659,38 @@ _state_sync(Evas_Object *obj)
           }
      }
 
-   return EINA_TRUE;
+   return EINA_TRUE;*/
+
+   if (horizontal)
+     {
+        if (w <= 0) return EINA_TRUE;
+
+        panel_size = w * sd->content_size_ratio;
+        eo_do(obj, elm_interface_scrollable_content_pos_get(&pos, NULL));
+        reverse ^= elm_widget_mirrored_get(obj);
+     }
+   else
+     {
+        if (h <= 0) return EINA_TRUE;
+
+        panel_size = h * sd->content_size_ratio;
+        eo_do(obj, elm_interface_scrollable_content_pos_get(NULL, &pos));
+     }
+   threshold = (sd->hidden) ? panel_size - (panel_size / 4) : (panel_size / 4);
+
+   if (reverse)
+     {
+        if (pos > panel_size - threshold) sd->hidden = EINA_FALSE;
+        else sd->hidden = EINA_TRUE;
+     }
+   else
+     {
+        if (pos < threshold) sd->hidden = EINA_FALSE;
+        else sd->hidden = EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+   //
 }
 
 static Eina_Bool
@@ -809,7 +861,13 @@ _on_mouse_up(void *data,
 {
    Elm_Panel_Data *sd = data;
    Evas_Event_Mouse_Up *ev = event_info;
-   Evas_Coord panel_size, threshold, pos, w, h;
+   // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+   //Evas_Coord panel_size, threshold, pos, w, h;
+   Evas_Coord w, h;
+   Eina_Bool hidden;
+
+   hidden = sd->hidden;
+   //
 
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
 
@@ -817,7 +875,8 @@ _on_mouse_up(void *data,
 
    if (_state_sync(obj)) return;
 
-   switch (sd->orient)
+   // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+   /*switch (sd->orient)
      {
       case ELM_PANEL_ORIENT_TOP:
          panel_size = h * sd->content_size_ratio;
@@ -918,7 +977,13 @@ _on_mouse_up(void *data,
                 }
            }
          break;
-     }
+     }*/
+   if (sd->hidden) _drawer_close(obj, w, h, EINA_TRUE);
+   else _drawer_open(obj, w, h, EINA_TRUE);
+
+   if (sd->hidden != hidden)
+     eo_do(obj, eo_event_callback_call(ELM_PANEL_EVENT_TOGGLED, NULL));
+   //
 
    if (!sd->freeze && sd->hidden)
      ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
@@ -1343,8 +1408,91 @@ _elm_panel_elm_widget_on_focus_region(Eo *obj,
 static void
 _anim_stop_cb(Evas_Object *obj, void *data EINA_UNUSED)
 {
+   // TIZEN_ONLY(20170316): set hidden property when panel is close/open
+   /*if (elm_widget_disabled_get(obj)) return;
+   _state_sync(obj);*/
+
+   ELM_PANEL_DATA_GET(obj, sd);
+   Evas_Object *ao;
+   Evas_Coord pos, w, h, panel_size = 0;
+   Eina_Bool open = EINA_FALSE, horizontal = EINA_FALSE, reverse = EINA_FALSE;
+
    if (elm_widget_disabled_get(obj)) return;
-   _state_sync(obj);
+
+   switch (sd->orient)
+     {
+      case ELM_PANEL_ORIENT_BOTTOM:
+         reverse = EINA_TRUE;
+      case ELM_PANEL_ORIENT_TOP:
+         break;
+
+      case ELM_PANEL_ORIENT_RIGHT:
+         reverse = EINA_TRUE;
+      case ELM_PANEL_ORIENT_LEFT:
+         horizontal = EINA_TRUE;
+         break;
+     }
+
+   evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+   if (horizontal)
+     {
+         if (w <= 0) return;
+
+         panel_size = w * sd->content_size_ratio;
+         eo_do(obj, elm_interface_scrollable_content_pos_get(&pos, NULL));
+         reverse ^= elm_widget_mirrored_get(obj);
+     }
+   else
+     {
+         if (h <= 0) return;
+
+         panel_size = h * sd->content_size_ratio;
+         eo_do(obj, elm_interface_scrollable_content_pos_get(NULL, &pos));
+     }
+
+   if (pos == 0) open = !reverse;
+   else if (pos == panel_size) open = reverse;
+   else return;
+
+   if (open)
+     {
+        eo_do(obj, elm_interface_scrollable_single_direction_set
+              (ELM_SCROLLER_SINGLE_DIRECTION_HARD));
+
+        //focus & access
+        elm_object_tree_focus_allow_set(obj, EINA_TRUE);
+        if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
+          {
+             ao = _access_object_get(obj, ACCESS_OUTLINE_PART);
+             evas_object_show(ao);
+             _elm_access_highlight_set(ao);
+          }
+        else
+          elm_object_focus_set(obj, EINA_TRUE);
+     }
+   else
+     {
+        if (horizontal)
+          eo_do(obj, elm_interface_scrollable_movement_block_set
+                (ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL));
+        else
+          eo_do(obj, elm_interface_scrollable_movement_block_set
+                (ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL));
+        sd->freeze = EINA_TRUE;
+        elm_layout_signal_emit(sd->scr_ly, "elm,state,content,hidden", "elm");
+
+        eo_do(obj, elm_interface_scrollable_single_direction_set
+              (ELM_SCROLLER_SINGLE_DIRECTION_NONE));
+
+        //focus & access
+        elm_object_tree_focus_allow_set(obj, EINA_FALSE);
+        if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
+          {
+             ao = _access_object_get(obj, ACCESS_OUTLINE_PART);
+             evas_object_hide(ao);
+          }
+     }
+   //
 }
 
 static void