bugfix: sometimes image shown when textonly setted & dim move from evas_rect(c) to...
[framework/uifw/cbhm.git] / src / clipdrawer.c
index 8e686e6..68911ab 100644 (file)
@@ -70,6 +70,99 @@ const char* clipdrawer_get_plain_string_from_escaped(char *escstr)
        return remove_tags(escstr);
 }
 
+static char* _get_string_for_entry(char *str)
+{
+       if (!str)
+               return NULL;
+
+       Eina_Strbuf *strbuf = eina_strbuf_new();
+       if (!strbuf)
+               return strdup(str);
+       eina_strbuf_prepend(strbuf, "<font_size=18>");
+
+       char *trail = str;
+
+       while (trail && *trail)
+       {
+               char *pretrail = trail;
+               unsigned long length;
+               char *temp;
+               char *endtag;
+
+               trail = strchr(trail, '<');
+               if (!trail)
+               {
+                       eina_strbuf_append(strbuf, pretrail);
+                       break;
+               }
+               endtag = strchr(trail, '>');
+               if (!endtag)
+                       break;
+
+               length = trail - pretrail;
+
+               temp = strndup(pretrail, length);
+               if (!temp)
+               {
+                       trail++;
+                       continue;
+               }
+
+               DTRACE("temp str: %s \n", temp);
+               eina_strbuf_append(strbuf, temp);
+               free(temp);
+               trail++;
+
+               if (trail[0] == '/')
+               {
+                       trail = endtag + 1;
+                       continue;
+               }
+
+               if (strncmp(trail, "br", 2) == 0)
+               {
+                       eina_strbuf_append(strbuf, "<br>");
+                       trail = endtag + 1;
+                       continue;
+               }
+
+               if (strncmp(trail, "img", 3) == 0)
+               {
+                       char *src = strstr(trail, "file://");
+                       char *src_endtag = strchr(trail, '>');
+                       if (!src || !src_endtag || src_endtag < src)
+                               continue;
+
+                       length = src_endtag - src;
+
+                       src = strndup(src, length);
+                       if (!src)
+                       {
+                               trail = endtag + 1;
+                               continue;
+                       }
+                       temp = src;
+                       while(*temp)
+                       {
+                               if (*temp == '\"' || *temp == '>')
+                                       *temp = '\0';
+                               else
+                                       temp++;
+                       }
+
+                       eina_strbuf_append_printf(strbuf, "<item absize=66x62 href=%s></item>", src);
+                       DTRACE("src str: %s \n", src);
+                       free(src);
+               }
+               trail = endtag + 1;
+       }
+
+       char *ret = eina_strbuf_string_steal(strbuf);
+       eina_strbuf_free(strbuf);
+       DTRACE("result str: %s \n", ret);
+       return ret;
+}
+
 static void _grid_del_response_cb(void *data, Evas_Object *obj, void *event_info)
 {
        Elm_Gengrid_Item *it = (Elm_Gengrid_Item *)data;
@@ -145,7 +238,6 @@ _grid_item_ly_clicked(void *data, Evas_Object *obj, const char *emission, const
                                DTRACE("ERR: cbhm image paste mode is false\n");
                        }
                }
-
                return;
        }
 
@@ -219,9 +311,14 @@ Evas_Object* _grid_icon_get(const void *data, Evas_Object *obj, const char *part
                        eina_strbuf_replace_all(strent, " absize=240x180 ", " absize=52x39 ");
                        if (strcnt > 100)
                                eina_strbuf_append(strent, "...");
-                       eina_strbuf_prepend(strent, "<font_size=18>");
                        elm_entry_scrollable_set(ientry, EINA_TRUE);
-                       elm_object_text_part_set(ientry, NULL, eina_strbuf_string_get(strent));
+                       char *entry_text = eina_strbuf_string_get(strent);
+                       entry_text = _get_string_for_entry(entry_text);
+                       if (entry_text)
+                       {
+                               elm_object_text_part_set(ientry, NULL, entry_text);
+                               free(entry_text);
+                       }
                        elm_entry_editable_set(ientry, EINA_FALSE);
                        elm_entry_context_menu_disabled_set(ientry, EINA_TRUE);
                        evas_object_show(ientry);
@@ -248,14 +345,10 @@ Evas_Object* _grid_icon_get(const void *data, Evas_Object *obj, const char *part
 
                        struct appdata *ad = g_get_main_appdata();
                        
-                       if (!clipdrawer_paste_textonly_get(ad))
-                       {
-                               edje_object_signal_emit(elm_layout_edje_get(layout), "elm,state,hide,delbtn", "elm");
-                               Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(obj));
-                               evas_object_color_set(rect, 0, 0, 0, 200);
-                               evas_object_show(rect);
-                               elm_layout_content_set(layout, "elm.swallow.cover", rect);
-                       }
+                       if (clipdrawer_paste_textonly_get(ad))
+                               edje_object_signal_emit(elm_layout_edje_get(layout), "elm,state,show,dim", "elm");
+                       else
+                               edje_object_signal_emit(elm_layout_edje_get(layout), "elm,state,hide,dim", "elm");
 
                        ti->ilayout = layout;
                        return layout;
@@ -303,7 +396,7 @@ char* clipdrawer_get_item_data(void *data, int pos)
                return NULL;
 
        Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
-       while (item)    
+       while (item)
        {
                ti = elm_gengrid_item_data_get(item);
                if (count == pos)
@@ -316,7 +409,7 @@ char* clipdrawer_get_item_data(void *data, int pos)
                                return ti->ipathdata;
                }
                count++;
-               item = elm_gengrid_item_next_get(item);      
+               item = elm_gengrid_item_next_get(item);
        }
 
        return NULL;
@@ -349,7 +442,7 @@ int clipdrawer_add_item(char *idata, int type)
                        return -1;
                }
 
-               while (item)    
+               while (item)
                {
                        ti = elm_gengrid_item_data_get(item);
                        if ((ti->itype == type) && !strcmp(ti->ipathdata, idata))
@@ -357,7 +450,7 @@ int clipdrawer_add_item(char *idata, int type)
                                DTRACE("Error : duplicated file path = %s\n", idata);
                                return -1;
                        }
-                       item = elm_gengrid_item_next_get(item);      
+                       item = elm_gengrid_item_next_get(item);
                }
                newgi->ipathdata = eina_stringshare_add(idata);
        }
@@ -390,6 +483,40 @@ clipdrawer_ly_clicked(void *data, Evas_Object *obj, const char *emission, const
        }
 }
 
+static void set_sliding_win_geometry(void *data)
+{
+       struct appdata *ad = data;
+       Ecore_X_Window zone, xwin;
+       Evas_Coord x, y, w, h;
+       xwin = elm_win_xwindow_get(ad->win_main);
+       zone = ecore_x_e_illume_zone_get(xwin);
+       DTRACE("[CBHM] xwin:%x, zone:%x\n", xwin, zone);
+
+//     ecore_evas_geometry_get(ecore_evas_ecore_evas_get(evas_object_evas_get(ad->win_main)), &x, &y, &w, &h);
+
+       if (ad->o_degree == 90 || ad->o_degree == 270)
+       {
+               h = ad->anim_count/30.0 * CLIPDRAWER_HEIGHT_LANDSCAPE;
+               x = 0;
+               y = ad->root_w - h;
+               w = ad->root_h;
+       }
+       else
+       {
+               h = ad->anim_count/30.0 * CLIPDRAWER_HEIGHT;
+               x = 0;
+               y = ad->root_h - h;
+               w = ad->root_w;
+       }
+
+       if (!h)
+               w = 0;
+
+       DTRACE("[CBHM] change degree geometry... (%d, %d, %d x %d)\n", x, y, w, h);
+       ecore_x_e_illume_sliding_win_geometry_set(zone, x, y, w, h);
+       ecore_x_e_illume_sliding_win_state_set(zone, ad->anim_count != 0);
+}
+
 void set_rotation_to_clipdrawer(void *data)
 {
        struct appdata *ad = data;
@@ -428,6 +555,8 @@ void set_rotation_to_clipdrawer(void *data)
 
        evas_object_resize(ad->win_main, wwidth, (int)wh);
        evas_object_move(ad->win_main, wposx, (int)wy);
+       if (ad->anim_count == ANIM_DURATION)
+               set_sliding_win_geometry(data);
 }
 
 int clipdrawer_init(void *data)
@@ -597,6 +726,8 @@ static void stop_animation(void *data)
                ecore_timer_del(anim_timer);
                anim_timer = NULL;
        }
+
+       set_sliding_win_geometry(data);
 }
 
 Eina_Bool anim_pos_calc_cb(void *data)
@@ -693,43 +824,21 @@ void _change_gengrid_paste_textonly_mode(void *data)
 {
        struct appdata *ad = data;
 
-       Elm_Gengrid_Item *item;
        griditem_t *ti = NULL;
 
-       if (clipdrawer_paste_textonly_get(ad))
-       { // textonly paste mode
-               Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
-
-               while (item)    
-               {
-                       ti = elm_gengrid_item_data_get(item);
-                       if ((ti->itype == GI_IMAGE) && (ti->ilayout))
-                       {
-                               edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,hide,delbtn", "elm");
-                               Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(ad->hig));
-                               evas_object_color_set(rect, 0, 0, 0, 200);
-                               evas_object_show(rect);
-                               elm_layout_content_set(ti->ilayout, "elm.swallow.cover", rect);
-                       }
-                       item = elm_gengrid_item_next_get(item);
-               }
-       }
-       else
-       { // text+image paste mode
-               Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
+       Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
 
-               while (item)    
+       while (item)
+       {
+               ti = elm_gengrid_item_data_get(item);
+               if ((ti->itype == GI_IMAGE) && (ti->ilayout))
                {
-                       ti = elm_gengrid_item_data_get(item);
-                       if ((ti->itype == GI_IMAGE) && (ti->ilayout))
-                       {
-                               edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,show,delbtn", "elm");
-                               Evas_Object *rect = elm_layout_content_unset(ti->ilayout, "elm.swallow.cover");
-                               evas_object_hide(rect);
-                               evas_object_del(rect);
-                       }
-                       item = elm_gengrid_item_next_get(item);      
+                       if (clipdrawer_paste_textonly_get(ad))
+                               edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,show,dim", "elm");
+                       else
+                               edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,hide,dim", "elm");
                }
+               item = elm_gengrid_item_next_get(item);
        }
 }