forked from enlightenment/efl
more on the new evas test. add some more api calls.
SVN revision: 3544
This commit is contained in:
parent
e5f8c61ec8
commit
faa90fe44b
|
@ -63,6 +63,7 @@ struct _Evas
|
|||
Drawable drawable;
|
||||
Visual *visual;
|
||||
Colormap colormap;
|
||||
int created_window;
|
||||
int screen;
|
||||
int colors;
|
||||
Imlib_Image image;
|
||||
|
@ -167,6 +168,7 @@ struct _Evas_Object_Any
|
|||
|
||||
Evas_Render_Data renderer_data;
|
||||
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct _Evas_Object_Image
|
||||
|
@ -237,8 +239,20 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* create and destroy */
|
||||
Evas evas_new(void);
|
||||
void evas_free(Evas e);
|
||||
Evas evas_new_all(Display *display, Window parent_window,
|
||||
int x, int y, int w, int h,
|
||||
Evas_Render_Method render_method,
|
||||
int colors, int font_cache, int image_cache,
|
||||
char *font_dir);
|
||||
Window evas_get_window(Evas e);
|
||||
Display *evas_get_display(Evas e);
|
||||
Visual *evas_get_visual(Evas e);
|
||||
Colormap evas_get_colormap(Evas e);
|
||||
int evas_get_colors(Evas e);
|
||||
Imlib_Image evas_get_image(Evas e);
|
||||
Evas_Render_Method evas_get_render_method(Evas e);
|
||||
Evas evas_new(void);
|
||||
void evas_free(Evas e);
|
||||
|
||||
/* for exposes or forced redraws (relative to output drawable) */
|
||||
void evas_update_rect(Evas e, int x, int y, int w, int h);
|
||||
|
@ -323,7 +337,10 @@ Evas_List evas_objects_in_rect(Evas e, double x, double y, double w, double h);
|
|||
Evas_List evas_objects_at_position(Evas e, double x, double y);
|
||||
Evas_Object evas_object_in_rect(Evas e, double x, double y, double w, double h);
|
||||
Evas_Object evas_object_at_position(Evas e, double x, double y);
|
||||
|
||||
Evas_Object evas_object_get_named(Evas e, char *name);
|
||||
void evas_object_set_name(Evas e, Evas_Object o, char *name);
|
||||
char *evas_object_get_name(Evas e, Evas_Object o);
|
||||
|
||||
/* object visibility */
|
||||
void evas_show(Evas e, Evas_Object o);
|
||||
void evas_hide(Evas e, Evas_Object o);
|
||||
|
|
|
@ -119,10 +119,15 @@ evas_event_move(Evas e, int x, int y)
|
|||
{
|
||||
if (e->mouse.object)
|
||||
{
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
if (!e->mouse.button_object)
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_OUT,
|
||||
{
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_OUT,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
}
|
||||
else
|
||||
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
}
|
||||
e->mouse.x = x;
|
||||
|
@ -131,16 +136,21 @@ evas_event_move(Evas e, int x, int y)
|
|||
if (e->mouse.object)
|
||||
{
|
||||
if (!e->mouse.button_object)
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_IN,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
{
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_IN,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
e->mouse.x = x;
|
||||
e->mouse.y = y;
|
||||
if (e->mouse.object)
|
||||
if (e->mouse.button_object)
|
||||
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
else if (e->mouse.object)
|
||||
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
||||
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,88 @@
|
|||
|
||||
void _evas_layer_free(Evas e, Evas_Layer layer);
|
||||
|
||||
Evas
|
||||
evas_new_all(Display *display, Window parent_window,
|
||||
int x, int y, int w, int h,
|
||||
Evas_Render_Method render_method,
|
||||
int colors, int font_cache, int image_cache,
|
||||
char *font_dir)
|
||||
{
|
||||
Evas e;
|
||||
Window window;
|
||||
XSetWindowAttributes att;
|
||||
Visual *visual;
|
||||
Colormap colormap;
|
||||
|
||||
e = evas_new();
|
||||
e->current.created_window = 1;
|
||||
evas_set_output_method(e, render_method);
|
||||
evas_set_output_colors(e, colors);
|
||||
visual = evas_get_optimal_visual(e, display);
|
||||
colormap = evas_get_optimal_colormap(e, display);
|
||||
att.background_pixmap = None;
|
||||
att.colormap = colormap;
|
||||
att.border_pixel = 0;
|
||||
att.event_mask = 0;
|
||||
window = XCreateWindow(display,
|
||||
parent_window,
|
||||
x, y, w, h, 0,
|
||||
imlib_get_visual_depth(display, visual),
|
||||
InputOutput,
|
||||
visual,
|
||||
CWColormap | CWBorderPixel | CWEventMask | CWBackPixmap,
|
||||
&att);
|
||||
if (font_dir) evas_font_add_path(e, font_dir);
|
||||
evas_set_output(e, display, window, visual, colormap);
|
||||
evas_set_output_size(e, w, h);
|
||||
evas_set_output_viewport(e, 0, 0, w, h);
|
||||
evas_set_font_cache(e, font_cache);
|
||||
evas_set_image_cache(e, image_cache);
|
||||
return e;
|
||||
}
|
||||
|
||||
Window
|
||||
evas_get_window(Evas e)
|
||||
{
|
||||
return e->current.drawable;
|
||||
}
|
||||
|
||||
Display *
|
||||
evas_get_display(Evas e)
|
||||
{
|
||||
return e->current.display;
|
||||
}
|
||||
|
||||
Visual *
|
||||
evas_get_visual(Evas e)
|
||||
{
|
||||
return e->current.visual;
|
||||
}
|
||||
|
||||
Colormap
|
||||
evas_get_colormap(Evas e)
|
||||
{
|
||||
return e->current.colormap;
|
||||
}
|
||||
|
||||
int
|
||||
evas_get_colors(Evas e)
|
||||
{
|
||||
return e->current.colors;
|
||||
}
|
||||
|
||||
Imlib_Image
|
||||
evas_get_image(Evas e)
|
||||
{
|
||||
return e->current.image;
|
||||
}
|
||||
|
||||
Evas_Render_Method
|
||||
evas_get_render_method(Evas e)
|
||||
{
|
||||
return e->current.render_method;
|
||||
}
|
||||
|
||||
Evas
|
||||
evas_new(void)
|
||||
{
|
||||
|
@ -30,7 +112,9 @@ void
|
|||
evas_free(Evas e)
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
|
||||
if (e->current.created_window)
|
||||
XDestroyWindow(e->current.display, e->current.drawable);
|
||||
for (l = e->layers; l; l = l->next)
|
||||
{
|
||||
Evas_Layer layer;
|
||||
|
|
|
@ -78,6 +78,7 @@ _evas_real_del_object(Evas e, Evas_Object o)
|
|||
_evas_callback_call(e, o, CALLBACK_FREE, 0, 0, 0);
|
||||
_evas_remove_callbacks(e, o);
|
||||
_evas_remove_data(e, o);
|
||||
if (o->name) free(o->name);
|
||||
o->object_renderer_data_free(e, o);
|
||||
o->object_free(o);
|
||||
return;
|
||||
|
@ -447,3 +448,40 @@ evas_hide(Evas e, Evas_Object o)
|
|||
if (_evas_point_in_object(e, o, e->mouse.x, e->mouse.y))
|
||||
evas_event_move(e, e->mouse.x, e->mouse.y);
|
||||
}
|
||||
|
||||
Evas_Object
|
||||
evas_object_get_named(Evas e, char *name)
|
||||
{
|
||||
Evas_List l, ll;
|
||||
Evas_Layer layer;
|
||||
Evas_Object o;
|
||||
|
||||
if (!e) return NULL;
|
||||
if (!name) return NULL;
|
||||
for (l = e->layers; l ; l = l->next)
|
||||
{
|
||||
layer = l->data;
|
||||
|
||||
for (ll = layer->objects; ll; ll = ll->next)
|
||||
{
|
||||
o = ll->data;
|
||||
if ((o->name) && (!strcmp(name, o->name))) return o;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
evas_object_set_name(Evas e, Evas_Object o, char *name)
|
||||
{
|
||||
if (o->name) free(o->name);
|
||||
o->name = NULL;
|
||||
if (name)
|
||||
o->name = strdup(name);
|
||||
}
|
||||
|
||||
char *
|
||||
evas_object_get_name(Evas e, Evas_Object o)
|
||||
{
|
||||
return o->name;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "../src/Evas.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -17,7 +18,8 @@ Colormap cmap_control = 0, cmap_view = 0;
|
|||
Evas evas_control = NULL, evas_view = NULL;
|
||||
int wait_for_events = 1;
|
||||
|
||||
Evas_Object o_logo, o_logo_shadow, o_software, o_hardware, o_x11;
|
||||
Evas_Object o_logo, o_logo_shadow, o_software, o_hardware, o_x11, o_box1,
|
||||
o_box2, o_box3, o_brush, o_paint;
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
/* prototypes */
|
||||
|
@ -48,15 +50,11 @@ void
|
|||
setup(void)
|
||||
{
|
||||
XSetWindowAttributes att;
|
||||
XSizeHints hnt;
|
||||
XClassHint *xch;
|
||||
|
||||
display = XOpenDisplay(NULL);
|
||||
|
||||
evas_control = evas_new();
|
||||
evas_set_output_method(evas_control, RENDER_METHOD_ALPHA_SOFTWARE);
|
||||
evas_set_output_colors(evas_control, 216);
|
||||
vis_control = evas_get_optimal_visual(evas_control, display);
|
||||
cmap_control = evas_get_optimal_colormap(evas_control, display);
|
||||
|
||||
att.background_pixel = 0;
|
||||
att.colormap = cmap_control;
|
||||
att.border_pixel = 0;
|
||||
|
@ -64,31 +62,34 @@ setup(void)
|
|||
win_base = XCreateWindow(display,
|
||||
RootWindow(display, DefaultScreen(display)),
|
||||
0, 0, 1024, 768, 0,
|
||||
imlib_get_visual_depth(display, vis_control),
|
||||
DefaultDepth(display, DefaultScreen(display)),
|
||||
InputOutput,
|
||||
vis_control,
|
||||
DefaultVisual(display, DefaultScreen(display)),
|
||||
CWColormap | CWBorderPixel | CWEventMask | CWBackPixel,
|
||||
&att);
|
||||
att.background_pixmap = None;
|
||||
att.colormap = cmap_control;
|
||||
att.border_pixel = 0;
|
||||
att.event_mask = 0;
|
||||
win_control = XCreateWindow(display,
|
||||
win_base,
|
||||
0, 0, 128, 768, 0,
|
||||
imlib_get_visual_depth(display, vis_control),
|
||||
InputOutput,
|
||||
vis_control,
|
||||
CWColormap | CWBorderPixel | CWEventMask | CWBackPixmap,
|
||||
&att);
|
||||
XStoreName(display, win_base, "Evas Test Program");
|
||||
hnt.flags = USSize | PSize | PMinSize | PMaxSize;
|
||||
hnt.width = 1024;
|
||||
hnt.height = 768;
|
||||
hnt.min_width = 1024;
|
||||
hnt.max_width = 1024;
|
||||
hnt.min_height = 768;
|
||||
hnt.max_height = 768;
|
||||
XSetWMNormalHints(display, win_base, &hnt);
|
||||
xch = XAllocClassHint();
|
||||
xch->res_name = "Main";
|
||||
xch->res_class = "Evas_Test";
|
||||
XSetClassHint(display, win_base, xch);
|
||||
XFree(xch);
|
||||
|
||||
evas_control = evas_new_all(display, win_base, 0, 0, 128,768,
|
||||
RENDER_METHOD_ALPHA_SOFTWARE, 216,
|
||||
1 * 1024 * 1024, 8 * 1024 * 1024,
|
||||
FNTDIR);
|
||||
win_control = evas_get_window(evas_control);
|
||||
|
||||
XSelectInput(display, win_control, ButtonPressMask |
|
||||
ButtonReleaseMask | PointerMotionMask | ExposureMask);
|
||||
evas_font_add_path(evas_control, FNTDIR);
|
||||
evas_set_output(evas_control, display, win_control, vis_control, cmap_control);
|
||||
evas_set_output_size(evas_control, 128, 768);
|
||||
evas_set_output_viewport(evas_control, 0, 0, 128, 768);
|
||||
evas_set_font_cache(evas_control, 1 * 1024 * 1024);
|
||||
evas_set_image_cache(evas_control, 8 * 1024 * 1024);
|
||||
|
||||
XMapWindow(display, win_control);
|
||||
XMapWindow(display, win_base);
|
||||
|
@ -105,6 +106,7 @@ setup_controls(void)
|
|||
double ascent, descent;
|
||||
|
||||
e = evas_control;
|
||||
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_control_bg.png");
|
||||
evas_move(e, o, 0, 0);
|
||||
evas_resize(e, o, 128, 768);
|
||||
|
@ -112,9 +114,24 @@ setup_controls(void)
|
|||
evas_set_layer(e, o, -999);
|
||||
evas_show(e, o);
|
||||
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_control_selection1.png");
|
||||
evas_set_image_border(e, o, 3, 3, 3, 3);
|
||||
evas_show(e, o);
|
||||
o_box1 = o;
|
||||
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_control_selection1.png");
|
||||
evas_set_image_border(e, o, 3, 3, 3, 3);
|
||||
evas_show(e, o);
|
||||
o_box2 = o;
|
||||
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_control_selection1.png");
|
||||
evas_set_image_border(e, o, 3, 3, 3, 3);
|
||||
evas_show(e, o);
|
||||
o_box3 = o;
|
||||
|
||||
o = evas_add_text(e, "notepad", 16, "Software");
|
||||
evas_set_color(e, o, 255, 255, 255, 160);
|
||||
evas_move(e, o, 4, 4);
|
||||
evas_set_color(e, o, 0, 0, 0, 160);
|
||||
evas_move(e, o, 8, 44);
|
||||
evas_show(e, o);
|
||||
evas_text_get_max_ascent_descent(e, o, &ascent, &descent);
|
||||
evas_callback_add(e, o, CALLBACK_MOUSE_DOWN, mouse_down, NULL);
|
||||
|
@ -122,10 +139,13 @@ setup_controls(void)
|
|||
evas_callback_add(e, o, CALLBACK_MOUSE_IN, mouse_in, NULL);
|
||||
evas_callback_add(e, o, CALLBACK_MOUSE_OUT, mouse_out, NULL);
|
||||
o_software = o;
|
||||
evas_move(e, o_box1, 4, 42);
|
||||
evas_resize(e, o_box1, 114, ascent - descent + 4);
|
||||
evas_set_image_fill(e, o_box1, 0, 0, 114, ascent - descent + 4);
|
||||
|
||||
o = evas_add_text(e, "notepad", 16, "Hardware");
|
||||
evas_set_color(e, o, 255, 255, 255, 160);
|
||||
evas_move(e, o, 4, 4 + (ascent - descent));
|
||||
evas_set_color(e, o, 0, 0, 0, 160);
|
||||
evas_move(e, o, 8, 44 + 8 + (ascent - descent));
|
||||
evas_show(e, o);
|
||||
evas_text_get_max_ascent_descent(e, o, &ascent, &descent);
|
||||
evas_callback_add(e, o, CALLBACK_MOUSE_DOWN, mouse_down, NULL);
|
||||
|
@ -133,10 +153,13 @@ setup_controls(void)
|
|||
evas_callback_add(e, o, CALLBACK_MOUSE_IN, mouse_in, NULL);
|
||||
evas_callback_add(e, o, CALLBACK_MOUSE_OUT, mouse_out, NULL);
|
||||
o_hardware = o;
|
||||
evas_move(e, o_box2, 4, 42 + 8 + (ascent - descent));
|
||||
evas_resize(e, o_box2, 114, ascent - descent + 4);
|
||||
evas_set_image_fill(e, o_box2, 0, 0, 114, ascent - descent + 4);
|
||||
|
||||
o = evas_add_text(e, "notepad", 16, "Basic X11");
|
||||
evas_set_color(e, o, 255, 255, 255, 160);
|
||||
evas_move(e, o, 4, 4 + ((ascent - descent) * 2));
|
||||
evas_set_color(e, o, 0, 0, 0, 160);
|
||||
evas_move(e, o, 8, 44 + 16 + ((ascent - descent) * 2));
|
||||
evas_show(e, o);
|
||||
evas_text_get_max_ascent_descent(e, o, &ascent, &descent);
|
||||
evas_callback_add(e, o, CALLBACK_MOUSE_DOWN, mouse_down, NULL);
|
||||
|
@ -144,6 +167,9 @@ setup_controls(void)
|
|||
evas_callback_add(e, o, CALLBACK_MOUSE_IN, mouse_in, NULL);
|
||||
evas_callback_add(e, o, CALLBACK_MOUSE_OUT, mouse_out, NULL);
|
||||
o_x11 = o;
|
||||
evas_move(e, o_box3, 4, 42 + 16 + ((ascent - descent) * 2));
|
||||
evas_resize(e, o_box3, 114, ascent - descent + 4);
|
||||
evas_set_image_fill(e, o_box3, 0, 0, 114, ascent - descent + 4);
|
||||
|
||||
}
|
||||
|
||||
|
@ -156,38 +182,21 @@ setup_view(Evas_Render_Method method)
|
|||
int w, h;
|
||||
double x, y;
|
||||
|
||||
if (win_view) XDestroyWindow(display, win_view);
|
||||
evas_view = evas_new();
|
||||
evas_set_output_method(evas_view, method);
|
||||
e = evas_new_all(display, win_base, 128, 0, 1024 - 128, 768,
|
||||
method, 216, 1 * 1024 * 1024, 8 * 1024 * 1024,
|
||||
FNTDIR);
|
||||
/*
|
||||
if (method == RENDER_METHOD_BASIC_HARDWARE)
|
||||
evas_set_scale_smoothness(evas_view, 0);
|
||||
evas_set_output_colors(evas_view, 216);
|
||||
vis_view = evas_get_optimal_visual(evas_view, display);
|
||||
cmap_view = evas_get_optimal_colormap(evas_view, display);
|
||||
|
||||
att.background_pixmap = None;
|
||||
att.colormap = cmap_view;
|
||||
att.border_pixel = 0;
|
||||
att.event_mask = 0;
|
||||
win_view = XCreateWindow(display,
|
||||
win_base,
|
||||
128, 0, 1024 - 128, 768, 0,
|
||||
imlib_get_visual_depth(display, vis_view),
|
||||
InputOutput,
|
||||
vis_view,
|
||||
CWColormap | CWBorderPixel | CWEventMask | CWBackPixmap,
|
||||
&att);
|
||||
XMapWindow(display, win_view);
|
||||
|
||||
evas_set_scale_smoothness(e, 0);
|
||||
else
|
||||
*/
|
||||
evas_set_scale_smoothness(e, 1);
|
||||
win_view = evas_get_window(e);
|
||||
XSelectInput(display, win_view, ButtonPressMask |
|
||||
ButtonReleaseMask | PointerMotionMask | ExposureMask);
|
||||
|
||||
evas_font_add_path(evas_view, FNTDIR);
|
||||
evas_set_output(evas_view, display, win_view, vis_view, cmap_view);
|
||||
evas_set_output_size(evas_view, 1024 - 128, 768);
|
||||
evas_set_output_viewport(evas_view, 0, 0, 1024 - 128, 768);
|
||||
evas_set_font_cache(evas_view, 1 * 1024 * 1024);
|
||||
evas_set_image_cache(evas_view, 8 * 1024 * 1024);
|
||||
XMapWindow(display, win_view);
|
||||
if (evas_view) evas_free(evas_view);
|
||||
evas_view = e;
|
||||
|
||||
e = evas_view;
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_view_bg.png");
|
||||
|
@ -211,6 +220,22 @@ setup_view(Evas_Render_Method method)
|
|||
evas_set_layer(e, o, 100);
|
||||
evas_show(e, o);
|
||||
o_logo_shadow = o;
|
||||
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_view_logo_image_paint.png");
|
||||
evas_get_image_size(e, o, &w, &h);
|
||||
x = (1024 - 128 - w) / 2; y = (768 - h) / 2;
|
||||
evas_move(e, o, 0, 0);
|
||||
evas_set_layer(e, o, 98);
|
||||
evas_show(e, o);
|
||||
o_paint = o;
|
||||
|
||||
o = evas_add_image_from_file(e, IMGDIR"evas_test_view_logo_image_brush.png");
|
||||
evas_get_image_size(e, o, &w, &h);
|
||||
x = (1024 - 128 - w) / 2; y = (768 - h) / 2;
|
||||
evas_move(e, o, 0, 0);
|
||||
evas_set_layer(e, o, 99);
|
||||
evas_show(e, o);
|
||||
o_brush = o;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -220,12 +245,98 @@ animate(double val)
|
|||
int w, h;
|
||||
|
||||
evas_get_image_size(evas_view, o_logo, &w, &h);
|
||||
x = ((1024 - 128) / 2) + (256 * cos((val * 3.141592654 * 2 / 100) * 27));
|
||||
y = (768 / 2) + (256 * sin((val * 3.141592654 * 2 / 100) * 16));
|
||||
if (val < 20)
|
||||
{
|
||||
x = ((1024 - 128) / 2) + ((((20 - val) * 256) / 20) * cos((val * 3.141592654 * 2 / 100) * 27));
|
||||
y = (768 / 2) + ((((20 - val) * 256) / 20) * sin((val * 3.141592654 * 2 / 100) * 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
x = ((1024 - 128) / 2);
|
||||
y = (768 / 2);
|
||||
wait_for_events = 1;
|
||||
}
|
||||
evas_move(evas_view, o_logo, x - (w / 2), y - (h / 2));
|
||||
evas_move(evas_view, o_logo_shadow,
|
||||
x - (w / 2) - ((mouse_x - x) / 16),
|
||||
y - (h / 2) - ((mouse_y - y) / 16));
|
||||
if (val < 8)
|
||||
{
|
||||
evas_get_image_size(evas_view, o_paint, &w, &h);
|
||||
x = (1024 - 128 - w) / 2; y = (768 - h) / 2;
|
||||
evas_move(evas_view, o_paint, x, y);
|
||||
}
|
||||
if (val < 5)
|
||||
{
|
||||
double brush_x[500], brush_y[500];
|
||||
int i;
|
||||
const double points[15][2] =
|
||||
{
|
||||
{ 10, -18},
|
||||
{-18, 15},
|
||||
{ 25, -13},
|
||||
{ 15, 20},
|
||||
{ 30, 5},
|
||||
{ 34, 17},
|
||||
{ 38, 15},
|
||||
{ 38, 27},
|
||||
{ 45, 16},
|
||||
{ 48, 23},
|
||||
{ 55, 23},
|
||||
{ 56, 31},
|
||||
{ 63, 33},
|
||||
{ 100, 50},
|
||||
{ 150, 75}
|
||||
};
|
||||
|
||||
evas_set_color(evas_view, o_paint, 255, 255, 255, (val * 255) / 5);
|
||||
evas_get_image_size(evas_view, o_brush, &w, &h);
|
||||
x = ((1024 - 128) - w) / 2;
|
||||
y = (768 - h) / 2;
|
||||
|
||||
for (i = 0; i < 500; i++)
|
||||
{
|
||||
int j;
|
||||
double a;
|
||||
|
||||
j = (i * 13) / 500;
|
||||
a = (double)(((double)i * 13) / 500) - (double)j;
|
||||
a = 0.5 + (sin((a - 0.5) * 3.141592654) / 2);
|
||||
brush_x[i] = ((1.0 - a) * points[j][0]) + (a * points[j + 1][0]);
|
||||
brush_y[i] = ((1.0 - a) * points[j][1]) + (a * points[j + 1][1]);
|
||||
}
|
||||
|
||||
x += brush_x[(int)(val * 100)];
|
||||
y += brush_y[(int)(val * 100)];
|
||||
|
||||
evas_move(evas_view, o_brush, x, y);
|
||||
if (val > 4)
|
||||
evas_set_color(evas_view, o_brush, 255, 255, 255, (1 - (val - 4)) * 255);
|
||||
}
|
||||
else if (val < 8)
|
||||
{
|
||||
evas_get_image_size(evas_view, o_brush, &w, &h);
|
||||
x = ((1024 - 128) - w) / 2;
|
||||
y = (768 - h) / 2;
|
||||
evas_move(evas_view, o_brush, x, y);
|
||||
evas_set_color(evas_view, o_paint, 255, 255, 255, 255);
|
||||
evas_set_color(evas_view, o_brush, 255, 255, 255, ((val - 5) * 255) / 3);
|
||||
}
|
||||
else if (val < 15)
|
||||
{
|
||||
double a;
|
||||
|
||||
evas_get_image_size(evas_view, o_brush, &w, &h);
|
||||
x = ((1024 - 128) - w) / 2;
|
||||
y = (768 - h) / 2;
|
||||
a = (7 - (val - 8)) / 7;
|
||||
a = 0.5 + (sin((a - 0.5) * 3.141592654) / 2);
|
||||
x *= a;
|
||||
y *= a;
|
||||
evas_set_color(evas_view, o_brush, 255, 255, 255, 255);
|
||||
evas_move(evas_view, o_brush, x, y);
|
||||
evas_move(evas_view, o_paint, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -301,7 +412,6 @@ handle_events(void)
|
|||
t2 = get_time();
|
||||
val += t2 - t1;
|
||||
t1 = t2;
|
||||
if (val >= 100.0) val -= 100.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,7 +421,32 @@ mouse_down (void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
{
|
||||
if ((_e == evas_control) &&
|
||||
((_o == o_software) || (_o == o_hardware) || (_o == o_x11)))
|
||||
evas_set_color(_e, _o, 255, 255, 0, 255);
|
||||
{
|
||||
double w, h;
|
||||
|
||||
evas_set_color(_e, _o, 255, 255, 255, 255);
|
||||
if (_o == o_software)
|
||||
{
|
||||
evas_get_geometry(_e, o_box1, NULL, NULL, &w, &h);
|
||||
evas_set_image_file(_e, o_box1, IMGDIR"evas_test_control_selection2.png");
|
||||
evas_resize(_e, o_box1, w, h);
|
||||
evas_set_image_fill(_e, o_box1, 0, 0, w, h);
|
||||
}
|
||||
else if (_o == o_hardware)
|
||||
{
|
||||
evas_get_geometry(_e, o_box2, NULL, NULL, &w, &h);
|
||||
evas_set_image_file(_e, o_box2, IMGDIR"evas_test_control_selection2.png");
|
||||
evas_resize(_e, o_box2, w, h);
|
||||
evas_set_image_fill(_e, o_box2, 0, 0, w, h);
|
||||
}
|
||||
else if (_o == o_x11)
|
||||
{
|
||||
evas_get_geometry(_e, o_box3, NULL, NULL, &w, &h);
|
||||
evas_set_image_file(_e, o_box3, IMGDIR"evas_test_control_selection2.png");
|
||||
evas_resize(_e, o_box3, w, h);
|
||||
evas_set_image_fill(_e, o_box3, 0, 0, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -320,13 +455,33 @@ mouse_up (void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
if ((_e == evas_control) &&
|
||||
((_o == o_software) || (_o == o_hardware) || (_o == o_x11)))
|
||||
{
|
||||
evas_set_color(_e, _o, 255, 255, 255, 255);
|
||||
double w, h;
|
||||
|
||||
evas_set_color(_e, _o, 0, 0, 0, 255);
|
||||
if (_o == o_software)
|
||||
setup_view(RENDER_METHOD_ALPHA_SOFTWARE);
|
||||
{
|
||||
evas_get_geometry(_e, o_box1, NULL, NULL, &w, &h);
|
||||
evas_set_image_file(_e, o_box1, IMGDIR"evas_test_control_selection1.png");
|
||||
evas_resize(_e, o_box1, w, h);
|
||||
evas_set_image_fill(_e, o_box1, 0, 0, w, h);
|
||||
setup_view(RENDER_METHOD_ALPHA_SOFTWARE);
|
||||
}
|
||||
else if (_o == o_hardware)
|
||||
setup_view(RENDER_METHOD_3D_HARDWARE);
|
||||
{
|
||||
evas_get_geometry(_e, o_box2, NULL, NULL, &w, &h);
|
||||
evas_set_image_file(_e, o_box2, IMGDIR"evas_test_control_selection1.png");
|
||||
evas_resize(_e, o_box2, w, h);
|
||||
evas_set_image_fill(_e, o_box2, 0, 0, w, h);
|
||||
setup_view(RENDER_METHOD_3D_HARDWARE);
|
||||
}
|
||||
else if (_o == o_x11)
|
||||
setup_view(RENDER_METHOD_BASIC_HARDWARE);
|
||||
{
|
||||
evas_get_geometry(_e, o_box3, NULL, NULL, &w, &h);
|
||||
evas_set_image_file(_e, o_box3, IMGDIR"evas_test_control_selection1.png");
|
||||
evas_resize(_e, o_box3, w, h);
|
||||
evas_set_image_fill(_e, o_box3, 0, 0, w, h);
|
||||
setup_view(RENDER_METHOD_BASIC_HARDWARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,7 +495,7 @@ mouse_in (void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
{
|
||||
if ((_e == evas_control) &&
|
||||
((_o == o_software) || (_o == o_hardware) || (_o == o_x11)))
|
||||
evas_set_color(_e, _o, 255, 255, 255, 255);
|
||||
evas_set_color(_e, _o, 0, 0, 0, 255);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -348,7 +503,7 @@ mouse_out (void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
{
|
||||
if ((_e == evas_control) &&
|
||||
((_o == o_software) || (_o == o_hardware) || (_o == o_x11)))
|
||||
evas_set_color(_e, _o, 255, 255, 255, 160);
|
||||
evas_set_color(_e, _o, 0, 0, 0, 160);
|
||||
}
|
||||
|
||||
/* Mr. main */
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 165 B |
Binary file not shown.
After Width: | Height: | Size: 189 B |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
Loading…
Reference in New Issue