Landscape implementation Gallery
[apps/osp/Gallery.git] / src / GlVideoListEditorPanel.cpp
index 287e426..7943fa7 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
 //
@@ -64,19 +64,20 @@ static const int W_VIDEO_DURATION = (16+172+16)+(16+64+16);
 static const int H_VIDEO_DURATION = 48;
 static const int FONT_SIZE_DURATION = 32;
 
-VideoListEditorPanel::VideoListEditorPanel()
+VideoListEditorPanel::VideoListEditorPanel(void)
        : __pContentIconListView(null)
        , __pCheckButton(null)
        , __pLabelSelectCnt(null)
        , __itemCount(0)
        , __pPresentationModel(null)
        , __pFileDelete(null)
+       , __pFileListEditorForm(null)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
-VideoListEditorPanel::~VideoListEditorPanel()
+VideoListEditorPanel::~VideoListEditorPanel(void)
 {
        AppLogDebug("ENTER");
        delete __pFileDelete;
@@ -109,7 +110,7 @@ VideoListEditorPanel::OnInitializing(void)
        clientAreaBounds.x = clientAreaBounds.y = 0;
        SetBounds(clientAreaBounds);
 
-       if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
+       if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
                __pContentIconListView = new (std::nothrow) ListView();
 
@@ -125,12 +126,23 @@ VideoListEditorPanel::OnInitializing(void)
                        __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
                        __pContentIconListView->SetItemProvider(*this);
                        __pContentIconListView->AddListViewItemEventListener(*this);
-                       AddControl(*__pContentIconListView);
+                       AddControl(__pContentIconListView);
                        __pContentIconListView->SetShowState(true);
+
+                       __pLabelSelectCnt = new (std::nothrow) Label();
+                       __pLabelSelectCnt->Construct(Rectangle(0, clientAreaBounds.height - H_COUNT_LABEL,
+                                       clientAreaBounds.width, H_COUNT_LABEL), ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
+                       __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
+                       __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
+                       __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
+                       __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
+                       __pLabelSelectCnt->SetTextConfig(COUNT_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
+                       AddControl(__pLabelSelectCnt);
                }
                else
                {
-                       __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height), true, false);
+                       __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width,
+                                       clientAreaBounds.height), true, false);
                        Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
                        if (pBitmapEmpty != null)
                        {
@@ -140,7 +152,7 @@ VideoListEditorPanel::OnInitializing(void)
                        __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
                        __pContentIconListView->SetItemProvider(*this);
                        __pContentIconListView->AddListViewItemEventListener(*this);
-                       AddControl(*__pContentIconListView);
+                       AddControl(__pContentIconListView);
                        __pContentIconListView->SetShowState(true);
                }
        }
@@ -148,7 +160,7 @@ VideoListEditorPanel::OnInitializing(void)
        {
                __pContentIconListView = new (std::nothrow) ListView();
                __pContentIconListView->Construct(
-                               Rectangle(0, H_SELECTALL_REGION, W_CLIENT_REGION, clientAreaBounds.height-H_SELECTALL_REGION),
+                               Rectangle(0, H_SELECTALL_REGION, W_CLIENT_REGION, clientAreaBounds.height - H_SELECTALL_REGION),
                                true, false);
                Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
                if (pBitmapEmpty != null)
@@ -159,19 +171,19 @@ VideoListEditorPanel::OnInitializing(void)
                __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
                __pContentIconListView->SetItemProvider(*this);
                __pContentIconListView->AddListViewItemEventListener(*this);
-               AddControl(*__pContentIconListView);
+               AddControl(__pContentIconListView);
                __pContentIconListView->SetShowState(true);
 
                __pLabelSelectCnt = new (std::nothrow) Label();
                __pLabelSelectCnt->Construct(
-                               Rectangle(0, clientAreaBounds.height-H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL),
+                               Rectangle(0, clientAreaBounds.height - H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL),
                                ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
                __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
                __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
                __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
                __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
                __pLabelSelectCnt->SetTextConfig(COUNT_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
-               AddControl(*__pLabelSelectCnt);
+               AddControl(__pLabelSelectCnt);
 
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -228,7 +240,7 @@ VideoListEditorPanel::CreateItem(int index, int itemWidth)
                pDuration = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
        }
 
-       if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
+       if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
                if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
                {
@@ -251,20 +263,21 @@ VideoListEditorPanel::CreateItem(int index, int itemWidth)
 
                                        Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
                                        pSelectedBitmap->Construct(canvas, canvas.GetBounds());
-                                       pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap,
-                                                       pSelectedBitmap);
+                                       pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap, pSelectedBitmap);
                                        delete pSelectedBitmap;
                                }
                                else
                                {
                                        AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
-
+                                       delete pTitle;
+                                       delete pItemText;
+                                       delete pDuration;
                                        return null;
                                }
                        }
                        else
                        {
-                               pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
+                               pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap);
                        }
 
                        if (pTitle == null)
@@ -278,18 +291,18 @@ VideoListEditorPanel::CreateItem(int index, int itemWidth)
                        }
 
                        Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
-                       pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
+                       pItem->AddElement(titleRect, IDA_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
                                        Color::GetColor(COLOR_ID_BLACK),null,null,false);
 
                        Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
                                        H_VIDEO_DURATION);
-                       pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
+                       pItem->AddElement(durationRect, IDA_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
                                        Color::GetColor(COLOR_ID_GREY),null,null,false);
                }
                else
                {
                        pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_NORMAL);
-                       pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
+                       pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap);
 
                        if (pTitle == null)
                        {
@@ -302,13 +315,13 @@ VideoListEditorPanel::CreateItem(int index, int itemWidth)
                        }
 
                        Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
-                       pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
-                                       Color::GetColor(COLOR_ID_BLACK),null,null,false);
+                       pItem->AddElement(titleRect, IDA_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
+                                       Color::GetColor(COLOR_ID_BLACK), null, null, false);
 
                        Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
                                        H_VIDEO_DURATION);
-                       pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
-                                       Color::GetColor(COLOR_ID_GREY),null,null,false);
+                       pItem->AddElement(durationRect, IDA_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
+                                       Color::GetColor(COLOR_ID_GREY), null, null, false);
                }
        }
        else
@@ -330,17 +343,17 @@ VideoListEditorPanel::CreateItem(int index, int itemWidth)
 
                                Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
                                pSelectedBitmap->Construct(canvas, canvas.GetBounds());
-                               pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap, pSelectedBitmap);
+                               pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap, pSelectedBitmap);
                                delete pSelectedBitmap;
                        }
                        else
                        {
-                               pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
+                               pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap);
                        }
                }
                else
                {
-                       pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
+                       pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap);
                }
 
                if (pTitle == null)
@@ -354,13 +367,13 @@ VideoListEditorPanel::CreateItem(int index, int itemWidth)
                }
 
                Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
-               pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
-                               Color::GetColor(COLOR_ID_BLACK),null,null,false);
+               pItem->AddElement(titleRect, IDA_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
+                               Color::GetColor(COLOR_ID_BLACK), null, null, false);
 
                Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth - W_VIDEO_DURATION,
                                H_VIDEO_DURATION);
-               pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
-                               Color::GetColor(COLOR_ID_GREY),null,null,false);
+               pItem->AddElement(durationRect, IDA_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
+                               Color::GetColor(COLOR_ID_GREY), null, null, false);
        }
 
        if (pBitmap != null)
@@ -402,7 +415,7 @@ VideoListEditorPanel::OnListViewItemStateChanged(ListView& listView, int index,
 
        if (status == LIST_ITEM_STATUS_CHECKED || status == LIST_ITEM_STATUS_UNCHECKED)
        {
-               if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
+               if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
                {
                        if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
                        {
@@ -455,58 +468,42 @@ VideoListEditorPanel::OnListViewItemStateChanged(ListView& listView, int index,
                }
        }
 
-       if (    __pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
+       if (    __pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
                && __pPresentationModel->GetAppControlSelectionMode() != APPCONTROL_SELECTION_MODE_MULTIPLE)
        {
                if (status == LIST_ITEM_STATUS_SELECTED)
                {
-                       HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
-                       result r = map->Construct();
+                       HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+                       result r = pMap->Construct();
                        if (r == E_SUCCESS)
                        {
-                               map->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH),
-                                               new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
                                ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                                pArrayList->Construct();
 
                                if (r == E_SUCCESS)
                                {
                                        pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
-                                       map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
+                                       pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
 
                                        GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
                                        if (pApp != null)
                                        {
-                                               pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
+                                               pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
                                                pApp->Terminate();
                                        }
                                        else
                                        {
-                                               delete map;
+                                               delete pMap;
                                        }
                                }
                        }
                        else
                        {
-                               delete map;
+                               delete pMap;
                        }
                }
        }
-       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
-}
-
-void
-VideoListEditorPanel::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
-{
-       AppLogDebug("ENTER");
-       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
-}
-
-void
-VideoListEditorPanel::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId,
-               ListContextItemStatus status)
-{
-       AppLogDebug("ENTER");
+       SetButtonState();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -539,9 +536,12 @@ VideoListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
                                                                const SceneId& currentSceneId, IList* pArgs)
 {
        AppLogDebug("ENTER");
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       __pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
 
-       if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
+       if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
                if (currentSceneId == IDSCN_VIDEO_LIST_EDITOR)
                {
@@ -643,11 +643,6 @@ VideoListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
 }
 
 void
-VideoListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
-{
-}
-
-void
 VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void)
 {
        AppLogDebug("ENTER");
@@ -660,8 +655,8 @@ VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void
                return;
        }
 
-       HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
-       result r = map->Construct();
+       HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+       result r = pMap->Construct();
 
        if (r == E_SUCCESS)
        {
@@ -670,37 +665,37 @@ VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void
 
                if (r == E_SUCCESS)
                {
-                       Integer* temp = null;
+                       Integer* pTemp = null;
                        int loopCount = pIndexList->GetCount();
 
                        for (int i = 0; i < loopCount; ++i)
                        {
-                               temp = static_cast<Integer*>(pIndexList->GetAt(i));
-                               pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(temp->ToInt())));
+                               pTemp = static_cast<Integer*>(pIndexList->GetAt(i));
+                               pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(pTemp->ToInt())));
                        }
 
-                       map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
+                       pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
 
                        GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
                        if (pApp != null)
                        {
-                               pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
+                               pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
                                pApp->Terminate();
                        }
                        else
                        {
-                               delete map;
+                               delete pMap;
                        }
                }
                else
                {
-                       delete map;
+                       delete pMap;
                        delete pArrayList;
                }
        }
        else
        {
-               delete map;
+               delete pMap;
        }
 
        delete pIndexList;
@@ -708,7 +703,7 @@ VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void
 }
 
 void
-VideoListEditorPanel::SelectAllPressed(void)
+VideoListEditorPanel::OnSelectAllPressed(void)
 {
        bool needToSelectAll = true;
        int checkedCount = GetItemCheckedCount();
@@ -720,24 +715,26 @@ VideoListEditorPanel::SelectAllPressed(void)
 
        if (needToSelectAll == true)
        {
-               for (int i = 0 ; i < totalFileCount; ++i)
+               for (int i = 0; i < totalFileCount; ++i)
                {
                        if (__pContentIconListView->IsItemChecked(i) == false)
                        {
-                               __pContentIconListView->SetItemChecked(i,true);
+                               __pContentIconListView->SetItemChecked(i, true);
                                __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
                        }
+                       __pFileListEditorForm->SetFooterButtonsState(true);
                }
        }
        else
        {
-               for (int i = 0 ; i < totalFileCount; ++i)
+               for (int i = 0; i < totalFileCount; ++i)
                {
                        if (__pContentIconListView->IsItemChecked(i) == true)
                        {
                                __pContentIconListView->SetItemChecked(i, false);
                                __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
                        }
+                       __pFileListEditorForm->SetFooterButtonsState(false);
                }
        }
 
@@ -755,3 +752,36 @@ VideoListEditorPanel::SelectAllPressed(void)
        __pLabelSelectCnt->SetText(tempString);
        __pLabelSelectCnt->RequestRedraw(true);
 }
+
+void
+VideoListEditorPanel::SetButtonState(void)
+{
+       AppLogDebug("ENTER");
+       
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
+
+       if (GetItemCheckedCount() > 0)
+       {
+               __pFileListEditorForm->SetFooterButtonsState(true);
+       }
+       else
+       {
+               __pFileListEditorForm->SetFooterButtonsState(false);
+       }
+       
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+VideoListEditorPanel::ChangeOrientation(void)
+{
+       AppLogDebug("ENTER");
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       const Form* pForm = dynamic_cast<Form*>(pSceneManager->GetCurrentScene()->GetForm());
+       TryReturn(pForm != null, , "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
+
+       Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
+       SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
+       __pContentIconListView->SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
+}