Customizable parts in EDC files

This snippet shows how to define customizable parts in EDC files. It makes creating multiple similar parts much faster and improves code readability.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define BUTTON_SIZE 60;
#define LETTER_BUTTON(letter, index, rel_to) \
part { \
    name: "button_"letter; \
    type: EXTERNAL; \
    source: "elm/button"; \
    description {  \
       state: "default" 0; \
       align: 0 0; \
       rel1 { \
          offset: (BUTTON_SIZE*index) 0; \
          to: rel_to; \
       } \
       rel2 { \
          offset: (BUTTON_SIZE*index) 0; \
          to: rel_to; \
       } \
       params { \
          string: "label" letter; \
       } \
    } \
} \
collections {
   group { name: "main";
      parts {
         part { name: "button_A";
            type: EXTERNAL;
            source: "elm/button";
            description { state: "default" 0;
               align: 0 0;
               rel1 {
                  relative: 0.5 0.5;
                  offset: (-3*BUTTON_SIZE) 0;
               }
               rel2 {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX