forked from enlightenment/terminology
much nicer font selector with previews of all fonts - faster to come
up too. use genlist.. woooo! SVN revision: 72224
This commit is contained in:
parent
28667adc4e
commit
b0a4efe651
|
@ -3,8 +3,17 @@ collections {
|
||||||
images {
|
images {
|
||||||
image: "bg_bevel.png" COMP;
|
image: "bg_bevel.png" COMP;
|
||||||
image: "bg_shine.png" COMP;
|
image: "bg_shine.png" COMP;
|
||||||
|
image: "bg_shadow.png" COMP;
|
||||||
}
|
}
|
||||||
parts {
|
parts {
|
||||||
|
part { name: "shadow";
|
||||||
|
mouse_events: 0;
|
||||||
|
description { state: "default" 0.0;
|
||||||
|
image.normal: "bg_shadow.png";
|
||||||
|
fill.smooth: 0;
|
||||||
|
visible: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
part { name: "base"; type: RECT;
|
part { name: "base"; type: RECT;
|
||||||
mouse_events: 1;
|
mouse_events: 1;
|
||||||
description { state: "default" 0.0;
|
description { state: "default" 0.0;
|
||||||
|
@ -125,4 +134,44 @@ collections {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
group { name: "terminology/fontpreview";
|
||||||
|
images {
|
||||||
|
image: "fn_shadow.png" COMP;
|
||||||
|
}
|
||||||
|
parts {
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
part { name: "clip"; type: RECT;
|
||||||
|
mouse_events: 1;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
MAINTAINERCLEANFILES = Makefile.in
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
bg_bevel.png \
|
bg_bevel.png \
|
||||||
bg_shine.png
|
bg_shine.png \
|
||||||
|
bg_shadow.png \
|
||||||
|
fn_shadow.png
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 333 B |
|
@ -65,6 +65,97 @@ _cb_op_font_sort(const void *d1, const void *d2)
|
||||||
return strcasecmp(d1, 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.content");
|
||||||
|
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;
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
|
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);
|
||||||
|
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;
|
||||||
|
if ((!strcmp(part, "elm.swallow.icon")) ||
|
||||||
|
(!strcmp(part, "elm.swallow.end")))
|
||||||
|
{
|
||||||
|
Evas_Object *o;
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
|
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");
|
||||||
|
evas_object_size_hint_min_set(o, 40, 40);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_cb_op_font_text_get(void *data, Evas_Object *obj, const char *part)
|
||||||
|
{
|
||||||
|
Font *f = data;
|
||||||
|
char buf[4096], *p;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%s", f->name);
|
||||||
|
buf[0] = toupper(buf[0]);
|
||||||
|
p = strrchr(buf, '.');
|
||||||
|
if (p) *p = 0;
|
||||||
|
return strdup(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_cb_op_font_group_text_get(void *data, Evas_Object *obj, const char *part)
|
||||||
|
{
|
||||||
|
return strdup(data);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
options_font(Evas_Object *opbox, Evas_Object *term)
|
options_font(Evas_Object *opbox, Evas_Object *term)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +163,8 @@ options_font(Evas_Object *opbox, Evas_Object *term)
|
||||||
char buf[4096], *file, *fname, *s;
|
char buf[4096], *file, *fname, *s;
|
||||||
Eina_List *files, *fontlist, *l;
|
Eina_List *files, *fontlist, *l;
|
||||||
Font *f;
|
Font *f;
|
||||||
Elm_Object_Item *it, *sel_it = NULL;
|
Elm_Object_Item *it, *sel_it = NULL, *grp_it = NULL;
|
||||||
|
Elm_Genlist_Item_Class *it_class, *it_group;
|
||||||
|
|
||||||
EINA_LIST_FREE(fonts, f)
|
EINA_LIST_FREE(fonts, f)
|
||||||
{
|
{
|
||||||
|
@ -98,18 +190,33 @@ options_font(Evas_Object *opbox, Evas_Object *term)
|
||||||
|
|
||||||
evas_object_smart_callback_add(o, "delay,changed",
|
evas_object_smart_callback_add(o, "delay,changed",
|
||||||
_cb_op_fontsize_sel, term);
|
_cb_op_fontsize_sel, term);
|
||||||
|
|
||||||
|
it_class = elm_genlist_item_class_new();
|
||||||
|
it_class->item_style = "default";
|
||||||
|
it_class->func.text_get = _cb_op_font_text_get;
|
||||||
|
it_class->func.content_get = _cb_op_font_content_get;
|
||||||
|
|
||||||
|
it_group = elm_genlist_item_class_new();
|
||||||
|
it_group->item_style = "group_index";
|
||||||
|
it_group->func.text_get = _cb_op_font_group_text_get;
|
||||||
|
|
||||||
op_fontlist = o = elm_list_add(opbox);
|
op_fontlist = o = elm_genlist_add(opbox);
|
||||||
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
elm_genlist_mode_set(o, ELM_LIST_COMPRESS);
|
||||||
elm_list_select_mode_set(o, ELM_OBJECT_SELECT_MODE_DEFAULT);
|
|
||||||
|
|
||||||
evas_event_freeze(evas_object_evas_get(opbox));
|
|
||||||
edje_freeze();
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
|
snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
|
||||||
files = ecore_file_ls(buf);
|
files = ecore_file_ls(buf);
|
||||||
|
|
||||||
|
if (files)
|
||||||
|
{
|
||||||
|
grp_it = elm_genlist_item_append(o, it_group, "Bitmap", NULL,
|
||||||
|
ELM_GENLIST_ITEM_GROUP,
|
||||||
|
NULL, NULL);
|
||||||
|
elm_genlist_item_select_mode_set(grp_it,
|
||||||
|
ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
EINA_LIST_FREE(files, file)
|
EINA_LIST_FREE(files, file)
|
||||||
{
|
{
|
||||||
f = calloc(1, sizeof(Font));
|
f = calloc(1, sizeof(Font));
|
||||||
|
@ -117,11 +224,14 @@ options_font(Evas_Object *opbox, Evas_Object *term)
|
||||||
f->term = term;
|
f->term = term;
|
||||||
f->bitmap = EINA_TRUE;
|
f->bitmap = EINA_TRUE;
|
||||||
fonts = eina_list_append(fonts, f);
|
fonts = eina_list_append(fonts, f);
|
||||||
it = elm_list_item_append(o, f->name, NULL, NULL, _cb_op_font_sel, f);
|
|
||||||
|
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) &&
|
if ((config->font.bitmap) && (config->font.name) &&
|
||||||
(!strcmp(config->font.name, f->name)))
|
(!strcmp(config->font.name, f->name)))
|
||||||
{
|
{
|
||||||
elm_list_item_selected_set(it, EINA_TRUE);
|
elm_genlist_item_selected_set(it, EINA_TRUE);
|
||||||
sel_it = it;
|
sel_it = it;
|
||||||
}
|
}
|
||||||
free(file);
|
free(file);
|
||||||
|
@ -132,12 +242,14 @@ options_font(Evas_Object *opbox, Evas_Object *term)
|
||||||
_cb_op_font_sort);
|
_cb_op_font_sort);
|
||||||
fonthash = eina_hash_string_superfast_new(NULL);
|
fonthash = eina_hash_string_superfast_new(NULL);
|
||||||
|
|
||||||
if ((files) && (fontlist))
|
if (fonts)
|
||||||
{
|
{
|
||||||
it = elm_list_item_append(o, "", NULL, NULL, NULL, NULL);
|
grp_it = elm_genlist_item_append(o, it_group, "Standard", NULL,
|
||||||
elm_list_item_separator_set(it, EINA_TRUE);
|
ELM_GENLIST_ITEM_GROUP,
|
||||||
|
NULL, NULL);
|
||||||
|
elm_genlist_item_select_mode_set(grp_it,
|
||||||
|
ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FOREACH(fontlist, l, fname)
|
EINA_LIST_FOREACH(fontlist, l, fname)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%s", fname);
|
snprintf(buf, sizeof(buf), "%s", fname);
|
||||||
|
@ -152,24 +264,25 @@ options_font(Evas_Object *opbox, Evas_Object *term)
|
||||||
f->bitmap = EINA_FALSE;
|
f->bitmap = EINA_FALSE;
|
||||||
eina_hash_add(fonthash, fname, f);
|
eina_hash_add(fonthash, fname, f);
|
||||||
fonts = eina_list_append(fonts, f);
|
fonts = eina_list_append(fonts, f);
|
||||||
it = elm_list_item_append(o, f->name, NULL, NULL, _cb_op_font_sel, f);
|
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) &&
|
if ((!config->font.bitmap) && (config->font.name) &&
|
||||||
(!strcmp(config->font.name, f->name)))
|
(!strcmp(config->font.name, f->name)))
|
||||||
{
|
{
|
||||||
elm_list_item_selected_set(it, EINA_TRUE);
|
elm_genlist_item_selected_set(it, EINA_TRUE);
|
||||||
sel_it = it;
|
sel_it = it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fontlist)
|
if (fontlist)
|
||||||
evas_font_available_list_free(evas_object_evas_get(opbox), fontlist);
|
evas_font_available_list_free(evas_object_evas_get(opbox), fontlist);
|
||||||
|
|
||||||
elm_list_go(o);
|
|
||||||
if (sel_it) elm_list_item_show(sel_it);
|
|
||||||
|
|
||||||
edje_thaw();
|
elm_genlist_item_show(sel_it, ELM_GENLIST_ITEM_SCROLLTO_TOP);
|
||||||
evas_event_thaw(evas_object_evas_get(opbox));
|
|
||||||
|
elm_genlist_item_class_free(it_class);
|
||||||
|
elm_genlist_item_class_free(it_group);
|
||||||
|
|
||||||
elm_box_pack_end(opbox, o);
|
elm_box_pack_end(opbox, o);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue