ui: adding textblock api.

This might need more work.
This commit is contained in:
Alastair Poole 2020-06-21 15:30:34 +01:00
parent c0f6f39970
commit e66cb85e64
3 changed files with 59 additions and 1 deletions

View File

@ -1202,7 +1202,7 @@ static Evas_Object *
_ui_tabs_add(Evas_Object *parent, Ui *ui)
{
Evas_Object *table, *box, *entry, *hbox, *frame, *btn;
Evas_Object *border;
Evas_Object *border, *tb;
ui->content = table = elm_table_add(parent);
evas_object_size_hint_weight_set(table, EXPAND, EXPAND);
@ -1327,6 +1327,15 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
elm_entry_scrollable_set(entry, EINA_TRUE);
elm_entry_editable_set(entry, EINA_TRUE);
evas_object_show(entry);
tb = elm_entry_textblock_get(entry);
if (tb)
{
int font_size = evisum_ui_textblock_font_size_get(tb);
if (font_size)
evisum_ui_textblock_font_size_set(tb, font_size + 2);
}
elm_object_content_set(border, entry);
elm_box_pack_end(box, border);

View File

@ -106,3 +106,46 @@ evisum_icon_path_get(const char *name)
return icon_path;
}
void
evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size)
{
Evas_Textblock_Style *ts;
if (!tb) return;
ts = evas_textblock_style_new();
evas_textblock_style_set(ts,
eina_slstr_printf("DEFAULT='font_size=%d'", new_size));
evas_object_textblock_style_user_push(tb, ts);
}
int
evisum_ui_textblock_font_size_get(Evas_Object *tb)
{
const char *style;
char *p, *p1;
Evas_Textblock_Style *ts;
int size = 0;
if (!tb) return size;
ts = evas_object_textblock_style_get(tb);
if (!ts) return size;
style = evas_textblock_style_get(ts);
if (!style && !style[0]) return size;
p = strdup(style);
p1 = strstr(p, "font_size=");
if (p1)
{
p1 += 10;
size = atoi(p1);
}
free(p);
return size;
}

View File

@ -19,4 +19,10 @@ evisum_size_format(unsigned long long bytes);
const char *
evisum_icon_path_get(const char *name);
int
evisum_ui_textblock_font_size_get(Evas_Object *tb);
void
evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size);
#endif