diff --git a/data/themes/default.edc b/data/themes/default.edc index 7c7f9e55..27328a18 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -86,21 +86,28 @@ collections { description { state: "default" 0.0; fixed: 1 1; min: 80 80; - align: 0.0 0.5; + align: 1.0 0.5; + visible: 0; rel1 { relative: 1.0 0.02; offset: 8 8; } rel2 { - relative: 1.0 0.98; - offset: 8 -9; + relative: 2.0 0.98; + offset: -9 -9; } } description { state: "visible" 0.0; inherit: "default" 0.0; - align: 1.0 0.5; - rel1.offset: -9 8; - rel2.offset: -9 -9; + visible: 1; + rel1 { + relative: 0.0 0.02; + offset: 8 8; + } + rel2 { + relative: 1.0 0.98; + offset: -9 -9; + } } } programs { @@ -222,34 +229,48 @@ collections { part { name: "shadow"; mouse_events: 0; description { state: "default" 0.0; - rel1.offset: -2 -1; - rel1.to: "base"; - rel2.offset: 1 2; - rel2.to: "base"; - image.normal: "fn_shadow.png"; - image.border: 5 5 5 5; + rel1 { + offset: -2 -1; + to: "base"; + } + rel2 { + offset: 1 2; + to: "base"; + } + image { + normal: "fn_shadow.png"; + border: 5 5 5 5; + } fill.smooth: 0; } } part { name: "base"; type: RECT; mouse_events: 1; description { state: "default" 0.0; - rel1.offset: 2 2; - rel2.offset: -3 -3; color: 255 255 255 255; + rel1 { + offset: -2 -2; + to: "terminology.text.preview"; + } + rel2 { + offset: 3 3; + to: "terminology.text.preview"; + } } } - part { name: "clip"; type: RECT; - mouse_events: 1; + part { name: "terminology.text.preview"; type: TEXT; description { state: "default" 0.0; - color: 255 255 255 255; - } - } - part { name: "terminology.content"; type: SWALLOW; - clip_to: "clip"; - description { state: "default" 0.0; - rel1.offset: 4 4; - rel2.offset: -5 -5; + color: 0 0 0 255; + rel1.offset: 5 5; + rel2.offset: -6 -6; + text { + text: "test"; + text_class: "terminology.preview"; + font: "Monospace"; + size: 14; + min: 1 1; + align: 0.0 0.5; + } } } } diff --git a/data/themes/mild.edc b/data/themes/mild.edc index 216a71ee..09fdc474 100644 --- a/data/themes/mild.edc +++ b/data/themes/mild.edc @@ -46,21 +46,28 @@ collections { description { state: "default" 0.0; fixed: 1 1; min: 80 80; - align: 0.0 0.5; + align: 1.0 0.5; + visible: 0; rel1 { relative: 1.0 0.02; offset: 8 8; } rel2 { - relative: 1.0 0.98; - offset: 8 -9; + relative: 2.0 0.98; + offset: -9 -9; } } description { state: "visible" 0.0; inherit: "default" 0.0; - align: 1.0 0.5; - rel1.offset: -9 8; - rel2.offset: -9 -9; + visible: 1; + rel1 { + relative: 0.0 0.02; + offset: 8 8; + } + rel2 { + relative: 1.0 0.98; + offset: -9 -9; + } } } programs { @@ -182,34 +189,48 @@ collections { part { name: "shadow"; mouse_events: 0; description { state: "default" 0.0; - rel1.offset: -2 -1; - rel1.to: "base"; - rel2.offset: 1 2; - rel2.to: "base"; - image.normal: "fn_shadow.png"; - image.border: 5 5 5 5; + rel1 { + offset: -2 -1; + to: "base"; + } + rel2 { + offset: 1 2; + to: "base"; + } + image { + normal: "fn_shadow.png"; + border: 5 5 5 5; + } fill.smooth: 0; } } part { name: "base"; type: RECT; mouse_events: 1; description { state: "default" 0.0; - rel1.offset: 2 2; - rel2.offset: -3 -3; color: 255 255 255 255; + rel1 { + offset: -2 -2; + to: "terminology.text.preview"; + } + rel2 { + offset: 3 3; + to: "terminology.text.preview"; + } } } - part { name: "clip"; type: RECT; - mouse_events: 1; + part { name: "terminology.text.preview"; type: TEXT; description { state: "default" 0.0; - color: 255 255 255 255; - } - } - part { name: "terminology.content"; type: SWALLOW; - clip_to: "clip"; - description { state: "default" 0.0; - rel1.offset: 4 4; - rel2.offset: -5 -5; + color: 0 0 0 255; + rel1.offset: 5 5; + rel2.offset: -6 -6; + text { + text: "test"; + text_class: "terminology.preview"; + font: "Monospace"; + size: 14; + min: 1 1; + align: 0.0 0.5; + } } } } diff --git a/src/bin/options_font.c b/src/bin/options_font.c index 08b8f2f7..d1feaac2 100644 --- a/src/bin/options_font.c +++ b/src/bin/options_font.c @@ -12,14 +12,25 @@ typedef struct _Font Font; struct _Font { + Elm_Object_Item *item; const char *name; Evas_Object *term; + Evas_Object *preview; /* TODO: move preview and term to a parent struct */ Eina_Bool bitmap : 1; }; static Eina_List *fonts = NULL; static Eina_Hash *fonthash = NULL; +static void +_update_preview(void) +{ + const Eina_List *l; + const Font *f; + EINA_LIST_FOREACH(fonts, l, f) + elm_genlist_item_update(f->item); +} + static void _update_sizing(Evas_Object *term) { @@ -63,6 +74,7 @@ _cb_op_fontsize_sel(void *data, Evas_Object *obj, void *event __UNUSED__) _update_sizing(term); elm_genlist_realized_items_update(op_fontlist); config_save(config, NULL); + _update_preview(); } static int @@ -71,81 +83,36 @@ _cb_op_font_sort(const void *d1, const void *d2) return strcasecmp(d1, d2); } -static void -_cb_op_font_preview_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSED__) -{ - Evas_Object *o; - - o = edje_object_part_swallow_get(obj, "terminology.content"); - if (o) evas_object_del(o); -} - -static void -_cb_op_font_preview_eval(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSED__) -{ - Font *f = data; - Evas_Object *o; - Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh; - char buf[4096]; - Config *config = termio_config_get(f->term); - - if (!evas_object_visible_get(obj)) return; - if (edje_object_part_swallow_get(obj, "terminology.content")) return; - evas_object_geometry_get(obj, &ox, &oy, &ow, &oh); - if ((ow < 2) || (oh < 2)) return; - evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh); - if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh)) - { - o = evas_object_text_add(evas_object_evas_get(obj)); - evas_object_color_set(o, 0, 0, 0, 255); - if (evas_object_data_get(obj, "_f")) - evas_object_text_text_set(o, "Abc"); - else - evas_object_text_text_set(o, "123"); - if (f->bitmap) - { - snprintf(buf, sizeof(buf), "%s/fonts/%s", - elm_app_data_dir_get(), f->name); - evas_object_text_font_set(o, buf, config->font.size); - } - else - evas_object_text_font_set(o, f->name, config->font.size); - evas_object_geometry_get(o, NULL, NULL, &ow, &oh); - evas_object_size_hint_min_set(o, ow, oh); - edje_object_part_swallow(obj, "terminology.content", o); - } -} - static Evas_Object * _cb_op_font_content_get(void *data, Evas_Object *obj, const char *part) { Font *f = data; Config *config = termio_config_get(f->term); + Evas_Object *o; + const char *font, *s = elm_object_text_get(f->preview); + char buf[PATH_MAX]; - if ((!strcmp(part, "elm.swallow.icon")) || - (!strcmp(part, "elm.swallow.end"))) + if (strcmp(part, "elm.swallow.end") != 0) return NULL; + + o = edje_object_add(evas_object_evas_get(obj)); + edje_object_file_set(o, config_theme_path_get(config), + "terminology/fontpreview"); + + if (!f->bitmap) + font = f->name; + else { - Evas_Object *o; - - o = edje_object_add(evas_object_evas_get(obj)); - edje_object_file_set(o, config_theme_path_get(config), - "terminology/fontpreview"); - evas_object_size_hint_min_set(o, - 40 * elm_config_scale_get(), - 40 * elm_config_scale_get()); - evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, - _cb_op_font_preview_eval, f); - evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, - _cb_op_font_preview_eval, f); - evas_object_event_callback_add(o, EVAS_CALLBACK_SHOW, - _cb_op_font_preview_eval, f); - evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, - _cb_op_font_preview_del, f); - if (!strcmp(part, "elm.swallow.icon")) - evas_object_data_set(o, "_f", o); - return o; + snprintf(buf, sizeof(buf), "%s/fonts/%s", + elm_app_data_dir_get(), f->name); + font = buf; } - return NULL; + + edje_object_text_class_set(o, "terminology.preview", + font, config->font.size); + edje_object_part_text_set(o, "terminology.text.preview", s); + edje_object_update_hints_set(o, EINA_TRUE); + + return o; } static char * @@ -167,6 +134,12 @@ _cb_op_font_group_text_get(void *data, Evas_Object *obj __UNUSED__, const char * return strdup(data); } +static void +_cb_op_text_changed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + _update_preview(); +} + void options_font_clear(void) { @@ -187,7 +160,7 @@ options_font_clear(void) void options_font(Evas_Object *opbox, Evas_Object *term) { - Evas_Object *o, *bx; + Evas_Object *o, *bx, *preview; char buf[4096], *file, *fname, *s; Eina_List *files, *fontlist, *l; Font *f; @@ -226,6 +199,17 @@ options_font(Evas_Object *opbox, Evas_Object *term) elm_box_pack_end(opbox, bx); evas_object_show(bx); + + preview = o = elm_entry_add(opbox); + elm_entry_scrollable_set(o, EINA_TRUE); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5); + elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_entry_single_line_set(o, EINA_TRUE); + elm_object_text_set(o, "Abc-123, O0, l1"); + evas_object_smart_callback_add(o, "changed,user", _cb_op_text_changed, NULL); + elm_box_pack_end(opbox, o); + evas_object_show(o); it_class = elm_genlist_item_class_new(); it_class->item_style = "default"; @@ -259,10 +243,11 @@ options_font(Evas_Object *opbox, Evas_Object *term) f = calloc(1, sizeof(Font)); f->name = eina_stringshare_add(file); f->term = term; + f->preview = preview; f->bitmap = EINA_TRUE; fonts = eina_list_append(fonts, f); - it = elm_genlist_item_append(o, it_class, f, grp_it, + f->item = it = elm_genlist_item_append(o, it_class, f, grp_it, ELM_GENLIST_ITEM_NONE, _cb_op_font_sel, f); if ((config->font.bitmap) && (config->font.name) && @@ -298,10 +283,11 @@ options_font(Evas_Object *opbox, Evas_Object *term) f = calloc(1, sizeof(Font)); f->name = eina_stringshare_add(fname); f->term = term; + f->preview = preview; f->bitmap = EINA_FALSE; eina_hash_add(fonthash, fname, f); fonts = eina_list_append(fonts, f); - it = elm_genlist_item_append(o, it_class, f, grp_it, + f->item = it = elm_genlist_item_append(o, it_class, f, grp_it, ELM_GENLIST_ITEM_NONE, _cb_op_font_sel, f); if ((!config->font.bitmap) && (config->font.name) &&