summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-03-21 23:33:28 -0400
committerMike Blumenkrantz <zmike@samsung.com>2014-03-21 23:56:05 -0400
commitb8bc366a28c74090821a7bd4f34ae56841f6ab32 (patch)
tree2e363da15c57eaad9234dee5e9b6fc614bc3ee9f /src
parent98eaad570bccac39409580d934806b8242f82aff (diff)
edje_cc now supports program.sequence for more easily chaining programs together
this is just some syntax shortening for program.after which causes program.action and program.script to create a new program and automatically chain it within the sequence{} block recursive sequences not currently allowed/planned (don't be insane) @feature
Diffstat (limited to 'src')
-rw-r--r--src/bin/edje/edje_cc.h1
-rw-r--r--src/bin/edje/edje_cc_handlers.c166
-rw-r--r--src/bin/edje/edje_cc_parse.c2
3 files changed, 135 insertions, 34 deletions
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 226c455..87fcb07 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -216,6 +216,7 @@ void error_and_abort(Eet_File *ef, const char *fmt, ...);
216 216
217void edje_cc_handlers_hierarchy_alloc(void); 217void edje_cc_handlers_hierarchy_alloc(void);
218void edje_cc_handlers_hierarchy_free(void); 218void edje_cc_handlers_hierarchy_free(void);
219void edje_cc_handlers_pop_notify(const char *token);
219 220
220/* global vars */ 221/* global vars */
221extern Eina_List *ext_dirs; 222extern Eina_List *ext_dirs;
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 688574c..20c70d1 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -117,6 +117,7 @@
117 * <li>@ref sec_collections_group_programs "Programs"</li> 117 * <li>@ref sec_collections_group_programs "Programs"</li>
118 * <ul> 118 * <ul>
119 * <li>@ref sec_collections_group_script "Script"</li> 119 * <li>@ref sec_collections_group_script "Script"</li>
120 * <li>@ref sec_collections_group_program_sequence "Sequence"</li>
120 * </ul> 121 * </ul>
121 * <li>@ref sec_collections_group_physics "Physics"</li> 122 * <li>@ref sec_collections_group_physics "Physics"</li>
122 * <ul> 123 * <ul>
@@ -138,6 +139,7 @@ static Edje_Part_Description_Common *current_desc = NULL;
138static Edje_Part_Description_Common *parent_desc = NULL; 139static Edje_Part_Description_Common *parent_desc = NULL;
139static Edje_Program *current_program = NULL; 140static Edje_Program *current_program = NULL;
140static Eina_Bool current_group_inherit = EINA_FALSE; 141static Eina_Bool current_group_inherit = EINA_FALSE;
142static Edje_Program *sequencing = NULL;
141 143
142struct _Edje_Cc_Handlers_Hierarchy_Info 144struct _Edje_Cc_Handlers_Hierarchy_Info
143{ /* Struct that keeps globals value to impl hierarchy */ 145{ /* Struct that keeps globals value to impl hierarchy */
@@ -389,6 +391,8 @@ static void st_collections_group_programs_program_targets(void);
389static void st_collections_group_programs_program_after(void); 391static void st_collections_group_programs_program_after(void);
390static void st_collections_group_programs_program_api(void); 392static void st_collections_group_programs_program_api(void);
391 393
394static void ob_collections_group_programs_program_sequence(void);
395
392static void ob_collections_group_programs_program_script(void); 396static void ob_collections_group_programs_program_script(void);
393static void st_collections_group_sound_sample_name(void); 397static void st_collections_group_sound_sample_name(void);
394static void st_collections_group_sound_sample_source(void); 398static void st_collections_group_sound_sample_source(void);
@@ -434,16 +438,27 @@ static void st_collections_group_physics_world_depth(void);
434 438
435#define PROGRAM_BASE(PREFIX) \ 439#define PROGRAM_BASE(PREFIX) \
436 {PREFIX".program.name", st_collections_group_programs_program_name}, /* dup */ \ 440 {PREFIX".program.name", st_collections_group_programs_program_name}, /* dup */ \
441 {PREFIX".program.sequence.name", st_collections_group_programs_program_name}, /* dup */ \
437 {PREFIX".program.signal", st_collections_group_programs_program_signal}, /* dup */ \ 442 {PREFIX".program.signal", st_collections_group_programs_program_signal}, /* dup */ \
443 {PREFIX".program.sequence.signal", st_collections_group_programs_program_signal}, /* dup */ \
438 {PREFIX".program.source", st_collections_group_programs_program_source}, /* dup */ \ 444 {PREFIX".program.source", st_collections_group_programs_program_source}, /* dup */ \
445 {PREFIX".program.sequence.source", st_collections_group_programs_program_source}, /* dup */ \
439 {PREFIX".program.in", st_collections_group_programs_program_in}, /* dup */ \ 446 {PREFIX".program.in", st_collections_group_programs_program_in}, /* dup */ \
447 {PREFIX".program.sequence.in", st_collections_group_programs_program_in}, /* dup */ \
440 {PREFIX".program.action", st_collections_group_programs_program_action}, /* dup */ \ 448 {PREFIX".program.action", st_collections_group_programs_program_action}, /* dup */ \
449 {PREFIX".program.sequence.action", st_collections_group_programs_program_action}, /* dup */ \
441 {PREFIX".program.transition", st_collections_group_programs_program_transition}, /* dup */ \ 450 {PREFIX".program.transition", st_collections_group_programs_program_transition}, /* dup */ \
451 {PREFIX".program.sequence.transition", st_collections_group_programs_program_transition}, /* dup */ \
442 {PREFIX".program.target", st_collections_group_programs_program_target}, /* dup */ \ 452 {PREFIX".program.target", st_collections_group_programs_program_target}, /* dup */ \
453 {PREFIX".program.sequence.target", st_collections_group_programs_program_target}, /* dup */ \
443 {PREFIX".program.targets", st_collections_group_programs_program_targets}, /* dup */ \ 454 {PREFIX".program.targets", st_collections_group_programs_program_targets}, /* dup */ \
455 {PREFIX".program.sequence.targets", st_collections_group_programs_program_targets}, /* dup */ \
444 {PREFIX".program.after", st_collections_group_programs_program_after}, /* dup */ \ 456 {PREFIX".program.after", st_collections_group_programs_program_after}, /* dup */ \
457 {PREFIX".program.sequence.after", st_collections_group_programs_program_after}, /* dup */ \
445 {PREFIX".program.api", st_collections_group_programs_program_api}, /* dup */ \ 458 {PREFIX".program.api", st_collections_group_programs_program_api}, /* dup */ \
446 {PREFIX".program.filter", st_collections_group_programs_program_filter}, /* dup */ 459 {PREFIX".program.sequence.api", st_collections_group_programs_program_api}, /* dup */ \
460 {PREFIX".program.filter", st_collections_group_programs_program_filter}, /* dup */ \
461 {PREFIX".program.sequence.filter", st_collections_group_programs_program_filter}, /* dup */
447 462
448#define PROGRAM_STATEMENTS(PREFIX) \ 463#define PROGRAM_STATEMENTS(PREFIX) \
449 IMAGE_SET_STATEMENTS(PREFIX".programs") \ 464 IMAGE_SET_STATEMENTS(PREFIX".programs") \
@@ -696,6 +711,8 @@ New_Statement_Handler statement_handlers[] =
696#define PROGRAM_OBJECTS(PREFIX) \ 711#define PROGRAM_OBJECTS(PREFIX) \
697 {PREFIX".program", ob_collections_group_programs_program}, /* dup */ \ 712 {PREFIX".program", ob_collections_group_programs_program}, /* dup */ \
698 {PREFIX".program.script", ob_collections_group_programs_program_script}, /* dup */ \ 713 {PREFIX".program.script", ob_collections_group_programs_program_script}, /* dup */ \
714 {PREFIX".program.sequence.script", ob_collections_group_programs_program_script}, /* dup */ \
715 {PREFIX".program.sequence", ob_collections_group_programs_program_sequence}, /* dup */ \
699 {PREFIX".programs", NULL}, /* dup */ \ 716 {PREFIX".programs", NULL}, /* dup */ \
700 {PREFIX".programs.set", ob_images_set}, /* dup */ \ 717 {PREFIX".programs.set", ob_images_set}, /* dup */ \
701 {PREFIX".programs.set.image", ob_images_set_image}, /* dup */ \ 718 {PREFIX".programs.set.image", ob_images_set_image}, /* dup */ \
@@ -705,6 +722,7 @@ New_Statement_Handler statement_handlers[] =
705 {PREFIX".programs.fonts", NULL}, /* dup */ \ 722 {PREFIX".programs.fonts", NULL}, /* dup */ \
706 {PREFIX".programs.program", ob_collections_group_programs_program}, /* dup */ \ 723 {PREFIX".programs.program", ob_collections_group_programs_program}, /* dup */ \
707 {PREFIX".programs.program.script", ob_collections_group_programs_program_script}, /* dup */ \ 724 {PREFIX".programs.program.script", ob_collections_group_programs_program_script}, /* dup */ \
725 {PREFIX".programs.program.sequence.script", ob_collections_group_programs_program_script}, /* dup */ \
708 {PREFIX".programs.script", ob_collections_group_script}, /* dup */ \ 726 {PREFIX".programs.script", ob_collections_group_script}, /* dup */ \
709 {PREFIX".script", ob_collections_group_script}, /* dup */ 727 {PREFIX".script", ob_collections_group_script}, /* dup */
710 728
@@ -9009,6 +9027,45 @@ st_collections_group_parts_part_description_params_choice(void)
9009 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE); 9027 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE);
9010} 9028}
9011 9029
9030static void
9031_program_after(const char *name)
9032{
9033 Edje_Part_Collection *pc;
9034 Edje_Program *ep;
9035 Edje_Program_After *pa;
9036 Edje_Program_After *pa2;
9037 Eina_List *l;
9038 char *copy;
9039
9040 pc = eina_list_data_get(eina_list_last(edje_collections));
9041 ep = current_program;
9042
9043 EINA_LIST_FOREACH(ep->after, l, pa2)
9044 {
9045 if (!strcmp(name, (char*) (pa2 + 1)))
9046 return;
9047 }
9048
9049 pa = mem_alloc(SZ(Edje_Program_After) + strlen(name) + 1);
9050 pa->id = -1;
9051 ep->after = eina_list_append(ep->after, pa);
9052 copy = (char*)(pa + 1);
9053 memcpy(copy, name, strlen(name) + 1);
9054 data_queue_program_lookup(pc, name, &(pa->id));
9055}
9056
9057static Edje_Program *
9058_program_sequence_new(void)
9059{
9060 Edje_Program *ep, *pr = current_program;
9061
9062 /* sequence a new program after current */
9063 ob_collections_group_programs_program();
9064 ep = current_program;
9065 current_program = pr;
9066 _program_after(ep->name);
9067 return current_program = ep;
9068}
9012 9069
9013/** 9070/**
9014 @edcsubsection{collections_group_programs,Programs} 9071 @edcsubsection{collections_group_programs,Programs}
@@ -9241,9 +9298,12 @@ st_collections_group_programs_program_action(void)
9241 Edje_Part_Collection *pc; 9298 Edje_Part_Collection *pc;
9242 Edje_Program *ep; 9299 Edje_Program *ep;
9243 int i; 9300 int i;
9244 9301
9245 pc = eina_list_data_get(eina_list_last(edje_collections)); 9302 pc = eina_list_data_get(eina_list_last(edje_collections));
9246 ep = current_program; 9303 if (sequencing)
9304 ep = _program_sequence_new();
9305 else
9306 ep = current_program;
9247 ep->action = parse_enum(0, 9307 ep->action = parse_enum(0,
9248 "STATE_SET", EDJE_ACTION_TYPE_STATE_SET, 9308 "STATE_SET", EDJE_ACTION_TYPE_STATE_SET,
9249 "ACTION_STOP", EDJE_ACTION_TYPE_ACTION_STOP, 9309 "ACTION_STOP", EDJE_ACTION_TYPE_ACTION_STOP,
@@ -9699,39 +9759,12 @@ st_collections_group_programs_program_targets(void)
9699static void 9759static void
9700st_collections_group_programs_program_after(void) 9760st_collections_group_programs_program_after(void)
9701{ 9761{
9702 Edje_Part_Collection *pc; 9762 char *name;
9703 Edje_Program *ep;
9704 9763
9705 check_arg_count(1); 9764 check_arg_count(1);
9706 9765 name = parse_str(0);
9707 pc = eina_list_data_get(eina_list_last(edje_collections)); 9766 _program_after(name);
9708 ep = current_program; 9767 free(name);
9709 {
9710 Edje_Program_After *pa;
9711 Edje_Program_After *pa2;
9712 Eina_List *l;
9713 char *name;
9714 char *copy;
9715
9716 name = parse_str(0);
9717
9718 EINA_LIST_FOREACH(ep->after, l, pa2)
9719 {
9720 if (!strcmp(name, (char*) (pa2 + 1)))
9721 {
9722 free(name);
9723 return;
9724 }
9725 }
9726
9727 pa = mem_alloc(SZ(Edje_Program_After) + strlen(name) + 1);
9728 pa->id = -1;
9729 ep->after = eina_list_append(ep->after, pa);
9730 copy = (char*)(pa + 1);
9731 memcpy(copy, name, strlen(name) + 1);
9732 data_queue_program_lookup(pc, name, &(pa->id));
9733 free(name);
9734 }
9735} 9768}
9736 9769
9737/** 9770/**
@@ -9761,6 +9794,60 @@ st_collections_group_programs_program_api(void)
9761 } 9794 }
9762} 9795}
9763 9796
9797/**
9798 @edcsubsection{collections_group_program_sequence,Sequence}
9799 */
9800
9801/**
9802 @page edcref
9803 @block
9804 sequence
9805 @context
9806 ..
9807 program {
9808 name: "programname";
9809 signal: "signalname";
9810 source: "partname";
9811 filter: "partname" "statename";
9812 in: 0.3 0.0;
9813 action: STATE_SET "statename" state_value;
9814 transition: LINEAR 0.5;
9815 targets: "partname" "anotherpart";
9816 sequence {
9817 action: STATE_SET "somestate";
9818 transition: SINUSOIDAL 0.4;
9819 targets: "partname" "anotherpart";
9820 signal: "also,runs"; source: "on,signals";
9821 name: "runs_after_programname";
9822
9823 action: STATE_SET "someotherstate";
9824 transition: DECELERATE 4.0;
9825 in: 0.2 0.0;
9826 targets: "partname" "anotherpart";
9827 name: "runs_after_runs_after_programname";
9828 after: "coolprogram1337";
9829 filter: "partname" "goodstate";
9830 }
9831 }
9832 ..
9833 @description
9834 Sequences allow quick, easy chaining of programs.
9835 Each "action" keyword within the sequence will start a new program definition.
9836 Programs defined in sequences can be used as regular programs in every way,
9837 but they will automatically set up sequence chains which run after the originating program.
9838 After the sequence block is closed, the original program can continue to be
9839 modified.
9840 Scripts are allowed within sequences: each script block will be treated as a newly
9841 sequenced program.
9842 @since 1.10
9843 @endblock
9844*/
9845static void
9846ob_collections_group_programs_program_sequence(void)
9847{
9848 sequencing = current_program;
9849}
9850
9764static void 9851static void
9765st_collections_group_parts_part_api(void) 9852st_collections_group_parts_part_api(void)
9766{ 9853{
@@ -9821,6 +9908,8 @@ ob_collections_group_programs_program_script(void)
9821 if (!empty) 9908 if (!empty)
9822 { 9909 {
9823 cd->programs = eina_list_append(cd->programs, cp); 9910 cd->programs = eina_list_append(cd->programs, cp);
9911 if (sequencing)
9912 _program_sequence_new();
9824 data_queue_anonymous_lookup(pc, current_program, &(cp->id)); 9913 data_queue_anonymous_lookup(pc, current_program, &(cp->id));
9825 current_program->action = EDJE_ACTION_TYPE_SCRIPT; 9914 current_program->action = EDJE_ACTION_TYPE_SCRIPT;
9826 } 9915 }
@@ -9996,6 +10085,15 @@ st_collections_group_physics_world_z(void)
9996 </table> 10085 </table>
9997*/ 10086*/
9998 10087
10088
10089void
10090edje_cc_handlers_pop_notify(const char *token)
10091{
10092 if ((!sequencing) || strcmp(token, "sequence")) return;
10093 current_program = sequencing;
10094 sequencing = NULL;
10095}
10096
9999static void 10097static void
10000edje_cc_handlers_hierarchy_set(Edje_Part *src) 10098edje_cc_handlers_hierarchy_set(Edje_Part *src)
10001{ /* This funcion makes current part rel_1.id, rel_2.id relative to src */ 10099{ /* This funcion makes current part rel_1.id, rel_2.id relative to src */
diff --git a/src/bin/edje/edje_cc_parse.c b/src/bin/edje/edje_cc_parse.c
index 2b35c89..81c1b60 100644
--- a/src/bin/edje/edje_cc_parse.c
+++ b/src/bin/edje/edje_cc_parse.c
@@ -518,6 +518,8 @@ stack_pop(void)
518 do_remove = EINA_FALSE; 518 do_remove = EINA_FALSE;
519 } 519 }
520 } 520 }
521 else
522 edje_cc_handlers_pop_notify(tmp);
521 523
522 if (do_remove) 524 if (do_remove)
523 eina_strbuf_remove(stack_buf, 525 eina_strbuf_remove(stack_buf,