implement zoom in and out

This commit is contained in:
Vincent Torri 2021-04-08 13:51:38 +02:00
parent 485ff4e395
commit 36023b5c7a
5 changed files with 60 additions and 2 deletions

View File

@ -57,6 +57,8 @@ rotation clockwise| Ctrl-r
rotation counter-clockwise | Ctrl-Alt-r
Original size | Ctrl-0
Best fit | f
Zoom in | +
Zoom out | -
Open Settings | s
Copy file name in clipboard | Ctrl-c
Exit Settings | Esc

View File

@ -107,7 +107,8 @@ _cb_image_zoomin(void *win, Evas_Object *obj EINA_UNUSED, const char *emission E
Entice *entice;
entice = evas_object_data_get(win, "entice");
//entice_image_rotate(entice->image, 1);
entice_image_zoom_increase(entice->image);
entice_image_update(entice->image);
printf("zoom in \n");
fflush(stdout);
}
@ -118,7 +119,8 @@ _cb_image_zoomout(void *win, Evas_Object *obj EINA_UNUSED, const char *emission
Entice *entice;
entice = evas_object_data_get(win, "entice");
//entice_image_rotate(entice->image, 1);
entice_image_zoom_decrease(entice->image);
entice_image_update(entice->image);
printf("zoom out \n");
fflush(stdout);
}

View File

@ -454,6 +454,46 @@ int entice_image_zoom_get(Evas_Object *obj)
return sd->zoom;
}
void
entice_image_zoom_increase(Evas_Object *obj)
{
Img *sd;
size_t l;
sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN(sd);
l = sizeof(_zoom_levels) / sizeof(int);
for (size_t i = 0; i < (l - 1); i++)
{
if ((_zoom_levels[i] <= sd->zoom) && (sd->zoom < _zoom_levels[i + 1]))
{
entice_image_zoom_set(obj, _zoom_levels[i + 1]);
break;
}
}
}
void
entice_image_zoom_decrease(Evas_Object *obj)
{
Img *sd;
size_t l;
sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN(sd);
l = sizeof(_zoom_levels) / sizeof(int);
for (size_t i = (l - 1); i > 0; i--)
{
if ((_zoom_levels[i - 1] < sd->zoom) && (sd->zoom <= _zoom_levels[i]))
{
entice_image_zoom_set(obj, _zoom_levels[i - 1]);
break;
}
}
}
void
entice_image_update(Evas_Object *obj)
{

View File

@ -50,6 +50,10 @@ void entice_image_zoom_set(Evas_Object *obj, int zoom);
int entice_image_zoom_get(Evas_Object *obj);
void entice_image_zoom_increase(Evas_Object *obj);
void entice_image_zoom_decrease(Evas_Object *obj);
void entice_image_update(Evas_Object *obj);
#endif /* ENTICE_IMAGE_H */

View File

@ -88,6 +88,16 @@ void entice_key_handle(Evas_Object *win, Evas_Event_Key_Down *ev)
entice_image_set(entice->image, prev);
}
}
else if (!strcmp(ev->key, "plus"))
{
entice_image_zoom_increase(entice->image);
entice_image_update(entice->image);
}
else if (!strcmp(ev->key, "minus"))
{
entice_image_zoom_decrease(entice->image);
entice_image_update(entice->image);
}
else if (!strcmp(ev->keyname, "f"))
{
entice_image_zoom_mode_set(entice->image, ENTICE_ZOOM_MODE_FIT);