forked from enlightenment/efl
evas: add example to test transparent background
Summary: Reviewers: raster, devilhorns, cedric Subscribers: capOM, cedric Differential Revision: https://phab.enlightenment.org/D1228 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
9e8ece571b
commit
23892343cc
|
@ -167,6 +167,11 @@ evas_table_SOURCES = evas-table.c
|
|||
evas_table_LDADD = $(ECORE_EVAS_COMMON_LDADD)
|
||||
evas_table_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS += evas_transparent
|
||||
evas_transparent_SOURCES = evas-transparent.c
|
||||
evas_transparent_LDADD = $(ECORE_EVAS_COMMON_LDADD)
|
||||
evas_transparent_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS += evas_multi_touch
|
||||
evas_multi_touch_SOURCES = evas-multi-touch.c
|
||||
evas_multi_touch_LDADD = $(ECORE_EVAS_COMMON_LDADD)
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* Simple Evas example illustrating a trasnparent window
|
||||
*
|
||||
* @verbatim
|
||||
* gcc -o evas-transparent evas-transparent.c `pkg-config --libs --cflags evas ecore ecore-evas eina`
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#else
|
||||
#define PACKAGE_EXAMPLES_DIR "."
|
||||
#endif
|
||||
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_Evas.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define WIDTH (640)
|
||||
#define HEIGHT (480)
|
||||
|
||||
static const char *commands = \
|
||||
"commands are:\n"
|
||||
"\tn - turn on alpha"
|
||||
"\tm - turn off alpha"
|
||||
"\th - print help\n";
|
||||
|
||||
struct exemple_data
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *bg;
|
||||
};
|
||||
|
||||
static struct exemple_data d;
|
||||
|
||||
static void
|
||||
_on_keydown(void *data EINA_UNUSED,
|
||||
Evas *evas EINA_UNUSED,
|
||||
Evas_Object *o EINA_UNUSED,
|
||||
void *einfo)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = einfo;
|
||||
|
||||
if (strcmp(ev->key, "h") == 0) /* print help */
|
||||
{
|
||||
fprintf(stdout, "%s", commands);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->key, "n") == 0)
|
||||
{
|
||||
ecore_evas_alpha_set(d.ee, EINA_TRUE);
|
||||
|
||||
fprintf(stdout, "turn on alpha\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ev->key, "m") == 0)
|
||||
{
|
||||
ecore_evas_alpha_set(d.ee, EINA_FALSE);
|
||||
|
||||
fprintf(stdout, "turn off alpha\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_on_delete(Ecore_Evas *ee EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
if (!ecore_evas_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
|
||||
if (!d.ee)
|
||||
goto panic;
|
||||
|
||||
ecore_evas_callback_delete_request_set(d.ee, _on_delete);
|
||||
ecore_evas_show(d.ee);
|
||||
|
||||
d.evas = ecore_evas_get(d.ee);
|
||||
|
||||
d.bg = evas_object_rectangle_add(d.evas);
|
||||
evas_object_color_set(d.bg, 0, 0, 0, 0);
|
||||
evas_object_show(d.bg);
|
||||
|
||||
evas_object_focus_set(d.bg, EINA_TRUE);
|
||||
evas_object_event_callback_add(d.bg, EVAS_CALLBACK_KEY_DOWN,
|
||||
_on_keydown, NULL);
|
||||
ecore_main_loop_begin();
|
||||
ecore_evas_shutdown();
|
||||
return 0;
|
||||
|
||||
panic:
|
||||
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 -2;
|
||||
}
|
||||
|
Loading…
Reference in New Issue