Enventor: Prototipe of Drag-n-Drop feature. Patch 1.
Summary: This commit contains the basic implementation of Live Edit mode. With this commit Live Edit toggling is added to Menu, Tools and Ctrl-M hot-key. Activating of Live Edit mode disables the EDC-Editor and allows user to add new parts by selecting corresponding part type in the menu that appears on right click on the EDJ-Viewer area. Reviewers: Hermet Projects: #enventor Differential Revision: https://phab.enlightenment.org/D1276
|
@ -10,6 +10,13 @@ images {
|
|||
image: "status.png" COMP;
|
||||
image: "swallow_s.png" COMP;
|
||||
image: "goto.png" COMP;
|
||||
image: "live_edit_icons/icon-image.png" COMP;
|
||||
image: "live_edit_icons/icon-rectangle.png" COMP;
|
||||
image: "live_edit_icons/icon-swallow.png" COMP;
|
||||
image: "live_edit_icons/icon-spacer.png" COMP;
|
||||
image: "live_edit_icons/icon-text.png" COMP;
|
||||
image: "live_edit_icons/icon-textblock.png" COMP;
|
||||
image: "live_edit_icons/icon-live-edit.png" COMP;
|
||||
}
|
||||
|
||||
group { name: "line";
|
||||
|
@ -131,3 +138,36 @@ group { name: "minus";
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
group { name: "live-edit";
|
||||
parts {
|
||||
part { name: "img";
|
||||
type: IMAGE;
|
||||
description { state: "default" 0.0;
|
||||
image.normal: "live_edit_icons/icon-live-edit.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define ADD_LIVE_EDIT_ICON_GROUP(_group_name, _image_path) \
|
||||
group { name: _group_name; \
|
||||
parts { \
|
||||
part { name: "img"; \
|
||||
description { state: "default" 0.0; \
|
||||
image.normal: _image_path; \
|
||||
min: 10 10; \
|
||||
max: 10 10; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
ADD_LIVE_EDIT_ICON_GROUP("IMAGE", "live_edit_icons/icon-image.png")
|
||||
ADD_LIVE_EDIT_ICON_GROUP("RECT", "live_edit_icons/icon-rectangle.png")
|
||||
ADD_LIVE_EDIT_ICON_GROUP("SPACER", "live_edit_icons/icon-spacer.png")
|
||||
ADD_LIVE_EDIT_ICON_GROUP("SWALLOW", "live_edit_icons/icon-swallow.png")
|
||||
ADD_LIVE_EDIT_ICON_GROUP("TEXT", "live_edit_icons/icon-text.png")
|
||||
ADD_LIVE_EDIT_ICON_GROUP("TEXTBLOCK", "live_edit_icons/icon-textblock.png")
|
||||
|
||||
#undef ADD_LIVE_EDIT_ICON_GROUP
|
||||
|
|
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 299 B |
After Width: | Height: | Size: 323 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 208 B |
After Width: | Height: | Size: 182 B |
After Width: | Height: | Size: 286 B |
|
@ -6,6 +6,7 @@ images {
|
|||
image: "logo.png" COMP;
|
||||
image: "shine.png" COMP;
|
||||
image: "bub_over_bot.png" COMP;
|
||||
image: "disabler.png" COMP;
|
||||
}
|
||||
|
||||
group { name: "about_layout";
|
||||
|
@ -2132,6 +2133,28 @@ group { name: "edit_layout";
|
|||
fixed: 0 1;
|
||||
}
|
||||
}
|
||||
part { name: "disabler_bg";
|
||||
type: RECT;
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
color: 0 0 0 0;
|
||||
}
|
||||
description { state: "disabled" 0.0;
|
||||
color: 0 0 0 160;
|
||||
}
|
||||
}
|
||||
part { name: "disabler_decorations";
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
image.normal: "disabler.png";
|
||||
fill.type: TILE;
|
||||
color: 155 155 155 0;
|
||||
}
|
||||
description { state: "disabled" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
color: 55 55 77 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program { name: "linenumber_show";
|
||||
|
@ -2147,4 +2170,22 @@ group { name: "edit_layout";
|
|||
transition: DECELERATE 0.35;
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program { name: "layout_disable";
|
||||
signal: "elm,state,disabled";
|
||||
source: "editor";
|
||||
action: STATE_SET "disabled" 0.0;
|
||||
target: "disabler_bg";
|
||||
target: "disabler_decorations";
|
||||
transition: DECELERATE 0.35;
|
||||
}
|
||||
program { name: "layout_enable";
|
||||
signal: "elm,state,enabled";
|
||||
source: "editor";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "disabler_bg";
|
||||
target: "disabler_decorations";
|
||||
transition: DECELERATE 0.35;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ enventor_SOURCES = \
|
|||
setting.c \
|
||||
globals.c \
|
||||
redoundo.c \
|
||||
template.c
|
||||
template.c \
|
||||
live_edit.c
|
||||
|
||||
enventor_LDADD = @ENVENTOR_LIBS@
|
||||
enventor_LDFLAGS = $(LTLIBINTL)
|
||||
|
|
|
@ -30,6 +30,7 @@ typedef struct config_s
|
|||
Eina_Bool tools;
|
||||
Eina_Bool auto_complete;
|
||||
Eina_Bool console;
|
||||
Eina_Bool live_edit;
|
||||
} config_data;
|
||||
|
||||
static config_data *g_cd = NULL;
|
||||
|
@ -138,6 +139,7 @@ config_load(void)
|
|||
cd->tools = EINA_FALSE;
|
||||
cd->auto_complete = EINA_TRUE;
|
||||
cd->console = EINA_FALSE;
|
||||
cd->live_edit = EINA_FALSE;
|
||||
}
|
||||
|
||||
g_cd = cd;
|
||||
|
@ -613,6 +615,21 @@ config_font_size_get(void)
|
|||
return cd->font_size;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
config_live_edit_get(void)
|
||||
{
|
||||
config_data *cd = g_cd;
|
||||
return cd->live_edit;
|
||||
}
|
||||
|
||||
void
|
||||
config_live_edit_set(Eina_Bool enabled)
|
||||
{
|
||||
config_data *cd = g_cd;
|
||||
cd->live_edit = enabled;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
config_auto_complete_set(Eina_Bool auto_complete)
|
||||
{
|
||||
|
|
|
@ -1187,3 +1187,15 @@ edit_redoundo_region_push(edit_data *ed, int cursor_pos1, int cursor_pos2)
|
|||
redoundo_entry_region_push(ed->rd, cursor_pos1, cursor_pos2);
|
||||
}
|
||||
|
||||
void
|
||||
edit_disabled_set(edit_data *ed, Eina_Bool disable)
|
||||
{
|
||||
elm_object_disabled_set(ed->layout, disable);
|
||||
elm_object_focus_allow_set(ed->layout, disable);
|
||||
evas_object_freeze_events_set (ed->layout, disable);
|
||||
|
||||
if (disable)
|
||||
elm_object_signal_emit(ed->layout, "elm,state,disabled", "editor");
|
||||
else
|
||||
elm_object_signal_emit(ed->layout, "elm,state,enabled", "editor");
|
||||
}
|
||||
|
|
|
@ -921,3 +921,108 @@ parser_term(parser_data *pd)
|
|||
|
||||
free(pd);
|
||||
}
|
||||
|
||||
static const char *
|
||||
end_of_parts_block_find(const char *pos)
|
||||
{
|
||||
//TODO: Process comments and quotes.
|
||||
pos = strstr(pos, "parts");
|
||||
if (!pos) return NULL;
|
||||
pos = strstr(pos, "{");
|
||||
if (!pos) return NULL;
|
||||
pos++;
|
||||
char level = 1;
|
||||
|
||||
while (*pos)
|
||||
{
|
||||
if (*pos == '{') level++;
|
||||
else if (*pos == '}')
|
||||
{
|
||||
level--;
|
||||
}
|
||||
if (!level) return --pos;
|
||||
pos++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
group_beginning_pos_get(const char* source, const char *group_name)
|
||||
{
|
||||
const char* group_block_name = "group";
|
||||
const int quot_len = QUOT_LEN;
|
||||
const char *quot = QUOT;
|
||||
|
||||
const char *pos = strstr(source, group_block_name);
|
||||
//TODO: Process comments and quotes.
|
||||
while (pos)
|
||||
{
|
||||
const char *name = strstr(pos, quot);
|
||||
if (!name) return NULL;
|
||||
pos = strstr(++name, quot);
|
||||
if (!pos) return NULL;
|
||||
if (!strncmp(name, group_name, strlen(group_name)))
|
||||
return pos;
|
||||
pos = strstr(++pos, group_block_name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Evas_Coord
|
||||
parser_end_of_parts_block_pos_get(const Evas_Object *entry, const char *group_name)
|
||||
{
|
||||
if (!group_name)
|
||||
return -1;
|
||||
|
||||
const char *text = elm_entry_entry_get(entry);
|
||||
if (!text) return -1;
|
||||
|
||||
char *utf8 = elm_entry_markup_to_utf8(text);
|
||||
if (!utf8) return -1;
|
||||
|
||||
const char *pos = group_beginning_pos_get(utf8, group_name);
|
||||
if (!pos) return -1;
|
||||
pos = end_of_parts_block_find(++pos);
|
||||
if (pos) return pos - utf8 + 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
parser_images_pos_get(const Evas_Object *entry, Evas_Coord *res_position)
|
||||
{
|
||||
if (!res_position) return EINA_FALSE;
|
||||
|
||||
const char* group_block_name = "group";
|
||||
const char* images_block_name = "images";
|
||||
Evas_Coord images_block_name_len = 6; //strlen of "images"
|
||||
|
||||
*res_position = -1;
|
||||
const char *text = elm_entry_entry_get(entry);
|
||||
if (!text) return EINA_FALSE;
|
||||
|
||||
char *utf8 = elm_entry_markup_to_utf8(text);
|
||||
if (!utf8) return EINA_FALSE;
|
||||
|
||||
const char *pos = strstr(utf8, images_block_name);
|
||||
if (pos)
|
||||
{
|
||||
// TODO: Remove this check and process lines of the form "images.image: "logo.png" COMP;"
|
||||
if (*(pos + images_block_name_len + 1) == '.')
|
||||
return EINA_FALSE;
|
||||
|
||||
pos = strstr(pos, "{\n");
|
||||
if (!pos) return EINA_FALSE;
|
||||
|
||||
*res_position = pos - utf8 + 2;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
pos = strstr(utf8, group_block_name);
|
||||
if (pos)
|
||||
{
|
||||
*res_position = pos - utf8;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,6 +318,12 @@ view_obj_get(view_data *vd)
|
|||
return vd->scroller;
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
view_layout_get(view_data *vd)
|
||||
{
|
||||
return vd->layout;
|
||||
}
|
||||
|
||||
void
|
||||
view_program_run(view_data *vd, const char *program)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
#include <Elementary.h>
|
||||
#include "common.h"
|
||||
|
||||
struct live_editor_s
|
||||
{
|
||||
Evas_Object *menu;
|
||||
edit_data *ed;
|
||||
};
|
||||
|
||||
#define LIVE_EDIT_ITEMS_NUM 6
|
||||
static const char *LIVE_EDIT_MENU_LABELS[LIVE_EDIT_ITEMS_NUM] =
|
||||
{
|
||||
"RECT",
|
||||
"IMAGE",
|
||||
"SPACER",
|
||||
"SWALLOW",
|
||||
"TEXT",
|
||||
"TEXTBLOCK"
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
live_edit_part_insert(live_edit_data *led, unsigned int part_type,
|
||||
Eina_Stringshare *group_name)
|
||||
{
|
||||
Edje_Part_Type type;
|
||||
switch (part_type)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
type = EDJE_PART_TYPE_RECTANGLE;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
type = EDJE_PART_TYPE_IMAGE;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
type = EDJE_PART_TYPE_SPACER;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
type = EDJE_PART_TYPE_SWALLOW;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
type = EDJE_PART_TYPE_TEXT;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
type = EDJE_PART_TYPE_TEXTBLOCK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
template_live_edit_part_insert(led->ed, type, group_name);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
live_edit_data*
|
||||
live_edit_init(edit_data *ed)
|
||||
{
|
||||
live_edit_data *led = calloc(1, sizeof(live_edit_data));
|
||||
if (!led)
|
||||
{
|
||||
EINA_LOG_ERR("Failed to allocate Memory!");
|
||||
return NULL;
|
||||
}
|
||||
led->ed = ed;
|
||||
|
||||
return led;
|
||||
}
|
||||
|
||||
static void
|
||||
live_edit_menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
live_edit_data *led = data;
|
||||
const Elm_Object_Item *it = event_info;
|
||||
unsigned int part_type = elm_menu_item_index_get(it);
|
||||
live_edit_part_insert(led, part_type, view_group_name_get(VIEW_DATA));
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
live_edit_menu_create(Evas_Object *parent, live_edit_data *led)
|
||||
{
|
||||
long int i;
|
||||
Evas_Object* icon;
|
||||
Elm_Object_Item *it;
|
||||
|
||||
Evas_Object *menu = elm_menu_add(parent);
|
||||
|
||||
for (i = 0; i < LIVE_EDIT_ITEMS_NUM; i++)
|
||||
{
|
||||
it = elm_menu_item_add(menu, NULL, NULL,
|
||||
LIVE_EDIT_MENU_LABELS[i],
|
||||
live_edit_menu_item_selected_cb, led);
|
||||
icon = elm_image_add(menu);
|
||||
elm_image_file_set(icon, EDJE_PATH, LIVE_EDIT_MENU_LABELS[i]);
|
||||
elm_object_item_part_content_set(it, NULL, icon);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
live_edit_menu_show_cb(void *data, Evas *e EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Up *ev = event_info;
|
||||
live_edit_data *led = data;
|
||||
|
||||
// Check if the right button is pressed
|
||||
if (ev->button != 3) return;
|
||||
|
||||
if (!led->menu)
|
||||
led->menu = live_edit_menu_create(obj, led);
|
||||
|
||||
elm_menu_move(led->menu, ev->canvas.x, ev->canvas.y);
|
||||
evas_object_show(led->menu);
|
||||
}
|
||||
|
||||
void
|
||||
live_edit_toggle(live_edit_data* led, Eina_Bool is_on)
|
||||
{
|
||||
if (VIEW_DATA)
|
||||
{
|
||||
Evas_Object *view_layout = view_layout_get(VIEW_DATA);
|
||||
|
||||
if (is_on)
|
||||
evas_object_event_callback_add(view_layout, EVAS_CALLBACK_MOUSE_UP,
|
||||
live_edit_menu_show_cb, led);
|
||||
else
|
||||
evas_object_event_callback_del(view_layout, EVAS_CALLBACK_MOUSE_UP,
|
||||
live_edit_menu_show_cb);
|
||||
}
|
||||
|
||||
edit_disabled_set(led->ed, is_on);
|
||||
if (is_on)
|
||||
stats_info_msg_update("Enabled Live View Edit Mode");
|
||||
else
|
||||
stats_info_msg_update("Disabled Live View Edit Mode");
|
||||
}
|
||||
|
||||
void
|
||||
live_edit_term(live_edit_data* led)
|
||||
{
|
||||
if (led->menu)
|
||||
evas_object_del(led->menu);
|
||||
free(led);
|
||||
}
|
||||
|
||||
#undef LIVE_EDIT_ITEMS_NUM
|
|
@ -6,6 +6,7 @@
|
|||
typedef struct app_s
|
||||
{
|
||||
edit_data *ed;
|
||||
live_edit_data *led;
|
||||
|
||||
Eio_Monitor *edc_monitor;
|
||||
|
||||
|
@ -189,6 +190,14 @@ ctrl_func(app_data *ad, const char *key)
|
|||
autocomp_toggle();
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
//Live Edit
|
||||
if (!strcmp(key, "m") || !strcmp(key, "M"))
|
||||
{
|
||||
Eina_Bool is_on = !config_live_edit_get();
|
||||
config_live_edit_set(is_on);
|
||||
live_edit_toggle(ad->led, is_on);
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
@ -383,6 +392,14 @@ edc_edit_set(app_data *ad)
|
|||
ad->ed = ed;
|
||||
}
|
||||
|
||||
static void
|
||||
live_edit_set(app_data *ad)
|
||||
{
|
||||
ad->led = live_edit_init(ad->ed);
|
||||
Eina_Bool is_on = config_live_edit_get();
|
||||
live_edit_toggle(ad->led, is_on);
|
||||
}
|
||||
|
||||
static void
|
||||
statusbar_set()
|
||||
{
|
||||
|
@ -405,6 +422,7 @@ config_update_cb(void *data)
|
|||
base_statusbar_toggle(EINA_FALSE);
|
||||
edit_part_highlight_toggle(ad->ed, EINA_FALSE);
|
||||
view_dummy_toggle(VIEW_DATA, EINA_FALSE);
|
||||
live_edit_toggle(ad->led, config_live_edit_get());
|
||||
|
||||
//previous build was failed, Need to rebuild then reload the edj.
|
||||
if (edj_mgr_reload_need_get())
|
||||
|
@ -527,9 +545,9 @@ edj_mgr_set()
|
|||
}
|
||||
|
||||
static void
|
||||
tools_set(edit_data *ed)
|
||||
tools_set(edit_data *ed, live_edit_data *led)
|
||||
{
|
||||
Evas_Object *tools = tools_create(base_layout_get(), ed);
|
||||
Evas_Object *tools = tools_create(base_layout_get(), ed, led);
|
||||
base_tools_set(tools);
|
||||
}
|
||||
|
||||
|
@ -554,9 +572,10 @@ init(app_data *ad, int argc, char **argv)
|
|||
edj_mgr_set();
|
||||
statusbar_set();
|
||||
edc_edit_set(ad);
|
||||
live_edit_set(ad);
|
||||
edc_view_set(stats_group_name_get());
|
||||
menu_init(ad->ed);
|
||||
tools_set(ad->ed);
|
||||
tools_set(ad->ed, ad->led);
|
||||
|
||||
base_gui_show();
|
||||
|
||||
|
@ -574,6 +593,7 @@ term(app_data *ad)
|
|||
build_term();
|
||||
menu_term();
|
||||
edit_term(ad->ed);
|
||||
live_edit_term(ad->led);
|
||||
edj_mgr_term();
|
||||
stats_term();
|
||||
base_gui_term();
|
||||
|
|
|
@ -19,6 +19,7 @@ struct setting_s
|
|||
Evas_Object *toggle_swallow;
|
||||
Evas_Object *toggle_indent;
|
||||
Evas_Object *toggle_autocomp;
|
||||
Evas_Object *toggle_live_edit;
|
||||
};
|
||||
|
||||
typedef struct setting_s setting_data;
|
||||
|
@ -115,6 +116,7 @@ setting_apply_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
config_dummy_swallow_set(elm_check_state_get(sd->toggle_swallow));
|
||||
config_auto_indent_set(elm_check_state_get(sd->toggle_indent));
|
||||
config_auto_complete_set(elm_check_state_get(sd->toggle_autocomp));
|
||||
config_live_edit_set(elm_check_state_get(sd->toggle_live_edit));
|
||||
|
||||
config_apply();
|
||||
|
||||
|
@ -154,6 +156,7 @@ setting_reset_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
elm_check_state_set(sd->toggle_swallow, config_dummy_swallow_get());
|
||||
elm_check_state_set(sd->toggle_indent, config_auto_indent_get());
|
||||
elm_check_state_set(sd->toggle_autocomp, config_auto_complete_get());
|
||||
elm_check_state_set(sd->toggle_live_edit, config_live_edit_get());
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
|
@ -349,8 +352,13 @@ setting_open(void)
|
|||
|
||||
//Toggle (Auto Complete)
|
||||
Evas_Object *toggle_autocomp = toggle_create(box, "Auto Completion",
|
||||
config_auto_complete_get());
|
||||
config_auto_complete_get());
|
||||
elm_box_pack_end(box, toggle_autocomp);
|
||||
|
||||
//Toggle (Live Edit)
|
||||
Evas_Object *toggle_live_edit = toggle_create(box, "Live Edit",
|
||||
config_live_edit_get());
|
||||
elm_box_pack_end(box, toggle_live_edit);
|
||||
|
||||
Evas_Object *btn;
|
||||
|
||||
|
@ -388,6 +396,7 @@ setting_open(void)
|
|||
sd->toggle_swallow = toggle_swallow;
|
||||
sd->toggle_indent = toggle_indent;
|
||||
sd->toggle_autocomp = toggle_autocomp;
|
||||
sd->toggle_live_edit = toggle_live_edit;
|
||||
|
||||
menu_activate_request();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
#include "common.h"
|
||||
#include "template_code.h"
|
||||
|
||||
typedef enum {
|
||||
TEMPLATE_PART_INSERT_DEFAULT,
|
||||
TEMPLATE_PART_INSERT_LIVE_EDIT
|
||||
} Template_Part_Insert_Type;
|
||||
|
||||
const char *NAME_SEED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
const int NAME_SEED_LEN = 52;
|
||||
|
||||
|
@ -9,11 +14,12 @@ static const char *
|
|||
template_part_first_line_get(void)
|
||||
{
|
||||
static char buf[40];
|
||||
char name[8];
|
||||
char name[9];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
name[i] = NAME_SEED[(rand() % NAME_SEED_LEN)];
|
||||
name[8] = '\0';
|
||||
|
||||
snprintf(buf, sizeof(buf), "part { name: \"%s\";<br/>", name);
|
||||
|
||||
|
@ -102,16 +108,73 @@ end:
|
|||
eina_stringshare_del(paragh);
|
||||
}
|
||||
|
||||
void
|
||||
template_part_insert(edit_data *ed, Edje_Part_Type type)
|
||||
static void
|
||||
image_description_add(edit_data *ed)
|
||||
{
|
||||
int cursor_pos;
|
||||
Evas_Object * edit_entry = edit_entry_get(ed);
|
||||
|
||||
Evas_Coord cursor_pos_to_restore = elm_entry_cursor_pos_get(edit_entry_get(ed));
|
||||
|
||||
Eina_Bool images_block = parser_images_pos_get(edit_entry, &cursor_pos);
|
||||
if (cursor_pos == -1) return;
|
||||
if (images_block)
|
||||
{
|
||||
elm_entry_cursor_pos_set(edit_entry, cursor_pos);
|
||||
template_insert(ed);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_entry_cursor_pos_set(edit_entry, cursor_pos);
|
||||
elm_entry_cursor_line_begin_set(edit_entry);
|
||||
int cursor_pos1 = elm_entry_cursor_pos_get(edit_entry);
|
||||
elm_entry_entry_insert(edit_entry, TEMPLATE_IMG_BLOCK);
|
||||
edit_line_increase(ed, TEMPLATE_IMG_BLOCK_LINE_CNT);
|
||||
int cursor_pos2 = elm_entry_cursor_pos_get(edit_entry);
|
||||
edit_redoundo_region_push(ed, cursor_pos1, cursor_pos2);
|
||||
}
|
||||
elm_entry_cursor_pos_set(edit_entry, cursor_pos_to_restore);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
template_part_insert_cursor_pos_set(edit_data *ed,
|
||||
Template_Part_Insert_Type insert_type,
|
||||
const Eina_Stringshare *group_name)
|
||||
{
|
||||
int cursor_pos = -1;
|
||||
Evas_Object *edit_entry = edit_entry_get(ed);
|
||||
if (insert_type == TEMPLATE_PART_INSERT_LIVE_EDIT)
|
||||
{
|
||||
cursor_pos = parser_end_of_parts_block_pos_get(edit_entry, group_name);
|
||||
if (cursor_pos != -1)
|
||||
elm_entry_cursor_pos_set(edit_entry, cursor_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor_pos = elm_entry_cursor_pos_get(edit_entry);
|
||||
}
|
||||
elm_entry_cursor_line_begin_set(edit_entry);
|
||||
return cursor_pos;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
internal_template_part_insert(edit_data *ed,
|
||||
Edje_Part_Type type,
|
||||
Template_Part_Insert_Type insert_type,
|
||||
const Eina_Stringshare *group_name)
|
||||
{
|
||||
if (type == EDJE_PART_TYPE_NONE) return;
|
||||
if ((type == EDJE_PART_TYPE_IMAGE) &&
|
||||
(insert_type == TEMPLATE_PART_INSERT_LIVE_EDIT))
|
||||
image_description_add(ed);
|
||||
|
||||
Evas_Object *entry = edit_entry_get(ed);
|
||||
|
||||
int cursor_pos = elm_entry_cursor_pos_get(entry);
|
||||
elm_entry_cursor_line_begin_set(entry);
|
||||
int cursor_pos1 = elm_entry_cursor_pos_get(entry);
|
||||
Evas_Object *edit_entry = edit_entry_get(ed);
|
||||
int cursor_pos = template_part_insert_cursor_pos_set(ed, insert_type,
|
||||
group_name);
|
||||
if (cursor_pos == -1) return;
|
||||
int cursor_pos1 = elm_entry_cursor_pos_get(edit_entry);
|
||||
int space = edit_cur_indent_depth_get(ed);
|
||||
|
||||
//Alloc Empty spaces
|
||||
|
@ -166,30 +229,46 @@ template_part_insert(edit_data *ed, Edje_Part_Type type)
|
|||
break;
|
||||
}
|
||||
|
||||
elm_entry_entry_insert(entry, p);
|
||||
elm_entry_entry_insert(edit_entry, p);
|
||||
const char *first_line = template_part_first_line_get();
|
||||
elm_entry_entry_insert(entry, first_line);
|
||||
elm_entry_entry_insert(edit_entry, first_line);
|
||||
edit_line_increase(ed, 1);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < (line_cnt - 1); i++)
|
||||
{
|
||||
elm_entry_entry_insert(entry, p);
|
||||
elm_entry_entry_insert(entry, t[i]);
|
||||
elm_entry_entry_insert(edit_entry, p);
|
||||
elm_entry_entry_insert(edit_entry, t[i]);
|
||||
//Incease line by (line count - 1)
|
||||
edit_line_increase(ed, 1);
|
||||
}
|
||||
|
||||
elm_entry_entry_insert(entry, p);
|
||||
elm_entry_entry_insert(entry, t[i]);
|
||||
elm_entry_entry_insert(edit_entry, t[i]);
|
||||
|
||||
int cursor_pos2 = elm_entry_cursor_pos_get(entry);
|
||||
int cursor_pos2 = elm_entry_cursor_pos_get(edit_entry);
|
||||
edit_redoundo_region_push(ed, cursor_pos1, cursor_pos2);
|
||||
|
||||
elm_entry_cursor_pos_set(entry, cursor_pos);
|
||||
elm_entry_cursor_pos_set(edit_entry, cursor_pos);
|
||||
|
||||
edit_syntax_color_partial_apply(ed, 0);
|
||||
snprintf(buf, sizeof(buf), "Template code inserted. (%s Part)", part);
|
||||
stats_info_msg_update(buf);
|
||||
edit_changed_set(ed, EINA_TRUE);
|
||||
edit_save(ed);
|
||||
}
|
||||
|
||||
void
|
||||
template_live_edit_part_insert(edit_data *ed,
|
||||
Edje_Part_Type type,
|
||||
const Eina_Stringshare *group_name)
|
||||
{
|
||||
internal_template_part_insert(ed, type, TEMPLATE_PART_INSERT_LIVE_EDIT,
|
||||
group_name);
|
||||
}
|
||||
|
||||
void
|
||||
template_part_insert(edit_data *ed,
|
||||
Edje_Part_Type type)
|
||||
{
|
||||
internal_template_part_insert(ed, type,
|
||||
TEMPLATE_PART_INSERT_DEFAULT, NULL);
|
||||
}
|
||||
|
|
|
@ -100,8 +100,18 @@ console_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
item_unselect((Elm_Object_Item *)event_info);
|
||||
}
|
||||
|
||||
static void
|
||||
live_edit_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
live_edit_data *led = data;
|
||||
Eina_Bool is_on = !config_live_edit_get();
|
||||
config_live_edit_set(is_on);
|
||||
live_edit_toggle(led, is_on);
|
||||
item_unselect((Elm_Object_Item *)event_info);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
tools_create(Evas_Object *parent, edit_data *ed)
|
||||
tools_create(Evas_Object *parent, edit_data *ed, live_edit_data *led)
|
||||
{
|
||||
Evas_Object *toolbar = elm_toolbar_add(parent);
|
||||
elm_object_style_set(toolbar, "item_horizontal");
|
||||
|
@ -136,6 +146,8 @@ tools_create(Evas_Object *parent, edit_data *ed)
|
|||
elm_toolbar_item_icon_file_set(it, EDJE_PATH, "status");
|
||||
it = elm_toolbar_item_append(toolbar, NULL, "Console", console_cb, NULL);
|
||||
elm_toolbar_item_icon_file_set(it, EDJE_PATH, "console");
|
||||
it = elm_toolbar_item_append(toolbar, NULL, "LiveEdit", live_edit_cb, led);
|
||||
elm_toolbar_item_icon_file_set(it, EDJE_PATH, "live-edit");
|
||||
|
||||
return toolbar;
|
||||
}
|
||||
|
|
|
@ -26,4 +26,5 @@ EXTRA_DIST = common.h \
|
|||
setting.h \
|
||||
search.h \
|
||||
redoundo.h \
|
||||
template.h
|
||||
template.h \
|
||||
live_edit.h
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
typedef struct viewer_s view_data;
|
||||
typedef struct statusbar_s stats_data;
|
||||
typedef struct editor_s edit_data;
|
||||
typedef struct live_editor_s live_edit_data;
|
||||
typedef struct syntax_color_s color_data;
|
||||
typedef struct parser_s parser_data;
|
||||
typedef struct attr_value_s attr_value;
|
||||
|
@ -34,5 +35,6 @@ typedef struct redoundo_s redoundo_data;
|
|||
#include "setting.h"
|
||||
#include "redoundo.h"
|
||||
#include "template.h"
|
||||
#include "live_edit.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,8 @@ 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);
|
||||
Eina_Bool config_auto_complete_get(void);
|
||||
Eina_Bool config_live_edit_get(void);
|
||||
void config_live_edit_set(Eina_Bool live_edit);
|
||||
void config_font_size_set(float font_size);
|
||||
float config_font_size_get(void);
|
||||
void config_view_scale_set(double view_scale);
|
||||
|
|
|
@ -12,8 +12,6 @@ void edit_new(edit_data* ed);
|
|||
void edit_view_sync_cb_set(edit_data *ed, void (*cb)(void *data, Eina_Stringshare *part_name, Eina_Stringshare *group_name), void *data);
|
||||
void edit_view_sync(edit_data *ed);
|
||||
void edit_font_size_update(edit_data *ed, Eina_Bool msg, Eina_Bool update);
|
||||
void edit_template_insert(edit_data *ed);
|
||||
void edit_template_part_insert(edit_data *ed, Edje_Part_Type type);
|
||||
void edit_part_highlight_toggle(edit_data *ed, Eina_Bool msg);
|
||||
void edit_line_delete(edit_data *ed);
|
||||
void edit_edc_reload(edit_data *ed, const char *edc_path);
|
||||
|
@ -29,3 +27,4 @@ void edit_line_increase(edit_data *ed, int cnt);
|
|||
void edit_line_decrease(edit_data *ed, int cnt);
|
||||
int edit_cur_indent_depth_get(edit_data *ed);
|
||||
void edit_redoundo_region_push(edit_data *ed, int cursor_pos1, int cursor_pos2);
|
||||
void edit_disabled_set(edit_data *ed, Eina_Bool disable);
|
||||
|
|
|
@ -19,4 +19,5 @@ char *parser_name_get(parser_data *pd, const char *cur);
|
|||
void parser_cancel(parser_data *pd);
|
||||
int parser_line_cnt_get(parser_data *pd EINA_UNUSED, const char *src);
|
||||
Eina_List *parser_states_filtered_name_get(Eina_List *states);
|
||||
|
||||
Evas_Coord parser_end_of_parts_block_pos_get(const Evas_Object *entry, const char *group_name);
|
||||
Eina_Bool parser_images_pos_get(const Evas_Object *entry, Evas_Coord *res_position);
|
||||
|
|
|
@ -2,6 +2,7 @@ view_data * view_init(Evas_Object *parent, const char *group,
|
|||
void (*del_cb)(void *data), void *data);
|
||||
void view_term(view_data *vd);
|
||||
Evas_Object *view_obj_get(view_data *vd);
|
||||
Evas_Object *view_layout_get(view_data *vd);
|
||||
void view_new(view_data *vd, const char *group);
|
||||
void view_part_highlight_set(view_data *vd, const char *part_name);
|
||||
void view_dummy_toggle(view_data *vd, Eina_Bool msg);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
live_edit_data* live_edit_init(edit_data *ed);
|
||||
void live_edit_toggle(live_edit_data* led, Eina_Bool is_on);
|
||||
void live_edit_term(live_edit_data* led);
|
|
@ -1,3 +1,3 @@
|
|||
void template_insert(edit_data *ed);
|
||||
void template_part_insert(edit_data *ed, Edje_Part_Type type);
|
||||
|
||||
void template_live_edit_part_insert(edit_data *ed, Edje_Part_Type type, const Eina_Stringshare *group_name);
|
||||
|
|
|
@ -9,8 +9,8 @@ const char *TEMPLATE_GROUP[TEMPLATE_GROUP_LINE_CNT] =
|
|||
" scale: 1;<br/>",
|
||||
" mouse_events: 1;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
|
@ -40,8 +40,8 @@ const char *TEMPLATE_PART_IMAGE[TEMPLATE_PART_IMAGE_LINE_CNT] =
|
|||
" scale: 1;<br/>",
|
||||
" mouse_events: 1;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
|
@ -49,7 +49,8 @@ const char *TEMPLATE_PART_IMAGE[TEMPLATE_PART_IMAGE_LINE_CNT] =
|
|||
" image.normal: \"logo.png\";<br/>",
|
||||
" //aspect: 1 1;<br/>",
|
||||
" }<br/>",
|
||||
"}"
|
||||
"}<br/>",
|
||||
""
|
||||
};
|
||||
|
||||
#define TEMPLATE_PART_RECT_LINE_CNT 14
|
||||
|
@ -60,15 +61,16 @@ const char *TEMPLATE_PART_RECT[TEMPLATE_PART_RECT_LINE_CNT] =
|
|||
" scale: 1;<br/>",
|
||||
" mouse_events: 1;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" color: 255 255 255 255;<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
" visible: 1;<br/>",
|
||||
" }<br/>",
|
||||
"}"
|
||||
"}<br/>",
|
||||
""
|
||||
};
|
||||
|
||||
#define TEMPLATE_PART_SWALLOW_LINE_CNT 13
|
||||
|
@ -79,14 +81,15 @@ const char *TEMPLATE_PART_SWALLOW[TEMPLATE_PART_SWALLOW_LINE_CNT] =
|
|||
" scale: 1;<br/>",
|
||||
" mouse_events: 1;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
" visible: 1;<br/>",
|
||||
" }<br/>",
|
||||
"}"
|
||||
"}<br/>",
|
||||
""
|
||||
};
|
||||
|
||||
#define TEMPLATE_PART_SPACER_LINE_CNT 11
|
||||
|
@ -96,13 +99,14 @@ const char *TEMPLATE_PART_SPACER[TEMPLATE_PART_SPACER_LINE_CNT] =
|
|||
" type: SPACER;<br/>",
|
||||
" scale: 1;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
" }<br/>",
|
||||
"}"
|
||||
"}<br/>",
|
||||
""
|
||||
};
|
||||
|
||||
#define TEMPLATE_PART_TEXT_LINE_CNT 24
|
||||
|
@ -114,8 +118,8 @@ const char *TEMPLATE_PART_TEXT[TEMPLATE_PART_TEXT_LINE_CNT] =
|
|||
" mouse_events: 1;<br/>",
|
||||
" //effect: SHADOW;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
|
@ -131,17 +135,18 @@ const char *TEMPLATE_PART_TEXT[TEMPLATE_PART_TEXT_LINE_CNT] =
|
|||
" min: 0 0;<br/>",
|
||||
" }<br/>",
|
||||
" }<br/>",
|
||||
"}"
|
||||
"}<br/>",
|
||||
""
|
||||
};
|
||||
|
||||
#define TEMPLATE_PART_TEXTBLOCK_LINE_CNT 18
|
||||
#define TEMPLATE_PART_TEXTBLOCK_LINE_CNT 17
|
||||
|
||||
const char *TEMPLATE_PART_TEXTBLOCK[TEMPLATE_PART_TEXTBLOCK_LINE_CNT] =
|
||||
{
|
||||
" type: TEXTBLOCK;<br/>",
|
||||
" description { state: \"default\" 0.0;<br/>",
|
||||
" rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 1.0 1.0; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel1 { relative: 0.25 0.25; offset: 0 0; /*to: \"XXX\";*/ }<br/>",
|
||||
" rel2 { relative: 0.75 0.75; offset: -1 -1; /*to: \"XXX\";*/ }<br/>",
|
||||
" align: 0.5 0.5;<br/>",
|
||||
" fixed: 0 0;<br/>",
|
||||
" min: 0 0;<br/>",
|
||||
|
@ -153,7 +158,8 @@ const char *TEMPLATE_PART_TEXTBLOCK[TEMPLATE_PART_TEXTBLOCK_LINE_CNT] =
|
|||
" min: 0 0;<br/>",
|
||||
" }<br/>",
|
||||
" }<br/>",
|
||||
"}"
|
||||
"}<br/>",
|
||||
""
|
||||
};
|
||||
|
||||
#define TEMPLATE_DESC_LINE_CNT 10
|
||||
|
@ -189,5 +195,11 @@ const char *TEMPLATE_PROG[TEMPLATE_PROG_LINE_CNT] =
|
|||
|
||||
const char *TEMPLATE_IMG[TEMPLATE_IMG_LINE_CNT] =
|
||||
{
|
||||
"image: \"logo.png\" COMP;"
|
||||
"image: \"logo.png\" COMP;<br/>"
|
||||
};
|
||||
|
||||
#define TEMPLATE_IMG_BLOCK_LINE_CNT 3
|
||||
|
||||
const char *TEMPLATE_IMG_BLOCK = " images {<br/>"
|
||||
" image: \"logo.png\" COMP;<br/>"
|
||||
" }<br/>";
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Evas_Object *tools_create(Evas_Object *parent, edit_data *ed);
|
||||
Evas_Object *tools_create(Evas_Object *parent, edit_data *ed, live_edit_data *led);
|
||||
|
||||
|
|