EVAS_TEXTBLOCK_ITEM_FORMAT,
} Evas_Textblock_Item_Type;
+typedef enum _Evas_Textblock_Align_Auto
+{
+ EVAS_TEXTBLOCK_ALIGN_AUTO_NONE,
+ EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL,
+ EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE
+} Evas_Textblock_Align_Auto;
+
struct _Evas_Object_Textblock_Item
{
EINA_INLIST;
Eina_Bool strikethrough : 1; /**< EINA_TRUE if text should be stricked off, else EINA_FALSE */
Eina_Bool backing : 1; /**< EINA_TRUE if enable background color, else EINA_FALSE */
Eina_Bool password : 1; /**< EINA_TRUE if the text is password, else EINA_FALSE */
- Eina_Bool halign_auto : 1; /**< EINA_TRUE if auto horizontal align, else EINA_FALSE */
+ Evas_Textblock_Align_Auto halign_auto : 2; /**< Auto horizontal align mode */
};
struct _Efl_Canvas_Text_Style
* Sets the horizontal alignment of the text. The value can either be
* a number, a percentage or one of several presets:
* @li "auto" - Respects LTR/RTL settings
+ * @li "locale" - Respects locale(language) direction settings
* @li "center" - Centers the text in the line
* @li "middle" - Alias for "center"
* @li "left" - Puts the text at the left of the line
*/
if (len == 4 && !strcmp(param, "auto"))
{
- fmt->halign_auto = EINA_TRUE;
+ fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL;
+ }
+ if (len == 6 && !strcmp(param, "locale"))
+ {
+ fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE;
}
else
{
if (fmt->halign < 0.0) fmt->halign = 0.0;
else if (fmt->halign > 1.0) fmt->halign = 1.0;
}
- fmt->halign_auto = EINA_FALSE;
+ fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_NONE;
}
}
else if (cmd == valignstr)
int have_underline, have_underline2;
double align, valign;
Textblock_Position position;
- Eina_Bool align_auto : 1;
+ Evas_Textblock_Align_Auto align_auto : 2;
Eina_Bool width_changed : 1;
};
_layout_line_align_get(Ctxt *c)
{
#ifdef BIDI_SUPPORT
- if (c->align_auto && c->ln)
+ if ((c->align_auto == EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL) && c->ln)
{
if (c->ln->items && c->ln->items->text_node &&
(c->ln->par->direction == EVAS_BIDI_DIRECTION_RTL))
return 0.0;
}
}
+ else if (c->align_auto == EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE)
+ {
+ if (evas_common_language_direction_get() == EVAS_BIDI_DIRECTION_RTL)
+ {
+ /* Align right*/
+ return 1.0;
+ }
+ else
+ {
+ /* Align left */
+ return 0.0;
+ }
+ }
+
#endif
return c->align;
}
#include <stdlib.h>
#include <locale.h>
+#include <libintl.h>
#ifdef HAVE_EVIL
# include <Evil.h>
static char lang[6]; /* FIXME: Maximum length I know about */
static char lang_full[32];
+static Evas_BiDi_Direction lang_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
static Evas_Script_Type
_evas_common_language_char_script_search(Eina_Unicode unicode)
return "";
}
+Evas_BiDi_Direction
+evas_common_language_direction_get(void)
+{
+ if (lang_dir == EVAS_BIDI_DIRECTION_NEUTRAL)
+ {
+ const char *dir_str = dgettext(PACKAGE, "default:LTR");
+
+ if (dir_str && !strcmp(dir_str, "default:RTL"))
+ lang_dir = EVAS_BIDI_DIRECTION_RTL;
+ else
+ lang_dir = EVAS_BIDI_DIRECTION_LTR;
+ }
+
+ return lang_dir;
+}
+
void
evas_common_language_reinit(void)
{
*lang = *lang_full = '\0';
+ lang_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
}
/*