edje: add APIs for handling text properties of Edje
authorYoungbok Shin <youngb.shin@samsung.com>
Wed, 22 Nov 2017 10:16:47 +0000 (19:16 +0900)
committerJiyoun Park <jy0703.park@samsung.com>
Thu, 21 Dec 2017 08:27:02 +0000 (17:27 +0900)
It adds the following APIs.
- edje_object_part_text_min_policy_set/get => for backward compatability of elm_label.
- edje_object_part_text_valign_set/get => for C# Xamarin

@tizen_feature

Change-Id: I6fe6cf000185c403dcdcc4d541dcae23a82cd123

src/lib/edje/edje_private.h
src/lib/edje/edje_textblock.c
src/lib/edje/edje_util.c
src/lib/edje/efl_canvas_layout.eo

index 1cff50d..03299b3 100644 (file)
@@ -2016,6 +2016,13 @@ struct _Edje_Real_Part_Text
    const char            *style; // 4
    Edje_Position          offset; // 8
    short                  size; // 2
+   /***********************************************************************************
+    * TIZEN_ONLY_FEATURE: API for handling text properties of Edje                    *
+    ***********************************************************************************/
+   FLOAT_T                valign; // 4
+   /*******
+    * END *
+    *******/
 
    /***********************************************************************************
     * TIZEN_ONLY_FEATURE: ellipsize.marquee, ellipsize.fade for TEXTBLOCK, TEXT part. *
index d331d69..9bcc1c7 100644 (file)
@@ -557,7 +557,18 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
                }
           }
 
+        /***********************************************************************************
+         * TIZEN_ONLY_FEATURE: API for handling text properties of Edje                    *
+         ***********************************************************************************
         evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
+         */
+        if (ep->typedata.text->valign != -1.0)
+          evas_object_textblock_valign_set(ep->object, TO_DOUBLE(ep->typedata.text->valign));
+        else
+          evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
+        /*******
+         * END *
+         *******/
      }
 }
 
index a87caa7..16216e0 100644 (file)
@@ -6282,6 +6282,121 @@ edje_object_part_text_get(const Edje_Object *obj, const char *part)
 }
 
 /***********************************************************************************
+ * TIZEN_ONLY_FEATURE: API for handling text properties of Edje                    *
+ ***********************************************************************************/
+EOLIAN Eina_Bool
+_edje_object_part_text_min_policy_set(Eo *eo_obj EINA_UNUSED, Edje *ed, const char *part, const char *state_name, Eina_Bool min_x, Eina_Bool min_y)
+{
+   Edje_Real_Part *rp;
+   Edje_Part_Description_Text *desc;
+
+   if ((!part) || (!state_name)) return EINA_FALSE;
+   rp = _edje_real_part_recursive_get(&ed, part);
+   if (!rp) return EINA_FALSE;
+   if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) &&
+       (rp->part->type != EDJE_PART_TYPE_TEXT))
+     return EINA_FALSE;
+
+   desc = (Edje_Part_Description_Text *)_edje_part_description_find(ed, rp, state_name, 0.0, EINA_FALSE);
+
+   if (desc)
+     {
+        desc->text.min_x = (unsigned char)min_x;
+        desc->text.min_y = (unsigned char)min_y;
+     }
+
+   return EINA_TRUE;
+}
+
+EOLIAN Eina_Bool
+_edje_object_part_text_min_policy_get(Eo *eo_obj EINA_UNUSED, Edje *ed, const char *part, const char *state_name, Eina_Bool *min_x, Eina_Bool *min_y)
+{
+   Edje_Real_Part *rp;
+   Edje_Part_Description_Text *desc;
+
+   if ((!part) || (!state_name) || (!min_x && !min_y)) return EINA_FALSE;
+   rp = _edje_real_part_recursive_get(&ed, part);
+   if (!rp) return EINA_FALSE;
+   if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) &&
+       (rp->part->type != EDJE_PART_TYPE_TEXT))
+     return EINA_FALSE;
+
+   desc = (Edje_Part_Description_Text *)_edje_part_description_find(ed, rp, state_name, 0.0, EINA_FALSE);
+
+   if (desc)
+     {
+        if (min_x) *min_x = (Eina_Bool)desc->text.min_x;
+        if (min_y) *min_y = (Eina_Bool)desc->text.min_y;
+     }
+
+   return EINA_TRUE;
+}
+
+EOLIAN Eina_Bool
+_edje_object_part_text_valign_set(Eo *eo_obj EINA_UNUSED, Edje *ed, const char *part, double valign)
+{
+   Edje_Real_Part *rp;
+   Edje_Part_Description_Text *desc;
+
+   if (!part) return EINA_FALSE;
+   rp = _edje_real_part_recursive_get(&ed, part);
+   if (!rp) return EINA_FALSE;
+   if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) &&
+       (rp->part->type != EDJE_PART_TYPE_TEXT))
+     return EINA_FALSE;
+
+   if (rp->typedata.text)
+     {
+        rp->typedata.text->valign = FROM_DOUBLE(valign);
+
+        if (rp->typedata.text->valign == -1.0)
+          {
+             desc = (Edje_Part_Description_Text *)rp->chosen_description;
+             evas_object_textblock_valign_set(rp->object, TO_DOUBLE(desc->text.align.y));
+          }
+        else
+          {
+             evas_object_textblock_valign_set(rp->object, valign);
+          }
+        return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
+
+EOLIAN double
+_edje_object_part_text_valign_get(Eo *eo_obj EINA_UNUSED, Edje *ed, const char *part)
+{
+   Edje_Real_Part *rp;
+   Edje_Part_Description_Text *desc;
+
+   if (!part) return -1.0;
+   rp = _edje_real_part_recursive_get(&ed, part);
+   if (!rp) return -1.0;
+   if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) &&
+       (rp->part->type != EDJE_PART_TYPE_TEXT))
+     return -1.0;
+
+   if (rp->typedata.text)
+     {
+        if (rp->typedata.text->valign == -1.0)
+          {
+             desc = (Edje_Part_Description_Text *)rp->chosen_description;
+             return TO_DOUBLE(desc->text.align.y);
+          }
+        else
+          {
+             return TO_DOUBLE(rp->typedata.text->valign);
+          }
+     }
+
+   return -1.0;
+}
+/*******
+ * END *
+ *******/
+
+/***********************************************************************************
  * TIZEN_ONLY_FEATURE: ellipsize.marquee, ellipsize.fade for TEXTBLOCK, TEXT part. *
  ***********************************************************************************/
 EOLIAN Eina_Bool
index d50960a..c8b1477 100644 (file)
@@ -89,6 +89,73 @@ class Efl.Canvas.Layout (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
             device: Efl.Input.Device; [[The seat device]]
          }
       }
+      /***********************************************************************************
+       * TIZEN_ONLY_FEATURE: API for handling text properties of Edje                    *
+       ***********************************************************************************/
+      @property part_text_min_policy {
+         set {
+            [[Sets the object text min calculation policy.
+
+              Do not use this API without understanding whats going on.
+              It is made for internal usage.
+
+              \@if MOBILE \@since_tizen 3.0
+              \@elseif WEARABLE \@since_tizen 3.0
+              \@endif
+              \@internal
+            ]]
+            return: bool; [[$true on success, or $false on error]]
+         }
+         get {
+            [[Gets the object text min calculation policy.
+
+              Do not use this API without understanding whats going on.
+              It is made for internal usage.
+
+              \@if MOBILE \@since_tizen 3.0
+              \@elseif WEARABLE \@since_tizen 3.0
+              \@endif
+              \@internal
+            ]]
+            return: bool; [[$true on success, or $false on error]]
+         }
+         keys {
+            part: string; [[The part name]]
+            state_name: string; [[The state name]]
+         }
+         values {
+            min_x: bool; [[The min width policy]]
+            min_y: bool; [[The min height policy]]
+         }
+      }
+      @property part_text_valign {
+         set {
+            [[Sets the valign for text.
+
+              Do not use this API without understanding whats going on.
+              It is made for internal usage.
+              \@internal
+            ]]
+            return: bool; [[$true, on success or $false, on error]]
+         }
+         get {
+            [[Gets the valign for text.
+
+              Do not use this API without understanding whats going on.
+              It is made for internal usage.
+              \@internal
+            ]]
+         }
+         keys {
+            part: string; [[The part name]]
+         }
+         values {
+            valign: double; [[The valign 0.0~1.0. -1.0 for respect EDC's align value.]]
+         }
+      }
+      /*******
+       * END *
+       *******/
    }
    implements {
       Efl.Gfx.visible { set; }