forked from enlightenment/efl
Canvas text: change halign/valign to use doubles
There are use cases where you would want to align by a value. The wordy alignment values are thus removed. This commit also separates auto-modes (none, normal, locale) for horizontal alignment to its own API. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
941fe1ffbd
commit
58ce1d654b
|
@ -53,11 +53,11 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
efl_text_set(en, "This is a\t small label");
|
||||
// 012345678901234567890
|
||||
_apply_style(en, 0, 21, "font_size=12 font_weight=bold");
|
||||
efl_text_halign_set(en, EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER);
|
||||
efl_text_halign_set(en, 0.5);
|
||||
efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD);
|
||||
|
||||
en = _create_label(win, bx);
|
||||
efl_text_halign_set(en, EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER);
|
||||
efl_text_halign_set(en, 0.5);
|
||||
efl_text_set(en, "This is a text. Is also has\n"
|
||||
"newlines. There are several styles applied.");
|
||||
_apply_style(en, 40, 45, "font_weight=bold color=#ff0");
|
||||
|
@ -65,7 +65,7 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
efl_text_multiline_set(en, EINA_TRUE);
|
||||
|
||||
en = _create_label(win, bx);
|
||||
efl_text_halign_set(en, EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER);
|
||||
efl_text_halign_set(en, 0.5);
|
||||
efl_text_set(en, "By default 'multiline' is disabled.\n"
|
||||
"So, \\n would only work if you enable it.");
|
||||
|
||||
|
|
|
@ -7,23 +7,13 @@ enum Efl.Text.Format.Wrap {
|
|||
hyphenation [[Wrap mode hyphenation]]
|
||||
}
|
||||
|
||||
enum Efl.Text.Format.Horizontal_Alignment_Type {
|
||||
[[Horizontal alignment of the text]]
|
||||
legacy: efl_text_horizontal_alignment;
|
||||
auto, [[Respects LTR/RTL (bidirectional) settings]]
|
||||
locale, [[Respects locale's langauge settings]]
|
||||
left, [[Text is placed at the left end of the line]]
|
||||
right, [[Text is placed at the right end of the line]]
|
||||
center, [[Text is places at the center of the line]]
|
||||
end [[Text is places at opposite side of LTR/RTL (bidirectional) settings]]
|
||||
}
|
||||
|
||||
enum Efl.Text.Format.Vertical_Alignment_Type {
|
||||
[[Horizontal alignment of the text]]
|
||||
legacy: efl_text_vertical_alignment;
|
||||
top, [[Text is placed at the top]]
|
||||
center, [[Text is placed at the center]]
|
||||
bottom [[Text is placed at the bottom]]
|
||||
enum Efl.Text.Format.Horizontal_Alignment_Auto_Type {
|
||||
[[Auto-horizontal alignment of the text]]
|
||||
legacy: efl_text_horizontal_alignment_auto;
|
||||
none, [[No auto-alignment rule]]
|
||||
normal, [[Respects LTR/RTL (bidirectional) settings]]
|
||||
locale, [[Respects locale's langauge settings]]
|
||||
end [[Text is places at opposite side of LTR/RTL (bidirectional) settings]]
|
||||
}
|
||||
|
||||
interface Efl.Text.Format {
|
||||
|
@ -58,17 +48,24 @@ interface Efl.Text.Format {
|
|||
}
|
||||
}
|
||||
|
||||
@property halign_auto_type {
|
||||
[[Horizontal alignment of text]]
|
||||
values {
|
||||
value: Efl.Text.Format.Horizontal_Alignment_Auto_Type; [[Alignment type]]
|
||||
}
|
||||
}
|
||||
|
||||
@property halign {
|
||||
[[Horizontal alignment of text]]
|
||||
values {
|
||||
value: Efl.Text.Format.Horizontal_Alignment_Type; [[Alignment type]]
|
||||
value: double; [[Horizontal alignment value]]
|
||||
}
|
||||
}
|
||||
|
||||
@property valign {
|
||||
[[Vertical alignment of text]]
|
||||
values {
|
||||
value: Efl.Text.Format.Vertical_Alignment_Type; [[Allignment type]]
|
||||
value: double; [[Vertical alignment value]]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -308,6 +308,7 @@ Efl.Text.Cursor, Efl.Text.Annotate, Efl.Text.Markup)
|
|||
Efl.Text.Format.wrap { get; set; }
|
||||
Efl.Text.Format.multiline { get; set; }
|
||||
Efl.Text.Format.halign { get; set; }
|
||||
Efl.Text.Format.halign_auto_type { get; set; }
|
||||
Efl.Text.Format.valign { get; set; }
|
||||
Efl.Text.Format.linegap { get; set; }
|
||||
Efl.Text.Format.linerelgap { get; set; }
|
||||
|
|
|
@ -15397,6 +15397,11 @@ _efl_canvas_text_efl_text_font_font_bitmap_scalable_get(Eo *obj EINA_UNUSED, Efl
|
|||
_FMT(x) = v; \
|
||||
_canvas_text_format_changed(obj, o);
|
||||
|
||||
#define _FMT_DBL_SET(x, v) \
|
||||
if (EINA_DBL_EQ(_FMT(x), v)) return; \
|
||||
_FMT(x) = v; \
|
||||
_canvas_text_format_changed(obj, o);
|
||||
|
||||
/* Helper: updates format field of extended format information, and informs if changed. */
|
||||
#define _FMT_INFO_SET_START(x, v) \
|
||||
Eina_Bool changed = EINA_FALSE; \
|
||||
|
@ -15801,81 +15806,68 @@ _efl_canvas_text_efl_text_format_multiline_get(Eo *obj EINA_UNUSED, Efl_Canvas_T
|
|||
}
|
||||
|
||||
static void
|
||||
_efl_canvas_text_efl_text_format_halign_set(Eo *obj, Efl_Canvas_Text_Data *o, Efl_Text_Format_Horizontal_Alignment_Type type)
|
||||
_efl_canvas_text_efl_text_format_halign_auto_type_set(Eo *obj, Efl_Canvas_Text_Data *o, Efl_Text_Format_Horizontal_Alignment_Auto_Type type)
|
||||
{
|
||||
ASYNC_BLOCK;
|
||||
if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO)
|
||||
if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NONE)
|
||||
{
|
||||
_FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_NONE);
|
||||
}
|
||||
else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NORMAL)
|
||||
{
|
||||
_FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL);
|
||||
}
|
||||
else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_END)
|
||||
{
|
||||
_FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_END);
|
||||
}
|
||||
else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_LOCALE)
|
||||
else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_LOCALE)
|
||||
{
|
||||
_FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE);
|
||||
}
|
||||
else
|
||||
else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_END)
|
||||
{
|
||||
double value = 0.0; // EFL_TEXT_HORIZONTAL_ALIGNMENT_LEFT
|
||||
_FMT(halign_auto) = EINA_FALSE;
|
||||
|
||||
if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER)
|
||||
{
|
||||
value = 0.5;
|
||||
}
|
||||
else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_RIGHT)
|
||||
{
|
||||
value = 1.0;
|
||||
}
|
||||
_FMT_SET(halign, value);
|
||||
_FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_END);
|
||||
}
|
||||
}
|
||||
|
||||
static Efl_Text_Format_Horizontal_Alignment_Type
|
||||
_efl_canvas_text_efl_text_format_halign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o)
|
||||
static Efl_Text_Format_Horizontal_Alignment_Auto_Type
|
||||
_efl_canvas_text_efl_text_format_halign_auto_type_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o)
|
||||
{
|
||||
Efl_Text_Format_Horizontal_Alignment_Type ret =
|
||||
EFL_TEXT_HORIZONTAL_ALIGNMENT_LEFT;
|
||||
Efl_Text_Format_Horizontal_Alignment_Auto_Type ret =
|
||||
EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NONE;
|
||||
|
||||
if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL)
|
||||
{
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO;
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NORMAL;
|
||||
}
|
||||
else if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_END)
|
||||
{
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_END;
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_END;
|
||||
}
|
||||
else if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE)
|
||||
{
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_LOCALE;
|
||||
}
|
||||
else if (EINA_DBL_EQ(_FMT(halign), 0.5))
|
||||
{
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER;
|
||||
}
|
||||
else if (EINA_DBL_EQ(_FMT(halign), 1.0))
|
||||
{
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_RIGHT;
|
||||
ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_LOCALE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_canvas_text_efl_text_format_valign_set(Eo *obj, Efl_Canvas_Text_Data *o,
|
||||
Efl_Text_Format_Vertical_Alignment_Type type)
|
||||
_efl_canvas_text_efl_text_format_halign_set(Eo *obj, Efl_Canvas_Text_Data *o,
|
||||
double value)
|
||||
{
|
||||
ASYNC_BLOCK;
|
||||
_FMT_DBL_SET(halign, value);
|
||||
_FMT(halign_auto) = EVAS_TEXTBLOCK_ALIGN_AUTO_NONE;
|
||||
}
|
||||
|
||||
static double
|
||||
_efl_canvas_text_efl_text_format_halign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED)
|
||||
{
|
||||
return _FMT(halign);
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_canvas_text_efl_text_format_valign_set(Eo *obj, Efl_Canvas_Text_Data *o,
|
||||
double value)
|
||||
{
|
||||
ASYNC_BLOCK;
|
||||
double value = 0.0; // EFL_TEXT_VERTICAL_ALIGNMENT_TOP
|
||||
if (type == EFL_TEXT_VERTICAL_ALIGNMENT_CENTER)
|
||||
{
|
||||
value = 0.5;
|
||||
}
|
||||
else if (type == EFL_TEXT_VERTICAL_ALIGNMENT_BOTTOM)
|
||||
{
|
||||
value = 1.0;
|
||||
}
|
||||
if (!EINA_DBL_EQ(o->valign, value))
|
||||
{
|
||||
o->valign = value;
|
||||
|
@ -15883,7 +15875,7 @@ _efl_canvas_text_efl_text_format_valign_set(Eo *obj, Efl_Canvas_Text_Data *o,
|
|||
}
|
||||
}
|
||||
|
||||
static Efl_Text_Format_Vertical_Alignment_Type
|
||||
static double
|
||||
_efl_canvas_text_efl_text_format_valign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED)
|
||||
{
|
||||
return o->valign;
|
||||
|
|
Loading…
Reference in New Issue