Modify Elm conformant widget to notify display mode change
authorJiyoun Park <jijibe99@gmail.com>
Sun, 14 Oct 2012 14:48:02 +0000 (14:48 +0000)
committerJiyoun Park <jijibe99@gmail.com>
Sun, 14 Oct 2012 14:48:02 +0000 (14:48 +0000)
to child widget related with keypad state change.
elm naviframe check this change and deal with this using theme

SVN revision: 77965

ChangeLog
NEWS
src/lib/elc_naviframe.c
src/lib/elm_conform.c
src/lib/elm_widget.c
src/lib/elm_widget.h
src/lib/elm_widget_naviframe.h

index 1c2cb52..90bb978 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
         * Fix the transit to launch the effect directly when elm_transit_go is called.
 
+2012-10-14  Jiyoun Park (jypark)
+
+        * Add display mode change feature related with keypad state chante
+       to elm conformant and naviframe.
diff --git a/NEWS b/NEWS
index 03c77f2..3d6c0dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Improvements:
    * Diskselector handles dyanmic show/hide of icons now like buttons.
    * Plug widget handles image object deletion
    * Handle COMPOUND_TEXT cnp
+   * Conformant widget handles displaymode change related with keypad.
 
 Fixes:
 
index 5b20b4a..7d92c6f 100644 (file)
@@ -1015,6 +1015,34 @@ _item_new(Evas_Object *obj,
    return it;
 }
 
+
+static void
+_on_obj_size_hints_changed(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Elm_Naviframe_Item *it;
+   Evas_Display_Mode dispmode;
+
+   ELM_NAVIFRAME_DATA_GET(obj, sd);
+
+   it = elm_naviframe_top_item_get(obj);
+   if (!it) return;
+
+   dispmode = evas_object_size_hint_display_mode_get(obj);
+   if (sd->dispmode == dispmode) return;
+
+   sd->dispmode = dispmode;
+
+   switch (dispmode)
+     {
+      case EVAS_DISPLAY_MODE_COMPRESS:
+        edje_object_signal_emit(VIEW(it), "display,mode,compress", "");
+        break;
+      default:
+        edje_object_signal_emit(VIEW(it), "display,mode,default", "");
+        break;
+     }
+}
+
 static Eina_Bool
 _elm_naviframe_smart_focus_next(const Evas_Object *obj,
                                 Elm_Focus_Direction dir,
@@ -1083,6 +1111,7 @@ _elm_naviframe_smart_add(Evas_Object *obj)
    priv->auto_pushed = EINA_TRUE;
    priv->freeze_events = EINA_TRUE;
 
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_obj_size_hints_changed, obj);
    elm_widget_can_focus_set(obj, EINA_FALSE);
 }
 
index e8cbd2e..c10e6af 100644 (file)
@@ -446,16 +446,26 @@ _on_prop_change(void *data,
    else if (ev->atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE)
      {
         Ecore_X_Window zone;
+        Ecore_X_Virtual_Keyboard_State vkb_state;
 
         DBG("Keyboard Geometry Changed\n");
         zone = ecore_x_e_illume_zone_get(ev->win);
-        sd->vkb_state = ecore_x_e_virtual_keyboard_state_get(zone);
-        if (sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
+        vkb_state = ecore_x_e_virtual_keyboard_state_get(zone);
+        if (sd->vkb_state != vkb_state)
           {
-             evas_object_size_hint_min_set(sd->virtualkeypad, -1, 0);
-             evas_object_size_hint_max_set(sd->virtualkeypad, -1, 0);
+             sd->vkb_state = vkb_state;
+             if (sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
+               {
+                  evas_object_size_hint_min_set(sd->virtualkeypad, -1, 0);
+                  evas_object_size_hint_max_set(sd->virtualkeypad, -1, 0);
+                  elm_widget_display_mode_set(data,EVAS_DISPLAY_MODE_NONE);
+               }
+             else if (sd->vkb_state == ECORE_X_VIRTUAL_KEYBOARD_STATE_ON)
+               {
+                  elm_widget_display_mode_set(data,EVAS_DISPLAY_MODE_COMPRESS);
+                  _autoscroll_objects_update(data);
+               }
           }
-        else _autoscroll_objects_update(data);
      }
    else if (ev->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
      {
index c4b34b4..45aec13 100644 (file)
@@ -3533,6 +3533,72 @@ elm_widget_activate(Evas_Object *obj, Elm_Activate act)
 /**
  * @internal
  *
+ * Returns the widget's Evas_Display_Mode
+ *
+ * @param obj The widget.
+ * @return Evas_Display_Mode of the object.
+ *
+ * @see elm_widget_display_mode_set().
+ * @ingroup Widget
+ **/
+EAPI Evas_Display_Mode
+elm_widget_display_mode_get(Evas_Object *obj)
+{
+   Evas_Display_Mode new_mode;
+   Evas_Object *parent;
+
+   API_ENTRY return EVAS_DISPLAY_MODE_NONE;
+
+   new_mode = evas_object_size_hint_display_mode_get(obj);
+   parent = elm_widget_parent_get(obj);
+
+   if ((new_mode == EVAS_DISPLAY_MODE_INHERIT) && parent)
+     return elm_widget_display_mode_get(parent);
+   return new_mode;
+
+}
+
+/**
+ * @internal
+ *
+ * Sets the widget and child widget's Evas_Display_Mode.
+ *
+ * @param obj The widget.
+ * @param dispmode Evas_Display_Mode to set widget's mode.
+ *
+ * Widgets are resized by several reasons.
+ * Evas_Display_Mode can help for widgets to get more reson of resize.
+ * For example, elm conform widget resize it's contents when keypad state changed.
+ * After keypad showing, conform widget can change child's Evas_Display_Mode.
+ * @ingroup Widget
+ */
+EAPI void
+elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
+{
+   Evas_Display_Mode child_mode;
+   Evas_Object *child;
+   Eina_List *l;
+
+   API_ENTRY return;
+
+   if (elm_widget_display_mode_get(obj) == dispmode) return;
+   evas_object_size_hint_display_mode_set(obj, dispmode);
+
+   //TODO: Need to deal with EVAS_DISPLAY_MODE_INHERIT efficiently.
+   EINA_LIST_FOREACH (sd->subobjs, l, child)
+     {
+        child_mode = evas_object_size_hint_display_mode_get(child);
+        if (child_mode != EVAS_DISPLAY_MODE_DONT_CHANGE)
+          {
+             elm_widget_display_mode_set(child, dispmode);
+          }
+     }
+
+}
+
+/**
+ * @internal
+ *
  * Allocate a new Elm_Widget_Item-derived structure.
  *
  * The goal of this structure is to provide common ground for actions
index 96ab2f4..a7df6ba 100644 (file)
@@ -692,6 +692,8 @@ EAPI Evas_Object     *elm_widget_parent_get(const Evas_Object *obj);
 EAPI Evas_Object     *elm_widget_parent2_get(const Evas_Object *obj);
 EAPI void             elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent);
 EAPI void             elm_widget_focus_steal(Evas_Object *obj);
+EAPI Evas_Display_Mode elm_widget_display_mode_get(Evas_Object *obj);
+EAPI void             elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode);
 EAPI const Elm_Widget_Smart_Class *elm_widget_smart_class_get(void);
 
 /**
index a4f530e..a6900e7 100644 (file)
@@ -126,6 +126,7 @@ struct _Elm_Naviframe_Smart_Data
    Eina_Inlist          *stack; /* top item is the list's LAST item */
    Evas_Object          *dummy_edje;
    Ecore_Animator       *animator;
+   Evas_Display_Mode     dispmode;
 
    Eina_Bool             preserve : 1;
    Eina_Bool             on_deletion : 1;