Enlightenment CVS committal
Author : atmosphere
Project : e17
Module : apps/entice
Dir : e17/apps/entice/src/bin
Modified Files:
entice.c image.c image.h
Log Message:
Code to make the image dragable
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/entice.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- entice.c 24 Oct 2003 23:58:28 -0000 1.15
+++ entice.c 25 Oct 2003 09:54:01 -0000 1.16
@@ -187,7 +187,7 @@
if ((o = (Evas_Object *) _data))
{
int iw, ih;
- double w, h;
+ Evas_Coord w, h;
int should_fit = 0;
char buf[PATH_MAX];
@@ -200,7 +200,7 @@
evas_hash_find(entice->thumb.hash,
entice_image_file_get(entice->current))))
edje_object_signal_emit(thumb_edje, "EnticeThumbUnLoaded", "");
-
+
edje_object_signal_emit(entice->edje, "EnticeImageDisplayPrep", "");
tmp = e_thumb_evas_object_get(o);
@@ -255,7 +255,6 @@
edje_object_part_swallow(entice->edje, "EnticeImage", new_current);
edje_object_part_swallow(entice->edje, "EnticeImageScroller",
new_scroller);
- entice_image_edje_set(new_current, entice->edje);
if (should_fit)
entice_image_zoom_fit(new_current);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- image.c 19 Oct 2003 01:13:19 -0000 1.30
+++ image.c 25 Oct 2003 09:54:01 -0000 1.31
@@ -13,23 +13,8 @@
#define DEBUG 0
-static void entice_image_resize(Evas_Object * o, double w, double h);
+static void entice_image_resize(Evas_Object * o, Evas_Coord w, Evas_Coord h);
static int _entice_image_scroll_timer(void *data);
-static void _entice_image_mouse_down_translate(void *data, Evas * e,
- Evas_Object * obj,
- void *event_info);
-static void _entice_image_mouse_in_translate(void *data, Evas * e,
- Evas_Object * obj,
- void *event_info);
-static void _entice_image_mouse_out_translate(void *data, Evas * e,
- Evas_Object * obj,
- void *event_info);
-static void _entice_image_mouse_up_translate(void *data, Evas * e,
- Evas_Object * obj,
- void *event_info);
-static void _entice_image_mouse_wheel_translate(void *data, Evas * e,
- Evas_Object * obj,
- void *event_info);
const char *
entice_image_format_get(Evas_Object * o)
@@ -66,7 +51,7 @@
entice_image_rotate(Evas_Object * o, int orientation)
{
int iw, ih;
- double w, h, x, y;
+ Evas_Coord w, h, x, y;
Entice_Image *im = NULL;
Imlib_Image imlib_im = NULL;
@@ -110,7 +95,7 @@
entice_image_flip(Evas_Object * o, int orientation)
{
int iw, ih;
- double w, h, x, y;
+ Evas_Coord w, h, x, y;
Entice_Image *im = NULL;
Imlib_Image imlib_im = NULL;
@@ -157,7 +142,7 @@
entice_image_save(Evas_Object * o)
{
int iw, ih;
- double w, h;
+ Evas_Coord w, h;
Entice_Image *im = NULL;
Imlib_Image imlib_im = NULL;
@@ -426,27 +411,6 @@
entice_image_resize(o, im->w, im->h);
}
}
-void
-entice_image_edje_set(Evas_Object * o, Evas_Object * edje)
-{
- Entice_Image *im = NULL;
-
- if ((edje) && (im = evas_object_smart_data_get(o)))
- {
- evas_object_event_callback_add(im->obj, EVAS_CALLBACK_MOUSE_IN,
- _entice_image_mouse_in_translate, edje);
- evas_object_event_callback_add(im->obj, EVAS_CALLBACK_MOUSE_OUT,
- _entice_image_mouse_out_translate, edje);
- evas_object_event_callback_add(im->obj, EVAS_CALLBACK_MOUSE_UP,
- _entice_image_mouse_up_translate, edje);
- evas_object_event_callback_add(im->obj, EVAS_CALLBACK_MOUSE_DOWN,
- _entice_image_mouse_down_translate,
- edje);
- evas_object_event_callback_add(im->obj, EVAS_CALLBACK_MOUSE_WHEEL,
- _entice_image_mouse_wheel_translate,
- edje);
- }
-}
/**
* _entice_image_scroll_timer - our ecore timer to do continuous
@@ -464,8 +428,8 @@
if (data && ((im = evas_object_smart_data_get((Evas_Object *) data))))
{
double dt, dx;
- double ix, iy, iw, ih;
double offset;
+ Evas_Coord ix, iy, iw, ih;
dt = ecore_time_get() - im->scroll.start_time;
dx = 10 * (1 - exp(-dt));
@@ -630,12 +594,17 @@
entice_image_move(Evas_Object * o, double x, double y)
{
Entice_Image *im = NULL;
-
+ Evas_Coord w, h;
+
if ((im = evas_object_smart_data_get(o)))
{
- evas_object_move(im->clip, x, y);
- im->x = x;
- im->y = y;
+ if(im->dx == x && im->dy == y) return;
+ evas_object_geometry_get(im->obj, NULL, NULL, &w, &h);
+ im->scroll.x -= (im->dx - x);
+ im->scroll.y -= (im->dy - y);
+ im->dx = x;
+ im->dy = y;
+ entice_image_resize(o, im->w, im->h);
}
}
static void
@@ -649,8 +618,8 @@
im->w = w;
im->h = h;
- evas_object_resize(im->clip, im->w, im->h);
+ evas_object_resize(im->clip, w, h);
if (w < 5 || h < 5)
return;
if (im->zoom > w || im->zoom > h)
@@ -667,7 +636,12 @@
im->scroll.x = -((ww - w + 1) / 2);
}
else
- im->scroll.x = 0;
+ {
+ if (im->scroll.x > ((w - ww) / 2))
+ im->scroll.x = ((w - ww) / 2);
+ else if (im->scroll.x < -((w - ww + 1) / 2))
+ im->scroll.x = -((w - ww + 1) / 2);
+ }
if (hh > h)
{
if (im->scroll.y > ((hh - h) / 2))
@@ -676,7 +650,12 @@
im->scroll.y = -((hh - h + 1) / 2);
}
else
- im->scroll.y = 0;
+ {
+ if (im->scroll.y > ((h - hh) / 2))
+ im->scroll.y = ((h - hh) / 2);
+ else if (im->scroll.y < -((h - hh + 1) / 2))
+ im->scroll.y = -((h - hh + 1) / 2);
+ }
evas_object_move(im->obj, im->scroll.x + im->x + (im->w - ww) / 2,
im->scroll.y + im->y + (im->h - hh) / 2);
evas_object_resize(im->obj, ww, hh);
@@ -766,6 +745,10 @@
evas_object_image_size_get(im->obj, &w, &h);
evas_object_clip_set(im->obj, im->clip);
evas_object_show(im->obj);
+ evas_object_pass_events_set(im->clip, 1);
+ evas_object_pass_events_set(im->obj, 1);
+ evas_object_move(im->obj, 0, 0);
+
im->iw = w;
im->ih = h;
}
@@ -805,7 +788,7 @@
int w, h;
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
- evas_object_resize(bg, (double) w, (double) h);
+ evas_object_resize(bg, (Evas_Coord) w, (Evas_Coord) h);
}
/**
@@ -865,103 +848,3 @@
return (0);
}
#endif
-/**
- * The following five functions translate evas mouse events into edje
- * mouse event signal emissions
- */
-static void
-_entice_image_mouse_wheel_translate(void *data, Evas * e, Evas_Object * obj,
- void *event_info)
-{
- Evas_Event_Mouse_Wheel *ev = NULL;
- Evas_Object *o = NULL;
-
- if ((ev = (Evas_Event_Mouse_Wheel *) event_info))
- {
- if ((o = (Evas_Object *) data))
- {
- char buf[PATH_MAX];
-
- snprintf(buf, PATH_MAX, "mouse,wheel,%i,%i", (int) ev->direction,
- (int) ev->z);
- edje_object_signal_emit(o, buf, "EnticeImage");
- }
- }
-#if DEBUG
- fprintf(stderr, "MouseWheel\n");
-#endif
-}
-
-static void
-_entice_image_mouse_in_translate(void *data, Evas * e, Evas_Object * obj,
- void *event_info)
-{
- Evas_Event_Mouse_In *ev = NULL;
- Evas_Object *o = NULL;
-
- if ((ev = (Evas_Event_Mouse_In *) event_info))
- if ((o = (Evas_Object *) data))
- edje_object_signal_emit(o, "mouse,in", "EnticeImage");
-#if DEBUG
- fprintf(stderr, "MouseIn\n");
-#endif
-}
-
-static void
-_entice_image_mouse_out_translate(void *data, Evas * e, Evas_Object * obj,
- void *event_info)
-{
- Evas_Event_Mouse_Out *ev = NULL;
- Evas_Object *o = NULL;
-
- if ((ev = (Evas_Event_Mouse_Out *) event_info))
- if ((o = (Evas_Object *) data))
- edje_object_signal_emit(o, "mouse,out", "EnticeImage");
-#if DEBUG
- fprintf(stderr, "MouseOut\n");
-#endif
-}
-
-static void
-_entice_image_mouse_up_translate(void *data, Evas * e, Evas_Object * obj,
- void *event_info)
-{
- Evas_Event_Mouse_Up *ev = NULL;
- Evas_Object *o = NULL;
-
- if ((ev = (Evas_Event_Mouse_Up *) event_info))
- {
- if ((o = (Evas_Object *) data))
- {
- char buf[PATH_MAX];
-
- snprintf(buf, PATH_MAX, "mouse,up,%i", (int) ev->button);
- edje_object_signal_emit(o, buf, "EnticeImage");
- }
- }
-#if DEBUG
- fprintf(stderr, "MouseUp");
-#endif
-}
-
-static void
-_entice_image_mouse_down_translate(void *data, Evas * e, Evas_Object * obj,
- void *event_info)
-{
- Evas_Event_Mouse_Down *ev = NULL;
- Evas_Object *o = NULL;
-
- if ((ev = (Evas_Event_Mouse_Down *) event_info))
- {
- if ((o = (Evas_Object *) data))
- {
- char buf[PATH_MAX];
-
- snprintf(buf, PATH_MAX, "mouse,down,%i", (int) ev->button);
- edje_object_signal_emit(o, buf, "EnticeImage");
- }
- }
-#if DEBUG
- fprintf(stderr, "MouseDown\n");
-#endif
-}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- image.h 17 Oct 2003 21:36:08 -0000 1.16
+++ image.h 25 Oct 2003 09:54:01 -0000 1.17
@@ -36,6 +36,7 @@
char *filename; /* we need to keep track of this */
char *format; /* we need to keep track of this too */
int x, y, w, h, iw, ih; /* geometry */
+ Evas_Coord dx, dy;
Evas_Object *obj; /* the image object */
Evas_Object *clip; /* clip to this area when we swallow */
};
@@ -70,6 +71,5 @@
int entice_image_save(Evas_Object * o);
void entice_image_file_set(Evas_Object * o, const char *filename);
void entice_image_format_set(Evas_Object * o, const char *format);
-void entice_image_edje_set(Evas_Object * o, Evas_Object * edje);
#endif
-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community? Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs