summaryrefslogtreecommitdiff
path: root/main/src/view/ivug-slider-item.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/view/ivug-slider-item.c')
-rwxr-xr-xmain/src/view/ivug-slider-item.c703
1 files changed, 0 insertions, 703 deletions
diff --git a/main/src/view/ivug-slider-item.c b/main/src/view/ivug-slider-item.c
deleted file mode 100755
index 1b33e0c..0000000
--- a/main/src/view/ivug-slider-item.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
- *
- * 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.
- */
-
-
-#include "ivug-common.h"
-
-#include "ivug-slider-item.h"
-
-#include "ivug-main.h"
-
-#define DEFAULT_THUMBNAIL_PATH IMAGE_PATH"/T01_Nocontents_broken.png"
-
-#define IVUG_SLIDER_EDJ EDJ_PATH"/ivug-slider.edj"
-
-/*
- Use elm_icon istead of elm_image. elm_icon preserve image ratio. and seems more faster.
-*/
-#define USE_ELM_ICON
-
-bool
-_thumbnail_set( Slide_Item* si, const char *filepath)
-{
- IV_ASSERT(si != NULL);
- IV_ASSERT(filepath != NULL);
-
- if (si->thumbnail == NULL)
- {
- MSG_SITEM_FATAL("slide item or thumbnail object is NULL");
- return false;
- }
-
- MSG_SITEM_MED("Set thumbnail : %s", ivug_get_filename(filepath));
-
-#ifdef USE_ELM_ICON
- if (elm_icon_file_set(si->thumbnail, filepath, NULL) == EINA_FALSE)
- {
- MSG_SITEM_ERROR("Cannot load thumbnail : %s", filepath);
- si->thumbnail_show = EINA_FALSE;
- return false;
- }
-
-#else
- if (elm_image_file_set(si->thumbnail, filepath, NULL) == EINA_FALSE)
- {
- MSG_SITEM_ERROR("Cannot load thumbnail : %s", filepath);
- si->thumbnail_show = EINA_FALSE;
- return false;
- }
-#endif
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,show_thumbnail", "slider");
-
- si->thumbnail_show = EINA_TRUE;
- return true;
-}
-
-
-inline
-void _call_user_callback(Slide_Item* si)
-{
- if ( si->cb )
- {
- (si->cb)(si->state, si, si->client_data);
- }
-
-}
-
-
-static void
-_photocam_loaded_cb(void *data, Evas_Object *obj, void *event_info)
-{
- IV_ASSERT(data != NULL);
-
- Slide_Item* si = data;
-
- //hide progress.
- elm_progressbar_pulse(si->progress, EINA_FALSE); //stop pluse
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide,progress", "slider");
-
- if ( si->mitem == NULL)
- {
- MSG_SITEM_ERROR("Debug Me! Data item is NULL.");
- return;
- }
-
- Media_Data* sdata = ivug_data_get_data(si->mitem);
- if(sdata == NULL)
- {
- MSG_SITEM_ERROR("ivug_data_get_data failed.");
- si->state = SLIDE_STATE_ERROR;
- return;
- }
-
- Evas_Load_Error error = (Evas_Load_Error)event_info;
-
- if ( error != EVAS_LOAD_ERROR_NONE )
- {
- MSG_SITEM_ERROR("Image loading failed. Error=%d", error);
- si->state = SLIDE_STATE_ERROR;
-
- si->photocam_show = EINA_FALSE;
- evas_object_hide(obj);
-
- _thumbnail_set(si, DEFAULT_THUMBNAIL_PATH);
-
- evas_object_repeat_events_set(si->thumbnail, EINA_FALSE);
-
- _call_user_callback(si);
-
- return ;
- }
-
- si->state = SLIDE_STATE_LOADED;
-
- if (sdata->slide_type == SLIDE_TYPE_VIDEO) //if slide type is video,
- {
- // TODO : Never get here..
- MSG_SITEM_FATAL("slide type is video. thumbnail image ");
- return;
- }
-
- si->photocam_show = EINA_TRUE;
- evas_object_show(obj); //photocam show.
-
-// evas_object_move(obj, si->x, si->y);
-
-//hide thumbnail.
- if(si->thumbnail_show == EINA_TRUE)
- {
- MSG_SITEM_HIGH("Thumbnail Hide");
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide_thumbnail", "slider");
- si->thumbnail_show = EINA_FALSE;
- }
-
- _call_user_callback(si);
-
- MSG_SITEM_HIGH("Photocam Pre-loaded. File=%s", ivug_get_filename(sdata->filepath));
-}
-
-Slide_Item*
-ivug_slider_item_add(Evas_Object *slider)
-{
- Slide_Item* si = NULL;
-
- //create item
- si = (Slide_Item*)calloc(1, sizeof (Slide_Item));
-
- if ( si == NULL )
- {
- MSG_SITEM_FATAL("Cannot allocated memory : %d.", sizeof (Slide_Item));
- return NULL;
- }
-
- si->state = SLIDE_STATE_NONE; //set slide state
-
-//Create the slider item layout
- Evas_Object *layout = elm_layout_add(slider);
- if(elm_layout_file_set(layout, IVUG_SLIDER_EDJ, "slider") == EINA_FALSE)
- {
- MSG_SITEM_ERROR("Cannot load file : %s", IVUG_SLIDER_EDJ);
- free(si);
-
- return NULL;
- }
-
- si->layout = layout;
-
-//Add the photocam
- si->photocam = elm_photocam_add(slider);
- elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
- elm_photocam_paused_set(si->photocam, EINA_TRUE);
- evas_object_smart_callback_call(si->photocam, "scroll-freeze-on", si->photocam);
- evas_object_smart_callback_add(si->photocam, "loaded", _photocam_loaded_cb, si);
-
- elm_object_part_content_set(si->layout, "slider.photocam", si->photocam);
-
-//set thumbnail.
-#ifdef USE_ELM_ICON
- si->thumbnail = elm_icon_add(slider);
-#else
- si->thumbnail = elm_image_add(slider);
-#endif
- elm_object_part_content_set(si->layout, "slider.thumbnail", si->thumbnail);
-
-//set progress
- si->progress = elm_progressbar_add(slider);
- elm_object_style_set(si->progress, "list_process");
- elm_progressbar_pulse(si->progress, EINA_FALSE);
-
- elm_object_part_content_set(si->layout, "slider.progress", si->progress);
-
- si->icon = edje_object_part_object_get(_EDJ(si->layout), "slider.icon");
-
- evas_object_clip_set(si->layout, slider);
-
-// Add 하는 순서에 따라 Z-Order이 결정 된다.
- evas_object_smart_member_add(si->layout, slider);
-
- si->w = gGetScreenWidth();
- si->h = gGetScreenHeight();
-
- MSG_SITEM_HIGH("Creating slider item. 0x%08x. WH(%dx%d)", si, si->w, si->h);
-
- return si;
-
-}
-
-void
-ivug_slider_item_resize(Slide_Item* si, int w, int h)
-{
- IV_ASSERT(si != NULL );
-
- // TODO : Impelement
- MSG_SITEM_HIGH("SLIDER Resize to WH(%d,%d)", w, h );
-
-// w,h is not Image's scale, but Object's scale
- si->w = w;
- si->h = h;
-
-// MSG_SITEM_HIGH("resize layout: %d, %d", si->w, si->h);
- evas_object_resize(si->layout, si->w, si->h);
-
- ivug_slider_item_zoom_reset(si, EINA_FALSE, 0,0);
-}
-
-void ivug_slider_item_del(Slide_Item* si)
-{
- IV_ASSERT(si != NULL );
-
- if (si->photocam)
- {
- evas_object_del(si->photocam); //remove photocam
- si->photocam = NULL;
- }
-
- if (si->thumbnail)
- {
- evas_object_del(si->thumbnail);
- si->thumbnail = NULL;
- }
-
- if (si->progress)
- {
- evas_object_del(si->progress);
- si->progress = NULL;
- }
-
- if(si->layout)
- {
- evas_object_del(si->layout);
- si->layout = NULL;
- }
-
- free(si);
-
- MSG_SITEM_HIGH("Slide item is deleted");
-}
-
-void ivug_slider_item_hide(Slide_Item* si)
-{
- IV_ASSERT(si != NULL );
-
- MSG_SITEM_HIGH("hide bg");
- evas_object_hide(si->layout);
-}
-
-void ivug_slider_item_show(Slide_Item* si)
-{
- IV_ASSERT(si != NULL );
-
-// no need to check layout is NULL
- evas_object_show(si->layout);
-}
-
-void ivug_slider_item_move(Slide_Item* si, int x, int y)
-{
- IV_ASSERT(si != NULL );
-
-
-// MSG_SITEM_HIGH("SLIDER(%d) Move to XY(%d,%d)", si->idx, x, y );
- //photocam
- si->x = x;
- si->y = y;
-
-// MSG_SITEM_HIGH("move layout: %d, %d", x, y);
- evas_object_move(si->layout, x, y);
-}
-
-void
-ivug_slider_item_clip_set(Slide_Item* si, Evas_Object *clipper)
-{
- IV_ASSERT(si != NULL );
-// no need to check layout is NULL
- MSG_SITEM_HIGH("Clip SET!!");
-
- evas_object_clip_set(si->layout, clipper);
-}
-
-void
-ivug_slider_item_clip_unset(Slide_Item* si)
-{
- IV_ASSERT(si != NULL );
-// no need to check layout is NULL
- evas_object_clip_unset(si->layout);
-}
-
-bool
-ivug_slider_item_set_callback(Slide_Item* si, OnSliderStateChanged cb, void *data)
-{
- ivug_retv_if(!si, false);
-
- si->cb = cb;
- si->client_data = data;
-
- return true;
-}
-
-bool
-ivug_slider_item_data_loading(Slide_Item *si)
-{
- IV_ASSERT(si != NULL);
-
- if ( si->state != SLIDE_STATE_READY)
- {
- MSG_SITEM_ERROR("Invalid state : %d", si->state);
- return false;
- }
-
- Media_Data *mdata = ivug_data_get_data(si->mitem);
- if ( mdata == NULL )
- {
- MSG_SITEM_ERROR("Data is NULL");
- return false;
- }
-
- char path[IVUG_MAX_FILE_PATH_LEN] = {0,};
-
- strncpy(path, mdata->filepath, strlen(mdata->filepath));
-
- switch(mdata->slide_type)
- {
- case SLIDE_TYPE_IMAGE:
- {
- MSG_SITEM_HIGH("Load Image. %s", ivug_get_filename(path));
- si->state = SLIDE_STATE_LOADING;
-
- if (elm_photocam_file_set(si->photocam, path) != EVAS_LOAD_ERROR_NONE)
- {
- MSG_SITEM_ERROR("Failed photocam to set file file=%s", path);
-
- _photocam_loaded_cb(si, si->photocam, (void *) EVAS_LOAD_ERROR_UNKNOWN_FORMAT);
-
- return false;
- }
-
- return true;
-
- }
- break;
-
- case SLIDE_TYPE_VIDEO:
- return true;
- break;
-
- default:
- MSG_SITEM_ERROR("slide type invaild. Type=%d", mdata->slide_type);
- return false;
- break;
- }
-
- return true;
-}
-
-
-bool
-ivug_slider_item_data_set(Slide_Item* si, Media_Item *item)
-{
- ivug_retv_if(!si, false);
-
- if ( si->state != SLIDE_STATE_NONE )
- {
- MSG_SITEM_ERROR("State is not none... State=%d", si->state);
- si->state = SLIDE_STATE_NONE;
- }
-
- if ( item == NULL )
- {
- MSG_SITEM_WARN("Item is NULL");
- return false;
- }
-
- si->mitem = item;
-
- Media_Data *mdata = ivug_data_get_data(item);
-
- if ( mdata == NULL )
- {
- MSG_SITEM_ERROR("Data is NULL");
- return false;
- }
-
- switch(mdata->slide_type)
- {
- case SLIDE_TYPE_IMAGE:
- MSG_SITEM_HIGH("Set image. %s", ivug_get_filename(mdata->filepath));
-
- si->state = SLIDE_STATE_READY;
-
- break;
- case SLIDE_TYPE_VIDEO:
- if (mdata->thumbnail_path)
- {
- _thumbnail_set(si, mdata->thumbnail_path);
- // Go through
- }
- else
- {
- _thumbnail_set(si, DEFAULT_THUMBNAIL_PATH);
- }
-
- si->photocam_show = EINA_FALSE;
-
- evas_object_repeat_events_set(si->thumbnail, EINA_FALSE); // In case of video, photocam should not receive events
-
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,show_icon", "slider"); // Video icon
-
- MSG_SITEM_HIGH("Set video. %s", ivug_get_filename(mdata->filepath));
-
- si->state = SLIDE_STATE_LOADED; // Video dont need to load photocam
-
- break;
-
- case SLIDE_TYPE_UNKNOWN:
- if (mdata->thumbnail_path)
- {
- _thumbnail_set(si, mdata->thumbnail_path);
- // Go through
- }
-
- MSG_SITEM_ERROR("Unknown image. %s", ivug_get_filename(mdata->filepath));
-
- si->state = SLIDE_STATE_ERROR;
-
- break;
-
- default:
- MSG_SITEM_ERROR("slide type invaild. Type=%d", mdata->slide_type);
- si->state = SLIDE_STATE_ERROR;
- return false;
- break;
-
- }
-
- si->zoom_level = 0;
-
- return true;
-}
-
-slide_state_t
-ivug_slider_item_get_state(Slide_Item *si)
-{
- IV_ASSERT(si != NULL);
-
- return si->state;
-}
-
-const Media_Item *
-ivug_slider_item_data_get(Slide_Item *si)
-{
- IV_ASSERT(si != NULL);
-
- return si->mitem;
-}
-
-
-void
-ivug_slider_item_data_unset(Slide_Item* si)
-{
- IV_ASSERT(si != NULL);
-
- if ( si->state == SLIDE_STATE_NONE )
- {
- MSG_SITEM_WARN("Slide item is already cleared. just return");
- return;
- }
-
- if(si->progress)
- {
- elm_progressbar_pulse(si->progress, EINA_FALSE); //stop pluse
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide,progress", "slider");
- }
-
- if ( si->mitem == NULL )
- {
- // When delete case, this code is launched.
- MSG_SITEM_WARN("MItem is NULL.");
- // Go through
- }
- else
- {
- Media_Data *mdata = ivug_data_get_data(si->mitem);
-
- if ( mdata == NULL )
- {
- MSG_SITEM_ERROR("Data is NULL");
- return ;
- }
-
- MSG_SITEM_HIGH("Clear Image. %s", ivug_get_filename(mdata->filepath));
-
- si->mitem = NULL;
- }
-
- if (si->thumbnail_show)
- {
- si->thumbnail_show = EINA_FALSE;
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide_thumbnail", "slider");
- }
-
- if(si->layout)
- {
- edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide_icon", "slider");
- }
-
-// does not check photocam_show flags. because photocam_show only set true when finish preloading.
-// during preloading photocam_show is remains false,
- si->photocam_show = EINA_FALSE;
-// elm_layout_content_unset(si->layout, "slider.photocam"); //
-
- evas_object_hide(si->photocam);
-
- evas_object_del(si->photocam);
- si->photocam = elm_photocam_add(si->layout);
- elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
- elm_photocam_paused_set(si->photocam, EINA_TRUE);
- evas_object_smart_callback_call(si->photocam, "scroll-freeze-on", si->photocam);
- evas_object_smart_callback_add(si->photocam, "loaded", _photocam_loaded_cb, si);
- elm_object_part_content_set(si->layout, "slider.photocam", si->photocam);
-
- si->state = SLIDE_STATE_NONE;
-
- si->zoom_level = 0;
-
- MSG_SITEM_MED("Slider Item is cleared.");
-
-}
-
-
-void ivug_slider_item_change_mitem_pointer(Slide_Item* si, Media_Item *item)
-{
- IV_ASSERT(si != NULL );
-
- si->mitem = item;
-}
-
-
-
-// Photocam
-bool
-ivug_slider_item_region_size_get(Slide_Item* si, int *x, int *y, int *w, int *h)
-{
- IV_ASSERT(si != NULL );
-
- if ( si->mitem == NULL)
- {
- MSG_SITEM_ERROR("Debug Me! Data item is NULL.");
- return false;
- }
-
- Media_Data *mdata = ivug_data_get_data(si->mitem);
-
- if ( mdata == NULL )
- {
- MSG_SITEM_ERROR("slide type is NULL. Item=0x%08x", si);
- return false; // TODO : Temp..
- }
-
- if ( mdata->slide_type == SLIDE_TYPE_VIDEO)
- {
- return false;
- }
-
- Evas_Object *image = elm_photocam_internal_image_get(si->photocam);
- evas_object_geometry_get(image, x, y, w, h);
- MSG_SITEM_MED("x = %d, y = %d, w = %d, h = %d", *x, *y, *w, *h);
-
- return true;
-}
-
-
-
-void
-ivug_slider_item_hold_set(Slide_Item* si, Eina_Bool hold)
-{
- IV_ASSERT(si != NULL );
-
- if(hold == EINA_TRUE)
- {
- evas_object_smart_callback_call(si->photocam, "scroll-freeze-on", si->photocam);
- }
- else
- {
- evas_object_smart_callback_call(si->photocam, "scroll-freeze-off", si->photocam);
- }
-}
-
-
-void
-ivug_slider_item_zoom_reset(Slide_Item* si, Eina_Bool bAnim, int center_x, int center_y)
-{
- IV_ASSERT(si != NULL );
-
- if ( si->photocam_show )
- {
- Evas_Point pt;
-
- pt.x = center_x;
- pt.y = center_y;
- elm_photocam_paused_set(si->photocam, !bAnim); //stop photocam animation
- elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
-
- si->zoom_level = 0;
- }
-}
-
-
-void
-ivug_slider_item_zoom_set(Slide_Item* si, double zoom, int center_x, int center_y)
-{
- IV_ASSERT(si != NULL );
-
- if ( si->photocam_show )
- {
- elm_photocam_paused_set(si->photocam, EINA_FALSE); //stop photocam animation
- elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
- elm_photocam_zoom_set(si->photocam, zoom);
- }
-}
-
-double
-ivug_slider_item_zoom_get(Slide_Item* si)
-{
- IV_ASSERT(si != NULL );
-
- double ret = 1.0;
-
- if ( si->photocam_show )
- {
- ret = elm_photocam_zoom_get(si->photocam);
- }
- return ret;
-}
-
-
-bool
-ivug_slider_item_icon_click_check(Slide_Item *si, int x, int y)
-{
- MSG_SITEM_HIGH("Check icon clicked. SI=0x%08x, XY(%d,%d)", si, x, y);
-
- IV_ASSERT(si != NULL );
-
- Media_Data *mdata = ivug_data_get_data(si->mitem);
-
- if ( mdata == NULL )
- {
- MSG_SITEM_ERROR("Debug Me! Data item is NULL.");
- return false;
- }
-
- if ( mdata->slide_type == SLIDE_TYPE_VIDEO )
- {
- if (si->icon)
- {
- Evas_Coord ix,iy,iw,ih;
-
- evas_object_geometry_get(si->icon, &ix, &iy, &iw, &ih);
-
- bool bInside = !( (x) > (ix + iw) || (x) < (ix)
- || (y) > (iy + iw) || (y) < (iy) );
-
- MSG_SITEM_HIGH("Item XYWH(%d,%d,%d,%d) XY(%d,%d) bInside=%d", ix,iy,iw,ih, x, y, bInside);
-
- return bInside;
- }
- }
-
- MSG_SITEM_HIGH("Slide type = %d", mdata->slide_type);
- return false;
-}
-
-