[Share-panel] resize the share-panel according to rotation 93/47193/1
authorJin Yoon <jinny.yoon@samsung.com>
Tue, 1 Sep 2015 02:53:20 +0000 (11:53 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Tue, 1 Sep 2015 02:53:20 +0000 (11:53 +0900)
Change-Id: Ifad6b5c4602e24a6d851fa9c4c053d58c90e251f

include/conf.h
include/share_panel.h
res/edje/layout.edc
src/share_panel.c
src/ui_manager.c

index 107e1c0..0f3caef 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __TIZEN_SHARE_PANEL_CONF_H__
 #define __TIZEN_SHARE_PANEL_CONF_H__
 
+#define BASE_WIDTH 480
 #define BASE_HEIGHT 800
 
 /* ITEM_ICON is changed from 74 to 63 about 87% decrease because of resolution issues. */
 
 #define INDEX_HEIGHT 50
 #define TITLE_HEIGHT 54
+#define SCROLLER_HEIGHT 320
 
 /* PANEL_HEIGHT is changed from 368 to 320 about 87% decrease because of resolution issues. */
-#define PANEL_HEIGHT (320+INDEX_HEIGHT)
+#define PANEL_HEIGHT (SCROLLER_HEIGHT+INDEX_HEIGHT+TITLE_HEIGHT)
 
 
 
index 0b311c1..9c8b0d1 100644 (file)
@@ -302,7 +302,6 @@ extern int share_panel_show(share_panel_h share_panel);
  */
 extern int share_panel_hide(share_panel_h share_panel);
 
-extern void share_panel_resize(share_panel_h share_panel, int width, int height);
 /**
  * @}
  */
index 7954b27..d955161 100644 (file)
@@ -56,13 +56,24 @@ collections {
                                }
                        }
                        part {
+                               name: "fixed_bg";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.5 1.0; }
+                                       rel2 { relative: 0.5 1.0; }
+                                       align: 0.5 1.0;
+                                       fixed: 1 1;
+                                       visible: 1;
+                               }
+                       }
+                       part {
                                name: "title,bg";
                                type: RECT;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 ((BASE_HEIGHT - (PANEL_HEIGHT + TITLE_HEIGHT)) / BASE_HEIGHT); to: "bg"; }
-                                       rel2 { relative: 1.0 0.0; to: "scroller,bg"; }
-                                       align: 0.5 1.0;
+                                       rel1 { relative: 0.0 (BASE_HEIGHT-PANEL_HEIGHT)/BASE_HEIGHT; to: "fixed_bg"; }
+                                       rel2 { relative: 1.0 (BASE_HEIGHT-(SCROLLER_HEIGHT+INDEX_HEIGHT))/BASE_HEIGHT; to: "fixed_bg"; }
                                        visible: 1;
                                        color: 250 250 250 255;
                                }
@@ -87,8 +98,8 @@ collections {
                                type: RECT;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 ((BASE_HEIGHT - PANEL_HEIGHT) / BASE_HEIGHT); to: "bg"; }
-                                       rel2 { relative: 1.0 ((BASE_HEIGHT - INDEX_HEIGHT) / BASE_HEIGHT); to: "bg"; }
+                                       rel1 { relative: 0.0 (BASE_HEIGHT-(SCROLLER_HEIGHT+INDEX_HEIGHT))/BASE_HEIGHT; to: "fixed_bg"; }
+                                       rel2 { relative: 1.0 (BASE_HEIGHT-INDEX_HEIGHT)/BASE_HEIGHT; to: "fixed_bg"; }
                                        visible: 1;
                                        color: 250 250 250 255;
                                }
@@ -101,6 +112,7 @@ collections {
                                        rel1.to: "scroller,bg";
                                        rel2.to: "scroller,bg";
                                        visible: 1;
+                                       fixed: 1 1;
                                }
                        }
                        part {
@@ -108,8 +120,8 @@ collections {
                                type: RECT;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 ((BASE_HEIGHT - INDEX_HEIGHT) / BASE_HEIGHT); to: "bg"; }
-                                       rel2 { relative: 1.0 1.0; to: "bg"; }
+                                       rel1 { relative: 0.0 (BASE_HEIGHT-INDEX_HEIGHT)/BASE_HEIGHT; to: "fixed_bg"; }
+                                       rel2 { relative: 1.0 1.0; to: "fixed_bg"; }
                                        visible: 1;
                                        color: 250 250 250 255;
                                }
@@ -122,6 +134,7 @@ collections {
                                        rel1.to: "index,bg";
                                        rel2.to: "index,bg";
                                        visible: 1;
+                                       fixed: 1 1;
                                }
                        }
                }
index 0b7edf7..d7a7eec 100644 (file)
@@ -48,21 +48,6 @@ typedef struct custom_effect {
 
 
 
-EAPI void share_panel_resize(share_panel_h share_panel, int width, int height)
-{
-       ret_if(!share_panel);
-
-       if (width > height) {
-               _D("resize the share-panel to land");
-       } else {
-               _D("resize the share-panel to port");
-       }
-
-       _ui_manager_resize(share_panel->ui_manager, width, height);
-}
-
-
-
 static Eina_Bool _back_key_pressed(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
 {
        Evas_Event_Key_Down *ev = event_info;
@@ -94,19 +79,6 @@ static void _rotate_cb(void *data, Evas_Object *obj, void *event)
 
        angle = elm_win_rotation_get(obj);
        _D("Angle is %d degree", angle);
-
-       switch (angle) {
-       case 0:
-       case 180:
-               share_panel_resize(share_panel, share_panel->root_width, share_panel->root_height);
-               break;
-       case 90:
-       case 270:
-               share_panel_resize(share_panel, share_panel->root_height, share_panel->root_width);
-               break;
-       default:
-               _E("cannot reach here");
-       }
 }
 
 
@@ -116,9 +88,10 @@ static Evas_Object *__create_win(share_panel_h share_panel)
        share_panel->win = elm_win_add(NULL, "Share Panel", ELM_WIN_BASIC);
        retv_if(!share_panel->win, NULL);
 
+       elm_win_alpha_set(share_panel->win, EINA_TRUE);
        if (elm_win_wm_rotation_supported_get(share_panel->win)) {
                int rots[4] = {0, 90, 180, 270};
-               elm_win_wm_rotation_available_rotations_set(share_panel->win, rots, 4);
+               elm_win_wm_rotation_available_rotations_set(share_panel->win, rots, (sizeof(rots) / sizeof(int)));
        }
 
        elm_win_screen_size_get(share_panel->win, NULL, NULL, &share_panel->root_width, &share_panel->root_height);
@@ -129,7 +102,6 @@ static Evas_Object *__create_win(share_panel_h share_panel)
 
        elm_win_indicator_mode_set(share_panel->win, ELM_WIN_INDICATOR_HIDE);
        elm_win_borderless_set(share_panel->win, EINA_TRUE);
-       elm_win_alpha_set(share_panel->win, EINA_TRUE);
        evas_object_show(share_panel->win);
 
        return share_panel->win;
index 05becc4..3664ac3 100644 (file)
@@ -139,6 +139,34 @@ void __destroy_back_btn(Evas_Object *button)
 
 
 
+Evas_Object *__create_bg_rect(Evas_Object *ui_manager, int width, int height)
+{
+       Evas_Object *ui_bg = NULL;
+
+       ui_bg = evas_object_rectangle_add(evas_object_evas_get(ui_manager));
+       retv_if(!ui_bg, NULL);
+
+       evas_object_size_hint_weight_set(ui_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_min_set(ui_bg, ELM_SCALE_SIZE(BASE_WIDTH), ELM_SCALE_SIZE(BASE_HEIGHT));
+       evas_object_size_hint_max_set(ui_bg, ELM_SCALE_SIZE(BASE_WIDTH), ELM_SCALE_SIZE(BASE_HEIGHT));
+       evas_object_color_set(ui_bg, 0, 0, 0, 0);
+       evas_object_show(ui_bg);
+       elm_object_part_content_set(ui_manager, "fixed_bg", ui_bg);
+
+       return ui_bg;
+}
+
+
+
+void __destroy_bg_rect(Evas_Object *bg)
+{
+       ret_if(!bg);
+
+       evas_object_del(bg);
+}
+
+
+
 Evas_Object *_ui_manager_create(share_panel_s *share_panel)
 {
        Evas_Object *ui_manager = NULL;
@@ -157,6 +185,8 @@ Evas_Object *_ui_manager_create(share_panel_s *share_panel)
 
        evas_object_data_set(ui_manager, DATA_KEY_SHARE_PANEL_INFO, share_panel);
 
+       goto_if(!__create_bg_rect(ui_manager, share_panel->root_width, share_panel->root_height), ERROR);
+
        goto_if(!__create_back_btn(ui_manager, share_panel), ERROR);
 
        elm_object_part_text_set(ui_manager, "title", _("IDS_AM_HEADER_SHARE"));
@@ -199,6 +229,7 @@ ERROR:
 void _ui_manager_destroy(Evas_Object *ui_manager)
 {
        Evas_Object *button = NULL;
+       Evas_Object *bg = NULL;
        share_panel_s *share_panel = NULL;
        ret_if(!ui_manager);
 
@@ -225,6 +256,12 @@ void _ui_manager_destroy(Evas_Object *ui_manager)
        if(button) {
                __destroy_back_btn(button);
        }
+
+       bg = elm_object_part_content_unset(ui_manager, "fixed_bg");
+       if(bg) {
+               __destroy_bg_rect(bg);
+       }
+
        evas_object_del(ui_manager);
 }
 
@@ -238,6 +275,7 @@ void _ui_manager_resize(Evas_Object *ui_manager, int width, int height)
        evas_object_size_hint_max_set(ui_manager, width, height);
        evas_object_resize(ui_manager, width, height);
        evas_object_move(ui_manager, 0, 0);
+       edje_object_message_signal_process(elm_layout_edje_get(ui_manager));
 }