fix caller id rotate region error
[apps/core/preloaded/ug-image-viewer-efl.git] / main / src / view / ivug-setas-view-callerid.cpp
index b5912f5..a67f105 100755 (executable)
@@ -5,7 +5,7 @@
  * 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
+ *       http://floralicense.org/license/
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -96,6 +96,14 @@ static void _put_scissorbox_default(TSetAsData *pSetAsData)
 
        ivug_image_image_size_get(pSetAsData->photocam, &image_w, &image_h);    // Get original image size.
 
+       /*int degree = ivug_image_rotate_get(pSetAsData->photocam);
+       if(degree == 90 || degree == 270)       //rotated
+       {
+               int temp = image_w;
+               image_w = image_h;
+               image_h = temp;
+       }*/
+
        int px, py, pw, ph;
        ivug_image_region_get(pSetAsData->photocam, &px, &py, &pw, &ph);
 
@@ -146,6 +154,18 @@ static void _put_scissorbox_default(TSetAsData *pSetAsData)
        ivug_scissorbox_region_set(pSetAsData->crop.box, rect.x, rect.y, rect.w, rect.h);
 
        ivug_scissorbox_attach(pSetAsData->crop.box, image);            // Attach to photocam
+
+       int lcd_x, lcd_y, lcd_w, lcd_h;
+
+       evas_object_geometry_get(pSetAsData->contents_area, &lcd_x, &lcd_y, &lcd_w, &lcd_h);
+       MSG_SETAS_MED("lcd_x=%d, lcd_y=%d, lcd_w=%d, lcd_h=%d", lcd_x, lcd_y, lcd_w, lcd_h);
+
+       ivug_scissorbox_boundary_set(pSetAsData->crop.box, px, lcd_y+py, pw, ph);
+
+       pSetAsData->prev_x = px;        //lcd_x is wrong because transition effect
+       pSetAsData->prev_y = lcd_y+py;
+       pSetAsData->prev_w = pw;
+       pSetAsData->prev_h = ph;
 }
 
 static Eina_Bool _put_scissorbox_timer_cb(void *data)
@@ -233,14 +253,6 @@ _on_photocam_loaded(void *data, Evas_Object *obj, void *event_info)
                                                                                                                                "setasview.contents.swallow.notify"));
 
        pSetAsData->notify = ivug_notify_static_create(pSetAsData->notify_area, IDS_CALLER_ID_NOTIFY, NOTIFY_ALIGN_BOTTOM);
-
-       int x, y, w, h;
-       ivug_image_region_get(pSetAsData->photocam,  &x, &y, &w, &h);
-
-       pSetAsData->prev_x = x;
-       pSetAsData->prev_y = y;
-       pSetAsData->prev_w = w;
-       pSetAsData->prev_h = h;
 }
 
 
@@ -276,7 +288,7 @@ static void _on_resized(void *data, Evas *e, Evas_Object *obj, void *event_info)
 
        int lcd_x, lcd_y, lcd_w, lcd_h;
 
-       evas_object_geometry_get(obj, &lcd_x, &lcd_y, &lcd_w, &lcd_h);
+       evas_object_geometry_get(pSetAsData->contents_area, &lcd_x, &lcd_y, &lcd_w, &lcd_h);
        MSG_SETAS_MED("lcd_x=%d, lcd_y=%d, lcd_w=%d, lcd_h=%d", lcd_x, lcd_y, lcd_w, lcd_h);
 
        int ph, pw;
@@ -319,10 +331,18 @@ static void _on_resized(void *data, Evas *e, Evas_Object *obj, void *event_info)
        dx *= zoom;
        dy *= zoom;
 
-       sx = (ext_w-img_w*zoom)/2 + dx;
-       sy = (ext_h-img_h*zoom)/2 + dy;
+       sx = lcd_x + (ext_w-img_w*zoom)/2 + dx;
+       sy = lcd_y + (ext_h-img_h*zoom)/2 + dy;
+
+
+       int bound_x, bound_y, bound_w, bound_h;
 
-       ivug_scissorbox_boundary_set(pSetAsData->crop.box, (ext_w-img_w*zoom)/2, (ext_h-img_h*zoom)/2, img_w*zoom, img_h*zoom);
+       bound_x = lcd_x+(ext_w-img_w*zoom)/2;
+       bound_y = lcd_y+(ext_h-img_h*zoom)/2;
+       bound_w = img_w*zoom;
+       bound_h = img_h*zoom;
+
+       ivug_scissorbox_boundary_set(pSetAsData->crop.box, bound_x, bound_y, bound_w, bound_h);
 
        ///////////////////////////////////////////////////////////////////
 
@@ -330,14 +350,12 @@ static void _on_resized(void *data, Evas *e, Evas_Object *obj, void *event_info)
 
        ivug_scissorbox_region_set(pSetAsData->crop.box, sx, sy, sw, sh);
 
-       ivug_image_region_get(pSetAsData->photocam, &org_x, &org_y, &org_w, &org_h);
-
-       MSG_SETAS_MED("org_x=%d, org_y=%d, org_w=%d, org_h=%d", org_x, org_y, org_w, org_h);
+       pSetAsData->prev_x = bound_x;
+       pSetAsData->prev_y = bound_y;
+       pSetAsData->prev_w = bound_w;
+       pSetAsData->prev_h = bound_h;
 
-       pSetAsData->prev_x = org_x;
-       pSetAsData->prev_y = org_y;
-       pSetAsData->prev_w = org_w;
-       pSetAsData->prev_h = org_h;
+       MSG_SETAS_MED("prev_x=%d, prev_y=%d, prev_w=%d, prev_h=%d", pSetAsData->prev_x, pSetAsData->prev_y, pSetAsData->prev_w, pSetAsData->prev_h);
 }
 
 static Evas_Event_Flags _finger_tap_end(void *data , void *event_info)
@@ -355,7 +373,7 @@ static Evas_Event_Flags _finger_tap_end(void *data , void *event_info)
        {
                MSG_SETAS_HIGH("Hide");
                elm_win_indicator_mode_set((Evas_Object*)ug_get_window(), ELM_WIN_INDICATOR_HIDE);
-               evas_object_hide(pSetAsData->notify);
+               //evas_object_hide(pSetAsData->notify);
        }
        else
        {
@@ -364,7 +382,7 @@ static Evas_Event_Flags _finger_tap_end(void *data , void *event_info)
                {
                        elm_win_indicator_mode_set((Evas_Object *)ug_get_window(), ELM_WIN_INDICATOR_SHOW);
                }
-               evas_object_show(pSetAsData->notify);
+               //evas_object_show(pSetAsData->notify);
        }
 
        pSetAsData->bShowMenu = !pSetAsData->bShowMenu;