summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-03-21 15:45:17 -0400
committerMike Blumenkrantz <zmike@samsung.com>2014-03-21 15:47:04 -0400
commit4619c3de4e897a60b9c173c8867f93be790dcf8b (patch)
tree88ef8d247192bb2061422c2a20b75428782c48e9 /src
parent79a6653f59394c1cdb75f6e73853fdfa9cb5d794 (diff)
edje_cc now supports part.inherit for copying attributes of parts within a group more easily
@feature
Diffstat (limited to 'src')
-rw-r--r--src/bin/edje/edje_cc_handlers.c295
1 files changed, 179 insertions, 116 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 4458d9f..3f10e73 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -208,9 +208,10 @@ static void ob_collections_group_lua_script(void);
208 208
209static void st_collections_group_parts_alias(void); 209static void st_collections_group_parts_alias(void);
210 210
211static Edje_Part *edje_cc_handlers_part_make(void); 211static Edje_Part *edje_cc_handlers_part_make(int);
212static void ob_collections_group_parts_part(void); 212static void ob_collections_group_parts_part(void);
213static void st_collections_group_parts_part_name(void); 213static void st_collections_group_parts_part_name(void);
214static void st_collections_group_parts_part_inherit(void);
214static void st_collections_group_parts_part_type(void); 215static void st_collections_group_parts_part_type(void);
215#ifdef HAVE_EPHYSICS 216#ifdef HAVE_EPHYSICS
216static void st_collections_group_parts_part_physics_body(void); 217static void st_collections_group_parts_part_physics_body(void);
@@ -515,6 +516,7 @@ New_Statement_Handler statement_handlers[] =
515 {"collections.group.parts.color_classes.color_class.color2", st_color_class_color2}, /* dup */ 516 {"collections.group.parts.color_classes.color_class.color2", st_color_class_color2}, /* dup */
516 {"collections.group.parts.color_classes.color_class.color3", st_color_class_color3}, /* dup */ 517 {"collections.group.parts.color_classes.color_class.color3", st_color_class_color3}, /* dup */
517 {"collections.group.parts.part.name", st_collections_group_parts_part_name}, 518 {"collections.group.parts.part.name", st_collections_group_parts_part_name},
519 {"collections.group.parts.part.inherit", st_collections_group_parts_part_inherit},
518 {"collections.group.parts.part.api", st_collections_group_parts_part_api}, 520 {"collections.group.parts.part.api", st_collections_group_parts_part_api},
519 {"collections.group.parts.part.type", st_collections_group_parts_part_type}, 521 {"collections.group.parts.part.type", st_collections_group_parts_part_type},
520#ifdef HAVE_EPHYSICS 522#ifdef HAVE_EPHYSICS
@@ -2815,6 +2817,121 @@ _edje_data_item_list_foreach(const Eina_Hash *hash EINA_UNUSED, const void *key,
2815 return EINA_TRUE; 2817 return EINA_TRUE;
2816} 2818}
2817 2819
2820#define STRDUP(x) x ? strdup(x) : NULL
2821static void
2822_part_copy(Edje_Part *ep, Edje_Part *ep2)
2823{
2824 Edje_Part_Collection *pc;
2825 Edje_Part_Parser *epp, *epp2;
2826 Edje_Pack_Element *item, *item2;
2827 Edje_Pack_Element_Parser *pitem;
2828 Edje_Part_Description_Common *ed, *ed2;
2829 unsigned int j;
2830
2831 pc = eina_list_last_data_get(edje_collections);
2832
2833 ep->name = STRDUP(ep2->name);
2834 ep->source = STRDUP(ep2->source);
2835 ep->source2 = STRDUP(ep2->source2);
2836 ep->source3 = STRDUP(ep2->source3);
2837 ep->source4 = STRDUP(ep2->source4);
2838 ep->source5 = STRDUP(ep2->source5);
2839 ep->source6 = STRDUP(ep2->source6);
2840
2841 data_queue_copied_part_lookup(pc, &(ep2->clip_to_id), &(ep->clip_to_id));
2842
2843 ep->type = ep2->type;
2844 ep->mouse_events = ep2->mouse_events;
2845 ep->repeat_events = ep2->repeat_events;
2846 ep->ignore_flags = ep2->ignore_flags;
2847 ep->scale = ep2->scale;
2848 ep->pointer_mode = ep2->pointer_mode;
2849 ep->precise_is_inside = ep2->precise_is_inside;
2850 ep->use_alternate_font_metrics = ep2->use_alternate_font_metrics;
2851 ep->effect = ep2->effect;
2852 ep->entry_mode = ep2->entry_mode;
2853 ep->select_mode = ep2->select_mode;
2854 ep->cursor_mode = ep2->cursor_mode;
2855 ep->multiline = ep2->multiline;
2856 ep->access = ep2->access;
2857 ep->dragable.x = ep2->dragable.x;
2858 ep->dragable.step_x = ep2->dragable.step_x;
2859 ep->dragable.count_x = ep2->dragable.count_x;
2860 ep->dragable.y = ep2->dragable.y;
2861 ep->dragable.step_y = ep2->dragable.step_y;
2862 ep->dragable.count_y = ep2->dragable.count_y;
2863 ep->nested_children_count = ep2->nested_children_count;
2864
2865 data_queue_copied_part_lookup(pc, &(ep2->dragable.confine_id), &(ep->dragable.confine_id));
2866 data_queue_copied_part_lookup(pc, &(ep2->dragable.threshold_id), &(ep->dragable.threshold_id));
2867 data_queue_copied_part_lookup(pc, &(ep2->dragable.event_id), &(ep->dragable.event_id));
2868
2869 epp = (Edje_Part_Parser *)ep;
2870 epp2 = (Edje_Part_Parser *)ep2;
2871 epp->reorder.insert_before = STRDUP(epp2->reorder.insert_before);
2872 epp->reorder.insert_after = STRDUP(epp2->reorder.insert_after);
2873 epp->can_override = EINA_TRUE;
2874
2875 for (j = 0 ; j < ep2->items_count ; j++)
2876 {
2877 ob_collections_group_parts_part_box_items_item();
2878 item = ep->items[j];
2879 item2 = ep2->items[j];
2880 item->type = item2->type;
2881 item->name = STRDUP(item2->name);
2882 item->source = STRDUP(item2->source);
2883 item->min.w = item2->min.w;
2884 item->min.h = item2->min.h;
2885 item->prefer.w = item2->prefer.w;
2886 item->prefer.h = item2->prefer.h;
2887 item->max.w = item2->max.w;
2888 item->max.h = item2->max.h;
2889 item->padding.l = item2->padding.l;
2890 item->padding.r = item2->padding.r;
2891 item->padding.t = item2->padding.t;
2892 item->padding.b = item2->padding.b;
2893 item->align.x = item2->align.x;
2894 item->align.y = item2->align.y;
2895 item->weight.x = item2->weight.x;
2896 item->weight.y = item2->weight.y;
2897 item->aspect.w = item2->aspect.w;
2898 item->aspect.h = item2->aspect.h;
2899 item->aspect.mode = item2->aspect.mode;
2900 item->options = STRDUP(item2->options);
2901 item->col = item2->col;
2902 item->row = item2->row;
2903 item->colspan = item2->colspan;
2904 item->rowspan = item2->rowspan;
2905
2906 pitem = (Edje_Pack_Element_Parser *)item;
2907 pitem->can_override = EINA_TRUE;
2908 }
2909
2910 ep->api.name = STRDUP(ep2->api.name);
2911 if (ep2->api.description) ep->api.description = STRDUP(ep2->api.description);
2912
2913 // copy default description
2914 ob_collections_group_parts_part_description();
2915 ed = ep->default_desc;
2916 parent_desc = ed2 = ep2->default_desc;
2917 ed->state.name = STRDUP(ed2->state.name);
2918 ed->state.value = ed2->state.value;
2919 st_collections_group_parts_part_description_inherit();
2920 parent_desc = NULL;
2921
2922 // copy other description
2923 for (j = 0 ; j < ep2->other.desc_count ; j++)
2924 {
2925 ob_collections_group_parts_part_description();
2926 ed = ep->other.desc[j];
2927 parent_desc = ed2 = ep2->other.desc[j];
2928 ed->state.name = STRDUP(ed2->state.name);
2929 ed->state.value = ed2->state.value;
2930 st_collections_group_parts_part_description_inherit();
2931 parent_desc = NULL;
2932 }
2933}
2934
2818/** 2935/**
2819 @page edcref 2936 @page edcref
2820 @property 2937 @property
@@ -2837,10 +2954,6 @@ st_collections_group_inherit(void)
2837 Edje_Part_Collection *pc, *pc2; 2954 Edje_Part_Collection *pc, *pc2;
2838 Edje_Part_Collection_Parser *pcp, *pcp2; 2955 Edje_Part_Collection_Parser *pcp, *pcp2;
2839 Edje_Part *ep, *ep2; 2956 Edje_Part *ep, *ep2;
2840 Edje_Part_Parser *epp, *epp2;
2841 Edje_Pack_Element *item, *item2;
2842 Edje_Pack_Element_Parser *pitem;
2843 Edje_Part_Description_Common *ed, *ed2;
2844 Edje_List_Foreach_Data fdata; 2957 Edje_List_Foreach_Data fdata;
2845 Eina_List *l; 2958 Eina_List *l;
2846 char *parent_name; 2959 char *parent_name;
@@ -2938,113 +3051,13 @@ st_collections_group_inherit(void)
2938 3051
2939 // FIXME: Handle limits dup 3052 // FIXME: Handle limits dup
2940 3053
2941 #define STRDUP(x) x ? strdup(x) : NULL
2942 for (i = 0 ; i < pc2->parts_count ; i++) 3054 for (i = 0 ; i < pc2->parts_count ; i++)
2943 { 3055 {
2944 // copy the part 3056 // copy the part
2945 edje_cc_handlers_part_make(); 3057 edje_cc_handlers_part_make(-1);
2946 ep = pc->parts[i]; 3058 ep = pc->parts[i];
2947 ep2 = pc2->parts[i]; 3059 ep2 = pc2->parts[i];
2948 ep->name = STRDUP(ep2->name); 3060 _part_copy(ep, ep2);
2949 ep->source = STRDUP(ep2->source);
2950 ep->source2 = STRDUP(ep2->source2);
2951 ep->source3 = STRDUP(ep2->source3);
2952 ep->source4 = STRDUP(ep2->source4);
2953 ep->source5 = STRDUP(ep2->source5);
2954 ep->source6 = STRDUP(ep2->source6);
2955
2956 data_queue_copied_part_lookup(pc, &(ep2->clip_to_id), &(ep->clip_to_id));
2957
2958 ep->type = ep2->type;
2959 ep->mouse_events = ep2->mouse_events;
2960 ep->repeat_events = ep2->repeat_events;
2961 ep->ignore_flags = ep2->ignore_flags;
2962 ep->scale = ep2->scale;
2963 ep->pointer_mode = ep2->pointer_mode;
2964 ep->precise_is_inside = ep2->precise_is_inside;
2965 ep->use_alternate_font_metrics = ep2->use_alternate_font_metrics;
2966 ep->effect = ep2->effect;
2967 ep->entry_mode = ep2->entry_mode;
2968 ep->select_mode = ep2->select_mode;
2969 ep->cursor_mode = ep2->cursor_mode;
2970 ep->multiline = ep2->multiline;
2971 ep->access = ep2->access;
2972 ep->dragable.x = ep2->dragable.x;
2973 ep->dragable.step_x = ep2->dragable.step_x;
2974 ep->dragable.count_x = ep2->dragable.count_x;
2975 ep->dragable.y = ep2->dragable.y;
2976 ep->dragable.step_y = ep2->dragable.step_y;
2977 ep->dragable.count_y = ep2->dragable.count_y;
2978 ep->nested_children_count = ep2->nested_children_count;
2979
2980 data_queue_copied_part_lookup(pc, &(ep2->dragable.confine_id), &(ep->dragable.confine_id));
2981 data_queue_copied_part_lookup(pc, &(ep2->dragable.threshold_id), &(ep->dragable.threshold_id));
2982 data_queue_copied_part_lookup(pc, &(ep2->dragable.event_id), &(ep->dragable.event_id));
2983
2984 epp = (Edje_Part_Parser *)ep;
2985 epp2 = (Edje_Part_Parser *)ep2;
2986 epp->reorder.insert_before = STRDUP(epp2->reorder.insert_before);
2987 epp->reorder.insert_after = STRDUP(epp2->reorder.insert_after);
2988 epp->can_override = EINA_TRUE;
2989
2990 for (j = 0 ; j < ep2->items_count ; j++)
2991 {
2992 ob_collections_group_parts_part_box_items_item();
2993 item = ep->items[j];
2994 item2 = ep2->items[j];
2995 item->type = item2->type;
2996 item->name = STRDUP(item2->name);
2997 item->source = STRDUP(item2->source);
2998 item->min.w = item2->min.w;
2999 item->min.h = item2->min.h;
3000 item->prefer.w = item2->prefer.w;
3001 item->prefer.h = item2->prefer.h;
3002 item->max.w = item2->max.w;
3003 item->max.h = item2->max.h;
3004 item->padding.l = item2->padding.l;
3005 item->padding.r = item2->padding.r;
3006 item->padding.t = item2->padding.t;
3007 item->padding.b = item2->padding.b;
3008 item->align.x = item2->align.x;
3009 item->align.y = item2->align.y;
3010 item->weight.x = item2->weight.x;
3011 item->weight.y = item2->weight.y;
3012 item->aspect.w = item2->aspect.w;
3013 item->aspect.h = item2->aspect.h;
3014 item->aspect.mode = item2->aspect.mode;
3015 item->options = STRDUP(item2->options);
3016 item->col = item2->col;
3017 item->row = item2->row;
3018 item->colspan = item2->colspan;
3019 item->rowspan = item2->rowspan;
3020
3021 pitem = (Edje_Pack_Element_Parser *)item;
3022 pitem->can_override = EINA_TRUE;
3023 }
3024
3025 ep->api.name = STRDUP(ep2->api.name);
3026 if (ep2->api.description) ep->api.description = STRDUP(ep2->api.description);
3027
3028 // copy default description
3029 ob_collections_group_parts_part_description();
3030 ed = ep->default_desc;
3031 parent_desc = ed2 = ep2->default_desc;
3032 ed->state.name = STRDUP(ed2->state.name);
3033 ed->state.value = ed2->state.value;
3034 st_collections_group_parts_part_description_inherit();
3035 parent_desc = NULL;
3036
3037 // copy other description
3038 for (j = 0 ; j < ep2->other.desc_count ; j++)
3039 {
3040 ob_collections_group_parts_part_description();
3041 ed = ep->other.desc[j];
3042 parent_desc = ed2 = ep2->other.desc[j];
3043 ed->state.name = STRDUP(ed2->state.name);
3044 ed->state.value = ed2->state.value;
3045 st_collections_group_parts_part_description_inherit();
3046 parent_desc = NULL;
3047 }
3048 } 3061 }
3049 3062
3050 //copy programs 3063 //copy programs
@@ -3583,7 +3596,7 @@ st_collections_group_parts_alias(void)
3583 @endblock 3596 @endblock
3584*/ 3597*/
3585static Edje_Part * 3598static Edje_Part *
3586edje_cc_handlers_part_make(void) 3599edje_cc_handlers_part_make(int id)
3587{ /* Doing ob_collections_group_parts_part() job, without hierarchy */ 3600{ /* Doing ob_collections_group_parts_part() job, without hierarchy */
3588 Edje_Part_Collection *pc; 3601 Edje_Part_Collection *pc;
3589 Edje_Part_Collection_Parser *pcp; 3602 Edje_Part_Collection_Parser *pcp;
@@ -3593,17 +3606,21 @@ edje_cc_handlers_part_make(void)
3593 ep = mem_alloc(SZ(Edje_Part_Parser)); 3606 ep = mem_alloc(SZ(Edje_Part_Parser));
3594 3607
3595 pc = eina_list_data_get(eina_list_last(edje_collections)); 3608 pc = eina_list_data_get(eina_list_last(edje_collections));
3596 pc->parts_count++; 3609 if (id < 0)
3597 pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *));
3598 if (!pc->parts)
3599 { 3610 {
3600 ERR("Not enough memory."); 3611 pc->parts_count++;
3601 exit(-1); 3612 pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *));
3613 if (!pc->parts)
3614 {
3615 ERR("Not enough memory.");
3616 exit(-1);
3617 }
3618 id = pc->parts_count - 1;
3602 } 3619 }
3603 current_part = pc->parts[pc->parts_count - 1] = ep; 3620 current_part = pc->parts[id] = ep;
3604 pcp = (Edje_Part_Collection_Parser *)pc; 3621 pcp = (Edje_Part_Collection_Parser *)pc;
3605 3622
3606 ep->id = pc->parts_count - 1; 3623 ep->id = id;
3607 ep->type = EDJE_PART_TYPE_IMAGE; 3624 ep->type = EDJE_PART_TYPE_IMAGE;
3608 ep->mouse_events = pcp->default_mouse_events; 3625 ep->mouse_events = pcp->default_mouse_events;
3609 ep->repeat_events = 0; 3626 ep->repeat_events = 0;
@@ -3637,7 +3654,7 @@ static void
3637ob_collections_group_parts_part(void) 3654ob_collections_group_parts_part(void)
3638{ 3655{
3639 Edje_Part *cp = current_part; /* Save to restore on pop */ 3656 Edje_Part *cp = current_part; /* Save to restore on pop */
3640 Edje_Part *ep = edje_cc_handlers_part_make(); /* This changes current_part */ 3657 Edje_Part *ep = edje_cc_handlers_part_make(-1); /* This changes current_part */
3641 Edje_Part *prnt; 3658 Edje_Part *prnt;
3642 3659
3643 /* Add this new part to hierarchy stack (removed part finished parse) */ 3660 /* Add this new part to hierarchy stack (removed part finished parse) */
@@ -3692,6 +3709,52 @@ _part_free(Edje_Part *ep)
3692/** 3709/**
3693 @page edcref 3710 @page edcref
3694 @property 3711 @property
3712 inherit
3713 @parameters
3714 [part name]
3715 @effect
3716 Copies all attributes except part name from referenced part into current part.
3717 ALL existing attributes, except part name, are overwritten.
3718 @endproperty
3719 @since 1.10
3720*/
3721static void
3722st_collections_group_parts_part_inherit(void)
3723{
3724 char *name;
3725 Edje_Part_Collection *pc;
3726 unsigned int i;
3727
3728 check_arg_count(1);
3729
3730 name = parse_str(0);
3731 pc = eina_list_data_get(eina_list_last(edje_collections));
3732 for (i = 0; i < pc->parts_count; i++)
3733 {
3734 int id = current_part->id;
3735 const char *pname;
3736
3737 if (strcmp(pc->parts[i]->name, name)) continue;
3738 pname = current_part->name;
3739 current_part->name = NULL;
3740 _part_free(current_part);
3741 edje_cc_handlers_part_make(id);
3742 _part_copy(current_part, pc->parts[i]);
3743 free((void*)current_part->name);
3744 current_part->name = pname;
3745 free(name);
3746 return;
3747 }
3748
3749 ERR("Cannot inherit non-existing part '%s' in group '%s'", name, current_de->entry);
3750 exit(-1);
3751
3752 free(name);
3753}
3754
3755/**
3756 @page edcref
3757 @property
3695 remove 3758 remove
3696 @parameters 3759 @parameters
3697 [part name] [part name] [part name] ... 3760 [part name] [part name] [part name] ...