add close button
authorHyoyoung Chang <hyoyoung.chang@samsung.com>
Wed, 6 Oct 2010 12:40:39 +0000 (21:40 +0900)
committerHyoyoung Chang <hyoyoung.chang@samsung.com>
Wed, 6 Oct 2010 12:40:39 +0000 (21:40 +0900)
CMakeLists.txt
data/images/clipboard_arrow_bar.png [new file with mode: 0755]
data/images/clipboard_close_arrow.png [new file with mode: 0644]
data/images/clipboard_close_bg.png [new file with mode: 0644]
data/images/clipboard_panel_bg.png [new file with mode: 0755]
data/images/clipboard_panel_list_bg.png [new file with mode: 0755]
data/themes/cbhmdrawer.edc
src/clipdrawer.c
src/clipdrawer.h
src/xcnphandler.c

index 0650b44..4d3ce5d 100755 (executable)
@@ -29,6 +29,7 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 
 ADD_CUSTOM_TARGET(cbhmdrawer.edj 
                COMMAND edje_cc 
+               -id ${CMAKE_CURRENT_SOURCE_DIR}/data/images             
                ${CMAKE_SOURCE_DIR}/data/themes/cbhmdrawer.edc ${CMAKE_BINARY_DIR}/data/themes/cbhmdrawer.edj
                DEPENDS ${CMAKE_SOURCE_DIR}/data/themes/cbhmdrawer.edc
 )
diff --git a/data/images/clipboard_arrow_bar.png b/data/images/clipboard_arrow_bar.png
new file mode 100755 (executable)
index 0000000..ff213e6
Binary files /dev/null and b/data/images/clipboard_arrow_bar.png differ
diff --git a/data/images/clipboard_close_arrow.png b/data/images/clipboard_close_arrow.png
new file mode 100644 (file)
index 0000000..bcf7b1c
Binary files /dev/null and b/data/images/clipboard_close_arrow.png differ
diff --git a/data/images/clipboard_close_bg.png b/data/images/clipboard_close_bg.png
new file mode 100644 (file)
index 0000000..4fc47fa
Binary files /dev/null and b/data/images/clipboard_close_bg.png differ
diff --git a/data/images/clipboard_panel_bg.png b/data/images/clipboard_panel_bg.png
new file mode 100755 (executable)
index 0000000..bca7741
Binary files /dev/null and b/data/images/clipboard_panel_bg.png differ
diff --git a/data/images/clipboard_panel_list_bg.png b/data/images/clipboard_panel_list_bg.png
new file mode 100755 (executable)
index 0000000..8068680
Binary files /dev/null and b/data/images/clipboard_panel_list_bg.png differ
index 4fb5c80..4ed52ab 100644 (file)
@@ -1,5 +1,5 @@
 #define MAIN_W 480
-#define MAIN_H 400
+#define MAIN_H 335
 
 collections 
 {
@@ -8,13 +8,24 @@ collections
                name: "cbhmdrawer";
                //min: MAIN_W MAIN_H;
                //max: MAIN_W MAIN_H;
+               images
+               {
+//     arrow_bar splited to two images (close_{bg,arrow})
+//                             image: "clipboard_arrow_bar.png" COMP;
+                               image: "clipboard_close_bg.png" COMP;
+                               image: "clipboard_close_arrow.png" COMP;
+                               image: "clipboard_panel_bg.png" COMP;
+                               image: "clipboard_panel_list_bg.png" COMP;
+               }
 
                parts 
                {
                        part 
                        { 
+                               // width: 480, height: 335
                                name: "background";
                                type: RECT;
+                               scale: 1;
                                mouse_events: 1;
                                description 
                                {
@@ -25,30 +36,88 @@ collections
                                }
                        }
 
+                       part
+                       {
+                               // width: 35, height: 335
+                               name: "cbhmdrawer/closebtn_bg";
+                               type: IMAGE;
+                               scale: 1;
+                               ignore_flags: ON_HOLD;
+                               mouse_events: 1;
+                               description
+                               {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; to: background; }
+                                       rel2 { relative: 0.0729166666 1.0; to: background; }
+                                       image
+                                       {
+                                               normal: "clipboard_close_bg.png";
+                                               border: 17 18 8 8;
+                                       }
+                               }
+                       }
+
+                       part
+                       {
+                               // width: 35, height: 335
+                               name: "cbhmdrawer/closebtn_arrow";
+                               type: IMAGE;
+                               scale: 1;
+                               ignore_flags: ON_HOLD;
+                               mouse_events: 1;
+                               description
+                               {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; to: "cbhmdrawer/closebtn_bg"; }
+                                       rel2 { relative: 1.0 1.0; to: "cbhmdrawer/closebtn_bg"; }
+                                       align: 0.5 0.5;
+                                       min: 35 39;
+                                       max: 35 39;
+                                       image
+                                       {
+                                               normal: "clipboard_close_arrow.png";
+                                       }
+                               }
+                       }
+
                        part 
                        {
+                               // width: 436, height: 155
                                name: "cbhmdrawer/imglist";
                                type: SWALLOW;
+                               scale: 1;
                                mouse_events: 1;
                                description
                                {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.02 0.01; to: background; }
-                                       rel2 { relative: 0.98 0.39; to: background; }
+                                       rel1 { relative: 0.0916666666 0.0537313432; to: background; }
+                                       rel2 { relative: 1.0 0.3641791044; to: background; }
                                }
                        }
                        part 
                        {
+                               // width: 427, height: 180
                                name: "cbhmdrawer/txtlist";
                                type: SWALLOW;
+                               scale: 1;
                                mouse_events: 1;
                                description
                                {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.02 0.4; to: background; }
-                                       rel2 { relative: 0.98 0.98; to: background; }
+                                       rel1 { relative: 0.0916666666 0.4626865672; to: background; }
+                                       rel2 { relative: 0.98125 1.0; to: background; }
                                }
                        }
-               }
-       }
-}
+               } // parts
+               programs
+               {
+                               program 
+                               {
+                                               name:   "mouse_up";
+                                               signal: "mouse,up,1";
+                                               source: "cbhmdrawer/closebtn_bg";
+                                               action: SIGNAL_EMIT "elm,action,click" "";
+                               }
+               } //programs
+       } // group
+} // collections
index f005bfd..53c39c2 100644 (file)
@@ -15,28 +15,19 @@ static const char *g_images_path[] = {
 };
 #define N_IMAGES (6)
 
+// FIXME: how to remove main_ad? 
+//        it's mainly used at 'clipdrawer_add_image_item'
+struct appdata *g_main_ad = NULL;
+
+// gic should live at gengrid callback functions
+Elm_Gengrid_Item_Class gic;
+
 typedef struct tag_gridimgitem
 {
        Elm_Gengrid_Item *item;
        const char *path;
 } gridimgitem_t;
 
-static void
-_image_click(void *data, Evas_Object *obj, void *event_info)
-{
-       struct appdata *ad = data;
-       char *p,*file;
-       int len;
-       file = evas_object_data_get(obj, "URI");
-       len = strlen(file);
-       p = malloc(len + 10);
-       snprintf(p,len+10,"file:///%s",file);
-
-       elm_selection_set(/*secondary*/1,obj,/*ELM_SEL_FORMAT_IMAGE*/4,p);
-
-       clipdrawer_lower_view(ad);
-}
-
 static void _list_click( void *data, Evas_Object *obj, void *event_info )
 {
        struct appdata *ad = data;
@@ -125,6 +116,8 @@ static void grid_selected(void *data, Evas_Object *obj, void *event_info)
        p = malloc(len + 10);
        snprintf(p,len+10, "file:///%s", ti->path);
 
+       fprintf(stderr, "## sel path = %s_\n", p);
+
        elm_selection_set(/*secondary*/1,obj,/*ELM_SEL_FORMAT_IMAGE*/4,p);
 
        clipdrawer_lower_view(ad);
@@ -139,19 +132,50 @@ void grid_del(const void *data, Evas_Object *obj)
        free(ti);
 }
 
+// FIXME: how to remove main_ad? 
+//        it's mainly used at 'clipdrawer_add_image_item'
+int clipdrawer_add_image_item(char *imagepath)
+{
+//     struct appdata *ad = data;
+       gridimgitem_t *newgenimg = NULL;
+       char* filepath = NULL;
+       filepath = &imagepath[7]; // skip 'file://'
+
+       fprintf(stderr, "## image_path = %s_\n", filepath);
+       newgenimg = malloc(sizeof(gridimgitem_t));
+       newgenimg->path = eina_stringshare_add(filepath);
+       newgenimg->item = elm_gengrid_item_append(g_main_ad->imggrid, &gic, newgenimg, NULL, NULL);
+
+       return TRUE;
+}
+
+static void
+clipdrawer_ly_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+       struct appdata *ad = data;
+
+       if (!strncmp(source, "cbhmdrawer/closebtn_", 20))
+       {
+               clipdrawer_lower_view(ad);
+       }
+}
+
 int clipdrawer_init(void *data)
 {
        struct appdata *ad = data;
+       g_main_ad = ad;
+
+       evas_object_resize(ad->win_main, CLIPDRAWER_WIDTH, CLIPDRAWER_HEIGHT);
+       evas_object_move(ad->win_main, CLIPDRAWER_POS_X, CLIPDRAWER_POS_Y);
+       evas_object_resize(ad->ly_main, CLIPDRAWER_WIDTH, CLIPDRAWER_HEIGHT);
+       evas_object_move(ad->ly_main, CLIPDRAWER_POS_X, CLIPDRAWER_POS_Y);
 
-       evas_object_resize(ad->win_main, 480, 360);
-       evas_object_move(ad->win_main, 0, 440);
-       evas_object_resize(ad->ly_main, 480, 360);
-       evas_object_move(ad->ly_main, 0, 440);
+       edje_object_signal_callback_add(elm_layout_edje_get(ad->ly_main), "mouse,up,1", "*", clipdrawer_ly_clicked, ad);
 
        ad->imggrid = NULL;
        ad->imggrid = elm_gengrid_add(ad->win_main);
        elm_layout_content_set(ad->ly_main, "cbhmdrawer/imglist", ad->imggrid);
-       elm_gengrid_item_size_set(ad->imggrid, 125, 135);
+       elm_gengrid_item_size_set(ad->imggrid, 100, 100+3);
        elm_gengrid_align_set(ad->imggrid, 0.5, 0.0);
        elm_gengrid_horizontal_set(ad->imggrid, EINA_TRUE);
        elm_gengrid_bounce_set(ad->imggrid, EINA_TRUE, EINA_FALSE);
@@ -161,8 +185,6 @@ int clipdrawer_init(void *data)
 
        elm_gengrid_clear(ad->imggrid);
 
-       // gic should live at gengrid callback functions
-       static Elm_Gengrid_Item_Class gic;
        gic.item_style = "default_grid";
        gic.func.label_get = NULL;
        gic.func.icon_get = grid_icon_get;
index 7c0be0e..9c909e8 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef _clipdrawer_h_
 #define _clipdrawer_h_
 
+#define CLIPDRAWER_POS_X 0
+#define CLIPDRAWER_POS_Y 465
+#define CLIPDRAWER_WIDTH 480
+#define CLIPDRAWER_HEIGHT 335
+
 /* view maintains */
 int clipdrawer_init(void *data);
 int clipdrawer_create_view(void *data);
@@ -11,4 +16,6 @@ void clipdrawer_lower_view(void *data);
 const char* clipdrawer_get_plain_string_from_escaped(char *escstr);
 int clipdrawer_update_contents(void *data);
 
+int clipdrawer_add_image_item(char *imagepath);
+
 #endif // _clipdrawer_h_
index f36cfb2..93cf049 100755 (executable)
@@ -209,7 +209,17 @@ int get_selection_content(void *data)
        unesc = clipdrawer_get_plain_string_from_escaped(cbbuf);
 //     add_to_storage_buffer(ad, cbbuf, cbitems);
 //     DTRACE("len = %ld, data = %s\n", cbitems, cbbuf);
-       add_to_storage_buffer(ad, unesc, strlen(unesc));
+
+/*
+       if (!strncmp(unesc, "file://", 7) && 
+               (strstr(unesc,".png") || strstr(unesc,".jpg")))
+       {
+               fprintf(stderr, "## clipdrawer add path = %s\n", unesc);
+               clipdrawer_add_image_item(unesc);
+       }
+       else
+*/
+               add_to_storage_buffer(ad, unesc, strlen(unesc));
        DTRACE("len = %ld, data = %s\n", strlen(unesc), unesc);
        free(unesc);