/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __IMAGE_COMMON_H__
#define __IMAGE_COMMON_H__

#include <Evas.h>

#define TITLE_MAX_LEN 128
#define LABEL_MAX_LEN 500
#define TOOLBAR_BUTTON_DATA_KEY "button_id"
#define IMAGES_REL_FOLDER "images"
#define LABEL_REL_PATH "res/"IMAGES_REL_FOLDER"/"

/**
 * @brief Load image file by name into elm_image.
 * @param[in,out] image   Evas_Object elm_image object
 * @param[in] file_name   Image file name relative to shared images resources directory
 * @return true if success, false otherwise
 */
bool ic_load_image(Evas_Object *image, const char *file_name);

/**
 * @brief Evas_Object_Event_Cb function that frees data passed in first parameter.
 * @param[in,out] data  data to be freed
 * @param[in] e         Evas
 * @param[in] obj       Layout object
 * @param[in] event_info    event info of Evas_Object_Event_Cb
 */
void ic_main_layout_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);

/**
 * @brief Add default grid and part content set it into parent swallow part.
 * @param[in] parent            Evas_Object parent
 * @param[in] rel_max_width     relative max width of grid
 * @param[in] rel_max_height    relative max height of grid
 * @return new grid object
 */
Evas_Object *ic_create_grid(Evas_Object *parent, double rel_max_width, double rel_max_height);

/**
 * @brief Add default image part and load file_name image.
 * @param[in] parent            Evas_Object parent
 * @param[in] file_name         Image file name relative to shared images resources directory
 * @return new image object
 */
Evas_Object *ic_create_image(Evas_Object *parent, const char *file_name);

/**
 * @brief Add default slider
 * @param[in] parent            Evas_Object parent
 * @param[in] slider_min        min slider value
 * @param[in] slider_max        max slider value
 * @return new slider object
 */
Evas_Object *ic_create_slider(Evas_Object *parent, double slider_min, double slider_max);

/**
 * @brief Add default label
 * @param[in] parent            Evas_Object parent
 * @return new lable object
 */
Evas_Object *ic_create_label(Evas_Object *parent);

/**
 * @brief Add default scroller
 * @param[in] parent            Evas_Object parent
 * @return new scroller object
 */
Evas_Object *ic_create_scroller(Evas_Object *parent);

/**
 * @brief Sets elm_image animated state if possible
 * @param[in,out] image   Evas_Object elm_image object
 */
void ic_image_set_animated(Evas_Object *image);

/**
 * @brief Calculate new centered geometry of evas_object_image object
 * @param[in,out] evas_image   Evas_Object evas_object_image
 * @param[in] evas_image_container   Evas_Object container of evas_image
 * @param[in] scale   Value of scaling the evas_image object
 * @param[out] new_geometry   Evas_Coord_Rectangle pointer to new centered geometry
 * @return true if success, false otherwise
 */
bool ic_calc_image_new_geometry(Evas_Object *evas_image, Evas_Object *evas_image_container,
                                    double scale, Evas_Coord_Rectangle *new_geometry);

/**
 * @brief Get current geometry of evas_object on screen
 * @param[in] object   The given Evas_Object geometry to get.
 * @return Evas_Coord_Rectangles of Evas_Object. In case of NULL passed as object, function returns Evas_Coord_Rectangle filled with zeros.
 */
Evas_Coord_Rectangle ic_get_geometry(const Evas_Object* object);

#endif // __IMAGE_COMMON_H__
