forked from enlightenment/efl
Edje: use eina_prefix to find the data files, improve and display the help, make all the examples codes looking the same
SVN revision: 69356
This commit is contained in:
parent
ce754d6a12
commit
76dc9d2e82
|
@ -59,14 +59,13 @@ EXTRA_DIST = $(files_DATA)
|
|||
if BUILD_EXAMPLES
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/include \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-DPACKAGE_EXAMPLES_DIR=\"$(datadir)/$(PACKAGE)/examples\" \
|
||||
@EDJE_CFLAGS@
|
||||
-I. \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/include \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
|
||||
@EDJE_CFLAGS@
|
||||
|
||||
files_DATA += $(EDJS)
|
||||
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -23,34 +22,59 @@
|
|||
#define WIDTH (400)
|
||||
#define HEIGHT (300)
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/animations.edj";
|
||||
static Ecore_Evas *ee;
|
||||
static Evas_Object *bg, *edje_obj;
|
||||
static double frametime = 1.0/30.0; /* default value */
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\t+ - increase frametime\n"
|
||||
"\t- - decrease frametime\n"
|
||||
"\t= - status of the animation\n"
|
||||
"\ts - pause\n"
|
||||
"\tp - play\n"
|
||||
"\tf - freeze one object\n"
|
||||
"\tF - freeze all objects\n"
|
||||
"\tt - thaw one object\n"
|
||||
"\tT - thaw all objects\n"
|
||||
"\ta - start animation of one object\n"
|
||||
"\tA - stop animation of one object\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static double frametime = 1.0 / 30.0; /* default value */
|
||||
|
||||
static void
|
||||
_on_delete_cb(Ecore_Evas *ee)
|
||||
_on_delete_cb(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static void
|
||||
_canvas_resize_cb(Ecore_Evas *ee)
|
||||
_on_canvas_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int w, h;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
bg = ecore_evas_data_get(ee, "background");
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
||||
_on_key_down(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
double ft;
|
||||
Evas_Event_Key_Down *ev;
|
||||
double ft;
|
||||
|
||||
if (!strcmp(ev->key, "plus"))
|
||||
ev = (Evas_Event_Key_Down *)event_info;
|
||||
|
||||
if (!strcmp(ev->keyname, "h"))
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(ev->key, "plus"))
|
||||
{
|
||||
frametime *= 2.0;
|
||||
fprintf(stdout, "Increasing frametime to: %f\n", frametime);
|
||||
|
@ -109,24 +133,52 @@ _on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|||
edje_object_animation_set(obj, EINA_FALSE);
|
||||
fprintf(stdout, "Stopping the animation in the Edje object\n");
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas *evas;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "animations.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete_cb);
|
||||
ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
|
||||
ecore_evas_callback_resize_set(ee, _on_canvas_resize);
|
||||
ecore_evas_title_set(ee, "Edje Animations Example");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -135,22 +187,41 @@ main(int argc, char *argv[])
|
|||
evas_object_move(bg, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg);
|
||||
ecore_evas_data_set(ee, "background", bg);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(edje_obj, edje_file_path, "animations_group");
|
||||
evas_object_move(edje_obj, 0, 0);
|
||||
evas_object_resize(edje_obj, WIDTH, HEIGHT);
|
||||
evas_object_show(edje_obj);
|
||||
ecore_evas_data_set(ee, "edje_obj", edje_obj);
|
||||
|
||||
evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN,
|
||||
_on_key_down_cb, NULL);
|
||||
_on_key_down, NULL);
|
||||
evas_object_focus_set(edje_obj, EINA_TRUE);
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -11,47 +11,46 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Eina.h>
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_Evas.h>
|
||||
#include <Edje.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define WIDTH (300)
|
||||
#define HEIGHT (300)
|
||||
|
||||
static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/basic.edj";
|
||||
|
||||
static Ecore_Evas *ee;
|
||||
static Evas_Object *edje_obj;
|
||||
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\ts - change Edje's global scaling factor\n"
|
||||
"\tr - change center rectangle's scaling factor\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static void
|
||||
_on_keydown(void *data __UNUSED__,
|
||||
_on_keydown(void *data,
|
||||
Evas *evas __UNUSED__,
|
||||
Evas_Object *o __UNUSED__,
|
||||
void *einfo)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = einfo;
|
||||
Evas_Event_Key_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
|
||||
ev = (Evas_Event_Key_Down *)einfo;
|
||||
edje_obj = (Evas_Object *)data;
|
||||
|
||||
if (strcmp(ev->keyname, "h") == 0) /* print help */
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "s") == 0) /* global scaling factor */
|
||||
else if (strcmp(ev->keyname, "s") == 0) /* global scaling factor */
|
||||
{
|
||||
double scale = edje_scale_get();
|
||||
|
||||
|
@ -66,8 +65,7 @@ _on_keydown(void *data __UNUSED__,
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "r") == 0) /* individual scaling factor */
|
||||
else if (strcmp(ev->keyname, "r") == 0) /* individual scaling factor */
|
||||
{
|
||||
double scale = edje_object_scale_get(edje_obj);
|
||||
|
||||
|
@ -84,6 +82,13 @@ _on_keydown(void *data __UNUSED__,
|
|||
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -93,27 +98,47 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
|
|||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas_Object *border, *bg;
|
||||
int x, y, w, h;
|
||||
Evas *evas;
|
||||
char border_img_path[PATH_MAX];
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "basic.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *border;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
return EXIT_FAILURE;
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto error;
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete);
|
||||
ecore_evas_title_set(ee, "Edje Basics Example");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -125,11 +150,12 @@ main(void)
|
|||
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
|
||||
|
||||
evas_object_focus_set(bg, EINA_TRUE);
|
||||
evas_object_event_callback_add(
|
||||
bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
printf("%s\n", edje_file_path);
|
||||
/* exercising Edje loading error, on purpose */
|
||||
if (!edje_object_file_set(edje_obj, edje_file_path, "unexistant_group"))
|
||||
{
|
||||
|
@ -147,7 +173,7 @@ main(void)
|
|||
errmsg);
|
||||
|
||||
evas_object_del(edje_obj);
|
||||
goto error_edj;
|
||||
goto free_prefix;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Loaded Edje object bound to group 'example_group' from"
|
||||
|
@ -157,6 +183,11 @@ main(void)
|
|||
evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
|
||||
evas_object_show(edje_obj);
|
||||
|
||||
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj);
|
||||
|
||||
snprintf(border_img_path, sizeof(border_img_path),
|
||||
"%s/edje/examples/red.png", eina_prefix_data_get(pfx));
|
||||
|
||||
/* this is a border around the Edje object above, here just to
|
||||
* emphasize its geometry */
|
||||
border = evas_object_image_filled_add(evas);
|
||||
|
@ -203,24 +234,24 @@ main(void)
|
|||
"y = %d, w = %d, h = %d\n", x, y, w, h);
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
error:
|
||||
fprintf(stderr, "You got to have at least one evas engine built"
|
||||
" and linked up to ecore-evas for this example to run"
|
||||
" properly.\n");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
return -1;
|
||||
|
||||
error_edj:
|
||||
fprintf(stderr, "Failed to load basic.edj!\n");
|
||||
|
||||
ecore_evas_shutdown();
|
||||
return -2;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -28,13 +27,13 @@
|
|||
|
||||
#define NRECTS 20
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/box.edj";
|
||||
|
||||
struct _App {
|
||||
Ecore_Evas *ee;
|
||||
Evas_Object *edje;
|
||||
Evas_Object *bg;
|
||||
};
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\ti - prepend rectangle\n"
|
||||
"\ta - append rectangle\n"
|
||||
"\tc - remove\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static void
|
||||
_on_destroy(Ecore_Evas *ee __UNUSED__)
|
||||
|
@ -45,32 +44,41 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
|
|||
/* here just to keep our example's window size and background image's
|
||||
* size in synchrony */
|
||||
static void
|
||||
_canvas_resize_cb(Ecore_Evas *ee)
|
||||
_on_canvas_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int w, h;
|
||||
struct _App *app = ecore_evas_data_get(ee, "app");
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
bg = ecore_evas_data_get(ee, "background");
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(app->bg, w, h);
|
||||
evas_object_resize(app->edje, w, h);
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)
|
||||
_on_rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)
|
||||
{
|
||||
struct _App *app = data;
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
Ecore_Evas *ee;
|
||||
Evas_Event_Mouse_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
|
||||
ee = (Ecore_Evas *)data;
|
||||
ev = (Evas_Event_Mouse_Down *)event_info;
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
|
||||
if (ev->button == 1)
|
||||
{
|
||||
printf("Removing rect %p under the mouse pointer.\n", o);
|
||||
edje_object_part_box_remove(app->edje, "example/box", o);
|
||||
edje_object_part_box_remove(edje_obj, "example/box", o);
|
||||
evas_object_del(o);
|
||||
}
|
||||
else if (ev->button == 3)
|
||||
{
|
||||
Evas_Object *rect;
|
||||
Eina_Bool r;
|
||||
Eina_Bool r;
|
||||
|
||||
rect = evas_object_rectangle_add(e);
|
||||
evas_object_color_set(rect, 0, 0, 255, 255);
|
||||
|
@ -78,23 +86,32 @@ _rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)
|
|||
evas_object_show(rect);
|
||||
|
||||
printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
|
||||
r = edje_object_part_box_insert_before(app->edje, "example/box", rect, o);
|
||||
r = edje_object_part_box_insert_before(edje_obj, "example/box", rect, o);
|
||||
if (!r)
|
||||
printf("An error ocurred when appending rect %p to the box.\n", rect);
|
||||
|
||||
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, app);
|
||||
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
||||
_on_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
||||
{
|
||||
struct _App *app = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
Evas_Object *rect;
|
||||
Eina_Bool r;
|
||||
Ecore_Evas *ee;
|
||||
Evas_Event_Key_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object *rect;
|
||||
Eina_Bool r;
|
||||
|
||||
ee = (Ecore_Evas *)data;
|
||||
ev = (Evas_Event_Key_Down *)event_info;
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
|
||||
if (!strcmp(ev->keyname, "h"))
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
if (!strcmp(ev->keyname, "i"))
|
||||
{
|
||||
rect = evas_object_rectangle_add(e);
|
||||
|
@ -103,11 +120,11 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
|||
evas_object_show(rect);
|
||||
|
||||
printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
|
||||
r = edje_object_part_box_insert_at(app->edje, "example/box", rect, 0);
|
||||
r = edje_object_part_box_insert_at(edje_obj, "example/box", rect, 0);
|
||||
if (!r)
|
||||
printf("An error ocurred when appending rect %p to the box.\n", rect);
|
||||
|
||||
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, app);
|
||||
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "a"))
|
||||
{
|
||||
|
@ -117,53 +134,82 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
|||
evas_object_show(rect);
|
||||
|
||||
printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
|
||||
r = edje_object_part_box_append(app->edje, "example/box", rect);
|
||||
r = edje_object_part_box_append(edje_obj, "example/box", rect);
|
||||
if (!r)
|
||||
printf("An error ocurred when appending rect %p to the box.\n", rect);
|
||||
|
||||
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, app);
|
||||
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "c"))
|
||||
edje_object_part_box_remove_all(app->edje, "example/box", EINA_TRUE);
|
||||
edje_object_part_box_remove_all(edje_obj, "example/box", EINA_TRUE);
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas *evas;
|
||||
struct _App app;
|
||||
int i;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "box.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
int i;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
app.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_destroy_set(app.ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(app.ee, _canvas_resize_cb);
|
||||
ecore_evas_title_set(app.ee, "Edje Box Example");
|
||||
ecore_evas_show(app.ee);
|
||||
ecore_evas_callback_destroy_set(ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(ee, _on_canvas_resize);
|
||||
ecore_evas_title_set(ee, "Edje Box Example");
|
||||
|
||||
ecore_evas_data_set(app.ee, "app", &app);
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
evas = ecore_evas_get(app.ee);
|
||||
bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(bg, 255, 255, 255, 255);
|
||||
evas_object_resize(bg, WIDTH, HEIGHT);
|
||||
evas_object_focus_set(bg, EINA_TRUE);
|
||||
evas_object_show(bg);
|
||||
ecore_evas_data_set(ee, "background", bg);
|
||||
|
||||
app.bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(app.bg, 255, 255, 255, 255);
|
||||
evas_object_resize(app.bg, WIDTH, HEIGHT);
|
||||
evas_object_focus_set(app.bg, EINA_TRUE);
|
||||
evas_object_show(app.bg);
|
||||
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee);
|
||||
|
||||
evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _bg_key_down, &app);
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
app.edje = edje_object_add(evas);
|
||||
|
||||
edje_object_file_set(app.edje, edje_file_path, "example/group");
|
||||
evas_object_move(app.edje, 0, 0);
|
||||
evas_object_resize(app.edje, WIDTH, HEIGHT);
|
||||
evas_object_show(app.edje);
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(edje_obj, edje_file_path, "example/group");
|
||||
evas_object_move(edje_obj, 0, 0);
|
||||
evas_object_resize(edje_obj, WIDTH, HEIGHT);
|
||||
evas_object_show(edje_obj);
|
||||
ecore_evas_data_set(ee, "edje_obj", edje_obj);
|
||||
|
||||
for (i = 0; i < NRECTS; i++)
|
||||
{
|
||||
|
@ -173,19 +219,34 @@ main(void)
|
|||
rect = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(rect, red, 0, 0, 255);
|
||||
evas_object_resize(rect, RECTW, RECTH);
|
||||
r = edje_object_part_box_append(app.edje, "example/box", rect);
|
||||
r = edje_object_part_box_append(edje_obj, "example/box", rect);
|
||||
if (!r)
|
||||
printf("An error ocurred when appending rect #%d to the box.\n", i);
|
||||
evas_object_show(rect);
|
||||
|
||||
evas_object_event_callback_add(
|
||||
rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, &app);
|
||||
rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, ee);
|
||||
}
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_evas_free(app.ee);
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -10,40 +10,35 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Ecore.h>
|
||||
#include <Evas.h>
|
||||
#include <Ecore_Evas.h>
|
||||
#include <Edje.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/box.edj";
|
||||
|
||||
struct _App {
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *box;
|
||||
};
|
||||
|
||||
static struct _App app;
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\tShift - remove box\n"
|
||||
"\tCtrl - insert box\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static void
|
||||
custom_layout(Evas_Object *o, Evas_Object_Box_Data *p, void *data)
|
||||
custom_layout(Evas_Object *o, Evas_Object_Box_Data *p, void *data __UNUSED__)
|
||||
{
|
||||
Evas_Object_Box_Option *opt;
|
||||
Eina_List *l;
|
||||
int x, y, w, h;
|
||||
int xx, yy, ww, hh;
|
||||
int count;
|
||||
Eina_List *l;
|
||||
Evas_Object_Box_Option *opt;
|
||||
|
||||
evas_object_geometry_get(o, &x, &y, &w, &h);
|
||||
count = eina_list_count(p->children);
|
||||
|
@ -76,129 +71,177 @@ new_greenie_block(Evas *e)
|
|||
}
|
||||
|
||||
static void
|
||||
on_keydown(void *data, Evas *evas, Evas_Object *o, void *einfo)
|
||||
on_keydown(void *data, Evas *evas, Evas_Object *o __UNUSED__, void *einfo)
|
||||
{
|
||||
struct _App *app = data;
|
||||
Evas_Event_Key_Down *ev = einfo;
|
||||
Evas_Event_Key_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
const Evas_Modifier *mods;
|
||||
|
||||
ev = (Evas_Event_Key_Down *)einfo;
|
||||
edje_obj = (Evas_Object *)data;
|
||||
|
||||
mods = evas_key_modifier_get(evas);
|
||||
if (!strcmp(ev->keyname, "h"))
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
if (evas_key_modifier_is_set(mods, "Shift"))
|
||||
{
|
||||
int pos;
|
||||
Evas_Object *obj = NULL;
|
||||
pos = atoi(ev->keyname);
|
||||
obj = edje_object_part_box_remove_at(app->box, "example/box", pos);
|
||||
obj = edje_object_part_box_remove_at(edje_obj, "example/box", pos);
|
||||
if (obj)
|
||||
evas_object_del(obj);
|
||||
return;
|
||||
}
|
||||
if (evas_key_modifier_is_set(mods, "Control"))
|
||||
{
|
||||
Evas_Object *o;
|
||||
Evas_Object *obj;
|
||||
int pos;
|
||||
pos = atoi(ev->keyname);
|
||||
o = new_greenie_block(app->evas);
|
||||
if (!edje_object_part_box_insert_at(app->box, "example/box", o, pos))
|
||||
edje_object_part_box_append(app->box, "example/box", o);
|
||||
obj = new_greenie_block(evas);
|
||||
if (!edje_object_part_box_insert_at(edje_obj, "example/box", obj, pos))
|
||||
edje_object_part_box_append(edje_obj, "example/box", obj);
|
||||
return;
|
||||
}
|
||||
if (strcmp(ev->keyname, "Escape") == 0)
|
||||
if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
box_new(Evas *evas, const char *name, int x, int y, int w, int h)
|
||||
box_new(Ecore_Evas *ee, const char *edje_file_path, const char *name, int x, int y, int w, int h)
|
||||
{
|
||||
Evas_Object *o;
|
||||
Evas_Object *edje_obj;
|
||||
|
||||
o = edje_object_add(evas);
|
||||
evas_object_move(o, x, y);
|
||||
evas_object_resize(o, w, h);
|
||||
if (!edje_object_file_set(o, edje_file_path, "example/group2"))
|
||||
edje_obj = edje_object_add(ecore_evas_get(ee));
|
||||
evas_object_move(edje_obj, x, y);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
if (!edje_object_file_set(edje_obj, edje_file_path, "example/group2"))
|
||||
{
|
||||
printf("error: could not load file object.\n");
|
||||
}
|
||||
evas_object_show(o);
|
||||
evas_object_show(edje_obj);
|
||||
evas_object_name_set(edje_obj, name);
|
||||
ecore_evas_data_set(ee, "edje_obj", edje_obj);
|
||||
|
||||
evas_object_name_set(o, name);
|
||||
|
||||
return o;
|
||||
return edje_obj;
|
||||
}
|
||||
|
||||
static void
|
||||
on_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int w, h;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
evas_output_viewport_get(app.evas, NULL, NULL, &w, &h);
|
||||
evas_object_resize(app.bg, w, h);
|
||||
evas_object_resize(app.box, w, h);
|
||||
bg = ecore_evas_data_get(ee, "background");
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
on_destroy(Ecore_Evas *ee)
|
||||
on_destroy(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
int w, h, i;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "box.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object *last;
|
||||
Evas_Object *o;
|
||||
Eina_Prefix *pfx;
|
||||
int w;
|
||||
int h;
|
||||
int i;
|
||||
|
||||
evas_init();
|
||||
ecore_init();
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, 640, 480, NULL);
|
||||
ecore_evas_show(ee);
|
||||
|
||||
app.ee = ee;
|
||||
app.evas = ecore_evas_get(ee);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_resize_set(ee, on_resize);
|
||||
ecore_evas_callback_destroy_set(ee, on_destroy);
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
|
||||
evas_output_viewport_get(app.evas, NULL, NULL, &w, &h);
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
app.bg = evas_object_rectangle_add(app.evas);
|
||||
evas_object_resize(app.bg, w, h);
|
||||
evas_object_show(app.bg);
|
||||
evas_object_focus_set(app.bg, 1);
|
||||
evas_object_event_callback_add(
|
||||
app.bg, EVAS_CALLBACK_KEY_DOWN, on_keydown, &app);
|
||||
bg = evas_object_rectangle_add(evas);
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_show(bg);
|
||||
evas_object_focus_set(bg, 1);
|
||||
ecore_evas_data_set(ee, "background", bg);
|
||||
|
||||
edje_box_layout_register("custom_layout", custom_layout, NULL, NULL, NULL, NULL);
|
||||
|
||||
app.box = box_new(app.evas, "box", 0, 0, w, h);
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_obj = box_new(ee, edje_file_path, "box", 0, 0, w, h);
|
||||
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, on_keydown, edje_obj);
|
||||
|
||||
for (i = 1; i <= 5; i++)
|
||||
{
|
||||
o = last = evas_object_rectangle_add(app.evas);
|
||||
o = last = evas_object_rectangle_add(evas);
|
||||
evas_object_size_hint_min_set(o, 50, 50);
|
||||
evas_object_resize(o, 50, 50);
|
||||
evas_object_color_set(o, 255, 0, 0, 128);
|
||||
evas_object_show(o);
|
||||
|
||||
if (!edje_object_part_box_append(app.box, "example/box", o))
|
||||
if (!edje_object_part_box_append(edje_obj, "example/box", o))
|
||||
{
|
||||
fprintf(stderr, "error appending child object!\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
edje_shutdown();
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
ecore_shutdown();
|
||||
evas_shutdown();
|
||||
edje_shutdown();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
return 0;
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -23,13 +22,11 @@
|
|||
#define WIDTH (400)
|
||||
#define HEIGHT (400)
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/color-class.edj";
|
||||
|
||||
typedef int color[4]; /* rgba */
|
||||
|
||||
static Ecore_Evas *ee, *ee2;
|
||||
static Evas *evas, *evas2;
|
||||
static Evas_Object *bg, *edje_obj, *bg2, *edje_obj2;
|
||||
static Ecore_Evas *ee1, *ee2;
|
||||
static Evas *evas1, *evas2;
|
||||
static Evas_Object *bg1, *edje_obj1, *bg2, *edje_obj2;
|
||||
static const char *selected_class;
|
||||
|
||||
static color colors_init_data[] =
|
||||
|
@ -96,21 +93,23 @@ _color_classes_print(void)
|
|||
}
|
||||
|
||||
static void
|
||||
_on_destroy(Ecore_Evas *ee)
|
||||
_on_destroy(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static void
|
||||
_on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
||||
_on_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
|
||||
if (ev->button == 1)
|
||||
if (obj == edje_obj)
|
||||
edje_color_class_del(selected_class);
|
||||
else
|
||||
edje_object_color_class_del(edje_obj2, selected_class);
|
||||
{
|
||||
if (obj == edje_obj1)
|
||||
edje_color_class_del(selected_class);
|
||||
else
|
||||
edje_object_color_class_del(edje_obj2, selected_class);
|
||||
}
|
||||
}
|
||||
|
||||
/* here just to keep our example's window size
|
||||
|
@ -122,10 +121,10 @@ _canvas_resize_cb(Ecore_Evas *_ee)
|
|||
|
||||
ecore_evas_geometry_get(_ee, NULL, NULL, &w, &h);
|
||||
|
||||
if (_ee == ee)
|
||||
if (_ee == ee1)
|
||||
{
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
evas_object_resize(bg1, w, h);
|
||||
evas_object_resize(edje_obj1, w, h);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -135,8 +134,8 @@ _canvas_resize_cb(Ecore_Evas *_ee)
|
|||
}
|
||||
|
||||
static void
|
||||
_color_class_callback_delete(void *data, Evas *evas, Evas_Object *obj,
|
||||
const char *emission, void *source)
|
||||
_color_class_callback_delete(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
|
||||
const char *emission, void *source __UNUSED__)
|
||||
{
|
||||
if (!strcmp(data, "process"))
|
||||
fprintf(stdout, "Color class: %s deleted on process level\n", emission);
|
||||
|
@ -144,32 +143,34 @@ _color_class_callback_delete(void *data, Evas *evas, Evas_Object *obj,
|
|||
fprintf(stdout, "Color class: %s deleted on object level\n", emission);
|
||||
}
|
||||
|
||||
static void
|
||||
_create_windows(void)
|
||||
static int
|
||||
_create_windows(const char *edje_file_path)
|
||||
{
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
ee1 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee1)
|
||||
return 0;
|
||||
ee2 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee2)
|
||||
return 0;
|
||||
|
||||
ecore_evas_callback_destroy_set(ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
|
||||
ecore_evas_title_set(ee, "Edje Color Class Example");
|
||||
ecore_evas_show(ee);
|
||||
ecore_evas_callback_destroy_set(ee1, _on_destroy);
|
||||
ecore_evas_callback_resize_set(ee1, _canvas_resize_cb);
|
||||
ecore_evas_title_set(ee1, "Edje Color Class Example");
|
||||
|
||||
ecore_evas_callback_destroy_set(ee2, _on_destroy);
|
||||
ecore_evas_callback_resize_set(ee2, _canvas_resize_cb);
|
||||
ecore_evas_title_set(ee2, "Edje Object Color Class Example");
|
||||
ecore_evas_show(ee2);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
evas1 = ecore_evas_get(ee1);
|
||||
evas2 = ecore_evas_get(ee2);
|
||||
|
||||
bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
|
||||
evas_object_move(bg, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg);
|
||||
bg1 = evas_object_rectangle_add(evas1);
|
||||
evas_object_color_set(bg1, 255, 255, 255, 255); /* white bg */
|
||||
evas_object_move(bg1, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(bg1, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg1);
|
||||
|
||||
bg2 = evas_object_rectangle_add(evas2);
|
||||
evas_object_color_set(bg2, 255, 255, 255, 255); /* white bg */
|
||||
|
@ -177,18 +178,18 @@ _create_windows(void)
|
|||
evas_object_resize(bg2, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg2);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
edje_obj1 = edje_object_add(evas1);
|
||||
evas_object_event_callback_add(edje_obj1, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_on_mouse_down, NULL);
|
||||
|
||||
edje_object_file_set(edje_obj, edje_file_path, "example_color_class");
|
||||
evas_object_move(edje_obj, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(edje_obj, WIDTH, HEIGHT);
|
||||
edje_object_part_text_set(edje_obj, "part_four", "EDJE EXAMPLE");
|
||||
edje_object_signal_callback_add(edje_obj, "color_class,del", "*",
|
||||
edje_object_file_set(edje_obj1, edje_file_path, "example_color_class");
|
||||
evas_object_move(edje_obj1, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(edje_obj1, WIDTH, HEIGHT);
|
||||
edje_object_part_text_set(edje_obj1, "part_four", "EDJE EXAMPLE");
|
||||
edje_object_signal_callback_add(edje_obj1, "color_class,del", "*",
|
||||
(Edje_Signal_Cb) _color_class_callback_delete,
|
||||
"process");
|
||||
evas_object_show(edje_obj);
|
||||
evas_object_show(edje_obj1);
|
||||
|
||||
edje_obj2 = edje_object_add(evas2);
|
||||
evas_object_event_callback_add(edje_obj2, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
|
@ -202,13 +203,18 @@ _create_windows(void)
|
|||
(Edje_Signal_Cb) _color_class_callback_delete,
|
||||
"object");
|
||||
evas_object_show(edje_obj2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
color c1, c2, c3;
|
||||
int i;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "color-class.edj";
|
||||
Eina_Prefix *pfx;
|
||||
color c1, c2, c3;
|
||||
int i;
|
||||
|
||||
if (argc != 5)
|
||||
{
|
||||
|
@ -218,7 +224,7 @@ main(int argc, char *argv[])
|
|||
for (i = 0; i < 8; i++)
|
||||
fprintf(stderr, "%s\n", color_names[i]);
|
||||
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
selected_class = argv[1];
|
||||
|
@ -227,13 +233,30 @@ main(int argc, char *argv[])
|
|||
_get_color_from_name(argv[4], &c3)))
|
||||
{
|
||||
fprintf(stderr, "Color not available!\n");
|
||||
return 2;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
_create_windows();
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
if (!_create_windows(edje_file_path))
|
||||
goto free_prefix;
|
||||
|
||||
edje_color_class_set(argv[1], /* class name */
|
||||
c1[0], c1[1], c1[2], c1[3], /* Object color */
|
||||
|
@ -248,10 +271,25 @@ main(int argc, char *argv[])
|
|||
39, 90, 187, 255); /* Text shadow */
|
||||
|
||||
_color_classes_print();
|
||||
|
||||
ecore_evas_show(ee1);
|
||||
ecore_evas_show(ee2);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_free(ee2);
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee1);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -28,16 +27,18 @@
|
|||
|
||||
#define NRECTS 20
|
||||
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\tDdown - set drag step to 1\n"
|
||||
"\tUp - set drag step to -1\n"
|
||||
"\tm - set drag value to 0.5\n"
|
||||
"\tPrior - set drag page to -1\n"
|
||||
"\tNext - set drag page to -1\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static const char *PARTNAME = "example/knob";
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/drag.edj";
|
||||
|
||||
struct _App {
|
||||
Ecore_Evas *ee;
|
||||
Evas_Object *edje;
|
||||
Evas_Object *bg;
|
||||
};
|
||||
|
||||
static void
|
||||
_on_destroy(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
|
@ -47,111 +48,163 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
|
|||
/* here just to keep our example's window size and background image's
|
||||
* size in synchrony */
|
||||
static void
|
||||
_canvas_resize_cb(Ecore_Evas *ee)
|
||||
_on_canvas_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int w, h;
|
||||
struct _App *app = ecore_evas_data_get(ee, "app");
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
bg = ecore_evas_data_get(ee, "background");
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(app->bg, w, h);
|
||||
evas_object_resize(app->edje, w, h);
|
||||
evas_object_resize(bg, w, h);
|
||||
evas_object_resize(edje_obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
||||
_on_bg_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
|
||||
{
|
||||
struct _App *app = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
Evas_Object *rect;
|
||||
Eina_Bool r;
|
||||
Ecore_Evas *ee;
|
||||
Evas_Event_Key_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
|
||||
ee = (Ecore_Evas *)data;
|
||||
ev = (Evas_Event_Key_Down *)event_info;
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
|
||||
if (!strcmp(ev->keyname, "Down"))
|
||||
if (!strcmp(ev->keyname, "h"))
|
||||
{
|
||||
edje_object_part_drag_step(app->edje, PARTNAME, 0, 1.0);
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Down"))
|
||||
{
|
||||
edje_object_part_drag_step(edje_obj, PARTNAME, 0, 1.0);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Up"))
|
||||
{
|
||||
edje_object_part_drag_step(app->edje, PARTNAME, 0, -1.0);
|
||||
edje_object_part_drag_step(edje_obj, PARTNAME, 0, -1.0);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "m"))
|
||||
{
|
||||
edje_object_part_drag_value_set(app->edje, PARTNAME, 0.0, 0.5);
|
||||
edje_object_part_drag_value_set(edje_obj, PARTNAME, 0.0, 0.5);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Prior"))
|
||||
{
|
||||
edje_object_part_drag_page(app->edje, PARTNAME, 0.0, -1.0);
|
||||
edje_object_part_drag_page(edje_obj, PARTNAME, 0.0, -1.0);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Next"))
|
||||
{
|
||||
edje_object_part_drag_page(app->edje, PARTNAME, 0.0, 1.0);
|
||||
edje_object_part_drag_page(edje_obj, PARTNAME, 0.0, 1.0);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_knob_moved_cb(void *data, Evas_Object *o, const char *emission, const char *source)
|
||||
_on_knob_moved(void *data __UNUSED__, Evas_Object *o, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||
{
|
||||
double val;
|
||||
|
||||
edje_object_part_drag_value_get(o, PARTNAME, NULL, &val);
|
||||
printf("value changed to: %0.3f\n", val);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas *evas;
|
||||
struct _App app;
|
||||
int i;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "drag.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
app.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_destroy_set(app.ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(app.ee, _canvas_resize_cb);
|
||||
ecore_evas_title_set(app.ee, "Edje Box Example");
|
||||
ecore_evas_show(app.ee);
|
||||
ecore_evas_callback_destroy_set(ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(ee, _on_canvas_resize);
|
||||
ecore_evas_title_set(ee, "Edje Box Example");
|
||||
|
||||
ecore_evas_data_set(app.ee, "app", &app);
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
evas = ecore_evas_get(app.ee);
|
||||
bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(bg, 255, 255, 255, 255);
|
||||
evas_object_resize(bg, WIDTH, HEIGHT);
|
||||
evas_object_focus_set(bg, EINA_TRUE);
|
||||
evas_object_show(bg);
|
||||
ecore_evas_data_set(ee, "background", bg);
|
||||
|
||||
app.bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(app.bg, 255, 255, 255, 255);
|
||||
evas_object_resize(app.bg, WIDTH, HEIGHT);
|
||||
evas_object_focus_set(app.bg, EINA_TRUE);
|
||||
evas_object_show(app.bg);
|
||||
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee);
|
||||
|
||||
evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _bg_key_down, &app);
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
app.edje = edje_object_add(evas);
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(edje_obj, edje_file_path, "example/group");
|
||||
evas_object_move(edje_obj, 0, 0);
|
||||
evas_object_resize(edje_obj, WIDTH, HEIGHT);
|
||||
evas_object_show(edje_obj);
|
||||
ecore_evas_data_set(ee, "edje_obj", edje_obj);
|
||||
|
||||
edje_object_file_set(app.edje, edje_file_path, "example/group");
|
||||
evas_object_move(app.edje, 0, 0);
|
||||
evas_object_resize(app.edje, WIDTH, HEIGHT);
|
||||
evas_object_show(app.edje);
|
||||
edje_object_part_drag_size_set(edje_obj, PARTNAME, 1.0, 0.4);
|
||||
|
||||
edje_object_part_drag_size_set(app.edje, PARTNAME, 1.0, 0.4);
|
||||
|
||||
if (!edje_object_part_drag_step_set(app.edje, PARTNAME, 0.0, 0.1))
|
||||
if (!edje_object_part_drag_step_set(edje_obj, PARTNAME, 0.0, 0.1))
|
||||
printf("error when setting drag step size.\n");
|
||||
|
||||
if (!edje_object_part_drag_page_set(app.edje, PARTNAME, 0.0, 0.3))
|
||||
if (!edje_object_part_drag_page_set(edje_obj, PARTNAME, 0.0, 0.3))
|
||||
printf("error when setting drag page step size.\n");
|
||||
|
||||
edje_object_signal_callback_add(app.edje, "drag", PARTNAME, _knob_moved_cb, &app);
|
||||
edje_object_signal_callback_add(edje_obj, "drag", PARTNAME, _on_knob_moved, NULL);
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_evas_free(app.ee);
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -23,11 +22,21 @@
|
|||
#define WIDTH 480
|
||||
#define HEIGHT 320
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/perspective.edj";
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\tDown - move part down\n"
|
||||
"\tUp - move part up\n"
|
||||
"\tLeft - move part left\n"
|
||||
"\tRight - move part right\n"
|
||||
"\tPrior - move part up-left\n"
|
||||
"\tNext - move part down-right\n"
|
||||
"\tInsert - increase focal\n"
|
||||
"\tSuppr - decrease focal\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
struct _App {
|
||||
Ecore_Evas *ee;
|
||||
Evas_Object *edje;
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object *bg;
|
||||
Edje_Perspective *ps;
|
||||
Eina_Bool animating;
|
||||
|
@ -44,14 +53,14 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
|
|||
/* here just to keep our example's window size and background image's
|
||||
* size in synchrony */
|
||||
static void
|
||||
_canvas_resize_cb(Ecore_Evas *ee)
|
||||
_on_canvas_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int w, h;
|
||||
struct _App *app = ecore_evas_data_get(ee, "app");
|
||||
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(app->bg, w, h);
|
||||
evas_object_resize(app->edje, w, h);
|
||||
evas_object_resize(app->edje_obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -74,20 +83,24 @@ _part_move(struct _App *app, int dx, int dy)
|
|||
app->y = 0;
|
||||
|
||||
snprintf(emission, sizeof(emission), "move,%d,%d", app->x, app->y);
|
||||
edje_object_signal_emit(app->edje, emission, "");
|
||||
edje_object_signal_emit(app->edje_obj, emission, "");
|
||||
app->animating = EINA_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
||||
_on_bg_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
|
||||
{
|
||||
struct _App *app = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
|
||||
|
||||
if (!strcmp(ev->keyname, "h"))
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
// just moving the part and text
|
||||
if (!strcmp(ev->keyname, "Down"))
|
||||
else if (!strcmp(ev->keyname, "Down"))
|
||||
{
|
||||
_part_move(app, 0, 1);
|
||||
}
|
||||
|
@ -116,7 +129,7 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
|||
{
|
||||
app->focal += 5;
|
||||
edje_perspective_set(app->ps, 240, 160, 0, app->focal);
|
||||
edje_object_calc_force(app->edje);
|
||||
edje_object_calc_force(app->edje_obj);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "KP_Subtract"))
|
||||
{
|
||||
|
@ -125,13 +138,16 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
|
|||
app->focal = 5;
|
||||
|
||||
edje_perspective_set(app->ps, 240, 160, 0, app->focal);
|
||||
edje_object_calc_force(app->edje);
|
||||
edje_object_calc_force(app->edje_obj);
|
||||
}
|
||||
// exiting
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -143,16 +159,33 @@ _animation_end_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __
|
|||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas *evas;
|
||||
struct _App app;
|
||||
int i;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "perspective.edj";
|
||||
struct _App app;
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
edje_frametime_set(((double)1) / 60);
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
edje_frametime_set(1.0 / 60.0);
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
|
@ -160,16 +193,18 @@ main(void)
|
|||
app.x = 0;
|
||||
app.y = 0;
|
||||
app.focal = 50;
|
||||
app.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
|
||||
ecore_evas_callback_destroy_set(app.ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(app.ee, _canvas_resize_cb);
|
||||
ecore_evas_title_set(app.ee, "Edje Box Example");
|
||||
ecore_evas_show(app.ee);
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_data_set(app.ee, "app", &app);
|
||||
ecore_evas_callback_destroy_set(ee, _on_destroy);
|
||||
ecore_evas_callback_resize_set(ee, _on_canvas_resize);
|
||||
ecore_evas_title_set(ee, "Edje Box Example");
|
||||
|
||||
evas = ecore_evas_get(app.ee);
|
||||
ecore_evas_data_set(ee, "app", &app);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
app.bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(app.bg, 255, 255, 255, 255);
|
||||
|
@ -177,25 +212,42 @@ main(void)
|
|||
evas_object_focus_set(app.bg, EINA_TRUE);
|
||||
evas_object_show(app.bg);
|
||||
|
||||
evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _bg_key_down, &app);
|
||||
evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, &app);
|
||||
|
||||
app.edje = edje_object_add(evas);
|
||||
app.edje_obj = edje_object_add(evas);
|
||||
|
||||
edje_object_file_set(app.edje, edje_file_path, "example/group");
|
||||
evas_object_move(app.edje, 0, 0);
|
||||
evas_object_resize(app.edje, WIDTH, HEIGHT);
|
||||
evas_object_show(app.edje);
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(app.edje_obj, edje_file_path, "example/group");
|
||||
evas_object_move(app.edje_obj, 0, 0);
|
||||
evas_object_resize(app.edje_obj, WIDTH, HEIGHT);
|
||||
evas_object_show(app.edje_obj);
|
||||
|
||||
edje_object_signal_callback_add(app.edje, "animation,end", "", _animation_end_cb, &app);
|
||||
edje_object_signal_callback_add(app.edje_obj, "animation,end", "", _animation_end_cb, &app);
|
||||
|
||||
app.ps = edje_perspective_new(evas);
|
||||
edje_perspective_set(app.ps, 240, 160, 0, app.focal);
|
||||
edje_perspective_global_set(app.ps, EINA_TRUE);
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_evas_free(app.ee);
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -27,34 +27,32 @@
|
|||
#define MSG_COLOR 1
|
||||
#define MSG_TEXT 2
|
||||
|
||||
static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
|
||||
static const char *edje_file_path = \
|
||||
PACKAGE_EXAMPLES_DIR "/signals-messages.edj";
|
||||
|
||||
static Ecore_Evas *ee;
|
||||
static Evas_Object *edje_obj;
|
||||
static Eina_Bool right_rect_show = EINA_TRUE;
|
||||
|
||||
static const char *commands = \
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\tt - toggle right rectangle's visibility\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static Eina_Bool right_rect_show = EINA_TRUE;
|
||||
|
||||
static void
|
||||
_on_keydown(void *data __UNUSED__,
|
||||
_on_keydown(void *data,
|
||||
Evas *evas __UNUSED__,
|
||||
Evas_Object *o __UNUSED__,
|
||||
void *einfo)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = einfo;
|
||||
Evas_Event_Key_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
|
||||
if (strcmp(ev->keyname, "h") == 0) /* print help */
|
||||
ev = (Evas_Event_Key_Down *)einfo;
|
||||
edje_obj = (Evas_Object *)data;
|
||||
|
||||
if (!strcmp(ev->keyname, "h")) /* print help */
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "t") == 0) /* toggle right rectangle's visibility */
|
||||
else if (!strcmp(ev->keyname, "t")) /* toggle right rectangle's visibility */
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
@ -68,6 +66,13 @@ _on_keydown(void *data __UNUSED__,
|
|||
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -85,7 +90,7 @@ _sig_print(const char *emission,
|
|||
}
|
||||
|
||||
static void
|
||||
_mouse_wheel_cb(void *data __UNUSED__,
|
||||
_on_mouse_wheel(void *data __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
const char *emission,
|
||||
const char *source)
|
||||
|
@ -95,8 +100,8 @@ _mouse_wheel_cb(void *data __UNUSED__,
|
|||
|
||||
/* mouse over signals */
|
||||
static void
|
||||
_mouse_over_cb(void *data __UNUSED__,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
_on_mouse_over(void *data __UNUSED__,
|
||||
Evas_Object *edje_obj,
|
||||
const char *emission,
|
||||
const char *source)
|
||||
{
|
||||
|
@ -133,28 +138,43 @@ _message_handle(void *data __UNUSED__,
|
|||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas_Object *border, *bg;
|
||||
Evas *evas;
|
||||
|
||||
srand(time(NULL));
|
||||
char border_img_path[PATH_MAX];
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "signals-messages.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object *border;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
return EXIT_FAILURE;
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto error;
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete);
|
||||
ecore_evas_title_set(ee, "Edje Basics Example");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -163,14 +183,13 @@ main(void)
|
|||
evas_object_move(bg, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg);
|
||||
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
|
||||
|
||||
evas_object_focus_set(bg, EINA_TRUE);
|
||||
evas_object_event_callback_add(
|
||||
bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
|
||||
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
if (!edje_object_file_set(edje_obj, edje_file_path, "example_group"))
|
||||
{
|
||||
int err = edje_object_load_error_get(edje_obj);
|
||||
|
@ -179,14 +198,14 @@ main(void)
|
|||
"signals-messages.edj: %s\n", errmsg);
|
||||
|
||||
evas_object_del(edje_obj);
|
||||
goto error_edj;
|
||||
goto free_prefix;
|
||||
}
|
||||
|
||||
edje_object_signal_callback_add(edje_obj, "mouse,wheel,*", "part_left",
|
||||
_mouse_wheel_cb, NULL);
|
||||
_on_mouse_wheel, NULL);
|
||||
|
||||
edje_object_signal_callback_add(edje_obj, "mouse,over", "part_right",
|
||||
_mouse_over_cb, NULL);
|
||||
_on_mouse_over, NULL);
|
||||
|
||||
edje_object_message_handler_set(edje_obj, _message_handle, NULL);
|
||||
|
||||
|
@ -194,6 +213,11 @@ main(void)
|
|||
evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
|
||||
evas_object_show(edje_obj);
|
||||
|
||||
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj);
|
||||
|
||||
snprintf(border_img_path, sizeof(border_img_path),
|
||||
"%s/edje/examples/red.png", eina_prefix_data_get(pfx));
|
||||
|
||||
/* this is a border around the Edje object above, here just to
|
||||
* emphasize its geometry */
|
||||
border = evas_object_image_filled_add(evas);
|
||||
|
@ -207,24 +231,24 @@ main(void)
|
|||
evas_object_show(border);
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
error:
|
||||
fprintf(stderr, "You got to have at least one Evas engine built"
|
||||
" and linked up to ecore-evas for this example to run"
|
||||
" properly.\n");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
return -1;
|
||||
|
||||
error_edj:
|
||||
fprintf(stderr, "Failed to load signals-messages.edj!\n");
|
||||
|
||||
ecore_evas_shutdown();
|
||||
return -2;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -23,11 +22,6 @@
|
|||
#define WIDTH (300)
|
||||
#define HEIGHT (300)
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/swallow.edj";
|
||||
|
||||
static Ecore_Evas *ee;
|
||||
static Evas_Object *bg;
|
||||
|
||||
static void
|
||||
_on_delete(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
|
@ -37,31 +31,56 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
|
|||
/* here just to keep our example's window size and background image's
|
||||
* size in synchrony */
|
||||
static void
|
||||
_canvas_resize_cb(Ecore_Evas *ee)
|
||||
_on_canvas_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int w, h;
|
||||
Evas_Object *bg;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
bg = ecore_evas_data_get(ee, "background");
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
evas_object_resize(bg, w, h);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas_Object *edje_obj, *rect, *obj;
|
||||
Evas *evas;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "swallow.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *rect;
|
||||
Evas_Object *obj;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete);
|
||||
ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
|
||||
ecore_evas_callback_resize_set(ee, _on_canvas_resize);
|
||||
ecore_evas_title_set(ee, "Edje Swallow Example");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -70,9 +89,12 @@ main(void)
|
|||
evas_object_move(bg, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg);
|
||||
ecore_evas_data_set(ee, "background", bg);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(edje_obj, edje_file_path, "example_group");
|
||||
evas_object_move(edje_obj, 20, 20);
|
||||
evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
|
||||
|
@ -86,10 +108,23 @@ main(void)
|
|||
if(obj == rect)
|
||||
printf("Swallowing worked!\n");
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -23,12 +22,6 @@
|
|||
#define WIDTH (400)
|
||||
#define HEIGHT (400)
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/table.edj";
|
||||
|
||||
static Ecore_Evas *ee;
|
||||
static Evas *evas;
|
||||
static Evas_Object *bg, *edje_obj, *rects[4];
|
||||
|
||||
static void
|
||||
_on_delete(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
|
@ -38,7 +31,7 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
|
|||
/* Try to get the number of columns and rows of the table
|
||||
* and print them. */
|
||||
static void
|
||||
_columns_rows_print(void)
|
||||
_columns_rows_print(Evas_Object *edje_obj)
|
||||
{
|
||||
int cols, rows;
|
||||
|
||||
|
@ -52,10 +45,18 @@ _columns_rows_print(void)
|
|||
/* here just to keep our example's window size and table items
|
||||
* size in synchrony. */
|
||||
static void
|
||||
_canvas_resize_cb(Ecore_Evas *ee)
|
||||
_on_canvas_resize(Ecore_Evas *ee)
|
||||
{
|
||||
int i, w, h;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object **rects;
|
||||
int i;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
bg = ecore_evas_data_get(ee, "background");
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
rects = ecore_evas_data_get(ee, "rects");
|
||||
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
|
||||
|
||||
evas_object_resize(bg, w, h);
|
||||
|
@ -68,9 +69,13 @@ _canvas_resize_cb(Ecore_Evas *ee)
|
|||
/* Mouse button 1 = remove the clicked item
|
||||
* any other button = remove all items. */
|
||||
static void
|
||||
_on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
||||
_on_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
Evas_Event_Mouse_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
|
||||
ev = (Evas_Event_Mouse_Down *)event_info;
|
||||
edje_obj = (Evas_Object *)data;
|
||||
|
||||
if (ev->button != 1)
|
||||
edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE);
|
||||
|
@ -78,11 +83,11 @@ _on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|||
fprintf(stderr, "Cannot remove the selected rectangle\n");
|
||||
|
||||
evas_object_del(obj);
|
||||
_columns_rows_print();
|
||||
_columns_rows_print(edje_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_rects_create(void)
|
||||
_rects_create(Evas *evas, Evas_Object **rects, Evas_Object *edje_obj)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -93,26 +98,48 @@ _rects_create(void)
|
|||
evas_object_size_hint_weight_set(rects[i], 1.0, 1.0);
|
||||
evas_object_show(rects[i]);
|
||||
evas_object_event_callback_add(rects[i], EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_on_mouse_down, NULL);
|
||||
_on_mouse_down, edje_obj);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "table.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object *rects[4];
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete);
|
||||
ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
|
||||
ecore_evas_callback_resize_set(ee, _on_canvas_resize);
|
||||
ecore_evas_title_set(ee, "Edje Table Example");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -121,15 +148,20 @@ main(void)
|
|||
evas_object_move(bg, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
|
||||
evas_object_show(bg);
|
||||
ecore_evas_data_set(ee, "background", bg);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(edje_obj, edje_file_path, "example_table");
|
||||
evas_object_move(edje_obj, 0, 0); /* at canvas' origin */
|
||||
evas_object_resize(edje_obj, WIDTH, HEIGHT);
|
||||
evas_object_show(edje_obj);
|
||||
ecore_evas_data_set(ee, "edje_obj", edje_obj);
|
||||
|
||||
_rects_create();
|
||||
_rects_create(evas, rects, edje_obj);
|
||||
ecore_evas_data_set(ee, "rects", rects);
|
||||
|
||||
/* Colouring the rectangles */
|
||||
evas_object_color_set(rects[0], 255, 0, 0, 255);
|
||||
|
@ -154,12 +186,25 @@ main(void)
|
|||
1, 1, 1, 1))
|
||||
fprintf(stderr, "Cannot add the rectangle 4 to table\n");
|
||||
|
||||
_columns_rows_print();
|
||||
_columns_rows_print(edje_obj);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#define __UNUSED__
|
||||
# define __UNUSED__
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
|
@ -23,11 +22,6 @@
|
|||
#define WIDTH (300)
|
||||
#define HEIGHT (300)
|
||||
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/text.edj";
|
||||
|
||||
static Ecore_Evas *ee;
|
||||
static Evas_Object *bg;
|
||||
|
||||
static void
|
||||
_on_delete(Ecore_Evas *ee __UNUSED__)
|
||||
{
|
||||
|
@ -35,27 +29,47 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
|
|||
}
|
||||
|
||||
static void
|
||||
_cb(void *data, Evas_Object *obj, const char *part)
|
||||
_on_text_change(void *data __UNUSED__, Evas_Object *obj, const char *part)
|
||||
{
|
||||
printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part));
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas_Object *edje_obj, *rect, *obj;
|
||||
Evas *evas;
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "text.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
ecore_evas_init();
|
||||
edje_init();
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete);
|
||||
ecore_evas_title_set(ee, "Edje text Example");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -68,12 +82,14 @@ main(void)
|
|||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
edje_object_file_set(edje_obj, edje_file_path, "example_group");
|
||||
evas_object_move(edje_obj, 20, 20);
|
||||
evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
|
||||
evas_object_show(edje_obj);
|
||||
|
||||
edje_object_text_change_cb_set(edje_obj, _cb, NULL);
|
||||
edje_object_text_change_cb_set(edje_obj, _on_text_change, NULL);
|
||||
edje_object_part_text_set(edje_obj, "part_one", "one");
|
||||
edje_object_part_text_set(edje_obj, "part_two", "<b>two");
|
||||
|
||||
|
@ -83,10 +99,23 @@ main(void)
|
|||
edje_object_part_text_select_none(edje_obj, "part_two");
|
||||
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -13,35 +13,37 @@
|
|||
#define WIDTH (300)
|
||||
#define HEIGHT (300)
|
||||
|
||||
static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
|
||||
static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/sigtest.edj";
|
||||
|
||||
static Ecore_Evas *ee;
|
||||
static Evas_Object *edje_obj;
|
||||
|
||||
static const char commands[] = \
|
||||
"commands are:\n"
|
||||
"\te - change te edje base\n"
|
||||
"\tl - change to lua base\n"
|
||||
"\tm - send message\n"
|
||||
"\ts - send signal\n"
|
||||
"\tEsc - exit\n"
|
||||
"\th - print help\n";
|
||||
|
||||
static void
|
||||
_on_keydown(void *data __UNUSED__,
|
||||
_on_keydown(void *data,
|
||||
Evas *evas __UNUSED__,
|
||||
Evas_Object *o __UNUSED__,
|
||||
void *einfo)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = einfo;
|
||||
Ecore_Evas *ee;
|
||||
Evas_Event_Key_Down *ev;
|
||||
Evas_Object *edje_obj;
|
||||
char *edje_file_path;
|
||||
|
||||
if (strcmp(ev->keyname, "h") == 0)
|
||||
ee = (Ecore_Evas *)data;
|
||||
ev = (Evas_Event_Key_Down *)einfo;
|
||||
edje_obj = ecore_evas_data_get(ee, "edje_obj");
|
||||
edje_file_path = ecore_evas_data_get(ee, "file_path");
|
||||
|
||||
if (!strcmp(ev->keyname, "h"))
|
||||
{
|
||||
fprintf(stdout, commands);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "e") == 0)
|
||||
else if (!strcmp(ev->keyname, "e"))
|
||||
{
|
||||
if (!edje_object_file_set(edje_obj, edje_file_path, "plain/edje/group"))
|
||||
{
|
||||
|
@ -55,8 +57,7 @@ _on_keydown(void *data __UNUSED__,
|
|||
" file sigtest.edj with success!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "l") == 0)
|
||||
else if (!strcmp(ev->keyname, "l"))
|
||||
{
|
||||
if (!edje_object_file_set(edje_obj, edje_file_path, "lua_base"))
|
||||
{
|
||||
|
@ -70,8 +71,7 @@ _on_keydown(void *data __UNUSED__,
|
|||
" file sigtest.edj with success!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "m") == 0)
|
||||
else if (!strcmp(ev->keyname, "m"))
|
||||
{
|
||||
Edje_Message_String *msg = malloc(sizeof(*msg));
|
||||
|
||||
|
@ -82,8 +82,7 @@ _on_keydown(void *data __UNUSED__,
|
|||
fprintf(stdout, "C message sent\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->keyname, "s") == 0)
|
||||
else if (!strcmp(ev->keyname, "s"))
|
||||
{
|
||||
fprintf(stdout, "\n");
|
||||
edje_object_signal_emit(edje_obj, "C signal 1", "Csource");
|
||||
|
@ -91,10 +90,17 @@ _on_keydown(void *data __UNUSED__,
|
|||
fprintf(stdout, "C signal sent\n");
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
ecore_main_loop_quit();
|
||||
else
|
||||
{
|
||||
printf("unhandled key: %s\n", ev->keyname);
|
||||
fprintf(stdout, commands);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_on_message(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg)
|
||||
_on_message(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Edje_Message_Type type, int id, void *msg)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -207,7 +213,7 @@ _on_message(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *
|
|||
}
|
||||
|
||||
static void
|
||||
_on_signal(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
|
||||
_on_signal(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
|
||||
{
|
||||
fprintf(stdout, "C::signal sig=|%s| src=|%s|\n", emission, source);
|
||||
}
|
||||
|
@ -219,26 +225,43 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
|
|||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc __UNUSED__, char *argv[])
|
||||
{
|
||||
Evas_Object *border, *bg;
|
||||
Evas *evas;
|
||||
char border_img_path[PATH_MAX];
|
||||
char edje_file_path[PATH_MAX];
|
||||
const char *edje_file = "sigtest.edj";
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *border;
|
||||
Evas_Object *edje_obj;
|
||||
Eina_Prefix *pfx;
|
||||
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!edje_init())
|
||||
return EXIT_FAILURE;
|
||||
goto shutdown_ecore_evas;
|
||||
|
||||
pfx = eina_prefix_new(argv[0], main,
|
||||
"EDJE_EXAMPLES",
|
||||
"edje/examples",
|
||||
edje_file,
|
||||
PACKAGE_BIN_DIR,
|
||||
PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR,
|
||||
PACKAGE_DATA_DIR);
|
||||
if (!pfx)
|
||||
goto shutdown_edje;
|
||||
|
||||
/* this will give you a window with an Evas canvas under the first
|
||||
* engine available */
|
||||
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!ee)
|
||||
goto error;
|
||||
goto free_prefix;
|
||||
|
||||
ecore_evas_callback_delete_request_set(ee, _on_delete);
|
||||
ecore_evas_title_set(ee, "Signals and wessages tester");
|
||||
ecore_evas_show(ee);
|
||||
|
||||
evas = ecore_evas_get(ee);
|
||||
|
||||
|
@ -250,14 +273,14 @@ main(void)
|
|||
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
|
||||
|
||||
evas_object_focus_set(bg, EINA_TRUE);
|
||||
evas_object_event_callback_add(
|
||||
bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
|
||||
|
||||
edje_obj = edje_object_add(evas);
|
||||
|
||||
edje_object_message_handler_set(edje_obj, _on_message, NULL);
|
||||
edje_object_signal_callback_add(edje_obj, "*", "*", _on_signal, NULL);
|
||||
|
||||
snprintf(edje_file_path, sizeof(edje_file_path),
|
||||
"%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
|
||||
if (!edje_object_file_set(edje_obj, edje_file_path, "lua_base"))
|
||||
{
|
||||
int err = edje_object_load_error_get(edje_obj);
|
||||
|
@ -266,7 +289,7 @@ main(void)
|
|||
errmsg);
|
||||
|
||||
evas_object_del(edje_obj);
|
||||
goto error_edj;
|
||||
goto free_prefix;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Loaded Edje object bound to group 'lua_base' from"
|
||||
|
@ -275,6 +298,13 @@ main(void)
|
|||
evas_object_move(edje_obj, 20, 20);
|
||||
evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
|
||||
evas_object_show(edje_obj);
|
||||
ecore_evas_data_set(ee, "edje_obj", edje_obj);
|
||||
ecore_evas_data_set(ee, "file_path", edje_file_path);
|
||||
|
||||
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, ee);
|
||||
|
||||
snprintf(border_img_path, sizeof(border_img_path),
|
||||
"%s/edje/examples/red.png", eina_prefix_data_get(pfx));
|
||||
|
||||
/* this is a border around the Edje object above, here just to
|
||||
* emphasize its geometry */
|
||||
|
@ -287,23 +317,25 @@ main(void)
|
|||
evas_object_move(border, 20 - 2, 20 - 2);
|
||||
evas_object_show(border);
|
||||
|
||||
fprintf(stdout, commands);
|
||||
|
||||
ecore_evas_show(ee);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_prefix_free(pfx);
|
||||
ecore_evas_free(ee);
|
||||
ecore_evas_shutdown();
|
||||
edje_shutdown();
|
||||
return 0;
|
||||
|
||||
error:
|
||||
fprintf(stderr, "You got to have at least one evas engine built"
|
||||
" and linked up to ecore-evas for this example to run"
|
||||
" properly.\n");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
free_prefix:
|
||||
eina_prefix_free(pfx);
|
||||
shutdown_edje:
|
||||
edje_shutdown();
|
||||
shutdown_ecore_evas:
|
||||
ecore_evas_shutdown();
|
||||
return -1;
|
||||
|
||||
error_edj:
|
||||
fprintf(stderr, "Failed to load sigtest.edj!\n");
|
||||
|
||||
ecore_evas_shutdown();
|
||||
return -2;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue