widget: Override evas_obj_paragraph_direction_set 81/75881/4
authorYoungbok Shin <youngb.shin@samsung.com>
Wed, 22 Jun 2016 05:24:04 +0000 (14:24 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 23 Jun 2016 10:46:26 +0000 (03:46 -0700)
For applying the paragraph direction to subobjs,
elm_widget_evas_object_paragraph_direction_set is added.
It allows to use evas_object_paragraph_direction_set API to
any elementary widget and the paragraph direction wil be propagated to
child objects and smart members.
It depends on D1690.

@tizen_feature

Change-Id: I777a669a8db3431d31bec3a0589c27a34bf7709c

src/lib/elm_widget.c
src/lib/elm_widget.eo
src/lib/elm_widget.h
src/lib/elm_win.c
src/lib/elm_win.eo

index adfc182237f3adb2473e12c959c445b36d9b8854..f8ce65f659c3bf435d8909f4c7c44225d69e84b0 100644 (file)
@@ -61,6 +61,11 @@ struct _Elm_Translate_String_Data
    Eina_Bool   preset : 1;
 };
 
+/* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+static void
+_elm_widget_evas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir);
+/* END */
+
 /* local subsystem globals */
 static unsigned int focus_order = 0;
 
@@ -1222,6 +1227,15 @@ _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
              if (obj == aparent)
                 elm_interface_atspi_accessible_children_changed_added_signal_emit(obj, sobj);
           }
+
+        /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+        if (sdc->inherit_paragraph_direction &&
+            (sdc->paragraph_direction != evas_object_paragraph_direction_get(obj)))
+          {
+             sdc->paragraph_direction = evas_object_paragraph_direction_get(obj);
+             _elm_widget_evas_object_paragraph_direction_set_internal(sobj, sdc, sdc->paragraph_direction);
+          }
+        /* END */
      }
 
 end:
@@ -1303,6 +1317,15 @@ _elm_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
 
         ELM_WIDGET_DATA_GET(sobj, sdc);
         sdc->parent_obj = NULL;
+
+        /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+        if (sdc->inherit_paragraph_direction &&
+            (sdc->paragraph_direction != EVAS_BIDI_DIRECTION_NEUTRAL))
+          {
+             sdc->paragraph_direction = EVAS_BIDI_DIRECTION_NEUTRAL;
+             _elm_widget_evas_object_paragraph_direction_set_internal(sobj, sdc, sdc->paragraph_direction);
+          }
+        /* END */
      }
 
    if (sd->resize_obj == sobj) sd->resize_obj = NULL;
@@ -5848,6 +5871,9 @@ _elm_widget_eo_base_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
 ///TIZEN_ONLY(20170717) : expose highlight information on atspi
    sd->can_highlight = EINA_TRUE;
 ///
+   /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+   sd->inherit_paragraph_direction = EINA_TRUE;
+   /* END */
 
    eo_do(obj, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_UNKNOWN));
    return obj;
@@ -6479,5 +6505,67 @@ _elm_widget_item_elm_interface_atspi_accessible_translation_domain_get(Eo *obj E
 }
 ///
 
+/* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+static void
+_elm_widget_evas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir)
+{
+   Evas_Object *child;
+   Eina_List *l;
+
+   if (sd->on_destroy) return;
+
+   EINA_LIST_FOREACH(sd->subobjs, l, child)
+     {
+        if (_elm_widget_is(child))
+          {
+             Elm_Widget_Smart_Data *sdc = eo_data_scope_get(child, MY_CLASS);
+
+             if (sdc->inherit_paragraph_direction &&
+                 (sdc->paragraph_direction != dir))
+               {
+                  sdc->paragraph_direction = dir;
+                  _elm_widget_evas_object_paragraph_direction_set_internal(child, sdc, dir);
+                  eo_do_super(child, MY_CLASS, evas_obj_paragraph_direction_set(dir));
+               }
+          }
+
+        /* FIXME: There is no way to handle non-widget child object.
+         * If a non-widget child object has smart parent, it will get the direction
+         * from the smart parent. */
+     }
+}
+
+EOLIAN static void
+_elm_widget_evas_object_paragraph_direction_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir)
+{
+   if ((!(sd->inherit_paragraph_direction) && (sd->paragraph_direction == dir)) ||
+       (sd->inherit_paragraph_direction && (dir == EVAS_BIDI_DIRECTION_INHERIT)))
+     return;
+
+   if (dir == EVAS_BIDI_DIRECTION_INHERIT)
+     {
+        sd->inherit_paragraph_direction = EINA_TRUE;
+        Evas_BiDi_Direction parent_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
+
+        if (sd->parent_obj)
+          parent_dir = evas_object_paragraph_direction_get(sd->parent_obj);
+
+        if (parent_dir != sd->paragraph_direction)
+          {
+             sd->paragraph_direction = parent_dir;
+             _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, parent_dir);
+          }
+     }
+   else
+     {
+        sd->inherit_paragraph_direction = EINA_FALSE;
+        sd->paragraph_direction = dir;
+        _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, dir);
+     }
+
+   eo_do_super(obj, MY_CLASS, evas_obj_paragraph_direction_set(dir));
+}
+/* END */
+
 #include "elm_widget_item.eo.c"
 #include "elm_widget.eo.c"
index d9289efb6e0ceff66cd335860ee69a3e07c8f9d7..6ae269169f49d50181d55ed38943e5d076b985ff 100644 (file)
@@ -763,6 +763,9 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible, Elm_Inte
       Eo.Base.constructor;
       Eo.Base.destructor;
       Eo.Base.dbg_info_get;
+         /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+      Evas.Object.paragraph_direction.set;
+         /* END */
       Evas.Object_Smart.hide;
       Evas.Object_Smart.calculate;
       Evas.Object_Smart.clip_unset;
index 1f5b4d40c3b7ca36764ad4c5ea17003be88e27f4..61416451cf236da3bcca28112f26f04de8d81c38 100644 (file)
@@ -434,6 +434,10 @@ typedef struct _Elm_Widget_Smart_Data
    int                           orient_mode; /* -1 is disabled */
    Elm_Focus_Move_Policy         focus_move_policy;
    Elm_Focus_Region_Show_Mode    focus_region_show_mode;
+   /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+   Evas_BiDi_Direction           paragraph_direction : 2;
+   Eina_Bool                     inherit_paragraph_direction : 1;
+   /* END */
 
    Eina_Bool                     drag_x_locked : 1;
    Eina_Bool                     drag_y_locked : 1;
index 1cc759c5a0e8fcf86b9ea5d98dae91e38a6ee34a..02c266f2797cdbd099eb1c49279346f3e4692617 100644 (file)
@@ -6225,6 +6225,16 @@ elm_win_window_id_get(const Evas_Object *obj)
    return ret;
 }
 
+/* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+EOLIAN static void
+_elm_win_evas_object_paragraph_direction_set(Eo *obj, Elm_Win_Data *sd, Evas_BiDi_Direction dir)
+{
+   evas_object_paragraph_direction_set(sd->edje, dir);
+
+   eo_do_super(obj, MY_CLASS, evas_obj_paragraph_direction_set(dir));
+}
+/* END */
+
 EOLIAN static void
 _elm_win_class_constructor(Eo_Class *klass)
 {
index 4139d78c81327fe8b5851f66b3b7ec3d550e2b39..4b158689d620b1dbf39a129880e7c90813af5cb9 100644 (file)
@@ -1282,6 +1282,9 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window,
       class.constructor;
       Eo.Base.constructor;
       Eo.Base.finalize;
+      /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
+      Evas.Object.paragraph_direction.set;
+      /* END */
       Evas.Object_Smart.hide;
       Evas.Object_Smart.show;
       Evas.Object_Smart.move;