New look ImageViewerForm
[apps/osp/ImageViewer.git] / src / IvImageViewerForm.cpp
index a18643a..6283d5f 100644 (file)
@@ -48,6 +48,7 @@ static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
+static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
 
 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
 
@@ -93,7 +94,7 @@ static const int DETAIL_COUNT_MAX = 9;
 
 ImageViewerForm::ImageViewerForm(void)
 : __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
-, __pHeader(null)
+, __pLabel(null)
 , __pFooter(null)
 , __pScrollPanel(null)
 , __pDetail_Label(null)
@@ -128,6 +129,10 @@ result
 ImageViewerForm::Initialize()
 {
        AppLogDebug("ENTER");
+
+
+       result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
+
        __pPresentationModel = ImageViewerPresentationModel::GetInstance();
 
        if (__pPresentationModel->GetFileCount() > 0)
@@ -162,8 +167,6 @@ ImageViewerForm::Initialize()
                __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
        }
 
-       result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
-
        if (filePath == EMPTY_SPACE)
        {
                MessageBox messageBox;
@@ -185,9 +188,28 @@ result
 ImageViewerForm::OnInitializing(void)
 {
        AppLogDebug("ENTER");
+       result r = E_SUCCESS;
        SetFormBackEventListener(this);
        __pPresentationModel->AddListener(this);
 
+       __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
+
+       if(__pLabel == null)
+       {
+               return E_FAILURE;
+       }
+       __pLabel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
+       SetControlAlwaysOnTop(*__pLabel,true);
+
+       int allCount = __pPresentationModel->GetFileCount();
+    int index = 1 ;
+    String displayText;
+    displayText.Append(index);
+    displayText.Append("/");
+    displayText.Append(allCount);
+
+    __pLabel->SetText(displayText);
+
        CreateGallery();
        InitializeDisplay(__initializeDisplayModeCurrent);
        InitializePanelDetail();
@@ -216,7 +238,7 @@ ImageViewerForm::OnInitializing(void)
                __pTimer->Construct(*this);
                __pTimer->Start(1);
        }
-       result r = SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
+
        AddOrientationEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -248,7 +270,7 @@ ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus o
        Rectangle clientRect = GetClientAreaBounds();
        Rectangle rect = GetBounds();
 
-       __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
+       __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
        __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
                        clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
 
@@ -260,20 +282,16 @@ void
 ImageViewerForm::InitializeDisplay(AppControlMode status)
 {
        AppLogDebug("ENTER");
-       String strItemText;
-       String strItemIdxText;
 
-       __pHeader = GetHeader();
-       __pHeader->AddActionEventListener(*this);
+       String strItemIdxText;
 
        __pFooter = GetFooter();
        __pFooter->AddActionEventListener(*this);
        __pFooter->RemoveAllItems();
 
-       GetHeaderString(0, strItemText, strItemIdxText);
+       GetLabelText(0, strItemIdxText);
        Rectangle rect = GetClientAreaBounds();
-       __pHeader->SetTitleText(strItemText);
-       __pHeader->SetDescriptionText(strItemIdxText);
+
 
        if (status == APPCONTROL_MODE_NORMAL)
        {
@@ -418,12 +436,11 @@ ImageViewerForm::InitializeDisplay(AppControlMode status)
 }
 
 void
-ImageViewerForm::GetHeaderString(int index, String &fileName, String &page)
+ImageViewerForm::GetLabelText(int index, String &page)
 {
        AppLogDebug("ENTER");
        int allCount = __pPresentationModel->GetFileCount();
        String pStr = __pPresentationModel->GetFilePathAt(index);
-       fileName = __pPresentationModel->GetFileName(pStr);
        page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -485,9 +502,7 @@ ImageViewerForm::DeleteImageFile()
        filePath = __pPresentationModel->GetFilePathAt(currentIndex);
        __pPresentationModel->RequestImage(filePath);
 
-       GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
-       __pHeader->SetTitleText(strItemText);
-       __pHeader->SetDescriptionText(strItemIdxText);
+       GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
 
        if (__visible == true)
        {
@@ -531,10 +546,11 @@ ImageViewerForm::CreateGallery(void)
        Rectangle rect = GetBounds();
 
        __pGallery = new (std::nothrow) Gallery();
-       __pGallery->Construct(Rectangle(0, -clientRect.y, rect.width, rect.height));
+       __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
        __pGallery->SetName(L"GalleryControl");
        __pGallery->SetItemProvider(*this);
        __pGallery->AddGalleryEventListener(*this);
+       __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
        AddControl(*__pGallery);
        __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
 
@@ -578,7 +594,7 @@ ImageViewerForm::InitializePanelDetail()
        }
 
        Rectangle clientRect = GetClientAreaBounds();
-       result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height));
+       result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
        if (r != E_SUCCESS)
        {
                AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
@@ -840,7 +856,7 @@ ImageViewerForm::SetDetailInfo(void)
        AppLogDebug("ENTER");
 
        Rectangle clientRect = GetClientAreaBounds();
-       __pScrollPanel->SetBounds(0, 0, clientRect.width, clientRect.height);
+       __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
 
        int currentIndex = __pGallery->GetCurrentItemIndex();
        String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
@@ -1100,11 +1116,9 @@ ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
        AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
        __pPresentationModel->RequestImage(filePath);
 
-       String strItemText;
        String strItemIdxText;
-       GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
-       __pHeader->SetTitleText(strItemText);
-       __pHeader->SetDescriptionText(strItemIdxText);
+       GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
+       __pLabel->SetText(strItemIdxText);
 
        if (__visible == true)
        {
@@ -1138,7 +1152,8 @@ ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
                        __pPlayButton->SetShowState(false);
                }
 
-               SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
+               SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
+               __pLabel->SetShowState(false);
                __visible = false;
        }
        else
@@ -1148,7 +1163,8 @@ ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
                        __pPlayButton->SetShowState(true);
                }
 
-               SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
+               SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
+               __pLabel->SetShowState(true);
                __visible = true;
 
                __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
@@ -1157,7 +1173,7 @@ ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
 
        Rectangle clientRect = GetClientAreaBounds();
        Rectangle rect = GetBounds();
-       __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
+       __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
        Invalidate(true);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -1169,7 +1185,8 @@ ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
        PowerManager::KeepScreenOnState(true, false);
        if (__visible  == true)
        {
-               SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
+               SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
+               __pLabel->SetShowState(false);
 
                int index = __pGallery->GetCurrentItemIndex();
                String filePath = __pPresentationModel->GetFilePathAt(index);
@@ -1199,8 +1216,8 @@ ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
 
        if (__visible == false)
        {
-               SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
-
+               SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
+               __pLabel->SetShowState(true);
                String filePath = __pPresentationModel->GetFilePathAt(index);
                ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
                if (contentType == CONTENT_TYPE_VIDEO)
@@ -1214,11 +1231,10 @@ ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
                __visible = true;
        }
 
-       String strItemText;
        String strItemIdxText;
-       GetHeaderString(index, strItemText, strItemIdxText);
-       __pHeader->SetTitleText(strItemText);
-       __pHeader->SetDescriptionText(strItemIdxText);
+       GetLabelText(index, strItemIdxText);
+       __pLabel->SetText(strItemIdxText);
+
 
        Rectangle clientRect = GetClientAreaBounds();
        Rectangle rect = GetBounds();
@@ -1560,18 +1576,16 @@ ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
        Rectangle clientRect = GetClientAreaBounds();
        Rectangle rect = GetBounds();
 
-       __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
-       __pScrollPanel->SetBounds(Rectangle(0, 0, clientRect.width, clientRect.height));
+       __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
+       __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height -  __pLabel->GetHeight()));
        __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
 
        if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
        {
                SetDetailInfo();
-               String strItemText(EMPTY_SPACE);
                String strItemIdxText(EMPTY_SPACE);
-               GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
-               __pHeader->SetTitleText(strItemText);
-               __pHeader->SetDescriptionText(strItemIdxText);
+               GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
+               __pLabel->SetText(strItemIdxText);
                Invalidate(true);
        }
 
@@ -2026,7 +2040,6 @@ void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned lo
                __pGallery->SetCurrentItemIndex(currentIndex);
        }
 
-       String strItemText(EMPTY_SPACE);
        String strItemIdxText(EMPTY_SPACE);
 
        __pGallery->UpdateGallery();
@@ -2034,9 +2047,8 @@ void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned lo
        String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
        __pPresentationModel->RequestImage(filePath);
 
-       GetHeaderString(currentIndex, strItemText, strItemIdxText);
-       __pHeader->SetTitleText(strItemText);
-       __pHeader->SetDescriptionText(strItemIdxText);
+       GetLabelText(currentIndex,strItemIdxText);
+       __pLabel->SetText(strItemIdxText);
 
        if (__visible == true)
        {