From 788488a4e2de689cfbbe34b219c4e8e2a6ec2a47 Mon Sep 17 00:00:00 2001 From: chitta ranjan Date: Wed, 3 Apr 2013 13:46:57 +0900 Subject: [PATCH] SlideShow Menu Implementation Change-Id: Idad2d607a0dc4779e04c760d0e5eb982944a4f8f Signed-off-by: chitta ranjan --- inc/IvImageViewerForm.h | 7 + inc/IvSlideSettingListener.h | 37 +++++ inc/IvSlideShowPopUp.h | 93 +++++++++++ inc/IvTypes.h | 2 + .../IDL_SLIDESHOW_SETTING_POPUP.xml | 22 +++ src/IvImageViewerForm.cpp | 106 +++++++++---- src/IvSlideShowPopUp.cpp | 174 +++++++++++++++++++++ src/IvTypes.cpp | 2 + 8 files changed, 411 insertions(+), 32 deletions(-) create mode 100644 inc/IvSlideSettingListener.h create mode 100644 inc/IvSlideShowPopUp.h create mode 100644 res/screen-size-normal/IDL_SLIDESHOW_SETTING_POPUP.xml create mode 100644 src/IvSlideShowPopUp.cpp diff --git a/inc/IvImageViewerForm.h b/inc/IvImageViewerForm.h index a5b0fe9..703f94a 100644 --- a/inc/IvImageViewerForm.h +++ b/inc/IvImageViewerForm.h @@ -34,6 +34,8 @@ #include "IvFileUpdateEventListener.h" #include "IvImageProvider.h" #include "IvImageViewerEventListener.h" +#include "IvSlideShowPopUp.h" +#include "IvSlideSettingListener.h" #include "IvTypes.h" class ImageInfo; @@ -41,6 +43,7 @@ class ImageViewerForm; class ImageViewerPresentationModel; class SettingPresentationModel; + class ImageViewerForm : public BaseForm , public Tizen::App::IAppControlResponseListener @@ -56,6 +59,7 @@ class ImageViewerForm , public Tizen::Ui::Scenes::ISceneEventListener , public IImageViewerEventListener , public IFileUpdateEventListener + , public ISlideSettingListener { public: ImageViewerForm(void); @@ -117,6 +121,8 @@ public: virtual void OnFormFileEventOccuered(const int index, const unsigned long eventId); + virtual void OnSlideSettingPopUpItemSelected(int index); + private: enum AppControlMode { @@ -186,6 +192,7 @@ private: Tizen::Base::String __downLordFileName; RequestId __requestId; Tizen::Content::ContentTransfer __contentTransfer; + SlideShowPopUp* __pPopUp; ImageViewerPresentationModel* __pPresentationModel; SettingPresentationModel* __pSettingPresentationModel; }; diff --git a/inc/IvSlideSettingListener.h b/inc/IvSlideSettingListener.h new file mode 100644 index 0000000..a2412a8 --- /dev/null +++ b/inc/IvSlideSettingListener.h @@ -0,0 +1,37 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file ISlideSettingListener.h + * @brief This is the header file for ISlideSettingListener class. + */ + +#ifndef _IV_SLIDE_SETTING_LISTENER_H_ +#define _IV_SLIDE_SETTING_LISTENER_H_ + +#include + + +class ISlideSettingListener +{ +public: + ISlideSettingListener(void){}; + virtual ~ISlideSettingListener(void) {}; + + virtual void OnSlideSettingPopUpItemSelected(int index ) = 0 ; +}; + +#endif /* _IV_SLIDE_SETTING_LISTENER_H_ */ diff --git a/inc/IvSlideShowPopUp.h b/inc/IvSlideShowPopUp.h new file mode 100644 index 0000000..402d21f --- /dev/null +++ b/inc/IvSlideShowPopUp.h @@ -0,0 +1,93 @@ +// +// Tizen Native SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +/** + * @file SlideShowPopUp.h + * @brief This header file contains the declarations of the SlideShowPopUp + * + */ + +#ifndef _SLIDE_SHOW_POPUP_H_ +#define _SLIDE_SHOW_POPUP_H_ + +#include +#include +#include + + +class ISlideSettingListener; + +class SlideShowPopUp + : public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Controls::Popup + , public Tizen::Ui::IActionEventListener + { + public: + /** + * @brief The Default Constructor + */ + SlideShowPopUp(void); + + /** + * @brief The Default Destructor + */ + ~SlideShowPopUp(void); + + /** + * @brief Initializes this SettingForm Form. + * + * @return An error code + * @exception true The method is succeIOrientationEventListenerssful. + * @exception false An error Occured. + */ + bool Initialize(void); + + /** + * This function terminates all the controls + * + * @return result type + * @param No parameter + */ + virtual result OnTerminating(void); + + public: + + //IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual int GetItemCount(void); + + //IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + // IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state){}; + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction){}; + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){}; + + void SetEventListner(ISlideSettingListener* listner); + + private: + Tizen::Ui::Controls::ListView* __pList; + ISlideSettingListener* __pListener; + }; + + +#endif /* _SLIDE_SHOW_POPUP_H_ */ diff --git a/inc/IvTypes.h b/inc/IvTypes.h index 53ef279..32ec1fd 100644 --- a/inc/IvTypes.h +++ b/inc/IvTypes.h @@ -93,11 +93,13 @@ extern const wchar_t* APPCONTROL_PROVIDER_ID_MESSAGES; extern const wchar_t* APPCONTROL_PROVIDER_ID_EMAIL; extern const wchar_t* APPCONTROL_PROVIDER_ID_CONTACTS; extern const wchar_t* APPCONTROL_PROVIDER_ID_VIDEO_PLAYER; +extern const wchar_t* APPCONTROL_PROVIDER_ID_GALLERY; extern const wchar_t* APPCONTROL_OPERATION_ID_PICK; extern const wchar_t* APPCONTROL_OPERATION_ID_VIEW; extern const wchar_t* APPCONTROL_OPERATION_ID_COMPOSE; extern const wchar_t* APPCONTROL_OPERATION_ID_MAIN; +extern const wchar_t* APPCONTROL_OPERATION_ID_CONFIGURE; extern const wchar_t* APPCONTROL_KEY_TYPE; extern const wchar_t* APPCONTROL_KEY_PATH; diff --git a/res/screen-size-normal/IDL_SLIDESHOW_SETTING_POPUP.xml b/res/screen-size-normal/IDL_SLIDESHOW_SETTING_POPUP.xml new file mode 100644 index 0000000..10b144b --- /dev/null +++ b/res/screen-size-normal/IDL_SLIDESHOW_SETTING_POPUP.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/IvImageViewerForm.cpp b/src/IvImageViewerForm.cpp index 6283d5f..22c5b31 100644 --- a/src/IvImageViewerForm.cpp +++ b/src/IvImageViewerForm.cpp @@ -27,6 +27,7 @@ #include "IvImageViewerPresentationModel.h" #include "IvResourceManager.h" #include "IvSettingPresentationModel.h" +#include "IvSlideShowPopUp.h" #include "IvTypes.h" using namespace Tizen::App; @@ -200,24 +201,34 @@ ImageViewerForm::OnInitializing(void) } __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); + int index = 1 ; + String displayText; + displayText.Append(index); + displayText.Append("/"); + displayText.Append(allCount); - __pLabel->SetText(displayText); + __pLabel->SetText(displayText); CreateGallery(); InitializeDisplay(__initializeDisplayModeCurrent); InitializePanelDetail(); InitializePopup(); + + __pPopUp = new (std::nothrow) SlideShowPopUp(); + + if (__pPopUp != null) + { + __pPopUp->Initialize(); + __pPopUp->SetEventListner(this); + AddControl(*__pPopUp); + } + + if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL - || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE - || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL) + || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE + || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL) { int index = __pPresentationModel->GetStartIndex(); __pGallery->UpdateGallery(); @@ -479,7 +490,7 @@ ImageViewerForm::DeleteImageFile() } if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true - || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true) + || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true) { ContentManager::ScanFile(filePath); } @@ -1335,28 +1346,12 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId) break; case ACTION_ID_FOOTER_BUTTON_SLIDE: { - int repeatValue = 0; - - if (__pPresentationModel->GetFileCount() > 1) + if (__pPopUp != null) { - __pGallery->UpdateGallery(); - if (__detail == false) - { - ShowPanelDetail(false); - } - - __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER, - ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue); - - if (repeatValue == 0) - { - __pGallery->StartSlideShow(false); - } - else - { - __pGallery->StartSlideShow(true); - } + __pPopUp->SetShowState(true); + __pPopUp->Show(); } + break; } case ACTION_ID_FOOTER_BUTTON_CROP: @@ -1539,7 +1534,7 @@ ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode) delete pRotatedBuffer; return; -CATCH: + CATCH: if (pRotatedBuffer != null) //this buffer is no longer used { delete pRotatedBuffer; @@ -1973,7 +1968,7 @@ ImageViewerForm::GetQuickThumbnailN(String& filePath) if (r == E_SUCCESS) { if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP - || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM) + || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM) { Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth()); pBitmap->Scale(srcDim); @@ -2072,3 +2067,50 @@ void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned lo Invalidate(true); AppLogDebug("EXIT"); } + +void +ImageViewerForm::OnSlideSettingPopUpItemSelected(int index) +{ + + if ( __pPopUp != NULL) + { + __pPopUp->SetShowState(false); + } + + if (index == 0) // start slide show + { + int repeatValue = 0; + + if (__pPresentationModel->GetFileCount() > 1) + { + __pGallery->UpdateGallery(); + + if (__detail == false) + { + ShowPanelDetail(false); + } + + __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER, + ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue); + + if (repeatValue == 0) + { + __pGallery->StartSlideShow(false); + } + else + { + __pGallery->StartSlideShow(true); + } + } + } + else if (index == 1) // launch settings + { + + HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter); + pDataList->Construct(); + + __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY, + APPCONTROL_OPERATION_ID_CONFIGURE, null, pDataList, this); + + } +} diff --git a/src/IvSlideShowPopUp.cpp b/src/IvSlideShowPopUp.cpp new file mode 100644 index 0000000..1cc127f --- /dev/null +++ b/src/IvSlideShowPopUp.cpp @@ -0,0 +1,174 @@ +// +// Tizen Native SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file SlideShowPopUp.cpp + * @brief This file contains the definitions of the SlideShowPopUp class. + */ + +#include +#include + +#include "IvSlideShowPopUp.h" +#include "IvSlideSettingListener.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + + +static const int ID_FORMAT_START = 501; +static const int ID_FORMAT_SETTING = 502; +static const int ID_CANCEL_BUTTON = 503; + + +SlideShowPopUp::SlideShowPopUp(void) +:__pList(null) +{ + +} + +SlideShowPopUp::~SlideShowPopUp(void) +{ + +} + +bool +SlideShowPopUp::Initialize(void) +{ + Button* pCancelButton = null; + Popup::Construct(L"IDL_SLIDESHOW_SETTING_POPUP"); + + __pList = static_cast(GetControl(L"IDC_POPUP_LIST")); + + if (__pList == null) + { + return false; + } + + __pList->SetItemProvider(*this); + __pList->AddListViewItemEventListener(*this); + + pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON", true)); + + if (pCancelButton != null) + { + pCancelButton->AddActionEventListener(*this); + pCancelButton->SetActionId(ID_CANCEL_BUTTON); + } + + return true; + +} + +result +SlideShowPopUp::OnTerminating(void) +{ + result r = E_SUCCESS; + return r; +} + +void +SlideShowPopUp::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_CANCEL_BUTTON: + { + Popup::SetShowState(false); + Popup::Show(); + } + break; + default: + break; + } + return; +} + +void +SlideShowPopUp::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status) +{ + + if (__pListener != null) + { + __pListener->OnSlideSettingPopUpItemSelected(index); + } + +} + +ListItemBase* +SlideShowPopUp::CreateItem(int index, int itemWidth) +{ + result r = E_FAILURE; + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + int listItemHeight = 112; + + CustomItem* pItem = new (std::nothrow) CustomItem(); + r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemHeight), style); + pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE)); + + if (IsFailed(r)) + { + AppLogDebug("Create Item Failed with error %s", GetErrorMessage(r)); + return null; + } + + switch (index) + { + + case 0: + { + pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_START, L"Start slideshow", true); + } + break; + + case 1: + { + pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_SETTING, L"Slideshow settings", true); + } + break; + + break; + default: + break; + } + + return pItem; +} + +bool +SlideShowPopUp::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + return true; +} + +int +SlideShowPopUp::GetItemCount(void) +{ + return 2; +} + +void +SlideShowPopUp::SetEventListner(ISlideSettingListener* listner) +{ + __pListener = listner; +} + diff --git a/src/IvTypes.cpp b/src/IvTypes.cpp index b35b86c..0b64e02 100644 --- a/src/IvTypes.cpp +++ b/src/IvTypes.cpp @@ -47,6 +47,8 @@ const wchar_t* APPCONTROL_OPERATION_ID_PICK = L"http://tizen.org/appcontrol/oper const wchar_t* APPCONTROL_OPERATION_ID_VIEW = L"http://tizen.org/appcontrol/operation/view"; const wchar_t* APPCONTROL_OPERATION_ID_COMPOSE = L"http://tizen.org/appcontrol/operation/compose"; const wchar_t* APPCONTROL_OPERATION_ID_MAIN = L"http://tizen.org/appcontrol/operation/main"; +const wchar_t* APPCONTROL_OPERATION_ID_CONFIGURE = L"http://tizen.org/appcontrol/operation/configure"; +const wchar_t* APPCONTROL_PROVIDER_ID_GALLERY = L"tizen.gallery"; const wchar_t* APPCONTROL_KEY_TYPE = L"http://tizen.org/appcontrol/data/type"; const wchar_t* APPCONTROL_KEY_PATH = L"http://tizen.org/appcontrol/data/path"; -- 2.7.4