Fixed issue 45595
[apps/osp/Gallery.git] / src / GlSlideShowPopUp.cpp
1 //
2 // Tizen Native SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        SlideShowPopUp.cpp
20  * @brief       This file contains the definitions of the SlideShowPopUp class.
21  */
22
23 #include <FUiScenes.h>
24
25 #include "GlResourceManager.h"
26 #include "GlSlideSettingListener.h"
27 #include "GlSlideShowPopUp.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
36
37 static const int ID_FORMAT_START = 501;
38 static const int ID_FORMAT_SETTING = 502;
39 static const int ID_CANCEL_BUTTON = 503;
40
41 SlideShowPopUp::SlideShowPopUp(void)
42         : __pList(null)
43         , __pListener(null)
44 {
45 }
46
47 SlideShowPopUp::~SlideShowPopUp(void)
48 {
49 }
50
51 bool
52 SlideShowPopUp::Initialize(void)
53 {
54         Button* pCancelButton = null;
55         Popup::Construct(L"IDL_SLIDESHOW_SETTING_POPUP");
56         Popup::SetPropagatedKeyEventListener(this);
57
58         __pList = static_cast<ListView*>(GetControl(L"IDC_POPUP_LIST"));
59
60         if (__pList == null)
61         {
62                 return false;
63         }
64
65         __pList->SetItemProvider(*this);
66         __pList->AddListViewItemEventListener(*this);
67
68         pCancelButton = static_cast<Button*>(GetControl(L"IDC_BUTTON", true));
69
70         if (pCancelButton != null)
71         {
72                 pCancelButton->AddActionEventListener(*this);
73                 pCancelButton->SetActionId(ID_CANCEL_BUTTON);
74         }
75
76         return true;
77 }
78
79 result
80 SlideShowPopUp::OnTerminating(void)
81 {
82         return E_SUCCESS;
83 }
84
85 void
86 SlideShowPopUp::OnActionPerformed(const Control& source, int actionId)
87 {
88         switch (actionId)
89         {
90         case ID_CANCEL_BUTTON:
91         {
92                 Popup::SetShowState(false);
93                 Popup::Show();
94         }
95         break;
96
97         default:
98                 break;
99         }
100         return;
101 }
102
103 void
104 SlideShowPopUp::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
105 {
106         if (__pListener != null)
107         {
108                 __pListener->OnSlideSettingPopUpItemSelected(index);
109         }
110 }
111
112 bool
113 SlideShowPopUp::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
114 {
115         AppLogDebug("ENTER");
116
117         if(keyEventInfo.GetKeyCode() == KEY_BACK)
118         {
119                 Popup::SetShowState(false);
120                 Popup::Show();
121         }
122         return false;
123 }
124
125 ListItemBase*
126 SlideShowPopUp::CreateItem(int index, int itemWidth)
127 {
128         ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
129         int listItemHeight = 112;
130
131         CustomItem* pItem = new (std::nothrow) CustomItem();
132         result r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemHeight), style);
133         pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
134
135         if (IsFailed(r))
136         {
137                 AppLogDebug("Create Item Failed with error %s", GetErrorMessage(r));
138                 return null;
139         }
140
141         switch (index)
142         {
143         case 0:
144         {
145                 pItem->AddElement(Rectangle(25, 0, GetClientAreaBounds().width -50, listItemHeight), ID_FORMAT_START,
146                                 ResourceManager::GetString(L"IDS_MEDIABR_OPT_START_SLIDESHOW"), true);
147         }
148         break;
149
150         case 1:
151         {
152                 pItem->AddElement(Rectangle(25, 0, GetClientAreaBounds().width -50, listItemHeight), ID_FORMAT_SETTING,
153                                 ResourceManager::GetString(L"IDS_MEDIABR_BODY_SLIDESHOW_SETTINGS"), true);
154         }
155         break;
156
157         break;
158         default:
159                 break;
160         }
161
162         return pItem;
163 }
164
165 bool
166 SlideShowPopUp::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
167 {
168         return true;
169 }
170
171 int
172 SlideShowPopUp::GetItemCount(void)
173 {
174         return 2;
175 }
176
177 void
178 SlideShowPopUp::SetEventListner(ISlideSettingListener* listner)
179 {
180         __pListener = listner;
181 }