Removed Context Menu, used option menu
[apps/osp/Gallery.git] / src / GlFileListForm.cpp
index a49f53d..0e96fae 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
 #include "GlAllListPanel.h"
 #include "GlFileListForm.h"
 #include "GlFileListPresentationModel.h"
+#include "GlGalleryApp.h"
 #include "GlResourceManager.h"
 #include "GlSlideSettingListener.h"
+#include "GlSlideShowPopUp.h"
 #include "GlTypes.h"
 
 using namespace Tizen::App;
@@ -37,7 +39,8 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Content;
 
 FileListForm::FileListForm(void)
-       : __pContextMenuMore(null)
+       : __pOptionMenu(null)
+       , __pPopUp(null)
        , __pPresentationModel(null)
 {
        AppLogDebug("ENTER");
@@ -66,6 +69,8 @@ FileListForm::OnInitializing(void)
        Header* pHeader = GetHeader();
        TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
 
+          SetFormMenuEventListener(this);
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
 
@@ -75,7 +80,7 @@ FileListForm::OnInitializing(void)
        {
                __pPopUp->Initialize();
                __pPopUp->SetEventListner(this);
-               AddControl(*__pPopUp);
+               AddControl(__pPopUp);
        }
 
        InitializeFooter();
@@ -90,11 +95,12 @@ FileListForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
 
-       if (__pContextMenuMore != null)
+       if ( __pOptionMenu != null )
        {
-               delete __pContextMenuMore;
-               __pContextMenuMore = null;
+               delete __pOptionMenu;
+               __pOptionMenu = null;
        }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -118,26 +124,7 @@ FileListForm::OnActionPerformed(const Control& source, int actionId)
 
        switch (actionId)
        {
-       case ACTION_ID_FOOTER_MORE:
-       {
-               AppLogDebug("ITEMCOUNT(%d)", __pPresentationModel->GetCurrentAlbumContentInfoCount());
-
-               InitializeFooter();
-
-               if (__pContextMenuMore->GetShowState() == false)
-               {
-                       Rectangle rect = source.GetBounds();
-                       __pContextMenuMore->SetAnchorPosition(Point(rect.width/8, rect.y));
-                       __pContextMenuMore->SetShowState(true);
-                       __pContextMenuMore->Show();
-               }
-               else
-               {
-                       __pContextMenuMore->SetShowState(false);
-               }
-               break;
-       }
-       case ACTION_ID_FOOTER_EDIT:
+       case IDA_FOOTER_EDIT:
        {
                if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
                {
@@ -155,9 +142,10 @@ FileListForm::OnActionPerformed(const Control& source, int actionId)
                {
                        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
                }
-               break;
        }
-       case ACTION_ID_FOOTER_SLIDESHOW:
+       break;
+
+       case IDA_FOOTER_SLIDESHOW:
        {
 
                if (__pPopUp != null)
@@ -165,18 +153,19 @@ FileListForm::OnActionPerformed(const Control& source, int actionId)
                        __pPopUp->SetShowState(true);
                        __pPopUp->Show();
                }
-
-               break;
        }
-       case ACTION_ID_FOOTER_CAMERA:
+       break;
+
+       case IDA_FOOTER_CAMERA:
        {
                HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
                pDataList->Construct();
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
                __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
                                null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
-               break;
        }
+       break;
+
        default:
                break;
        }
@@ -204,18 +193,11 @@ FileListForm::InitializeFooter(void)
 
        pFooter->RemoveAllItems();
        pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
-
-       ButtonItem footerMore;
-       footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
-       Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
-       if (pBitmapMore != null)
-       {
-               footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
-       }
-       pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
+       pFooter->SetMenuButton();
+       pFooter->SetBackButton();
 
        FooterItem itemCamera;
-       itemCamera.Construct(ACTION_ID_FOOTER_CAMERA);
+       itemCamera.Construct(IDA_FOOTER_CAMERA);
        Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
        if (pBitmapCamera != null)
        {
@@ -223,33 +205,31 @@ FileListForm::InitializeFooter(void)
        }
        pFooter->AddItem(itemCamera);
 
-       if (__pContextMenuMore != null)
+
+       if (__pOptionMenu != null)
        {
-               delete __pContextMenuMore;
-               __pContextMenuMore = null;
+               delete __pOptionMenu;
+               __pOptionMenu = null;
        }
 
-       __pContextMenuMore = new (std::nothrow) ContextMenu();
-       __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
+       __pOptionMenu = new (std::nothrow) OptionMenu();
+       __pOptionMenu->Construct();
 
        if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
        {
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"), ACTION_ID_FOOTER_SLIDESHOW);
+               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
        }
 
        if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
        {
-               __pContextMenuMore->SetEnabled(false);
+               __pOptionMenu->SetEnabled(false);
        }
        else
        {
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), ACTION_ID_FOOTER_EDIT);
-               __pContextMenuMore->SetShowState(false);
-               __pContextMenuMore->AddActionEventListener(*this);
+               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+               __pOptionMenu->AddActionEventListener(*this);
        }
 
-       pFooter->SetBackButton();
-
        pFooter->AddActionEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -277,6 +257,7 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
 
        if (index == 0)
        {
+               result r = E_SUCCESS;
                ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                pArrayList->Construct();
                int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
@@ -291,8 +272,17 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
 
-               __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
+               r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
                                new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
+
+               if (r == E_MAX_EXCEEDED)
+               {
+                       MessageBox messageBox;
+                       messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
+                                       MSGBOX_STYLE_NONE, 3000);
+                       int modalResult;
+                       messageBox.ShowAndWait(modalResult);
+               }
        }
        else if (index == 1)
        {
@@ -302,3 +292,26 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
                pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
        }
 }
+
+void
+FileListForm::SetFooterState(bool state)
+{
+       GetFooter()->SetMenuButtonEnabled(state);
+       GetFooter()->Invalidate(true);
+}
+
+void
+FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+
+       InitializeFooter();
+
+       if ( __pOptionMenu == null )
+       {
+               return ;
+       }
+
+       __pOptionMenu->SetShowState(true);
+       __pOptionMenu->Show();
+
+}