window compoment has been changed
authorlke01.lee <lke01.lee@samsung.com>
Fri, 21 Dec 2012 00:52:16 +0000 (09:52 +0900)
committerlke01.lee <lke01.lee@samsung.com>
Fri, 21 Dec 2012 02:58:44 +0000 (11:58 +0900)
[Issue#] The new policy for window
[Problem]
[Cause] To support indicator, window structure need to be changed.
[Solution] window structure have been changed.

Change-Id: I90686e6e35b038468667ac33fc745a456053ebd2

src/wrt-client/window_data.cpp
src/wrt-client/window_data.h
src/wrt-client/wrt-client.cpp

index 6d7ba51..c7597dd 100644 (file)
@@ -46,12 +46,14 @@ char const* const INDICATOR = "indicator";
 char const* const NOINDICATOR = "noindicator";
 char const* const INTERNAL_LAYOUT = "internal_layout";
 char const* const FLOATBACKWARD_BUTTON_STYLE = "wrt/backward";
+
 } // anonymous namespace
 
 WindowData::WindowData(unsigned long pid, bool manualInit) :
-    m_win(NULL), m_naviBackButton(NULL),
-    m_toolbarTimer(NULL),
-    m_debugMode(false)
+    m_debugMode(false),
+    m_win(NULL),
+    m_naviBackButton(NULL),
+    m_toolbarTimer(NULL)
 {
     m_win = createWindow(pid);
 
@@ -74,14 +76,14 @@ void WindowData::init()
     // import button theme
     elm_theme_overlay_add(NULL, THEME_EDJ_PATH);
 
-    m_platform_layout = createPlatformLayout(m_win);
+    m_conformant = createConformant(m_win);
+    evas_object_show(m_conformant);
+    m_platform_layout = createPlatformLayout(m_conformant);
     evas_object_show(m_platform_layout);
     m_navigation = createNavigationBar(m_platform_layout);
     evas_object_show(m_navigation);
     m_user_layout = createUserLayout(m_navigation);
     evas_object_show(m_user_layout);
-    m_conformant = createConformant(m_user_layout);
-    evas_object_show(m_conformant);
 }
 
 void WindowData::setEvasObjectForLayout(Evas_Object* evas_object)
@@ -100,16 +102,8 @@ void WindowData::toggleIndicator(bool fullscreen)
 
     if (!fullscreen) {
         elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_SHOW);
-        elm_layout_theme_set(m_platform_layout,
-                LAYOUT,
-                APPLICATION,
-                INDICATOR);
     } else {
         elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_HIDE);
-        elm_layout_theme_set(m_platform_layout,
-                LAYOUT,
-                APPLICATION,
-                NOINDICATOR);
     }
 }
 
@@ -118,7 +112,7 @@ void WindowData::setViewMode(
         bool backbutton,
         CtxMenuItems ctxMenuItems)
 {
-    LogDebug("setViewMode " <<m_debugMode);
+    LogDebug("setViewMode");
     LogDebug("fullscreen: " << fullscreen);
     LogDebug("backbutton: " << backbutton);
 
@@ -168,8 +162,11 @@ void WindowData::createToolbar(CtxMenuItems ctxMenuItems)
                 EVAS_HINT_EXPAND);
 
         Evas_Object *ic = elm_icon_add(toolbar);
-         snprintf(buf, sizeof(buf), (*itor).icon.c_str());
-         elm_icon_file_set(ic, buf, NULL);
+
+        // (*itor).icon.c_str() guarantied not to have format specifiers
+        snprintf(buf, sizeof(buf), (*itor).icon.c_str());
+
+        elm_icon_file_set(ic, buf, NULL);
         evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
         elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
         elm_object_part_content_set(toolbarButton, "icon", ic);
@@ -195,30 +192,6 @@ void WindowData::createToolbar(CtxMenuItems ctxMenuItems)
         elm_object_item_part_content_set(toolbarIt, "object", toolbarButton);
     }
 
-    toolbarButton = elm_button_add(toolbar);
-    if (!toolbarButton)
-        return;
-
-    Evas_Object *ic = elm_icon_add(toolbar);
-    snprintf(buf, sizeof(buf), WRT_OPTION_ICON_WINDOWVIEW);
-    elm_icon_file_set(ic, buf, NULL);
-    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
-    elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
-    elm_object_part_content_set(toolbarButton, "icon", ic);
-
-    evas_object_size_hint_align_set(toolbarButton,
-            EVAS_HINT_FILL,
-            EVAS_HINT_FILL);
-    evas_object_size_hint_weight_set(toolbarButton,
-            EVAS_HINT_EXPAND,
-            EVAS_HINT_EXPAND);
-    evas_object_smart_callback_add(toolbarButton,
-            "clicked",
-            changeViewModeCallback,
-            this);
-    toolbarIt = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL);
-    elm_object_item_part_content_set(toolbarIt, "object", toolbarButton);
-
     optionheaderClose = TRUE;
 
     elm_object_part_content_set(m_user_layout,
@@ -254,38 +227,70 @@ void WindowData::createFloatBackButton()
 
 Evas_Object* WindowData::createWindow(unsigned long pid)
 {
+    ADD_PROFILING_POINT("elm_win_add", "start");
     Evas_Object* window = elm_win_add(NULL, "wrt-widget", ELM_WIN_BASIC);
+    ADD_PROFILING_POINT("elm_win_add", "stop");
     ecore_x_window_prop_property_set(
         elm_win_xwindow_get(window),
         ECORE_X_ATOM_NET_WM_PID,
         ECORE_X_ATOM_CARDINAL, 32, &pid, 1);
-    elm_win_title_set(window, "wrt-widget");
-    elm_win_borderless_set(window, EINA_TRUE);
     elm_win_conformant_set(window, EINA_TRUE);
     int w, h;
     ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
     evas_object_resize(window, w, h);
+
     return window;
 }
 
+Evas_Object* WindowData::createConformant(Evas_Object* parent)
+{
+    Assert(parent != NULL && "Parent is null");
+    Evas_Object* conformant = elm_conformant_add(parent);
+
+    evas_object_size_hint_weight_set(
+            conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_win_resize_object_add(parent, conformant);
+    return conformant;
+}
+
 Evas_Object* WindowData::createPlatformLayout(Evas_Object* parent)
 {
     Evas_Object*  platform_layout = elm_layout_add(parent);
 
-    if (!elm_layout_file_set(platform_layout, PLATFORM_EDJ_PATH, "platformlayout"))
-        elm_layout_theme_set(platform_layout, LAYOUT, APPLICATION, NOINDICATOR);
-
-    evas_object_size_hint_expand_set(platform_layout,
-                                     EVAS_HINT_EXPAND,
-                                     EVAS_HINT_EXPAND);
+    ADD_PROFILING_POINT("elm_layout_theme_set", "start");
+    elm_layout_file_set(platform_layout, PLATFORM_EDJ_PATH, "platformlayout");
+    ADD_PROFILING_POINT("elm_layout_theme_set", "stop");
 
-    elm_win_resize_object_add(parent, platform_layout);
+    evas_object_size_hint_align_set(platform_layout,
+            EVAS_HINT_FILL,
+            EVAS_HINT_FILL);
+    evas_object_size_hint_weight_set(platform_layout,
+            EVAS_HINT_EXPAND,
+            EVAS_HINT_EXPAND);
 
+    elm_object_content_set(parent, platform_layout);
     edje_object_signal_emit(
             elm_layout_edje_get(platform_layout), ELM_STATE_SHOW_CONTENT, ELM);
     return platform_layout;
 }
 
+Evas_Object* WindowData::createNavigationBar(Evas_Object* parent)
+{
+    Assert(parent != NULL && "Parent for naviframe is null");
+    Evas_Object* navigation = elm_naviframe_add(parent);
+
+    evas_object_size_hint_align_set(navigation,
+            EVAS_HINT_FILL,
+            EVAS_HINT_FILL);
+    evas_object_size_hint_weight_set(navigation,
+            EVAS_HINT_EXPAND,
+            EVAS_HINT_EXPAND);
+    elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, navigation);
+    //elm_object_content_set(parent, navigation);
+    return navigation;
+}
+
 Evas_Object* WindowData::createUserLayout(Evas_Object* parent)
 {
     Assert(parent != NULL && "Parent for User Layout is null");
@@ -294,8 +299,8 @@ Evas_Object* WindowData::createUserLayout(Evas_Object* parent)
     evas_object_size_hint_weight_set(
             layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
     evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    elm_win_resize_object_add(parent, layout);
 
+    ADD_PROFILING_POINT("elm_naviframe_item_push", "start");
     Elm_Object_Item* naviIt = elm_naviframe_item_push(
         /* Evas_Object *obj */
         parent,
@@ -315,27 +320,6 @@ Evas_Object* WindowData::createUserLayout(Evas_Object* parent)
     return layout;
 }
 
-Evas_Object* WindowData::createConformant(Evas_Object* parent)
-{
-    Assert(parent != NULL && "Parent is null");
-    Evas_Object* conformant = elm_conformant_add(parent);
-    elm_object_style_set(conformant, INTERNAL_LAYOUT);
-    evas_object_size_hint_weight_set(
-            conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, conformant);
-    evas_object_show(conformant);
-    return conformant;
-}
-
-Evas_Object* WindowData::createNavigationBar(Evas_Object* parent)
-{
-    Assert(parent != NULL && "Parent for naviframe is null");
-    Evas_Object* navigation = elm_naviframe_add(parent);
-    elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, navigation);
-    return navigation;
-}
-
 void WindowData::showHiddenOption(Evas_Object* parent)
 {
     Assert(parent != NULL && "Parent for Hiden Option");
@@ -462,28 +446,21 @@ void WindowData::changeViewModeCallback(void *data,
 }
 
 void WindowData::controlHiddenOptionCallback(void *data,
-        Evas_Object */*obj*/,
-        const char */*emission*/,
-        const char */*source*/)
+        Evas_Object * /*obj*/,
+        const char * /*emission*/,
+        const char * /*source*/)
 {
     LogDebug("controlHiddenOptionCallback");
     WindowData* This = static_cast<WindowData *>(data);
-    Elm_Object_Item *naviIt = elm_naviframe_top_item_get(This->m_navigation);
-
-    if(!elm_naviframe_item_title_visible_get(naviIt)) {
-        const char* state = edje_object_part_state_get(
-                elm_layout_edje_get(This->m_user_layout),
-                "elm.swallow.toolbar",
-                NULL);
-
-        if (state && !strncmp(state, "default", strlen("default"))) {
-            This->showToolbar();
-            This->hideHiddenOption(This->m_user_layout);
-        }
-        else {
-            This->initFullViewMode();
-        }
+    const char* state = edje_object_part_state_get(
+            elm_layout_edje_get(This->m_user_layout), "elm.swallow.toolbar",
+            NULL);
 
+    if (state && !strncmp(state, "default", strlen("default"))) {
+        This->showToolbar();
+        This->hideHiddenOption(This->m_user_layout);
+    } else {
+        This->initFullViewMode();
     }
 }
 
@@ -508,9 +485,8 @@ void WindowData::toggleFullscreen(bool fullscreen)
         return;
     }
 
-    if (!m_fullscreen) {
-        //If ViewMode is not fullscreen, toggle the title bar and indicator
+    if (!m_fullscreen) //If ViewMode is not fullscreen, toggle indicator
         toggleIndicator(fullscreen);
-    }
+
     alreadyFullscreen = !alreadyFullscreen;
 }
index e5de07d..0082990 100644 (file)
@@ -44,12 +44,10 @@ namespace {
 const char *const WRT_OPTION_LABEL_BACKWARD = "Backward";
 const char *const WRT_OPTION_LABEL_FORWARD = "Forward";
 const char *const WRT_OPTION_LABEL_RELOAD = "Reload";
-const char *const WRT_OPTION_LABEL_FULLVIEW = "Full view";
 
 const char *const WRT_OPTION_ICON_BACKWARD = "/usr/etc/wrt/icon_left_arrow.png";
 const char *const WRT_OPTION_ICON_FORWARD = "/usr/etc/wrt/icon_right_arrow.png";
 const char *const WRT_OPTION_ICON_RELOAD  = "/usr/etc/wrt/icon_refresh.png";
-const char *const WRT_OPTION_ICON_WINDOWVIEW = "/usr/etc/wrt/mp_stop.png";
 }
 
 class WindowData : private DPL::Noncopyable
@@ -74,9 +72,10 @@ class WindowData : private DPL::Noncopyable
     typedef std::vector<EventWithFunction> EventWithFunctionVector;
 
   public:
-    Evas_Object* m_win;
-    Evas_Object* m_conformant;
     bool m_debugMode;
+    Evas_Object* m_win;
+    Evas_Object* m_user_layout;
+
 
     struct CtxMenuItem
     {
@@ -144,8 +143,8 @@ class WindowData : private DPL::Noncopyable
     void toggleFullscreen(bool fullscreen);
 
   protected:
+    Evas_Object* m_conformant;
     Evas_Object* m_platform_layout;
-    Evas_Object* m_user_layout;
     Evas_Object* m_navigation;
     Evas_Object* m_naviBackButton;
     Evas_Object* m_floatBackButton;
@@ -165,7 +164,7 @@ class WindowData : private DPL::Noncopyable
     void hideHiddenOption(Evas_Object* parent);
 
     void alignProgressPosition();
-    void toggleIndicator(bool indicator);
+    void toggleIndicator(bool fullscreen);
     void createFloatBackButton();
 };
 
index c590938..5508920 100644 (file)
@@ -35,6 +35,7 @@
 const char *EDJE_SHOW_BACKWARD_SIGNAL = "show,backward,signal";
 const std::string VIEWMODE_TYPE_FULLSCREEN = "fullscreen";
 const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized";
+char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
 
 WrtClient::WrtClient(int argc, char **argv) :
     Application(argc, argv, "wrt-client", false),
@@ -538,7 +539,6 @@ void WrtClient::initializeWindowModes()
             (settings.getBackButtonPresence() == BackButton_Enable);
      }
 
-
     FOREACH(it, windowModes)
     {
         std::string viewMode = DPL::ToUTF8String(*it);
@@ -550,23 +550,15 @@ void WrtClient::initializeWindowModes()
         }
     }
 
-    WrtDB::WidgetLocalizedInfo localizedInfo =
-            W3CFileLocalization::getLocalizedInfo(m_dao);
-    std::string name = "";
-    if (!(localizedInfo.name.IsNull())) {
-        name = DPL::ToUTF8String(*(localizedInfo.name));
-    }
     LogInfo("initializeWindowModes " << m_debugMode);
-#if 1
-    m_windowData->m_debugMode = FALSE;
-#else
+
     if(m_debugMode) {
         m_windowData->m_debugMode = TRUE;
     }
     else {
         m_windowData->m_debugMode = FALSE;
     }
-#endif
+
     WindowData::CtxMenuItems ctxMenuItems;
 
     WindowData::CtxMenuItem ctxMenuBackword;
@@ -674,16 +666,18 @@ void WrtClient::connectElmCallback()
 void WrtClient::setLayout(Evas_Object* newBuffer) {
     LogDebug("add new webkit buffer to window");
     Assert(newBuffer);
-    elm_object_content_set(m_windowData->m_conformant, newBuffer);
+
+    elm_object_part_content_set(m_windowData->m_user_layout, ELM_SWALLOW_CONTENT, newBuffer);
+
     evas_object_show(newBuffer);
-    evas_object_focus_set(newBuffer, EINA_TRUE);
 }
 
 void WrtClient::unsetLayout(Evas_Object* currentBuffer) {
     LogDebug("remove current webkit buffer from window");
     Assert(currentBuffer);
     evas_object_hide(currentBuffer);
-    elm_object_content_unset(m_windowData->m_conformant);
+
+    elm_object_part_content_unset(m_windowData->m_user_layout, ELM_SWALLOW_CONTENT);
 }
 
 void WrtClient::shutdownStep()