forked from enlightenment/efl
elm_photocam: add API's to change photocam image orientation
Summary: Added API's to rotate(90, 180, 270), flip(horizontal, vertical), transpose and transverse Photocam Image. Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewers: seoz, stephenmhouston, raster, cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1541 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
97cefca273
commit
7cc6360aee
|
@ -3,12 +3,38 @@
|
||||||
#endif
|
#endif
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
Evas_Image_Orient orient;
|
||||||
|
const char *name;
|
||||||
|
} photocam_orient[] = {
|
||||||
|
{ EVAS_IMAGE_ORIENT_NONE, "None" },
|
||||||
|
{ EVAS_IMAGE_ORIENT_90, "Rotate 90" },
|
||||||
|
{ EVAS_IMAGE_ORIENT_180, "Rotate 180" },
|
||||||
|
{ EVAS_IMAGE_ORIENT_270, "Rotate 270" },
|
||||||
|
{ EVAS_IMAGE_FLIP_HORIZONTAL, "Horizontal Flip" },
|
||||||
|
{ EVAS_IMAGE_FLIP_VERTICAL, "Vertical Flip" },
|
||||||
|
{ EVAS_IMAGE_FLIP_TRANSPOSE, "Transpose" },
|
||||||
|
{ EVAS_IMAGE_FLIP_TRANSVERSE, "Transverse" },
|
||||||
|
{ 0, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_ph_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
my_ph_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
printf("clicked\n");
|
printf("clicked\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
my_ph_ch(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Evas_Object *photocam = data;
|
||||||
|
Evas_Image_Orient orient = elm_radio_value_get(obj);
|
||||||
|
|
||||||
|
elm_photocam_image_orient_set(photocam, orient);
|
||||||
|
fprintf(stderr, "Set %i and got %i\n",
|
||||||
|
orient, elm_photocam_image_orient_get(photocam));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_ph_press(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
my_ph_press(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -254,9 +280,9 @@ _photocam_move_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
||||||
void
|
void
|
||||||
test_photocam(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
test_photocam(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Evas_Object *win, *ph, *tb2, *bt, *box;
|
Evas_Object *win, *ph, *tb2, *bt, *box, *rd, *rdg = NULL;
|
||||||
|
int i;
|
||||||
Evas_Object *rect = NULL;
|
Evas_Object *rect = NULL;
|
||||||
|
|
||||||
win = elm_win_util_standard_add("photocam", "PhotoCam");
|
win = elm_win_util_standard_add("photocam", "PhotoCam");
|
||||||
elm_win_autodel_set(win, EINA_TRUE);
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
|
||||||
|
@ -387,6 +413,27 @@ test_photocam(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
|
||||||
elm_box_pack_end(box, bt);
|
elm_box_pack_end(box, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
|
|
||||||
|
box = elm_box_add(tb2);
|
||||||
|
elm_box_horizontal_set(box, EINA_TRUE);
|
||||||
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(box, 0.9, 0.9);
|
||||||
|
elm_table_pack(tb2, box, 1, 2, 1, 1);
|
||||||
|
evas_object_show(box);
|
||||||
|
|
||||||
|
for (i = 0; photocam_orient[i].name; ++i)
|
||||||
|
{
|
||||||
|
rd = elm_radio_add(win);
|
||||||
|
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
elm_radio_state_value_set(rd, photocam_orient[i].orient);
|
||||||
|
elm_object_text_set(rd, photocam_orient[i].name);
|
||||||
|
elm_box_pack_end(box, rd);
|
||||||
|
evas_object_show(rd);
|
||||||
|
evas_object_smart_callback_add(rd, "changed", my_ph_ch, ph);
|
||||||
|
if (!rdg)
|
||||||
|
rdg = rd;
|
||||||
|
else
|
||||||
|
elm_radio_group_add(rd, rdg);
|
||||||
|
}
|
||||||
evas_object_show(box);
|
evas_object_show(box);
|
||||||
evas_object_show(tb2);
|
evas_object_show(tb2);
|
||||||
|
|
||||||
|
@ -397,10 +444,12 @@ test_photocam(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
|
||||||
void
|
void
|
||||||
test_photocam_remote(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
test_photocam_remote(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Evas_Object *win, *ph, *tb2, *bt, *box, *pb;
|
Evas_Object *win, *ph, *tb2, *bt, *box, *pb, *rd;
|
||||||
|
Evas_Object *rdg = NULL;
|
||||||
Evas_Object *rect = NULL;
|
Evas_Object *rect = NULL;
|
||||||
// these were just testing - use the "select photo" browser to select one
|
// these were just testing - use the "select photo" browser to select one
|
||||||
static const char *url = "http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x10800.jpg";
|
static const char *url = "http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x10800.jpg";
|
||||||
|
int i;
|
||||||
|
|
||||||
win = elm_win_util_standard_add("photocam", "PhotoCam");
|
win = elm_win_util_standard_add("photocam", "PhotoCam");
|
||||||
elm_win_autodel_set(win, EINA_TRUE);
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
@ -535,6 +584,27 @@ test_photocam_remote(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
|
||||||
elm_box_pack_end(box, bt);
|
elm_box_pack_end(box, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
|
|
||||||
|
box = elm_box_add(tb2);
|
||||||
|
elm_box_horizontal_set(box, EINA_TRUE);
|
||||||
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(box, 0.9, 0.9);
|
||||||
|
elm_table_pack(tb2, box, 1, 2, 1, 1);
|
||||||
|
evas_object_show(box);
|
||||||
|
|
||||||
|
for (i = 0; photocam_orient[i].name; ++i)
|
||||||
|
{
|
||||||
|
rd = elm_radio_add(win);
|
||||||
|
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
elm_radio_state_value_set(rd, photocam_orient[i].orient);
|
||||||
|
elm_object_text_set(rd, photocam_orient[i].name);
|
||||||
|
elm_box_pack_end(box, rd);
|
||||||
|
evas_object_show(rd);
|
||||||
|
evas_object_smart_callback_add(rd, "changed", my_ph_ch, ph);
|
||||||
|
if (!rdg)
|
||||||
|
rdg = rd;
|
||||||
|
else
|
||||||
|
elm_radio_group_add(rd, rdg);
|
||||||
|
}
|
||||||
evas_object_show(box);
|
evas_object_show(box);
|
||||||
evas_object_show(tb2);
|
evas_object_show(tb2);
|
||||||
|
|
||||||
|
|
|
@ -580,6 +580,7 @@ _grid_create(Evas_Object *obj)
|
||||||
g->grid[tn].img =
|
g->grid[tn].img =
|
||||||
evas_object_image_add(evas_object_evas_get(obj));
|
evas_object_image_add(evas_object_evas_get(obj));
|
||||||
evas_object_image_load_orientation_set(g->grid[tn].img, EINA_TRUE);
|
evas_object_image_load_orientation_set(g->grid[tn].img, EINA_TRUE);
|
||||||
|
evas_object_image_orient_set(g->grid[tn].img, sd->orient);
|
||||||
evas_object_image_scale_hint_set
|
evas_object_image_scale_hint_set
|
||||||
(g->grid[tn].img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
|
(g->grid[tn].img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
|
||||||
evas_object_pass_events_set(g->grid[tn].img, EINA_TRUE);
|
evas_object_pass_events_set(g->grid[tn].img, EINA_TRUE);
|
||||||
|
@ -1275,6 +1276,67 @@ _g_layer_zoom_end_cb(void *data,
|
||||||
return EVAS_EVENT_FLAG_NONE;
|
return EVAS_EVENT_FLAG_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_orient_do(Evas_Object *obj, Elm_Photocam_Data *sd)
|
||||||
|
{
|
||||||
|
evas_object_smart_member_del(sd->img);
|
||||||
|
elm_widget_sub_object_del(obj, sd->img);
|
||||||
|
evas_object_smart_member_add(sd->img, sd->pan_obj);
|
||||||
|
elm_widget_sub_object_add(obj, sd->img);
|
||||||
|
ecore_job_del(sd->calc_job);
|
||||||
|
sd->calc_job = ecore_job_add(_calc_job_cb, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_elm_photocam_image_orient_set(Eo *obj, Elm_Photocam_Data *sd, Evas_Image_Orient orient)
|
||||||
|
{
|
||||||
|
int iw, ih;
|
||||||
|
Eina_List *l;
|
||||||
|
Elm_Phocam_Grid *g, *g_orient = NULL;
|
||||||
|
|
||||||
|
if (sd->orient == orient) return;
|
||||||
|
|
||||||
|
sd->orient = orient;
|
||||||
|
g = _grid_create(obj);
|
||||||
|
if (g)
|
||||||
|
{
|
||||||
|
if (eina_list_count(sd->grids) > 1)
|
||||||
|
{
|
||||||
|
g_orient = eina_list_last(sd->grids)->data;
|
||||||
|
sd->grids = eina_list_remove(sd->grids, g_orient);
|
||||||
|
_grid_clear(obj, g_orient);
|
||||||
|
free(g_orient);
|
||||||
|
EINA_LIST_FOREACH(sd->grids, l, g_orient)
|
||||||
|
{
|
||||||
|
g_orient->dead = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sd->grids = eina_list_prepend(sd->grids, g);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EINA_LIST_FREE(sd->grids, g)
|
||||||
|
{
|
||||||
|
_grid_clear(obj, g);
|
||||||
|
free(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
evas_object_image_orient_set(sd->img, orient);
|
||||||
|
evas_object_image_size_get(sd->img, &iw, &ih);
|
||||||
|
sd->size.imw = iw;
|
||||||
|
sd->size.imh = ih;
|
||||||
|
sd->size.w = iw / sd->zoom;
|
||||||
|
sd->size.h = ih / sd->zoom;
|
||||||
|
_orient_do(obj, sd);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static Evas_Image_Orient
|
||||||
|
_elm_photocam_image_orient_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data *sd)
|
||||||
|
{
|
||||||
|
return sd->orient;
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_photocam_evas_object_smart_add(Eo *obj, Elm_Photocam_Data *priv)
|
_elm_photocam_evas_object_smart_add(Eo *obj, Elm_Photocam_Data *priv)
|
||||||
{
|
{
|
||||||
|
@ -1455,7 +1517,6 @@ _internal_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file, Eina_File *
|
||||||
sd->size.w = sd->size.imw / sd->zoom;
|
sd->size.w = sd->size.imw / sd->zoom;
|
||||||
sd->size.h = sd->size.imh / sd->zoom;
|
sd->size.h = sd->size.imh / sd->zoom;
|
||||||
evas_object_image_file_set(sd->img, NULL, NULL);
|
evas_object_image_file_set(sd->img, NULL, NULL);
|
||||||
evas_object_image_load_scale_down_set(sd->img, 8);
|
|
||||||
_photocam_image_file_set(sd->img, sd);
|
_photocam_image_file_set(sd->img, sd);
|
||||||
err = evas_object_image_load_error_get(sd->img);
|
err = evas_object_image_load_error_get(sd->img);
|
||||||
if (err != EVAS_LOAD_ERROR_NONE)
|
if (err != EVAS_LOAD_ERROR_NONE)
|
||||||
|
@ -1481,6 +1542,7 @@ _internal_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file, Eina_File *
|
||||||
tz = sd->zoom;
|
tz = sd->zoom;
|
||||||
sd->zoom = 0.0;
|
sd->zoom = 0.0;
|
||||||
elm_photocam_zoom_set(obj, tz);
|
elm_photocam_zoom_set(obj, tz);
|
||||||
|
sd->orient = EVAS_IMAGE_ORIENT_NONE;
|
||||||
|
|
||||||
if (ret) *ret = evas_object_image_load_error_get(sd->img);
|
if (ret) *ret = evas_object_image_load_error_get(sd->img);
|
||||||
}
|
}
|
||||||
|
@ -1831,7 +1893,6 @@ EOLIAN static void
|
||||||
_elm_photocam_zoom_mode_set(Eo *obj, Elm_Photocam_Data *sd, Elm_Photocam_Zoom_Mode mode)
|
_elm_photocam_zoom_mode_set(Eo *obj, Elm_Photocam_Data *sd, Elm_Photocam_Zoom_Mode mode)
|
||||||
{
|
{
|
||||||
double tz;
|
double tz;
|
||||||
|
|
||||||
if (sd->mode == mode) return;
|
if (sd->mode == mode) return;
|
||||||
sd->mode = mode;
|
sd->mode = mode;
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,36 @@ class Elm_Photocam (Elm_Widget, Elm_Interface_Scrollable,
|
||||||
int h; /*@ A pointer to the height return */
|
int h; /*@ A pointer to the height return */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
image_orient {
|
||||||
|
set {
|
||||||
|
/*@
|
||||||
|
Set the photocam image orientation.
|
||||||
|
|
||||||
|
This function allows to rotate or flip the photocam image.
|
||||||
|
|
||||||
|
@see elm_photocam_image_orient_get()
|
||||||
|
@see @ref Evas_Image_Orient
|
||||||
|
|
||||||
|
@since 1.14
|
||||||
|
@ingroup Photocam */
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
/*@
|
||||||
|
Get the photocam image orientation.
|
||||||
|
|
||||||
|
@return The photocam image orientation @ref Evas_Image_Orient
|
||||||
|
|
||||||
|
@see elm_photocam_image_orient_set()
|
||||||
|
@see @ref Evas_Image_Orient
|
||||||
|
|
||||||
|
@since 1.14
|
||||||
|
@ingroup Photocam */
|
||||||
|
}
|
||||||
|
values {
|
||||||
|
Evas_Image_Orient orient; /*@ The photocam image orientation @ref Evas_Image_Orient
|
||||||
|
Default is #EVAS_IMAGE_ORIENT_NONE. */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
methods {
|
methods {
|
||||||
image_region_show {
|
image_region_show {
|
||||||
|
|
|
@ -80,7 +80,6 @@ struct _Elm_Photocam_Progress
|
||||||
double total;
|
double total;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structre associated with smart callback 'download,error'
|
* Structre associated with smart callback 'download,error'
|
||||||
* @since 1.8
|
* @since 1.8
|
||||||
|
|
|
@ -120,6 +120,7 @@ struct _Elm_Photocam_Data
|
||||||
int preload_num;
|
int preload_num;
|
||||||
|
|
||||||
Eina_List *grids;
|
Eina_List *grids;
|
||||||
|
Evas_Image_Orient orient; /**< This stores the current orientation of Photocam. By default this is set to EVAS_IMAGE_ORIENT_NONE */
|
||||||
|
|
||||||
Eina_Bool main_load_pending : 1;
|
Eina_Bool main_load_pending : 1;
|
||||||
Eina_Bool longpressed : 1;
|
Eina_Bool longpressed : 1;
|
||||||
|
|
Loading…
Reference in New Issue