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.
#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 {
relative: 0.5 0.5;
offset: (-2*BUTTON_SIZE) BUTTON_SIZE;
}
params {
string: "label" "A";
}
}
}
LETTER_BUTTON("B", 1, "button_A");
LETTER_BUTTON("C", 2, "button_A");
LETTER_BUTTON("D", 3, "button_A");
LETTER_BUTTON("E", 4, "button_A");
LETTER_BUTTON("F", 5, "button_A");
}
}
}