sorry gustavo -> font preview has gone back to how it was before. it

was bithc-slow on creation and its a shame to waste the spare icon
slot. i'll add a new style ot genlist in e17 to have ONLy a start or
end icon and then use that. the preview text entry i feel has dubious
use... lets discuss, but it doesnt belong in that dialog/pane.



SVN revision: 72335
This commit is contained in:
Carsten Haitzler 2012-06-18 06:32:56 +00:00
parent fa397e90f6
commit a97e4a8763
2 changed files with 96 additions and 81 deletions

View File

@ -86,26 +86,25 @@ collections {
description { state: "default" 0.0;
fixed: 1 1;
min: 80 80;
align: 1.0 0.5;
align: 0.0 0.5;
visible: 0;
rel1 {
relative: 1.0 0.02;
offset: 8 8;
}
rel2 {
relative: 2.0 0.98;
offset: -9 -9;
relative: 1.0 0.98;
offset: 8 -9;
}
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
align: 1.0 0.5;
rel1 {
relative: 0.0 0.02;
offset: 8 8;
offset: -9 8;
}
rel2 {
relative: 1.0 0.98;
offset: -9 -9;
}
}
@ -248,28 +247,27 @@ collections {
mouse_events: 1;
description { state: "default" 0.0;
color: 255 255 255 255;
rel1 {
offset: -2 -2;
to: "terminology.text.preview";
}
rel2 {
offset: 3 3;
to: "terminology.text.preview";
}
rel1.offset: 2 2;
rel2.offset: -3 -3;
}
}
part { name: "terminology.text.preview"; type: TEXT;
part { name: "clip"; type: RECT;
description { state: "default" 0.0;
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;
rel1.to: "base";
rel2.to: "base";
color: 255 255 255 255;
}
}
part { name: "terminology.text.preview"; type: SWALLOW;
clip_to: "clip";
description { state: "default" 0.0;
rel1 {
to: "base";
offset: 1 1;
}
rel2 {
to: "base";
offset: -2 -2;
}
}
}

View File

@ -15,7 +15,6 @@ 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;
};
@ -34,15 +33,6 @@ _reload_theme(void *data __UNUSED__, Evas_Object *obj,
fprintf(stderr, "RELOADING THEME\n");
}
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)
{
@ -86,7 +76,6 @@ _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
@ -95,37 +84,84 @@ _cb_op_font_sort(const void *d1, const void *d2)
return strcasecmp(d1, d2);
}
static void
_cb_op_font_preview_del(void *data, Evas *e, Evas_Object *obj, void *event)
{
Evas_Object *o;
o = edje_object_part_swallow_get(obj, "terminology.text.preview");
if (o) evas_object_del(o);
}
static void
_cb_op_font_preview_eval(void *data, Evas *e, Evas_Object *obj, void *event)
{
Font *f = data;
Evas_Object *o;
Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh;
Config *config = termio_config_get(f->term);
char buf[4096];
if (!evas_object_visible_get(obj)) return;
if (edje_object_part_swallow_get(obj, "terminology.text.preview")) 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.text.preview", 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.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");
edje_object_signal_callback_add(o, "edje,change,file", "edje", _reload_theme, NULL);
if (!f->bitmap)
font = f->name;
else
if ((!strcmp(part, "elm.swallow.icon")) ||
(!strcmp(part, "elm.swallow.end")))
{
snprintf(buf, sizeof(buf), "%s/fonts/%s",
elm_app_data_dir_get(), f->name);
font = buf;
Evas_Object *o;
char buf[4096];
Config *config = termio_config_get(f->term);
o = edje_object_add(evas_object_evas_get(obj));
snprintf(buf, sizeof(buf), "%s/themes/%s",
elm_app_data_dir_get(), config->theme);
edje_object_file_set(o, buf, "terminology/fontpreview");
edje_object_signal_callback_add(o, "edje,change,file", "edje",
_reload_theme, NULL);
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;
}
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;
return NULL;
}
static char *
@ -147,12 +183,6 @@ _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)
{
@ -173,7 +203,7 @@ options_font_clear(void)
void
options_font(Evas_Object *opbox, Evas_Object *term)
{
Evas_Object *o, *bx, *preview;
Evas_Object *o, *bx;
char buf[4096], *file, *fname, *s;
Eina_List *files, *fontlist, *l;
Font *f;
@ -212,17 +242,6 @@ 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";
@ -256,7 +275,6 @@ 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);
@ -296,7 +314,6 @@ 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);