aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/options_font.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-06-18 06:32:56 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-06-18 06:32:56 +0000
commita97e4a87637125d7d7a0eef4b119c7a246282ae3 (patch)
tree72a47f9e494c79a3c09a7d8a2b88d15f43f9a231 /src/bin/options_font.c
parentterminology: reload theme when file change. (diff)
downloadterminology-a97e4a87637125d7d7a0eef4b119c7a246282ae3.tar.gz
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
Diffstat (limited to 'src/bin/options_font.c')
-rw-r--r--src/bin/options_font.c127
1 files changed, 72 insertions, 55 deletions
diff --git a/src/bin/options_font.c b/src/bin/options_font.c
index b06d34d..b15a3ed 100644
--- a/src/bin/options_font.c
+++ b/src/bin/options_font.c
@@ -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;
};
@@ -35,15 +34,6 @@ _reload_theme(void *data __UNUSED__, Evas_Object *obj,
}
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)
{
Evas_Coord ow = 0, oh = 0, mw = 1, mh = 1, w, h;
@@ -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 Evas_Object *
-_cb_op_font_content_get(void *data, Evas_Object *obj, const char *part)
+static void
+_cb_op_font_preview_del(void *data, Evas *e, Evas_Object *obj, void *event)
{
- 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);
+ o = edje_object_part_swallow_get(obj, "terminology.text.preview");
+ if (o) evas_object_del(o);
+}
- if (!f->bitmap)
- font = f->name;
- else
+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))
{
- snprintf(buf, sizeof(buf), "%s/fonts/%s",
- elm_app_data_dir_get(), f->name);
- font = buf;
+ 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);
}
+}
- 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 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];
+ 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;
+ }
+ 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);