Removed Context Menu, used option menu
[apps/osp/Gallery.git] / src / GlAlbumListForm.cpp
index 3d4deb6..143a193 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
 //
@@ -44,8 +44,9 @@ static const int H_FOLDER_SIZE = 348;
 AlbumListForm::AlbumListForm(void)
        : __itemCount(0)
        , __pAlbumViewIconList(null)
-       , __pContextMenuMore(null)
+       , __pOptionMenu(null)
        , __pPresentationModel(null)
+
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -163,6 +164,7 @@ AlbumListForm::InitializeFooter(void)
        {
                pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
                pFooter->SetBackButton();
+               pFooter->SetMenuButton();
                pFooter->RemoveAllItems();
 
                FooterItem itemCamera;
@@ -176,24 +178,16 @@ AlbumListForm::InitializeFooter(void)
                pFooter->AddItem(itemCamera);
                delete pBitmap1;
 
-               ButtonItem footerMore;
-               footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_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);
-               delete pBitmapMore;
-
-               __pContextMenuMore = new (std::nothrow) ContextMenu();
-               __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
-               __pContextMenuMore->SetShowState(false);
-               __pContextMenuMore->AddActionEventListener(*this);
-
+               __pOptionMenu = new (std::nothrow) OptionMenu();
+               __pOptionMenu->Construct();
+               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"),IDA_FOOTER_EDIT);
+               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+               __pOptionMenu->SetShowState(false);
+               __pOptionMenu->AddActionEventListener(*this);
+               SetFormMenuEventListener(this);
                SetFormBackEventListener(this);
        }
+
        pFooter->AddActionEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -325,7 +319,7 @@ AlbumListForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
        __pPresentationModel->RemovePresentationModelListener(*this);
-
+       __pPresentationModel->RemoveContentEventListener(*this);
        if (__pContextMenuMore != null)
        {
                delete __pContextMenuMore;
@@ -362,22 +356,6 @@ AlbumListForm::OnActionPerformed(const Control& source, int actionId)
        }
        break;
 
-       case IDA_FOOTER_MORE:
-       {
-               if (__pContextMenuMore->GetShowState() == false && __pPresentationModel->GetFolderCount() != 0)
-               {
-                       Rectangle rect = source.GetBounds();
-                       __pContextMenuMore->SetAnchorPosition(Point(rect.width/8, rect.y));
-                       __pContextMenuMore->SetShowState(true);
-                       __pContextMenuMore->Show();
-               }
-               else
-               {
-                       __pContextMenuMore->SetShowState(false);
-               }
-       }
-       break;
-
        default:
                break;
        }
@@ -420,6 +398,7 @@ AlbumListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        {
                if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
                {
+                       __pPresentationModel->ClearThumbnailRequests(false);
                        __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_IMAGE);
                }
                else if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_VIDEO)
@@ -437,6 +416,15 @@ AlbumListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        }
        __itemCount = __pPresentationModel->GetFolderCount();
 
+       if ( __itemCount == 0 )
+       {
+               GetFooter()->SetMenuButtonEnabled(false);
+       }
+       else
+       {
+               GetFooter()->SetMenuButtonEnabled(true);
+       }
+
        if (__pAlbumViewIconList != null)
        {
                __pAlbumViewIconList->UpdateList();
@@ -459,10 +447,17 @@ AlbumListForm::OnContentUpdated(void)
 {
        AppLogDebug("ENTER");
 
+       if ( __pOptionMenu != null && __pOptionMenu ->GetShowState() == true)
+       {
+               __pOptionMenu->SetShowState(false);
+               __pOptionMenu->Show();
+       }
+
        if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
                if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
                {
+                       __pPresentationModel->ClearThumbnailRequests(false);
                        __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_IMAGE);
                }
                else if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_VIDEO)
@@ -481,6 +476,17 @@ AlbumListForm::OnContentUpdated(void)
 
        __itemCount = __pPresentationModel->GetFolderCount();
        __pAlbumViewIconList->UpdateList();
+
+       if (__itemCount == 0 )
+       {
+               GetFooter()->SetMenuButtonEnabled(false);
+       }
+       else
+       {
+               GetFooter()->SetMenuButtonEnabled(true);
+       }
+
+       GetFooter()->Invalidate(true);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -509,3 +515,17 @@ AlbumListForm::Update(void)
 
        return r;
 }
+
+void
+AlbumListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+
+       if ( __pOptionMenu == null )
+       {
+               return ;
+       }
+
+       __pOptionMenu->SetShowState(true);
+       __pOptionMenu->Show();
+
+}