forked from enlightenment/efl
edje: update a style when a style is added as class's member
Summary: If there is no member styles when a text_class is updated, newly added styles can't be updated. So, newly added styles as member of text_class should be updated. @fix Test Plan: Test case is included. 1. Run "elementary_test -to "font overlay"" 2. Press Next button. Check the font size. 3. Press Prev button. 4. Put font_size as 50 5. Click Apply button. 6. Press Next button. Check the font size is not changed. Reviewers: cedric, tasn, herdsman, raster Subscribers: jpeg, z-wony, Blackmole Differential Revision: https://phab.enlightenment.org/D4125
This commit is contained in:
parent
5b791420ea
commit
8e93b88175
|
@ -833,4 +833,31 @@ group { name: "page_layout";
|
|||
}
|
||||
}
|
||||
}
|
||||
group { name: "font_overlay_layout";
|
||||
styles {
|
||||
style { name: "test_class_style";
|
||||
base: "font=Sans font_size=20 color=#fff text_class=font_overlay_test wrap=mixed";
|
||||
}
|
||||
}
|
||||
parts {
|
||||
part { name: "bg";
|
||||
type: RECT;
|
||||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
min: 400 300;
|
||||
color: 0 0 0 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.text";
|
||||
type: TEXTBLOCK;
|
||||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
fixed: 1 1;
|
||||
text {
|
||||
style: "test_class_style";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,6 +266,7 @@ void test_external_video(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_external_icon(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_external_combobox(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_config(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_config_font_overlay(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_video(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_eio(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_web(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -916,6 +917,7 @@ add_tests:
|
|||
ADD_TEST(NULL, "Miscellaneous", "Accessibility", test_access);
|
||||
ADD_TEST(NULL, "Miscellaneous", "Accessibility2", test_access2);
|
||||
ADD_TEST(NULL, "Miscellaneous", "Accessibility3", test_access3);
|
||||
ADD_TEST(NULL, "Miscellaneous", "Font overlay", test_config_font_overlay);
|
||||
|
||||
//------------------------------//
|
||||
ADD_TEST(NULL, "Application client/server", "Task switcher", test_task_switcher);
|
||||
|
|
|
@ -532,3 +532,122 @@ test_config(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|||
evas_object_resize(win, 400, 500);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_font_overlay_page_next(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *layout;
|
||||
Evas_Object *nf = (Evas_Object *)data;
|
||||
char buf[255];
|
||||
|
||||
layout = elm_layout_add(nf);
|
||||
snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
|
||||
elm_layout_file_set(layout, buf, "font_overlay_layout");
|
||||
elm_layout_text_set(layout, "elm.text", "TEXTBLOCK part of test_class");
|
||||
evas_object_show(layout);
|
||||
|
||||
elm_naviframe_item_push(nf, "Font Overlay", NULL, NULL, layout, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_apply_font_overlay_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *nf = (Evas_Object *)data;
|
||||
Evas_Object *entry;
|
||||
const char *font;
|
||||
const char *font_size_temp;
|
||||
int font_size;
|
||||
|
||||
entry = (Evas_Object *)evas_object_data_get(nf, "font_entry");
|
||||
font = elm_entry_entry_get(entry);
|
||||
entry = (Evas_Object *)evas_object_data_get(nf, "font_size_entry");
|
||||
font_size_temp = elm_entry_entry_get(entry);
|
||||
font_size = atoi(font_size_temp);
|
||||
|
||||
printf("Font overlay set: Font [%s], FontSize [%d]\n", font, font_size);
|
||||
elm_config_font_overlay_set("font_overlay_test", font, font_size);
|
||||
elm_config_font_overlay_apply();
|
||||
}
|
||||
|
||||
void
|
||||
test_config_font_overlay(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *nf, *box, *horizon_box, *label, *btn, *entry;
|
||||
Elm_Object_Item *it;
|
||||
|
||||
win = elm_win_util_standard_add("naviframe", "Naviframe");
|
||||
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
nf = elm_naviframe_add(win);
|
||||
evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, nf);
|
||||
evas_object_show(nf);
|
||||
|
||||
box = elm_box_add(nf);
|
||||
evas_object_show(box);
|
||||
|
||||
horizon_box = elm_box_add(box);
|
||||
elm_box_horizontal_set(horizon_box, EINA_TRUE);
|
||||
evas_object_size_hint_align_set(horizon_box, EVAS_HINT_FILL, -1);
|
||||
evas_object_size_hint_weight_set(horizon_box, EVAS_HINT_EXPAND, -1);
|
||||
elm_box_pack_end(box, horizon_box);
|
||||
evas_object_show(horizon_box);
|
||||
|
||||
label = elm_label_add(horizon_box);
|
||||
elm_object_text_set(label, "Font:");
|
||||
elm_box_pack_end(horizon_box, label);
|
||||
evas_object_show(label);
|
||||
|
||||
entry = elm_entry_add(horizon_box);
|
||||
elm_entry_single_line_set(entry, EINA_TRUE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, -1);
|
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, -1);
|
||||
elm_object_part_text_set(entry, "elm.guide", "Input Font");
|
||||
elm_box_pack_end(horizon_box, entry);
|
||||
evas_object_show(entry);
|
||||
evas_object_data_set(nf, "font_entry", entry);
|
||||
|
||||
horizon_box = elm_box_add(box);
|
||||
elm_box_horizontal_set(horizon_box, EINA_TRUE);
|
||||
evas_object_size_hint_align_set(horizon_box, EVAS_HINT_FILL, -1);
|
||||
evas_object_size_hint_weight_set(horizon_box, EVAS_HINT_EXPAND, -1);
|
||||
elm_box_pack_end(box, horizon_box);
|
||||
evas_object_show(horizon_box);
|
||||
|
||||
label = elm_label_add(horizon_box);
|
||||
elm_object_text_set(label, "Size:");
|
||||
elm_box_pack_end(horizon_box, label);
|
||||
evas_object_show(label);
|
||||
|
||||
entry = elm_entry_add(horizon_box);
|
||||
elm_entry_single_line_set(entry, EINA_TRUE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, -1);
|
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, -1);
|
||||
elm_object_part_text_set(entry, "elm.guide", "Input Font Size");
|
||||
elm_box_pack_end(horizon_box, entry);
|
||||
evas_object_show(entry);
|
||||
evas_object_data_set(nf, "font_size_entry", entry);
|
||||
|
||||
btn = elm_button_add(box);
|
||||
elm_object_text_set(btn, "Apply Font Overlay");
|
||||
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, -1);
|
||||
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, -1);
|
||||
evas_object_smart_callback_add(btn, "clicked", _apply_font_overlay_btn_clicked_cb, nf);
|
||||
elm_box_pack_end(box, btn);
|
||||
evas_object_show(btn);
|
||||
|
||||
btn = elm_button_add(nf);
|
||||
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_smart_callback_add(btn, "clicked", _font_overlay_page_next, nf);
|
||||
elm_object_text_set(btn, "Next");
|
||||
evas_object_show(btn);
|
||||
|
||||
it = elm_naviframe_item_push(nf, "Font Overlay", NULL, btn, box, NULL);
|
||||
evas_object_data_set(nf, "page1", it);
|
||||
|
||||
evas_object_resize(win, 400, 400);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -149,34 +149,33 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag **tag_ret)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Update all evas_styles which are in an edje
|
||||
|
||||
/* Update the given evas_style
|
||||
*
|
||||
* @param ed The edje containing styles which need to be updated
|
||||
* @param ed The edje containing the given style which need to be updated
|
||||
* @param style The style which need to be updated
|
||||
* @param force Update the given style forcely or not
|
||||
*/
|
||||
void
|
||||
_edje_textblock_style_all_update(Edje *ed)
|
||||
_edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
|
||||
{
|
||||
Eina_List *l, *ll;
|
||||
Edje_Style *stl;
|
||||
Eina_List *l;
|
||||
Eina_Strbuf *txt = NULL;
|
||||
|
||||
if (!ed->file) return;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->styles, l, stl)
|
||||
{
|
||||
Edje_Style_Tag *tag;
|
||||
Edje_Text_Class *tc;
|
||||
int found = 0;
|
||||
char *fontset = NULL, *fontsource = NULL;
|
||||
|
||||
if (!ed->file) return;
|
||||
|
||||
/* Make sure the style is already defined */
|
||||
if (!stl->style) break;
|
||||
if (!stl->style) return;
|
||||
|
||||
/* No need to compute it again and again and again */
|
||||
if (stl->cache) continue;
|
||||
if (!force && stl->cache) return;
|
||||
|
||||
/* Make sure the style contains a text_class */
|
||||
EINA_LIST_FOREACH(stl->tags, ll, tag)
|
||||
EINA_LIST_FOREACH(stl->tags, l, tag)
|
||||
{
|
||||
if (tag->text_class)
|
||||
{
|
||||
|
@ -186,7 +185,7 @@ _edje_textblock_style_all_update(Edje *ed)
|
|||
}
|
||||
|
||||
/* No text classes , goto next style */
|
||||
if (!found) continue;
|
||||
if (!found) return;
|
||||
if (!txt)
|
||||
txt = eina_strbuf_new();
|
||||
|
||||
|
@ -195,7 +194,7 @@ _edje_textblock_style_all_update(Edje *ed)
|
|||
fontsource = eina_str_escape(ed->file->path);
|
||||
|
||||
/* Build the style from each tag */
|
||||
EINA_LIST_FOREACH(stl->tags, ll, tag)
|
||||
EINA_LIST_FOREACH(stl->tags, l, tag)
|
||||
{
|
||||
if (!tag->key) continue;
|
||||
|
||||
|
@ -261,12 +260,26 @@ _edje_textblock_style_all_update(Edje *ed)
|
|||
/* Configure the style */
|
||||
stl->cache = EINA_TRUE;
|
||||
evas_textblock_style_set(stl->style, eina_strbuf_string_get(txt));
|
||||
eina_strbuf_reset(txt);
|
||||
}
|
||||
if (txt)
|
||||
eina_strbuf_free(txt);
|
||||
}
|
||||
|
||||
/* Update all evas_styles which are in an edje
|
||||
*
|
||||
* @param ed The edje containing styles which need to be updated
|
||||
*/
|
||||
void
|
||||
_edje_textblock_style_all_update(Edje *ed)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Style *stl;
|
||||
|
||||
if (!ed->file) return;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->styles, l, stl)
|
||||
_edje_textblock_style_update(ed, stl, EINA_FALSE);
|
||||
}
|
||||
|
||||
static inline Edje_Style *
|
||||
_edje_textblock_style_search(Edje *ed, const char *style)
|
||||
{
|
||||
|
@ -296,7 +309,13 @@ _edje_textblock_style_member_add(Edje *ed, Edje_Style *stl)
|
|||
EINA_LIST_FOREACH(stl->tags, l, tag)
|
||||
{
|
||||
if (tag->text_class)
|
||||
{
|
||||
_edje_text_class_member_add(ed, tag->text_class);
|
||||
|
||||
/* Newly added text_class member should be updated
|
||||
according to the latest text_class's status. */
|
||||
_edje_textblock_style_update(ed, stl, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue