photocam_example_01.c
//Compile with:
//gcc -o photocam_example_01 photocam_example_01.c -g `pkg-config --cflags --libs elementary` -DDATA_DIR="\"<directory>\""
//where directory is the path where images/insanely_huge_test_image.jpg can be found.
#include <Elementary.h>
static void _fit(void *data, Evas_Object *obj, void *event_info);
static void _unfit(void *data, Evas_Object *obj, void *event_info);
static void _zoom(void *data, Evas_Object *obj, void *event_info);
static void _bring_in(void *data, Evas_Object *obj, void *event_info);
static void _orient(void *data, Evas_Object *obj, void *event_info);
static void _orient_do(void *data, Evas_Object *obj, void *event_info);
typedef struct _Orient_Data Orient_Data;
struct _Orient_Data
{
};
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win, *obj, *photocam, *menu;
Orient_Data *orient_data;
char buf[PATH_MAX];
elm_app_info_set(elm_main, "elementary", "images/insanely_huge_test_image.jpg");
win = elm_win_util_standard_add("photocam", "Photocam");
photocam = elm_photocam_add(win);
snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
elm_photocam_file_set(photocam, buf);
evas_object_smart_callback_add(photocam, "loaded,detail", _bring_in, NULL);
evas_object_resize(photocam, 500, 400);
evas_object_show(photocam);
obj = elm_button_add(win);
elm_object_text_set(obj, "Fit");
evas_object_resize(obj, 50, 30);
evas_object_move(obj, 10, 410);
evas_object_smart_callback_add(obj, "clicked", _fit, photocam);
obj = elm_button_add(win);
elm_object_text_set(obj, "Unfit");
evas_object_resize(obj, 70, 30);
evas_object_move(obj, 70, 410);
evas_object_smart_callback_add(obj, "clicked", _unfit, photocam);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 0;
menu = elm_menu_add(win);
elm_menu_item_add(menu, NULL, NULL, "orient 0", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 1;
elm_menu_item_add(menu, NULL, NULL, "orient 90", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 2;
elm_menu_item_add(menu, NULL, NULL, "orient 180", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 3;
elm_menu_item_add(menu, NULL, NULL, "orient 270", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 4;
elm_menu_item_add(menu, NULL, NULL, "flip horizontal", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 5;
elm_menu_item_add(menu, NULL, NULL, "flip vertical", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 6;
elm_menu_item_add(menu, NULL, NULL, "flip transverse", _orient_do, orient_data);
orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
orient_data->ph = photocam;
orient_data->orient = 7;
elm_menu_item_add(menu, NULL, NULL, "flip transpose", _orient_do, orient_data);
obj = elm_button_add(win);
elm_object_text_set(obj, "Orient");
evas_object_resize(obj, 70, 30);
evas_object_move(obj, 470, 410);
evas_object_smart_callback_add(obj, "clicked", _orient, menu);
obj = elm_slider_add(win);
elm_object_text_set(obj, "Zoom");
evas_object_resize(obj, 300, 30);
evas_object_move(obj, 150, 410);
evas_object_smart_callback_add(obj, "changed", _zoom, photocam);
evas_object_resize(win, 500, 440);
return 0;
}
static void
_bring_in(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
int w, h;
elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
}
static void
_fit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
int x, y, w, h;
elm_photocam_image_region_get(data, &x, &y, &w, &h);
printf("region: {%d, %d, %d, %d}\n", x, y, w, h);
elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
}
static void
_unfit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
}
static void
_zoom(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
double z = elm_slider_value_get(obj) * 8;
}
static void
_orient(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *mn = data;
if (!mn) return;
}
static void
_orient_do(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Orient_Data *orient_data = data;
if (!orient_data) return;
elm_photocam_image_orient_set(orient_data->ph, orient_data->orient);
}
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition: eina_types.h:533
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
void elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
Re-locate the application somewhere else after compilation, if the developer wishes for easier distri...
Definition: elm_main.c:496
const char * elm_app_data_dir_get(void)
Get the application's run time data prefix directory, as set by elm_app_info_set() and the way (envir...
Definition: elm_main.c:586
Evas_Object * elm_button_add(Evas_Object *parent)
Add a new button to the parent's canvas.
Definition: efl_ui_button.c:459
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition: elm_general.h:556
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition: elm_main.c:1380
void elm_run(void)
Run Elementary's main loop.
Definition: elm_main.c:1357
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition: elm_general.h:248
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition: elm_general.h:227
Evas_Object * elm_menu_add(Evas_Object *parent)
Add a new menu to the parent.
Definition: elm_menu.c:811
void elm_photocam_zoom_set(Evas_Object *obj, double zoom)
Set the zoom level of the photo.
Definition: efl_ui_image_zoomable.c:3414
void elm_photocam_zoom_mode_set(Evas_Object *obj, Elm_Photocam_Zoom_Mode mode)
Set the zoom mode.
Definition: efl_ui_image_zoomable.c:3426
void elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h)
Bring in the viewed portion of the image.
Definition: efl_ui_image_zoomable.c:3471
Evas_Load_Error elm_photocam_file_set(Evas_Object *obj, const char *file)
Set the photo file to be shown.
Definition: efl_ui_image_zoomable.c:3438
void elm_photocam_image_orient_set(Eo *obj, Evas_Image_Orient evas_orient)
Set the photocam image orientation.
Definition: efl_ui_image_zoomable.c:3371
Evas_Object * elm_photocam_add(Evas_Object *parent)
Add a new Photocam object.
Definition: efl_ui_image_zoomable.c:3320
void elm_photocam_image_size_get(const Evas_Object *obj, int *w, int *h)
Get the current image pixel width and height.
Definition: efl_ui_image_zoomable.c:3393
void elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
Set bouncing behavior.
Definition: elm_scroller.c:1050
double elm_slider_value_get(const Evas_Object *obj)
Get the value displayed by the slider.
Definition: elm_slider.c:1531
Evas_Object * elm_slider_add(Evas_Object *parent)
Add a new slider widget to the given parent Elementary (container) object.
Definition: elm_slider.c:1437
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition: efl_ui_win.c:9582
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition: efl_ui_win.c:6194
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition: evas_object_main.c:1814
EVAS_API void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
Move the given Evas object to the given location inside its canvas' viewport.
Definition: evas_object_main.c:1171
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:185
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition: evas_object_main.c:1236
Evas_Image_Orient
Possible orientation options for evas_object_image_orient_set().
Definition: Evas_Legacy.h:4912
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition: evas_object_smart.c:1040