edj_viewer: add parts outline highlight feature

Summary:
When we add a live edit item, it is convenient to be support part outline.
so I added part outline feature. It can be toggling.

@T3626

Test Plan:
1. launch enventor
2. activate parts outline item on tools
3. see the parts outline in live edit view

Reviewers: Hermet, NikaWhite, bowonryu, Jaehyun_Cho

Reviewed By: Jaehyun_Cho

Differential Revision: https://phab.enlightenment.org/D4071
This commit is contained in:
Taehyub Kim 2016-06-28 14:20:57 +09:00 committed by Jaehyun Cho
parent dafc19ce3f
commit 4100cc9131
16 changed files with 391 additions and 2 deletions

View File

@ -2,6 +2,7 @@ images {
image: "part_highlight.png" COMP;
image: "swallow.png" COMP;
image: "live_spacer.png" COMP;
image: "outline.png" COMP;
}
group { "swallow";
@ -61,6 +62,19 @@ group { name: "part_highlight";
}
}
group { "outline";
parts {
image { name: "img";
repeat_events: 1;
desc {
image.normal: "outline.png";
image.border: 3 3 2 4;
fill.smooth: 0;
}
}
}
}
group { "ctrl_pt";
parts {
rect { "clipper";

View File

@ -45,6 +45,7 @@ images {
image: "brows_sound.png" COMP;
image: "brows_font.png" COMP;
image: "template.png" COMP;
image: "part_outline.png" COMP;
}
#define ICON_GROUP(_group_name, _image_path) \
@ -103,5 +104,6 @@ ICON_GROUP("brows_image", "brows_image.png")
ICON_GROUP("brows_sound", "brows_sound.png")
ICON_GROUP("brows_font", "brows_font.png")
ICON_GROUP("template", "template.png")
ICON_GROUP("part_outline", "part_outline.png")
#undef ICON_GROUP

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -2613,7 +2613,7 @@ group { "live_view_tools_layout";
align: 0.0 0.5;
}
}
swallow { "elm.swallow.mirror";
swallow { "elm.swallow.outline";
scale: 1;
desc { "default";
rel1 {
@ -2625,6 +2625,31 @@ group { "live_view_tools_layout";
align: 0.0 0.5;
}
}
spacer { "padding_outline";
scale: 1;
desc { "default";
rel1 {
to_x: "elm.swallow.outline";
relative: 1.0 0.0;
}
rel2.to_x: "elm.swallow.outline";
min: 8 0;
fixed: 1 0;
align: 0.0 0.5;
}
}
swallow { "elm.swallow.mirror";
scale: 1;
desc { "default";
rel1 {
to_x: "padding_outline";
relative: 1.0 0.0;
}
rel2.to_x: "padding_outline";
fixed: 1 0;
align: 0.0 0.5;
}
}
spacer { "padding4";
scale: 1;
desc { "default";

View File

@ -34,6 +34,7 @@ typedef struct config_s
Eina_Bool linenumber;
Eina_Bool part_highlight;
Eina_Bool dummy_parts;
Eina_Bool outline;
Eina_Bool mirror_mode;
Eina_Bool auto_indent;
Eina_Bool tools;
@ -185,6 +186,7 @@ config_load(void)
cd->linenumber = EINA_TRUE;
cd->part_highlight = EINA_TRUE;
cd->dummy_parts = EINA_TRUE;
cd->outline = EINA_FALSE;
cd->mirror_mode = EINA_FALSE;
cd->auto_indent = EINA_TRUE;
cd->tools = EINA_TRUE;
@ -303,6 +305,8 @@ eddc_init(void)
part_highlight, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_base, config_data, "dummy_parts",
dummy_parts, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_base, config_data, "outline",
outline, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_base, config_data, "mirror_mode",
mirror_mode, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_base, config_data, "auto_indent",
@ -736,6 +740,20 @@ config_dummy_parts_set(Eina_Bool dummy_parts)
cd->dummy_parts = dummy_parts;
}
Eina_Bool
config_parts_outline_get(void)
{
config_data *cd = g_cd;
return cd->outline;
}
void
config_parts_outline_set(Eina_Bool outline)
{
config_data *cd = g_cd;
cd->outline = outline;
}
Eina_Bool
config_mirror_mode_get(void)
{

View File

@ -42,6 +42,7 @@ tools_update(void)
tools_lines_update(EINA_FALSE);
tools_highlight_update(EINA_FALSE);
tools_dummy_update(EINA_FALSE);
tools_outline_update(EINA_FALSE);
tools_mirror_mode_update(EINA_FALSE);
tools_status_update(EINA_FALSE);
tools_file_browser_update(EINA_FALSE);
@ -680,6 +681,12 @@ ctrl_func(Evas_Event_Key_Down *event)
tools_dummy_update(EINA_TRUE);
return EINA_TRUE;
}
//Parts Outline
if (!strcmp(event->key, "p") || !strcmp(event->key, "P"))
{
tools_outline_update(EINA_TRUE);
return EINA_TRUE;
}
//Mirror Mode
if (!strcmp(event->key, "m") || !strcmp(event->key, "M"))
{
@ -889,6 +896,8 @@ keygrabber_init(app_data *ad)
GRAB_ADD("I", modifier);
GRAB_ADD("o", modifier);
GRAB_ADD("O", modifier);
GRAB_ADD("p", modifier);
GRAB_ADD("P", modifier);
GRAB_ADD("e", modifier);
GRAB_ADD("E", modifier);
GRAB_ADD("space", modifier);

View File

@ -7,6 +7,7 @@
typedef struct tools_s
{
Evas_Object *swallow_btn;
Evas_Object *outline_btn;
Evas_Object *status_btn;
Evas_Object *file_browser_btn;
Evas_Object *edc_navigator_btn;
@ -49,6 +50,13 @@ dummy_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
tools_dummy_update(EINA_TRUE);
}
static void
part_outline_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
tools_outline_update(EINA_TRUE);
}
static void
mirror_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@ -219,6 +227,16 @@ tools_init(Evas_Object *parent)
elm_object_part_content_set(live_view_ly, "elm.swallow.dummy", btn);
td->swallow_btn = btn;
btn = tools_btn_create(live_view_ly, "part_outline",
_("Parts Outline (Ctrl + P)<br>"
"Display parts outline"),
part_outline_cb);
elm_object_tooltip_orient_set(btn, ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT);
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_part_content_set(live_view_ly, "elm.swallow.outline", btn);
td->outline_btn = btn;
btn = tools_btn_create(live_view_ly, "mirror",
_("Mirror mode (Ctrl + M)<br>"
"Invert the layout horizontally and review<br>"
@ -507,6 +525,30 @@ tools_dummy_update(Eina_Bool toggle)
elm_object_signal_emit(td->swallow_btn, "icon,highlight,disabled", "");
}
void
tools_outline_update(Eina_Bool toggle)
{
tools_data *td = g_td;
if (!td) return;
if (toggle) config_parts_outline_set(!config_parts_outline_get());
enventor_object_parts_outline_set(base_enventor_get(),
config_parts_outline_get());
if (toggle)
{
if (config_parts_outline_get())
stats_info_msg_update(_("Parts Outline Enabled."));
else
stats_info_msg_update(_("Parts Outline Disabled."));
}
//Toggle on/off
if (config_parts_outline_get())
elm_object_signal_emit(td->outline_btn, "icon,highlight,enabled", "");
else
elm_object_signal_emit(td->outline_btn, "icon,highlight,disabled", "");
}
void
tools_mirror_mode_update(Eina_Bool toggle)
{

View File

@ -35,6 +35,8 @@ Eina_Bool config_part_highlight_get(void);
void config_part_highlight_set(Eina_Bool highlight);
Eina_Bool config_dummy_parts_get(void);
void config_dummy_parts_set(Eina_Bool dummy_parts);
Eina_Bool config_parts_outline_get(void);
void config_parts_outline_set(Eina_Bool outline);
void config_auto_indent_set(Eina_Bool auto_indent);
Eina_Bool config_auto_indent_get(void);
void config_auto_complete_set(Eina_Bool auto_complete);

View File

@ -3,6 +3,7 @@ void tools_term(void);
void tools_highlight_update(Eina_Bool toggle);
void tools_lines_update(Eina_Bool toggle);
void tools_dummy_update(Eina_Bool toggle);
void tools_outline_update(Eina_Bool toggle);
void tools_mirror_mode_update(Eina_Bool toggle);
void tools_status_update(Eina_Bool toggle);
void tools_file_browser_update(Eina_Bool toggle);

View File

@ -43,7 +43,8 @@ libenventor_la_SOURCES = \
template.c \
edj_mgr.c \
edj_viewer.c \
dummy_obj.c
dummy_obj.c \
outline_obj.c
libenventor_la_CFLAGS = @ENVENTOR_CFLAGS@
libenventor_la_LIBADD = @ENVENTOR_LIBS@

View File

@ -169,6 +169,9 @@ view_obj_create_post_job(view_data *vd)
if (enventor_obj_dummy_parts_get(vd->enventor))
dummy_obj_new(vd->layout);
if (enventor_obj_parts_outline_get(vd->enventor))
outline_obj_new(vd->layout);
view_mirror_mode_update(vd);
if (vd->changed_part.part)
@ -369,6 +372,7 @@ update_edj_file_internal(view_data *vd)
view_obj_min_update(vd);
view_part_highlight_set(vd, vd->part_name);
dummy_obj_update(vd->layout);
outline_obj_update(vd->layout);
view_mirror_mode_update(vd);
if (vd->changed_part.part)
edje_edit_part_selected_state_set(vd->layout, vd->changed_part.part,
@ -420,6 +424,7 @@ exe_del_event_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
if (!edje_object_file_set(vd->layout, build_edj_path_get(), vd->group_name))
{
dummy_obj_update(vd->layout);
outline_obj_update(vd->layout);
ecore_timer_del(vd->update_edj_timer);
vd->file_set_finished = EINA_FALSE;
vd->update_edj_timer = ecore_timer_add(0.25, update_edj_file, vd);
@ -590,6 +595,14 @@ view_dummy_set(view_data *vd, Eina_Bool dummy_parts)
else dummy_obj_del(vd->layout);
}
void
view_outline_set(view_data *vd, Eina_Bool outline)
{
if (!vd) return;
if (outline) outline_obj_new(vd->layout);
else outline_obj_del(vd->layout);
}
view_data *
view_init(Enventor_Object *enventor, const char *group,
void (*del_cb)(void *data), void *data)
@ -900,5 +913,6 @@ view_mirror_mode_update(view_data *vd)
edje_object_mirrored_set(vd->layout,
enventor_obj_mirror_mode_get(vd->enventor));
dummy_obj_update(vd->layout);
outline_obj_update(vd->layout);
part_obj_geom_cb(vd, evas_object_evas_get(vd->layout), vd->part_obj, NULL);
}

View File

@ -34,6 +34,15 @@ class Enventor.Object (Elm.Widget, Efl.File) {
dummy_parts: bool;
}
}
@property parts_outline {
set {
}
get {
}
values {
outline: bool;
}
}
@property mirror_mode {
set {
}

View File

@ -161,6 +161,10 @@ void dummy_obj_new(Evas_Object *layout);
void dummy_obj_del(Evas_Object *layout);
void dummy_obj_update(Evas_Object *layout);
/* outline_obj */
void outline_obj_new(Evas_Object *layout);
void outline_obj_del(Evas_Object *layout);
void outline_obj_update(Evas_Object *layout);
/* edj_mgr */
void edj_mgr_init(Enventor_Object *enventor);

View File

@ -48,6 +48,7 @@ struct _Enventor_Object_Data
Eina_Stringshare *font_style;
Eina_Bool dummy_parts : 1;
Eina_Bool outline : 1;
Eina_Bool disabled : 1;
Eina_Bool mirror_mode : 1;
Eina_Bool linenumber : 1;
@ -593,6 +594,25 @@ _enventor_object_dummy_parts_get(Eo *obj EINA_UNUSED,
return pd->dummy_parts;
}
EOLIAN static void
_enventor_object_parts_outline_set(Eo *obj EINA_UNUSED,
Enventor_Object_Data *pd,
Eina_Bool outline)
{
outline = !!outline;
view_outline_set(VIEW_DATA, outline);
pd->outline = outline;
}
EOLIAN static Eina_Bool
_enventor_object_parts_outline_get(Eo *obj EINA_UNUSED,
Enventor_Object_Data *pd)
{
return pd->outline;
}
EOLIAN static void
_enventor_object_part_highlight_set(Eo *obj EINA_UNUSED,
Enventor_Object_Data *pd,

228
src/lib/outline_obj.c Normal file
View File

@ -0,0 +1,228 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT 1
#include <Enventor.h>
#include <Edje_Edit.h>
#include "enventor_private.h"
typedef struct part_obj_s
{
Evas_Object *obj;
Eina_Stringshare *name;
} part_obj;
typedef struct outline_obj_s
{
Evas_Object *layout;
Eina_List *part_list;
Ecore_Animator *animator;
} outline_obj;
const char *OUTLINEOBJ = "outline_obj";
const char *OUTLINE_EDIT_LAYOUT_KEY = "edit_layout";
/*****************************************************************************/
/* Internal method implementation */
/*****************************************************************************/
static void
edje_part_clicked(void *data, Evas *e EINA_UNUSED,
Evas_Object *obj, void *ei EINA_UNUSED)
{
part_obj *po = (part_obj *)data;
Evas_Object *layout = evas_object_data_get(obj, OUTLINE_EDIT_LAYOUT_KEY);
}
static void
outline_objs_update(outline_obj *outline)
{
Eina_List *parts = edje_edit_parts_list_get(outline->layout);
Eina_List *l, *l_next, *l2;
char *part_name;
Edje_Part_Type type = EDJE_PART_TYPE_NONE;
part_obj *po;
Evas *evas = evas_object_evas_get(outline->layout);
Eina_Bool removed;
//Remove the outline objects that parts are removed.
EINA_LIST_FOREACH_SAFE(outline->part_list, l, l_next, po)
{
removed = EINA_TRUE;
EINA_LIST_FOREACH(parts, l2, part_name)
{
if (!part_name || !po->name[0]) continue;
if (po->name[0] != part_name[0]) continue;
if ((strlen(po->name) != strlen(part_name))) continue;
if (!strcmp(po->name, part_name))
{
type = edje_edit_part_type_get(outline->layout, part_name);
removed = EINA_FALSE;
break;
}
}
if (removed)
{
evas_object_del(po->obj);
eina_stringshare_del(po->name);
outline->part_list = eina_list_remove_list(outline->part_list, l);
free(po);
}
}
//Add new part object or Update changed part.
EINA_LIST_FOREACH(parts, l, part_name)
{
type = edje_edit_part_type_get(outline->layout, part_name);
Eina_List *part_l;
Evas_Object *pobj = NULL;
int part_x = 0, part_y = 0, part_w = 0, part_h = 0, part_lx = 0, part_ly = 0;
EINA_LIST_FOREACH(outline->part_list, part_l, po)
{
if (po->name == part_name)
{
pobj = po->obj;
break;
}
}
if (!pobj)
{
Evas_Object *scroller = view_obj_get(VIEW_DATA);
Evas_Object *scroller_edje = elm_layout_edje_get(scroller);
Evas_Object *clipper =
(Evas_Object *)edje_object_part_object_get(scroller_edje,
"clipper");
pobj = elm_layout_add(scroller);
elm_layout_file_set(pobj, EDJE_PATH, "outline");
evas_object_smart_member_add(pobj, scroller);
po = malloc(sizeof(part_obj));
po->obj = pobj;
po->name = eina_stringshare_add(part_name);
outline->part_list = eina_list_append(outline->part_list, po);
evas_object_show(pobj);
evas_object_clip_set(pobj, clipper);
evas_object_data_set(pobj, OUTLINE_EDIT_LAYOUT_KEY,
outline->layout);
evas_object_event_callback_add(pobj, EVAS_CALLBACK_MOUSE_DOWN,
edje_part_clicked, po);
}
evas_object_geometry_get(outline->layout, &part_lx, &part_ly,
NULL, NULL);
edje_object_part_geometry_get(outline->layout, part_name,
&part_x, &part_y, &part_w, &part_h);
evas_object_resize(pobj, part_w, part_h);
evas_object_move(pobj, part_lx + part_x, part_ly + part_y);
}
edje_edit_string_list_free(parts);
}
static void
layout_geom_changed_cb(void *data, Evas *evas EINA_UNUSED,
Evas_Object *obj, void *ei EINA_UNUSED)
{
outline_obj *outline = (outline_obj *)data;
Eina_List *spacer_l;
part_obj *po;
int x = 0, y = 0, w = 0, h = 0, lx = 0, ly = 0;
evas_object_geometry_get(obj, &lx, &ly, NULL, NULL);
EINA_LIST_FOREACH(outline->part_list, spacer_l, po)
if (edje_object_part_exists(obj, po->name))
{
edje_object_part_geometry_get(obj, po->name, &x, &y, &w, &h);
evas_object_resize(po->obj, w, h);
evas_object_move(po->obj, lx + x, ly + y);
}
}
static Eina_Bool
animator_cb(void *data)
{
outline_obj *outline = data;
outline_objs_update(outline);
outline->animator = NULL;
return ECORE_CALLBACK_CANCEL;
}
static void
layout_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
outline_obj_del(obj);
}
/*****************************************************************************/
/* Externally accessible calls */
/*****************************************************************************/
void
outline_obj_update(Evas_Object *layout)
{
outline_obj *outline = evas_object_data_get(layout, OUTLINEOBJ);
if (!outline) return;
outline_objs_update(outline);
}
void
outline_obj_new(Evas_Object *layout)
{
if (!layout) return;
outline_obj *outline = evas_object_data_get(layout, OUTLINEOBJ);
if (outline) return;
outline = calloc(1, sizeof(outline_obj));
if (!outline)
{
EINA_LOG_ERR("Failed to allocate Memory!");
return;
}
Ecore_Animator *animator = ecore_animator_add(animator_cb, outline);
evas_object_data_set(layout, OUTLINEOBJ, outline);
evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, layout_del_cb,
outline);
evas_object_event_callback_add(layout, EVAS_CALLBACK_RESIZE,
layout_geom_changed_cb, outline);
evas_object_event_callback_add(layout, EVAS_CALLBACK_MOVE,
layout_geom_changed_cb, outline);
outline->layout = layout;
outline->animator = animator;
}
void
outline_obj_del(Evas_Object *layout)
{
outline_obj *outline = evas_object_data_get(layout, OUTLINEOBJ);
if (!outline) return;
evas_object_event_callback_del_full(layout, EVAS_CALLBACK_RESIZE,
layout_geom_changed_cb, outline);
evas_object_event_callback_del_full(layout, EVAS_CALLBACK_MOVE,
layout_geom_changed_cb, outline);
part_obj *po;
EINA_LIST_FREE(outline->part_list, po)
{
evas_object_del(po->obj);
eina_stringshare_del(po->name);
free(po);
}
ecore_animator_del(outline->animator);
free(outline);
evas_object_data_set(layout, OUTLINEOBJ, NULL);
evas_object_event_callback_del(layout, EVAS_CALLBACK_DEL, layout_del_cb);
}