edje_cc: introduce "Anchors" - easy way to set parts relationship

Test Plan: compile src/examples/edc-anchors.c and run

Reviewers: zmike, raster, cedric, jpeg

Reviewed By: raster, jpeg

Subscribers: raster, barbieri, zmike, SanghyeonLee, taxi2se, Jaehyun_Cho

Differential Revision: https://phab.enlightenment.org/D4775

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Jeeyong Um 2017-04-25 16:25:11 -07:00 committed by Cedric BAIL
parent 7e7ff5059e
commit f8760a6813
2 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,58 @@
/**
* Simple Edje example for layouting parts with anchors.
*
* You'll need at least one Evas engine built for it (excluding the
* buffer one). See stdout/stderr for output.
*
* @verbatim
* edje_cc edje-anchors.edc && gcc -o edje-anchors edje-anchors.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
* @endverbatim
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#else
# define EINA_UNUSED
#endif
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Edje.h>
#include <libgen.h>
#define WIDTH 400
#define HEIGHT 400
int
main(int argc, char **argv)
{
char path[PATH_MAX] = { 0, };
ecore_init();
ecore_evas_init();
edje_init();
Ecore_Evas *ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
Evas *e = ecore_evas_get(ee);
ecore_evas_show(ee);
Evas_Object *bg = evas_object_rectangle_add(e);
evas_object_color_set(bg, 64, 64, 64, 255);
evas_object_resize(bg, WIDTH, HEIGHT);
evas_object_show(bg);
snprintf(path, sizeof(path), "%s/edje-anchors.edj", dirname(*argv));
Evas_Object *edje = edje_object_add(e);
edje_object_file_set(edje, path, "main");
evas_object_resize(edje, WIDTH, HEIGHT);
evas_object_show(edje);
ecore_main_loop_begin();
edje_shutdown();
ecore_evas_shutdown();
ecore_shutdown();
return 0;
}

View File

@ -0,0 +1,58 @@
collections {
group { "main";
parts {
rect { "rect1";
desc {
anchors.top: GROUP TOP;
anchors.left: GROUP; // anchors.left: GROUP LEFT;
color: "#f00";
min: 50 50;
}
}
rect { "rect2";
desc {
anchors.top: "rect1" BOTTOM;
anchors.left: "rect1" RIGHT;
color: "#00f";
min: 50 50;
}
}
rect { "rect3";
desc {
anchors.left: "rect2"; // anchors.left: "rect1" RIGHT;
anchors.fill: "rect2" VERTICAL;
anchors.margin: 20 0 0 0;
color: "#0f0";
min: 100 0;
}
}
rect { "rect4";
desc {
anchors {
top: "rect3";
left: "rect3";
right: GROUP;
bottom: GROUP;
margin: 0 10 0 50;
}
}
}
rect { "rect5";
desc {
anchors.vertical_center: "rect4";
anchors.fill: "rect4" HORIZONTAL;
min: 0 50;
color: "#000";
}
}
rect { "rect6";
desc {
anchors.right: "rect5" HORIZONTAL_CENTER;
anchors.fill: "rect5" VERTICAL;
min: 30 0;
color: "#ff0";
}
}
}
}
}