adc836bd6b63c8ead9bdd3f83d9d0b31055b8cc1
[apps/osp/Gallery.git] / src / GlMainFrame.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                GlMainFrame.cpp
19  * @brief               This is the implementation file for MainFrame class.
20  */
21
22 #include <FUi.h>
23 #include "GlGalleryApp.h"
24 #include "GlFormFactory.h"
25 #include "GlMainFrame.h"
26 #include "GlPanelFactory.h"
27 #include "GlTypes.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33 using namespace Tizen::Ui::Scenes;
34
35 MainFrame::MainFrame(void)
36 {
37         AppLogDebug("ENTER");
38         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
39 }
40
41 MainFrame::~MainFrame(void)
42 {
43         AppLogDebug("ENTER");
44         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
45 }
46
47 result
48 MainFrame::OnInitializing(void)
49 {
50         AppLogDebug("ENTER");
51         result r = E_SUCCESS;
52         static FormFactory formFactory;
53         static PanelFactory panelFactory;
54
55         SceneManager* pSceneManager = SceneManager::GetInstance();
56
57         r = pSceneManager->RegisterFormFactory(formFactory);
58         r = pSceneManager->RegisterPanelFactory(panelFactory);
59
60         r = pSceneManager->RegisterScene(IDSCN_ALBUM_LIST, IDC_FORM_ALBUM_LIST, IDC_PANEL_BLANK);
61         r = pSceneManager->RegisterScene(IDSCN_ALBUM_LIST_EDITOR, IDC_FORM_ALBUM_LIST_EDITOR, IDC_PANEL_BLANK);
62         r = pSceneManager->RegisterScene(IDSCN_ALBUM_NAME_EDITOR, IDC_FORM_ALBUM_NAME_EDITOR, IDC_PANEL_BLANK);
63
64         r = pSceneManager->RegisterScene(IDSCN_ALL_LIST, IDC_FORM_FILE_LIST, IDC_PANEL_ALL_LIST);
65         r = pSceneManager->RegisterScene(IDSCN_IMAGE_LIST, IDC_FORM_FILE_LIST, IDC_PANEL_IMAGE_LIST);
66         r = pSceneManager->RegisterScene(IDSCN_VIDEO_LIST, IDC_FORM_FILE_LIST, IDC_PANEL_VIDEO_LIST);
67
68         r = pSceneManager->RegisterScene(IDSCN_ALL_LIST_EDITOR, IDC_FORM_FILE_LIST_EDITOR, IDC_PANEL_ALL_LIST_EDITOR);
69         r = pSceneManager->RegisterScene(IDSCN_IMAGE_LIST_EDITOR, IDC_FORM_FILE_LIST_EDITOR, IDC_PANEL_IMAGE_LIST_EDITOR);
70         r = pSceneManager->RegisterScene(IDSCN_VIDEO_LIST_EDITOR, IDC_FORM_FILE_LIST_EDITOR, IDC_PANEL_VIDEO_LIST_EDITOR);
71
72         r = pSceneManager->RegisterScene(IDSCN_ALL_LIST_SELECTION, IDC_FORM_FILE_LIST_EDITOR,
73                         IDC_PANEL_ALL_LIST_SELECTION);
74
75         r = pSceneManager->RegisterScene(IDSCN_SETTING_MAIN, IDC_FORM_SETTING_MAIN, IDC_PANEL_BLANK);
76         r = pSceneManager->RegisterScene(IDSCN_SETTING_INTERVAL, IDC_FORM_SETTING_INTERVAL, IDC_PANEL_BLANK);
77         r = pSceneManager->RegisterScene(IDSCN_SETTING_TRANSITION, IDC_FORM_SETTING_TRANSITION, IDC_PANEL_BLANK);
78
79         SceneId sceneId;
80         GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
81
82         String operationID = pGalleryApp->GetAppControlOperationId();
83
84         if (operationID.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
85         {
86                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST), null);
87         }
88         else if (operationID.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
89         {
90                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST), null);
91         }
92         else if (operationID.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
93         {
94                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN), null);
95         }
96         else
97         {
98                 pGalleryApp->Terminate();
99         }
100         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
101
102         return r;
103 }
104
105 result
106 MainFrame::OnTerminating(void)
107 {
108         AppLogDebug("ENTER");
109         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
110
111         return E_SUCCESS;
112 }