void *einfo)
{
Evas_Event_Key_Down *ev = einfo;
+ Efl_Orient orient = efl_orientation_get(d.img);
if (strcmp(ev->key, "h") == 0) /* print help */
{
switch (key_val)
{
case 0:
- efl_orientation_set(d.img, EFL_ORIENT_0);
+ efl_orientation_set(d.img, EFL_ORIENT_UP | (orient & EFL_ORIENT_FLIP_BITMASK));
break;
case 1:
- efl_orientation_set(d.img, EFL_ORIENT_90);
+ efl_orientation_set(d.img, EFL_ORIENT_RIGHT | (orient & EFL_ORIENT_FLIP_BITMASK));
break;
case 2:
- efl_orientation_set(d.img, EFL_ORIENT_180);
+ efl_orientation_set(d.img, EFL_ORIENT_DOWN | (orient & EFL_ORIENT_FLIP_BITMASK));
break;
case 3:
- efl_orientation_set(d.img, EFL_ORIENT_270);
+ efl_orientation_set(d.img, EFL_ORIENT_LEFT | (orient & EFL_ORIENT_FLIP_BITMASK));
break;
case 4:
- efl_orientation_flip_set(d.img, EFL_FLIP_HORIZONTAL);
+ efl_orientation_set(d.img, (orient & EFL_ORIENT_ROTATION_BITMASK) | EFL_ORIENT_FLIP_HORIZONTAL);
break;
case 5:
- efl_orientation_flip_set(d.img, EFL_FLIP_VERTICAL);
+ efl_orientation_set(d.img, (orient & EFL_ORIENT_ROTATION_BITMASK) | EFL_ORIENT_FLIP_VERTICAL);
break;
case 6:
- efl_orientation_flip_set(d.img, EFL_FLIP_NONE);
+ efl_orientation_set(d.img, (orient & EFL_ORIENT_ROTATION_BITMASK));
break;
}
}
enum @beta Efl.Orient
{
- [[An orientation type, to rotate visual objects.
-
+ [[An orientation type, to rotate and flip images.
+
+ This is similar to EXIF's orientation.
+ Directional values ($up, $down, $left, $right) indicate the final direction in
+ which the top of the image will be facing (e.g. a picture of a house will have
+ its roof pointing to the right if the $right orientation is used).
+ Flipping values ($flip_horizontal and $flip_vertical) can be additionaly added
+ to produce a mirroring in each axis.
Not to be confused with @Efl.Ui.Dir which is meant for widgets, rather
than images and canvases. This enum is used to rotate images, videos and
the like.
-
- See also @Efl.Orientation.
- ]]
- none = 0, [[Default, same as up]]
- up = 0, [[Orient up, do not rotate.]]
- right = 90, [[Orient right, rotate 90 degrees counter clock-wise.]]
- down = 180, [[Orient down, rotate 180 degrees.]]
- left = 270, [[Orient left, rotate 90 degrees clock-wise.]]
-}
-
-enum @beta Efl.Flip
-{
- [[A flip type, to flip visual objects.
-
- See also @Efl.Orientation.
]]
- none = 0, [[No flip]]
- horizontal = 1, [[Flip image horizontally]]
- vertical = 2 [[Flip image vertically]]
+ none = 0, [[Default, same as up, do not rotate.]]
+ up = 0, [[Orient up, do not rotate.]]
+ right = 1, [[Orient right, rotate 90 degrees clock-wise.]]
+ down = 2, [[Orient down, rotate 180 degrees.]]
+ left = 3, [[Orient left, rotate 270 degrees clock-wise.]]
+ rotation_bitmask = 3, [[Bitmask that can be used to isolate rotation values, that is, $none, $up, $down, $left and $right.]]
+ flip_horizontal = 4, [[Mirror horizontally. Can be added to the other values.]]
+ flip_vertical = 8, [[Mirror vertically. Can be added to the other values.]]
+ flip_bitmask = 12 [[Bitmask that can be used to isolate flipping values, that is, $flip_vertical and $flip_horizontal.]]
}
interface @beta Efl.Orientation
{
- [[Efl orientation interface]]
+ [[Interface for objects which can be oriented.]]
methods {
@property orientation {
- [[Control the orientation of a given object.
+ [[Control the orientation (rotation and flipping) of a given object.
This can be used to set the rotation on an image or a window, for
instance.
dir: Efl.Orient(Efl.Orient.none); [[The rotation angle (CCW), see @Efl.Orient.]]
}
}
- @property flip {
- [[Control the flip of the given image
-
- Use this function to change how your image is to be
- flipped: vertically or horizontally or transpose
- or traverse.
- ]]
- values {
- flip: Efl.Flip; [[Flip method]]
- }
- }
}
}
if (!sd->edje)
{
efl_orientation_set(sd->img, sd->orient);
- efl_orientation_flip_set(sd->img, sd->flip);
}
if (sd->img)
return sd->orient;
}
-
-EOLIAN static void
-_efl_ui_image_efl_orientation_flip_set(Eo *obj, Efl_Ui_Image_Data *sd, Efl_Flip flip)
-{
- if (sd->edje) return;
- if (sd->flip == flip) return;
-
- sd->flip = flip;
- _efl_ui_image_sizing_eval(obj);
-}
-
-EOLIAN static Efl_Flip
-_efl_ui_image_efl_orientation_flip_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
-{
- return sd->flip;
-}
-
/**
* Turns on editing through drag and drop and copy and paste.
*/
}
EAPI void
-elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
-{
- Efl_Orient dir;
- Efl_Flip flip;
+elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient elm_orient)
+{
+ // This array takes an Elm_Image_Orient and turns it into an Efl_Orient
+ static const Efl_Orient efl_orient[8] = {
+ EFL_ORIENT_NONE,
+ EFL_ORIENT_RIGHT,
+ EFL_ORIENT_DOWN,
+ EFL_ORIENT_LEFT,
+ EFL_ORIENT_FLIP_HORIZONTAL,
+ EFL_ORIENT_FLIP_VERTICAL,
+ EFL_ORIENT_LEFT | EFL_ORIENT_FLIP_VERTICAL,
+ EFL_ORIENT_RIGHT | EFL_ORIENT_FLIP_VERTICAL
+ };
EFL_UI_IMAGE_CHECK(obj);
EFL_UI_IMAGE_DATA_GET(obj, sd);
- sd->image_orient = orient;
-
- switch (orient)
- {
- case EVAS_IMAGE_ORIENT_0:
- dir = EFL_ORIENT_0;
- flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_ORIENT_90:
- dir = EFL_ORIENT_90;
- flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_ORIENT_180:
- dir = EFL_ORIENT_180;
- flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_ORIENT_270:
- dir = EFL_ORIENT_270;
- flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_FLIP_HORIZONTAL:
- dir = EFL_ORIENT_0;
- flip = EFL_FLIP_HORIZONTAL;
- break;
- case EVAS_IMAGE_FLIP_VERTICAL:
- dir = EFL_ORIENT_0;
- flip = EFL_FLIP_VERTICAL;
- break;
- case EVAS_IMAGE_FLIP_TRANSVERSE:
- dir = EFL_ORIENT_270;
- flip = EFL_FLIP_HORIZONTAL;
- break;
- case EVAS_IMAGE_FLIP_TRANSPOSE:
- dir = EFL_ORIENT_270;
- flip = EFL_FLIP_VERTICAL;
- break;
- default:
- dir = EFL_ORIENT_0;
- flip = EFL_FLIP_NONE;
- break;
- }
-
- efl_orientation_set(obj, dir);
- efl_orientation_flip_set(obj, flip);
+ EINA_SAFETY_ON_FALSE_RETURN(elm_orient >= 0 && elm_orient < 8);
+ sd->image_orient = elm_orient;
+ efl_orientation_set(obj, efl_orient[elm_orient]);
}
EAPI Elm_Image_Orient
Efl.Gfx.Image.smooth_scale { get; set; }
Efl.Gfx.Image.scale_type { get; set; }
Efl.Orientation.orientation { get; set; }
- Efl.Orientation.flip { get; set; }
Efl.Player.playable { get; }
Efl.Player.play { get; set; }
Efl.Layout.Signal.signal_emit;
evas_object_image_add(evas_object_evas_get(obj));
evas_object_image_load_orientation_set(g->grid[tn].img, EINA_TRUE);
efl_orientation_set(g->grid[tn].img, sd->orient);
- efl_orientation_flip_set(g->grid[tn].img, sd->flip);
evas_object_image_scale_hint_set
(g->grid[tn].img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
evas_object_pass_events_set(g->grid[tn].img, EINA_TRUE);
}
efl_orientation_set(sd->img, sd->orient);
- efl_orientation_flip_set(sd->img, sd->flip);
evas_object_image_size_get(sd->img, &iw, &ih);
sd->size.imw = iw;
sd->size.imh = ih;
return sd->orient;
}
-EOLIAN static void
-_efl_ui_image_zoomable_efl_orientation_flip_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Efl_Flip flip)
-{
- if (sd->flip == flip) return;
-
- sd->flip = flip;
- _orient_apply(obj, sd);
-}
-
-EOLIAN static Efl_Flip
-_efl_ui_image_zoomable_efl_orientation_flip_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
-{
- return sd->flip;
-}
-
static void
_efl_ui_image_zoomable_bar_read_and_update(Eo *obj)
{
sd->zoom = 0.0;
elm_photocam_zoom_set(obj, tz);
sd->orient = EFL_ORIENT_NONE;
- sd->flip = EFL_FLIP_NONE;
sd->orientation_changed = EINA_FALSE;
return 0;
sd->zoom = 0.0;
elm_photocam_zoom_set(obj, tz);
sd->orient = EFL_ORIENT_NONE;
- sd->flip = EFL_FLIP_NONE;
sd->orientation_changed = EINA_FALSE;
if (ret) *ret = evas_object_image_load_error_get(sd->img);
return elm_legacy_add(EFL_UI_IMAGE_ZOOMABLE_LEGACY_CLASS, parent);
}
-static inline void
-_evas_orient_to_eo_orient_flip(const Evas_Image_Orient evas_orient,
- Efl_Orient *orient, Efl_Flip *flip)
-{
- switch (evas_orient) {
- case EVAS_IMAGE_ORIENT_NONE:
- *orient = EFL_ORIENT_NONE;
- *flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_ORIENT_90:
- *orient = EFL_ORIENT_90;
- *flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_ORIENT_180:
- *orient = EFL_ORIENT_180;
- *flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_ORIENT_270:
- *orient = EFL_ORIENT_270;
- *flip = EFL_FLIP_NONE;
- break;
- case EVAS_IMAGE_FLIP_HORIZONTAL:
- *orient = EFL_ORIENT_NONE;
- *flip = EFL_FLIP_HORIZONTAL;
- break;
- case EVAS_IMAGE_FLIP_VERTICAL:
- *orient = EFL_ORIENT_NONE;
- *flip = EFL_FLIP_VERTICAL;
- break;
- case EVAS_IMAGE_FLIP_TRANSVERSE:
- *orient = EFL_ORIENT_270;
- *flip = EFL_FLIP_HORIZONTAL;
- break;
- case EVAS_IMAGE_FLIP_TRANSPOSE:
- *orient = EFL_ORIENT_270;
- *flip = EFL_FLIP_VERTICAL;
- break;
- default:
- *orient = EFL_ORIENT_NONE;
- *flip = EFL_FLIP_NONE;
- break;
- }
+static inline Efl_Orient
+_evas_orient_to_efl_orient(const Evas_Image_Orient evas_orient)
+{
+ // This array takes an Elm_Image_Orient and turns it into an Efl_Orient
+ static const Efl_Orient efl_orient[8] = {
+ EFL_ORIENT_NONE,
+ EFL_ORIENT_RIGHT,
+ EFL_ORIENT_DOWN,
+ EFL_ORIENT_LEFT,
+ EFL_ORIENT_FLIP_HORIZONTAL,
+ EFL_ORIENT_FLIP_VERTICAL,
+ EFL_ORIENT_LEFT | EFL_ORIENT_FLIP_VERTICAL,
+ EFL_ORIENT_RIGHT | EFL_ORIENT_FLIP_VERTICAL
+ };
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(evas_orient >= 0 && evas_orient < 8, EFL_ORIENT_NONE);
+ return efl_orient[evas_orient];
}
static inline Evas_Image_Orient
-_eo_orient_flip_to_evas_orient(Efl_Orient orient, Efl_Flip flip)
-{
- switch (flip)
- {
- default:
- case EFL_FLIP_NONE:
- switch (orient)
- {
- default:
- case EFL_ORIENT_0: return EVAS_IMAGE_ORIENT_0;
- case EFL_ORIENT_90: return EVAS_IMAGE_ORIENT_90;
- case EFL_ORIENT_180: return EVAS_IMAGE_ORIENT_180;
- case EFL_ORIENT_270: return EVAS_IMAGE_ORIENT_270;
- }
- case EFL_FLIP_HORIZONTAL:
- switch (orient)
- {
- default:
- case EFL_ORIENT_0: return EVAS_IMAGE_FLIP_HORIZONTAL;
- case EFL_ORIENT_90: return EVAS_IMAGE_FLIP_TRANSPOSE;
- case EFL_ORIENT_180: return EVAS_IMAGE_FLIP_VERTICAL;
- case EFL_ORIENT_270: return EVAS_IMAGE_FLIP_TRANSVERSE;
- }
- case EFL_FLIP_VERTICAL:
- switch (orient)
- {
- default:
- case EFL_ORIENT_0: return EVAS_IMAGE_FLIP_VERTICAL;
- case EFL_ORIENT_90: return EVAS_IMAGE_FLIP_TRANSVERSE;
- case EFL_ORIENT_180: return EVAS_IMAGE_FLIP_HORIZONTAL;
- case EFL_ORIENT_270: return EVAS_IMAGE_FLIP_TRANSPOSE;
- }
- }
+_efl_orient_to_evas_orient(Efl_Orient efl_orient)
+{
+ // This array takes an Efl_Orient and turns it into an Elm_Image_Orient
+ static const Evas_Image_Orient evas_orient[16] = {
+ EVAS_IMAGE_ORIENT_NONE, // EFL_ORIENT_NONE
+ EVAS_IMAGE_ORIENT_90, // EFL_ORIENT_RIGHT
+ EVAS_IMAGE_ORIENT_180, // EFL_ORIENT_DOWN
+ EVAS_IMAGE_ORIENT_270, // EFL_ORIENT_LEFT
+ EVAS_IMAGE_FLIP_HORIZONTAL, // EFL_ORIENT_NONE + FLIP_HOR
+ EVAS_IMAGE_FLIP_TRANSPOSE, // EFL_ORIENT_RIGHT + FLIP_HOR
+ EVAS_IMAGE_FLIP_VERTICAL, // EFL_ORIENT_DOWN + FLIP_HOR
+ EVAS_IMAGE_FLIP_TRANSVERSE, // EFL_ORIENT_LEFT + FLIP_HOR
+ EVAS_IMAGE_FLIP_VERTICAL, // EFL_ORIENT_NONE + FLIP_VER
+ EVAS_IMAGE_FLIP_TRANSVERSE, // EFL_ORIENT_RIGHT + FLIP_VER
+ EVAS_IMAGE_FLIP_HORIZONTAL, // EFL_ORIENT_DOWN + FLIP_VER
+ EVAS_IMAGE_FLIP_TRANSPOSE, // EFL_ORIENT_LEFT + FLIP_VER
+ EVAS_IMAGE_ORIENT_180, // EFL_ORIENT_NONE + FLIP_HOR + FLIP_VER
+ EVAS_IMAGE_ORIENT_270, // EFL_ORIENT_RIGHT + FLIP_HOR + FLIP_VER
+ EVAS_IMAGE_ORIENT_0, // EFL_ORIENT_DOWN + FLIP_HOR + FLIP_VER
+ EVAS_IMAGE_ORIENT_90 // EFL_ORIENT_LEFT + FLIP_HOR + FLIP_VER
+ };
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_orient >= 0 && efl_orient < 16, EVAS_IMAGE_ORIENT_NONE);
+ return evas_orient[efl_orient];
}
EAPI void
elm_photocam_image_orient_set(Eo *obj, Evas_Image_Orient evas_orient)
{
- Efl_Orient orient;
- Efl_Flip flip;
-
- _evas_orient_to_eo_orient_flip(evas_orient, &orient, &flip);
- efl_orientation_set(obj, orient);
- efl_orientation_flip_set(obj, flip);
+ efl_orientation_set(obj, _evas_orient_to_efl_orient(evas_orient));
}
EAPI Evas_Image_Orient
{
ELM_PHOTOCAM_CHECK(obj) EVAS_IMAGE_ORIENT_NONE;
EFL_UI_IMAGE_ZOOMABLE_DATA_GET(obj, sd);
- return _eo_orient_flip_to_evas_orient(sd->orient, sd->flip);
+ return _efl_orient_to_evas_orient(sd->orient);
}
EAPI Evas_Object*
Efl.File.load;
Efl.File.file { get; set; }
Efl.Orientation.orientation { get; set; }
- Efl.Orientation.flip { get; set; }
Efl.Layout.Group.group_size_min { get; }
Efl.Layout.Group.group_size_max { get; }
Efl.Layout.Signal.signal_callback_add;
Eina_List *grids;
Efl_Orient orient;
- Efl_Flip flip;
Eina_Bool main_load_pending : 1;
Eina_Bool longpressed : 1;
Elm_Image_Orient image_orient; // to support EAPI
Efl_Orient orient;
- Efl_Flip flip;
struct {
Ecore_Thread *th;
Efl.Object.debug_name_override;
Efl.File_Save.save;
Efl.Orientation.orientation { get; set; }
- Efl.Orientation.flip { get; set; }
Efl.Gfx.Image.smooth_scale { get; set; }
Efl.Gfx.Image.ratio { get; }
Efl.Gfx.Image.border { get; set; }
Efl_Gfx_Image_Scale_Hint scale_hint;
Efl_Gfx_Image_Content_Hint content_hint;
- Efl_Flip flip_value;
Efl_Orient orient_value;
struct {
evas_object_change(eo_obj, obj);
}
-static Evas_Image_Orient
-_get_image_orient_from_orient_flip(Efl_Orient orient, Efl_Flip flip)
-{
- switch (orient)
- {
- case EFL_ORIENT_0:
- if (flip == EFL_FLIP_HORIZONTAL)
- return EVAS_IMAGE_FLIP_HORIZONTAL;
- else if (flip == EFL_FLIP_VERTICAL)
- return EVAS_IMAGE_FLIP_VERTICAL;
- else
- return EVAS_IMAGE_ORIENT_0;
-
- case EFL_ORIENT_90:
- if (flip == EFL_FLIP_HORIZONTAL)
- return EVAS_IMAGE_FLIP_TRANSPOSE;
- else if (flip == EFL_FLIP_VERTICAL)
- return EVAS_IMAGE_FLIP_TRANSVERSE;
- else
- return EVAS_IMAGE_ORIENT_90;
-
- case EFL_ORIENT_180:
- if (flip == EFL_FLIP_HORIZONTAL)
- return EVAS_IMAGE_FLIP_VERTICAL;
- else if (flip == EFL_FLIP_VERTICAL)
- return EVAS_IMAGE_FLIP_HORIZONTAL;
- else
- return EVAS_IMAGE_ORIENT_180;
-
- case EFL_ORIENT_270:
- if (flip == EFL_FLIP_HORIZONTAL)
- return EVAS_IMAGE_FLIP_TRANSVERSE;
- else if (flip == EFL_FLIP_VERTICAL)
- return EVAS_IMAGE_FLIP_TRANSPOSE;
- else
- return EVAS_IMAGE_ORIENT_270;
-
- default:
- return EVAS_IMAGE_ORIENT_NONE;
- }
-}
-
EOLIAN static void
-_efl_canvas_image_internal_efl_orientation_orientation_set(Eo *obj, Evas_Image_Data *o, Efl_Orient dir)
-{
- Evas_Image_Orient orient;
-
- o->orient_value = dir;
- orient = _get_image_orient_from_orient_flip(dir, o->flip_value);
+_efl_canvas_image_internal_efl_orientation_orientation_set(Eo *obj, Evas_Image_Data *o, Efl_Orient efl_orient)
+{
+ // This array takes an Efl_Orient and turns it into an Elm_Image_Orient
+ static const Evas_Image_Orient evas_orient[16] = {
+ EVAS_IMAGE_ORIENT_NONE, // EFL_ORIENT_NONE
+ EVAS_IMAGE_ORIENT_90, // EFL_ORIENT_RIGHT
+ EVAS_IMAGE_ORIENT_180, // EFL_ORIENT_DOWN
+ EVAS_IMAGE_ORIENT_270, // EFL_ORIENT_LEFT
+ EVAS_IMAGE_FLIP_HORIZONTAL, // EFL_ORIENT_NONE + FLIP_HOR
+ EVAS_IMAGE_FLIP_TRANSPOSE, // EFL_ORIENT_RIGHT + FLIP_HOR
+ EVAS_IMAGE_FLIP_VERTICAL, // EFL_ORIENT_DOWN + FLIP_HOR
+ EVAS_IMAGE_FLIP_TRANSVERSE, // EFL_ORIENT_LEFT + FLIP_HOR
+ EVAS_IMAGE_FLIP_VERTICAL, // EFL_ORIENT_NONE + FLIP_VER
+ EVAS_IMAGE_FLIP_TRANSVERSE, // EFL_ORIENT_RIGHT + FLIP_VER
+ EVAS_IMAGE_FLIP_HORIZONTAL, // EFL_ORIENT_DOWN + FLIP_VER
+ EVAS_IMAGE_FLIP_TRANSPOSE, // EFL_ORIENT_LEFT + FLIP_VER
+ EVAS_IMAGE_ORIENT_180, // EFL_ORIENT_NONE + FLIP_HOR + FLIP_VER
+ EVAS_IMAGE_ORIENT_270, // EFL_ORIENT_RIGHT + FLIP_HOR + FLIP_VER
+ EVAS_IMAGE_ORIENT_0, // EFL_ORIENT_DOWN + FLIP_HOR + FLIP_VER
+ EVAS_IMAGE_ORIENT_90 // EFL_ORIENT_LEFT + FLIP_HOR + FLIP_VER
+ };
+ EINA_SAFETY_ON_FALSE_RETURN(efl_orient >= 0 && efl_orient < 16);
- _evas_image_orientation_set(obj, o, orient);
+ o->orient_value = efl_orient;
+ _evas_image_orientation_set(obj, o, evas_orient[efl_orient]);
}
EOLIAN static Efl_Orient
}
EOLIAN static void
-_efl_canvas_image_internal_efl_orientation_flip_set(Eo *obj, Evas_Image_Data *o, Efl_Flip flip)
-{
- Evas_Image_Orient orient;
-
- o->flip_value = flip;
- orient = _get_image_orient_from_orient_flip(o->orient_value, flip);
-
- _evas_image_orientation_set(obj, o, orient);
-}
-
-EOLIAN static Efl_Flip
-_efl_canvas_image_internal_efl_orientation_flip_get(const Eo *obj EINA_UNUSED, Evas_Image_Data *o)
-{
- return o->flip_value;
-}
-
-EOLIAN static void
_efl_canvas_image_internal_efl_object_dbg_info_get(Eo *eo_obj, Evas_Image_Data *o, Efl_Dbg_Info *root)
{
efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);