forked from enlightenment/efl
Elm: add the zoom with the mouse wheel in the photocam test.
SVN revision: 43666
This commit is contained in:
parent
bf12a8e8e1
commit
5b36d0ceeb
|
@ -112,7 +112,7 @@ my_map_scroll(void *data, Evas_Object *obj, void *event_info)
|
||||||
Evas_Object *win = data;
|
Evas_Object *win = data;
|
||||||
double lon, lat;
|
double lon, lat;
|
||||||
elm_map_geo_region_get(obj, &lat, &lon);
|
elm_map_geo_region_get(obj, &lat, &lon);
|
||||||
printf("scroll latitude : %f longitude : %f\n", lat, lon);
|
//printf("scroll latitude : %f longitude : %f\n", lat, lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
#ifndef ELM_LIB_QUICKLAUNCH
|
#ifndef ELM_LIB_QUICKLAUNCH
|
||||||
|
|
||||||
|
static Evas_Object *rect;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_ph_clicked(void *data, Evas_Object *obj, void *event_info)
|
my_ph_clicked(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
|
@ -201,6 +203,47 @@ my_bt_zoom_fill(void *data, Evas_Object *obj, void *event_info)
|
||||||
elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL);
|
elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_photocam_mouse_wheel_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Evas_Object *photocam = data;
|
||||||
|
Evas_Object *ph = data;
|
||||||
|
Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
|
||||||
|
int zoom;
|
||||||
|
double val;
|
||||||
|
//unset the mouse wheel
|
||||||
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
|
|
||||||
|
zoom = elm_photocam_zoom_get(photocam);
|
||||||
|
if (ev->z>0 && zoom == 1) return;
|
||||||
|
|
||||||
|
if (ev->z > 0)
|
||||||
|
zoom /= 2;
|
||||||
|
else
|
||||||
|
zoom *= 2;
|
||||||
|
|
||||||
|
val = 1;
|
||||||
|
int _zoom = zoom;
|
||||||
|
while(_zoom>1)
|
||||||
|
{
|
||||||
|
_zoom /= 2;
|
||||||
|
val++;
|
||||||
|
}
|
||||||
|
|
||||||
|
elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
|
||||||
|
if (zoom >= 1) elm_photocam_zoom_set(photocam, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_photocam_move_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
int x,y,w,h;
|
||||||
|
|
||||||
|
evas_object_geometry_get(data,&x,&y,&w,&h);
|
||||||
|
evas_object_resize(rect,w,h);
|
||||||
|
evas_object_move(rect,x,y);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_photocam(void *data, Evas_Object *obj, void *event_info)
|
test_photocam(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
|
@ -229,7 +272,17 @@ test_photocam(void *data, Evas_Object *obj, void *event_info)
|
||||||
evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_win_resize_object_add(win, ph);
|
elm_win_resize_object_add(win, ph);
|
||||||
evas_object_data_set(ph, "window", win);
|
evas_object_data_set(ph, "window", win);
|
||||||
|
|
||||||
|
rect = evas_object_rectangle_add(evas_object_evas_get(win));
|
||||||
|
evas_object_color_set(rect, 0, 0, 0, 0);
|
||||||
|
evas_object_repeat_events_set(rect,1);
|
||||||
|
evas_object_show(rect);
|
||||||
|
evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_WHEEL, _photocam_mouse_wheel_cb, ph);
|
||||||
|
evas_object_raise(rect);
|
||||||
|
|
||||||
|
evas_object_event_callback_add(ph, EVAS_CALLBACK_RESIZE, _photocam_move_resize_cb, ph);
|
||||||
|
evas_object_event_callback_add(ph, EVAS_CALLBACK_MOVE, _photocam_move_resize_cb, ph);
|
||||||
|
|
||||||
evas_object_smart_callback_add(ph, "clicked", my_ph_clicked, win);
|
evas_object_smart_callback_add(ph, "clicked", my_ph_clicked, win);
|
||||||
evas_object_smart_callback_add(ph, "press", my_ph_press, win);
|
evas_object_smart_callback_add(ph, "press", my_ph_press, win);
|
||||||
evas_object_smart_callback_add(ph, "longpressed", my_ph_longpressed, win);
|
evas_object_smart_callback_add(ph, "longpressed", my_ph_longpressed, win);
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct _Grid_Item
|
||||||
Eina_Bool want : 1;
|
Eina_Bool want : 1;
|
||||||
Eina_Bool download : 1;
|
Eina_Bool download : 1;
|
||||||
Eina_Bool have : 1;
|
Eina_Bool have : 1;
|
||||||
Eina_Bool dead : 1; // old grid item, will die as sonn as the file is downloaded
|
Ecore_File_Download_Job *job;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Grid
|
struct _Grid
|
||||||
|
@ -232,13 +232,12 @@ grid_clear(Evas_Object *obj, Grid *g)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gi->download)
|
if(gi->job)
|
||||||
{
|
{
|
||||||
gi->dead = EINA_TRUE;
|
DBG("DOWNLOAD abort %p", gi);
|
||||||
gi->want = EINA_FALSE;
|
ecore_file_download_abort(gi->job);
|
||||||
}
|
}
|
||||||
else
|
free(gi);
|
||||||
free(gi);
|
|
||||||
}
|
}
|
||||||
eina_matrixsparse_free(g->grid);
|
eina_matrixsparse_free(g->grid);
|
||||||
g->grid = NULL;
|
g->grid = NULL;
|
||||||
|
@ -246,13 +245,25 @@ grid_clear(Evas_Object *obj, Grid *g)
|
||||||
g->gh = 0;
|
g->gh = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_tile_dl_progress(void *data, const char *file,
|
||||||
|
long int dltotal, long int dlnow,
|
||||||
|
long int ultotal, long int ulnow)
|
||||||
|
{
|
||||||
|
//printf("PROGREES %s\n", file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_tile_downloaded(void *data, const char *file, int status)
|
_tile_downloaded(void *data, const char *file, int status)
|
||||||
{
|
{
|
||||||
Grid_Item *gi = data;
|
Grid_Item *gi = data;
|
||||||
|
|
||||||
gi->download = EINA_FALSE;
|
gi->download = EINA_FALSE;
|
||||||
if (gi->want && !gi->dead)
|
gi->job = NULL;
|
||||||
|
|
||||||
|
DBG("DOWNLOAD done %p %s", gi, file);
|
||||||
|
if (gi->want)
|
||||||
{
|
{
|
||||||
gi->want = EINA_FALSE;
|
gi->want = EINA_FALSE;
|
||||||
evas_object_image_file_set(gi->img, file, NULL);
|
evas_object_image_file_set(gi->img, file, NULL);
|
||||||
|
@ -267,8 +278,6 @@ _tile_downloaded(void *data, const char *file, int status)
|
||||||
evas_object_smart_callback_call(gi->wd->obj, "loaded,detail", NULL);
|
evas_object_smart_callback_call(gi->wd->obj, "loaded,detail", NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gi->dead)
|
|
||||||
free(gi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Grid *
|
static Grid *
|
||||||
|
@ -440,10 +449,10 @@ grid_load(Evas_Object *obj, Grid *g)
|
||||||
snprintf(buf, PATH_MAX, SOURCE_PATH,
|
snprintf(buf, PATH_MAX, SOURCE_PATH,
|
||||||
wd->zoom, x, y);
|
wd->zoom, x, y);
|
||||||
|
|
||||||
DBG("DOWNLOAD %s \n\t in %s", buf, buf2);
|
|
||||||
|
|
||||||
if(ecore_file_exists(buf2) || g == eina_list_data_get(wd->grids))
|
if(ecore_file_exists(buf2) || g == eina_list_data_get(wd->grids))
|
||||||
{
|
{
|
||||||
|
DBG("DOWNLOAD %p %s \n\t in %s", gi, buf, buf2);
|
||||||
wd->preload_num++;
|
wd->preload_num++;
|
||||||
if (wd->preload_num == 1)
|
if (wd->preload_num == 1)
|
||||||
{
|
{
|
||||||
|
@ -455,7 +464,11 @@ grid_load(Evas_Object *obj, Grid *g)
|
||||||
if(ecore_file_exists(buf2))
|
if(ecore_file_exists(buf2))
|
||||||
_tile_downloaded(gi, buf2, EINA_TRUE);
|
_tile_downloaded(gi, buf2, EINA_TRUE);
|
||||||
else
|
else
|
||||||
ecore_file_download(buf, buf2, _tile_downloaded, NULL, gi);
|
{
|
||||||
|
ecore_file_download(buf, buf2, _tile_downloaded, _tile_dl_progress, gi, &gi->job);
|
||||||
|
if(!gi->job)
|
||||||
|
DBG("ERROR NO JOB !!!!!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(gi->have)
|
else if(gi->have)
|
||||||
|
|
Loading…
Reference in New Issue