forked from enlightenment/enventor
enventor - added image preview feature. to test it, double click the "image" word.
This commit is contained in:
parent
093d8e6da2
commit
eded0b4a6e
|
@ -4,6 +4,25 @@ styles {
|
|||
}
|
||||
}
|
||||
|
||||
group { name: "preview_layout";
|
||||
parts {
|
||||
part { name: "bg";
|
||||
type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
min: 100 100;
|
||||
color: 225 225 225 255;
|
||||
rel1.offset: 2 2;
|
||||
rel2.offset: -3 -3;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.img";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group { name: "slider_layout";
|
||||
parts {
|
||||
part { name: "bg";
|
||||
|
@ -11,6 +30,8 @@ group { name: "slider_layout";
|
|||
description { state: "default" 0.0;
|
||||
min: 100 25;
|
||||
color: 225 225 225 255;
|
||||
rel1.offset: 2 2;
|
||||
rel2.offset: -3 -3;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.plus";
|
||||
|
|
|
@ -306,25 +306,25 @@ config_apply(config_data *cd)
|
|||
if (cd->update_cb) cd->update_cb(cd->update_cb_data, cd);
|
||||
}
|
||||
|
||||
const Eina_List *
|
||||
Eina_List *
|
||||
config_edc_img_path_list_get(config_data *cd)
|
||||
{
|
||||
return cd->edc_img_path_list;
|
||||
}
|
||||
|
||||
const Eina_List *
|
||||
Eina_List *
|
||||
config_edc_snd_path_list_get(config_data *cd)
|
||||
{
|
||||
return cd->edc_snd_path_list;
|
||||
}
|
||||
|
||||
const Eina_List *
|
||||
Eina_List *
|
||||
config_edc_data_path_list_get(config_data *cd)
|
||||
{
|
||||
return cd->edc_data_path_list;
|
||||
}
|
||||
|
||||
const Eina_List *
|
||||
Eina_List *
|
||||
config_edc_fnt_path_list_get(config_data *cd)
|
||||
{
|
||||
return cd->edc_fnt_path_list;
|
||||
|
|
|
@ -171,3 +171,32 @@ ctxpopup_candidate_list_create(Evas_Object *parent, attr_value *attr,
|
|||
data);
|
||||
return ctxpopup;
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
ctxpopup_img_preview_create(Evas_Object *parent, const char *imgpath,
|
||||
Evas_Smart_Cb ctxpopup_dismiss_cb,
|
||||
Evas_Smart_Cb ctxpopup_selected_cb, void *data)
|
||||
{
|
||||
//create ctxpopup
|
||||
Evas_Object *ctxpopup = elm_ctxpopup_add(parent);
|
||||
if (!ctxpopup) return NULL;
|
||||
|
||||
elm_object_style_set(ctxpopup, elm_app_name_get());
|
||||
|
||||
//Layout
|
||||
Evas_Object *layout = elm_layout_add(ctxpopup);
|
||||
elm_layout_file_set(layout, EDJE_PATH, "preview_layout");
|
||||
evas_object_show(layout);
|
||||
|
||||
elm_object_content_set(ctxpopup, layout);
|
||||
|
||||
Evas *e = evas_object_evas_get(ctxpopup);
|
||||
Evas_Object *img = evas_object_image_filled_add(e);
|
||||
evas_object_image_file_set(img, imgpath, NULL);
|
||||
evas_object_show(img);
|
||||
elm_object_part_content_set(layout, "elm.swallow.img", img);
|
||||
|
||||
evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismiss_cb,
|
||||
data);
|
||||
return ctxpopup;
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ edit_save(edit_data *ed)
|
|||
}
|
||||
|
||||
static void
|
||||
ctxpopup_dismiss_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
ctxpopup_candidate_dismiss_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
edit_data *ed = data;
|
||||
evas_object_del(obj);
|
||||
|
@ -240,7 +240,7 @@ ctxpopup_dismiss_cb(void *data, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
static void
|
||||
ctxpopup_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
ctxpopup_candidate_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
edit_data *ed = data;
|
||||
const char *text = event_info;
|
||||
|
@ -250,6 +250,22 @@ ctxpopup_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
|||
edit_save(ed);
|
||||
}
|
||||
|
||||
static void
|
||||
ctxpopup_preview_dismiss_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
edit_data *ed = data;
|
||||
evas_object_del(obj);
|
||||
elm_object_disabled_set(ed->layout, EINA_FALSE);
|
||||
elm_object_focus_set(ed->en_edit, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
ctxpopup_preview_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
edit_data *ed = data;
|
||||
elm_ctxpopup_dismiss(obj);
|
||||
}
|
||||
|
||||
void
|
||||
edit_template_insert(edit_data *ed)
|
||||
{
|
||||
|
@ -428,11 +444,43 @@ program_run(edit_data *ed, char *cur)
|
|||
static void
|
||||
image_preview_show(edit_data *ed, char *cur)
|
||||
{
|
||||
char *img_path = parser_name_get(ed->pd, cur);
|
||||
if (img_path)
|
||||
char *filename = parser_name_get(ed->pd, cur);
|
||||
if (!filename) return;
|
||||
|
||||
char fullpath[PATH_MAX];
|
||||
|
||||
//1.Find the image path.
|
||||
Eina_List *list = config_edc_img_path_list_get(ed->cd);
|
||||
Eina_List *l;
|
||||
char *path;
|
||||
Eina_Bool found = EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(list, l, path)
|
||||
{
|
||||
free(img_path);
|
||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", path, filename);
|
||||
if (!ecore_file_exists(fullpath)) continue;
|
||||
found = EINA_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
Evas_Object *ctxpopup =
|
||||
ctxpopup_img_preview_create(ed->parent,
|
||||
fullpath,
|
||||
ctxpopup_preview_dismiss_cb,
|
||||
NULL,
|
||||
ed);
|
||||
if (!ctxpopup) return;
|
||||
|
||||
int x, y;
|
||||
evas_pointer_output_xy_get(evas_object_evas_get(ed->en_edit), &x, &y);
|
||||
evas_object_move(ctxpopup, x, y);
|
||||
evas_object_show(ctxpopup);
|
||||
menu_ctxpopup_register(ctxpopup);
|
||||
elm_object_disabled_set(ed->layout, EINA_TRUE);
|
||||
}
|
||||
free(filename);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -445,8 +493,8 @@ candidate_list_show(edit_data *ed, char *text, char *cur, char *selected)
|
|||
Evas_Object *ctxpopup =
|
||||
ctxpopup_candidate_list_create(ed->parent, attr,
|
||||
atof(selected),
|
||||
ctxpopup_dismiss_cb,
|
||||
ctxpopup_selected_cb, ed);
|
||||
ctxpopup_candidate_dismiss_cb,
|
||||
ctxpopup_candidate_selected_cb, ed);
|
||||
if (!ctxpopup) return;
|
||||
|
||||
int x, y;
|
||||
|
|
|
@ -12,10 +12,10 @@ void config_edc_img_path_set(config_data *cd, const char *edc_img_path);
|
|||
void config_edc_snd_path_set(config_data *cd, const char *edc_snd_path);
|
||||
void config_edc_fnt_path_set(config_data *cd, const char *edc_fnt_path);
|
||||
void config_edc_data_path_set(config_data *cd, const char *edc_fnt_path);
|
||||
const Eina_List *config_edc_img_path_list_get(config_data *cd);
|
||||
const Eina_List *config_edc_snd_path_list_get(config_data *cd);
|
||||
const Eina_List *config_edc_fnt_path_list_get(config_data *cd);
|
||||
const Eina_List *config_edc_data_path_list_get(config_data *cd);
|
||||
Eina_List *config_edc_img_path_list_get(config_data *cd);
|
||||
Eina_List *config_edc_snd_path_list_get(config_data *cd);
|
||||
Eina_List *config_edc_fnt_path_list_get(config_data *cd);
|
||||
Eina_List *config_edc_data_path_list_get(config_data *cd);
|
||||
void config_update_cb_set(config_data *cd,
|
||||
void (*cb)(void *data, config_data *cd),
|
||||
void *data);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Evas_Object * ctxpopup_candidate_list_create(Evas_Object *parent, attr_value *attr, double slider_val, Evas_Smart_Cb ctxpopup_dismiss_cb, Evas_Smart_Cb ctxpopup_selected_cb, void *data);
|
||||
Evas_Object * ctxpopup_img_preview_create(Evas_Object *parent, const char *imgpath, Evas_Smart_Cb ctxpopup_dismiss_cb, Evas_Smart_Cb ctxpopup_selected_cb, void *data);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue