Initialize Tizen 2.3
[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         AddFrameEventListener(*this);
56
57         SceneManager* pSceneManager = SceneManager::GetInstance();
58
59         r = pSceneManager->RegisterFormFactory(formFactory);
60         r = pSceneManager->RegisterPanelFactory(panelFactory);
61
62         r = pSceneManager->RegisterScene(IDSCN_ALBUM_LIST, IDC_FORM_ALBUM_LIST, IDC_PANEL_BLANK);
63         r = pSceneManager->RegisterScene(IDSCN_ALBUM_LIST_EDITOR, IDC_FORM_ALBUM_LIST_EDITOR, IDC_PANEL_BLANK);
64         r = pSceneManager->RegisterScene(IDSCN_ALBUM_NAME_EDITOR, IDC_FORM_ALBUM_NAME_EDITOR, IDC_PANEL_BLANK);
65
66         r = pSceneManager->RegisterScene(IDSCN_ALL_LIST, IDC_FORM_FILE_LIST, IDC_PANEL_ALL_LIST);
67         r = pSceneManager->RegisterScene(IDSCN_IMAGE_LIST, IDC_FORM_FILE_LIST, IDC_PANEL_IMAGE_LIST);
68         r = pSceneManager->RegisterScene(IDSCN_VIDEO_LIST, IDC_FORM_FILE_LIST, IDC_PANEL_VIDEO_LIST);
69
70         r = pSceneManager->RegisterScene(IDSCN_ALL_LIST_EDITOR, IDC_FORM_FILE_LIST_EDITOR, IDC_PANEL_ALL_LIST_EDITOR);
71         r = pSceneManager->RegisterScene(IDSCN_IMAGE_LIST_EDITOR, IDC_FORM_FILE_LIST_EDITOR, IDC_PANEL_IMAGE_LIST_EDITOR);
72         r = pSceneManager->RegisterScene(IDSCN_VIDEO_LIST_EDITOR, IDC_FORM_FILE_LIST_EDITOR, IDC_PANEL_VIDEO_LIST_EDITOR);
73
74         r = pSceneManager->RegisterScene(IDSCN_ALL_LIST_SELECTION, IDC_FORM_FILE_LIST_EDITOR,
75                         IDC_PANEL_ALL_LIST_SELECTION);
76
77         r = pSceneManager->RegisterScene(IDSCN_SETTING_MAIN, IDC_FORM_SETTING_MAIN, IDC_PANEL_BLANK);
78         r = pSceneManager->RegisterScene(IDSCN_SETTING_INTERVAL, IDC_FORM_SETTING_INTERVAL, IDC_PANEL_BLANK);
79         r = pSceneManager->RegisterScene(IDSCN_SETTING_TRANSITION, IDC_FORM_SETTING_TRANSITION, IDC_PANEL_BLANK);
80         r = pSceneManager->RegisterScene(IDSCN_IMAGE_CROP, IDC_FORM_IMAGE_CROP, IDC_PANEL_BLANK);
81
82         SceneId sceneId;
83         GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
84
85         String operationID = pGalleryApp->GetAppControlOperationId();
86
87         if (operationID.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
88         {
89                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST), null);
90         }
91         else if (operationID.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
92         {
93                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST), null);
94         }
95         else if (operationID.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
96         {
97                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN), null);
98         }
99         else
100         {
101                 pGalleryApp->Terminate();
102         }
103         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104
105         return r;
106 }
107
108 result
109 MainFrame::OnTerminating(void)
110 {
111         AppLogDebug("ENTER");
112         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
113
114         return E_SUCCESS;
115 }
116
117 void
118 MainFrame::OnFrameActivated(const Frame& source)
119 {
120         AppLogDebug("OnFrameActivated");
121
122         GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
123         if (pGalleryApp != null)
124         {
125                 pGalleryApp->SetFrameActivated(true);
126         }
127 }