Add edje signal for text direction 74/277274/13 submit/tizen/20220817.013648
authorBowon Ryu <bowon.ryu@samsung.com>
Mon, 4 Jul 2022 08:56:16 +0000 (17:56 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 9 Aug 2022 08:09:53 +0000 (08:09 +0000)
add signals "text,state,rtl", "text,state,ltr"

Change-Id: Ie8d31bbe5106d9af88e19243ffe2ac94bb90cb85
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/lib/edje/edje_calc.c
src/lib/edje/edje_load.c
src/lib/edje/edje_private.h
src/lib/edje/edje_util.c

index aee7f30..8cd08fa 100644 (file)
@@ -4056,6 +4056,59 @@ _edje_part_calc_params_memcpy(Edje_Calc_Params *p, Edje_Calc_Params *s, Edje_Par
 }
 /* END */
 
+
+static Evas_BiDi_Direction
+_edje_text_direction_get(Edje_Real_Part *ep)
+{
+   Evas_BiDi_Direction bidi_dir;
+
+   if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
+     {
+        Evas_Textblock_Cursor *cur;
+        cur = evas_object_textblock_cursor_new(ep->object);
+        bidi_dir = evas_textblock_cursor_paragraph_direction_get(cur);
+        evas_textblock_cursor_line_set(cur, 1);
+        evas_textblock_cursor_free(cur);
+     }
+   else
+     {
+        bidi_dir = evas_object_text_direction_get(ep->object);
+     }
+
+   return bidi_dir;
+}
+
+static void
+_edje_text_direction_update(Edje *ed, Edje_Real_Part *ep, Edje_Part_Description_Text *chosen_desc)
+{
+   if (!ep || !ep->typedata.text) return;
+
+   if (!ep->typedata.text->text && !edje_string_get(&chosen_desc->text.text))
+     return;
+
+   Evas_BiDi_Direction par_dir = evas_object_paragraph_direction_get(ep->object);
+
+   if (!ep->typedata.text->changed &&
+        ep->typedata.text->last_paragraph_direction == par_dir)
+     return;
+
+   Evas_BiDi_Direction text_dir;
+   text_dir = _edje_text_direction_get(ep);
+
+   if (ep->typedata.text->text_direction == text_dir)
+     return;
+
+   ep->typedata.text->text_direction = text_dir;
+   ep->typedata.text->last_paragraph_direction = par_dir;
+   ep->typedata.text->changed = EINA_FALSE;
+
+   if (text_dir == EVAS_BIDI_DIRECTION_RTL ||
+       text_dir == EVAS_BIDI_DIRECTION_ANY_RTL)
+     _edje_emit(ed, "text,state,rtl", ep->part->name);
+   else
+     _edje_emit(ed, "text,state,ltr", ep->part->name);
+}
+
 void
 _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
 {
@@ -5133,7 +5186,10 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
                         /* TIZEN_ONLY_FEATURE: ellipsize.marquee, ellipsize.fade for TEXTBLOCK, TEXT part. */
              if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK ||
                  ep->part->type == EDJE_PART_TYPE_TEXT)
-               _edje_text_ellipsize_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
+               {
+                  _edje_text_ellipsize_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
+                  _edje_text_direction_update(ed, ep, (Edje_Part_Description_Text*) chosen_desc);
+               }
              /* END */
           }
      }
index 5eb7448..f2738ea 100644 (file)
@@ -932,7 +932,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
                        /***********************************************************************************
                         * TIZEN_ONLY_FEATURE: API for handling text properties of Edje                    *
                         ***********************************************************************************/
-                       else rp->typedata.text->valign = -1.0;
+                       else
+                         {
+                            rp->typedata.text->valign = -1.0;
+                            rp->typedata.text->changed = EINA_TRUE;
+                            rp->typedata.text->text_direction = EVAS_BIDI_DIRECTION_NEUTRAL;
+                            rp->typedata.text->last_paragraph_direction = EVAS_BIDI_DIRECTION_NEUTRAL;
+                         }
                        /*******
                         * END *
                         *******/
index fa4dc7c..42811bb 100644 (file)
@@ -1929,6 +1929,11 @@ struct _Edje_Real_Part_Text
     * END *
     *******/
 
+
+   Eina_Bool              changed : 1;
+   Evas_BiDi_Direction    text_direction;
+   Evas_BiDi_Direction    last_paragraph_direction;
+
    /***********************************************************************************
     * TIZEN_ONLY_FEATURE: ellipsize.marquee, ellipsize.fade for TEXTBLOCK, TEXT part. *
     ***********************************************************************************/
index 7409c5a..64bbaf1 100644 (file)
@@ -2311,6 +2311,7 @@ _edje_object_part_text_raw_generic_set(Edje *ed, Evas_Object *obj, Edje_Real_Par
              rp->typedata.text->text = eina_stringshare_add(mkup);
              free(mkup);
           }
+        rp->typedata.text->changed = EINA_TRUE;
      }
    ed->dirty = EINA_TRUE;
    ed->recalc_call = EINA_TRUE;