Back event changes
[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
81         SceneId sceneId;
82         GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
83
84         String operationID = pGalleryApp->GetAppControlOperationId();
85
86         if (operationID.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
87         {
88                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST), null);
89         }
90         else if (operationID.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
91         {
92                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST), null);
93         }
94         else if (operationID.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
95         {
96                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN), null);
97         }
98         else
99         {
100                 pGalleryApp->Terminate();
101         }
102         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
103
104         return r;
105 }
106
107 result
108 MainFrame::OnTerminating(void)
109 {
110         AppLogDebug("ENTER");
111         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
112
113         return E_SUCCESS;
114 }
115
116 void
117 MainFrame::OnFrameActivated(const Frame& source)
118 {
119         AppLogDebug("OnFrameActivated");
120
121         GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
122         if (pGalleryApp != null)
123         {
124                 pGalleryApp->SetFrameActivated(true);
125         }
126 }