From 39e89dca13dc1afe603234c9e2753deefaa63f1a Mon Sep 17 00:00:00 2001 From: Dae young Ryu Date: Mon, 8 Apr 2013 15:57:11 +0900 Subject: [PATCH] add _NativeObjectHandler class for ChatOnV Change-Id: I4880a03d4df0c11d9cf48401ae506a6a3a90d7f5 Signed-off-by: Dae young Ryu --- src/ui/CMakeLists.txt | 1 + src/ui/FUiControl.cpp | 146 ------------------ src/ui/FUi_NativeObjectHandler.cpp | 294 +++++++++++++++++++++++++++++++++++++ src/ui/FUi_NativeObjectHandler.h | 113 ++++++++++++++ 4 files changed, 408 insertions(+), 146 deletions(-) create mode 100644 src/ui/FUi_NativeObjectHandler.cpp create mode 100755 src/ui/FUi_NativeObjectHandler.h diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index ba08933..7e721eb 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -231,6 +231,7 @@ SET (${this_target}_SOURCE_FILES FUi_BidiUtils.cpp FUi_DimmingLayer.cpp FUi_DimmingManager.cpp + FUi_NativeObjectHandler.cpp controls/FUiCtrlAnimation.cpp controls/FUiCtrlAnimationFrame.cpp controls/FUiCtrlButton.cpp diff --git a/src/ui/FUiControl.cpp b/src/ui/FUiControl.cpp index ff24840..f782935 100644 --- a/src/ui/FUiControl.cpp +++ b/src/ui/FUiControl.cpp @@ -29,15 +29,6 @@ #include "FUi_ContainerImpl.h" #include "FUi_ErrorMessages.h" #include "FUiAnimVisualElement.h" -#include "FUiAnimVisualElementSurface.h" -#include "FUiAnim_VisualElementSurfaceImpl.h" - -// for sto -#include -#include "FUiAnim_EflNode.h" -#include "FUiAnim_EflLayer.h" -#include "FUiAnim_VisualElementImpl.h" -#include "FUiAnim_DisplayContextImpl.h" using namespace Tizen::Base; @@ -45,143 +36,6 @@ using namespace Tizen::Base::Collection; using namespace Tizen::Graphics; using namespace Tizen::Ui::Animations; -extern "C" _OSP_EXPORT_ void* -STO_GetNativeHandle(void* pControl) -{ - Handle nativeHandle = 0; - Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl; - - if (pControlPointer) - { - Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer); - - if (pControlImpl) - { - VisualElement *pVisualElement = pControlImpl->GetVisualElement(); - - if (pVisualElement) - { - VisualElementSurface* pSurface = pVisualElement->GetSurfaceN(); - - if (pSurface) - { - _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface); - if (pSurfaceImpl) - nativeHandle = pSurfaceImpl->GetNativeHandle(); - - delete pSurface; - } - } - } - } - - return (void*)nativeHandle; -} - -extern "C" _OSP_EXPORT_ void -STO_NativeHandleSetShowState(void* pNative, bool show) -{ - if(show) - evas_object_show((Evas_Object*)pNative); - else - evas_object_hide((Evas_Object*)pNative); -} - -extern "C" _OSP_EXPORT_ void* -STO_GetVisualElement(void* pControl) -{ - Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl; - Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer); - - return (void *)pControlImpl->GetVisualElement(); -} - -extern "C" _OSP_EXPORT_ -void STO_NativeHandleDataSet(void* pEvasObject, void* pData, int width, int height) -{ - evas_object_image_size_set((Evas_Object*)pEvasObject, width, height); - evas_object_image_data_set((Evas_Object*)pEvasObject, pData); -} - - - -extern "C" _OSP_EXPORT_ void -STO_SetVisualElementNativeObject(void* pVisualElement, void* pNativeObject) -{ - VisualElement* pVE = (VisualElement* )pVisualElement; - Evas_Object* pEO = (Evas_Object*)pNativeObject; - - _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); - - _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); - pNode->AddNativeSmartObject(*pVE, pEO); - - int imageWidth = 0; - int imageHeight = 0; - - evas_object_image_size_get(pEO, &imageWidth, &imageHeight); - evas_object_image_data_update_add(pEO, 0, 0, imageWidth, imageHeight); -} - -extern "C" _OSP_EXPORT_ -void* STO_CreateNativeImageObject(void* pDisplayContext, int width, int height) -{ - - if(!pDisplayContext) - { - return null; - } - - _DisplayContextImpl* pDispImpl = _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext); - - if(!pDispImpl->GetNativeLayer()) - { - return null; - } - Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas(); - - if(!pEvas) - { - return null; - } - - Evas_Object* pImage = evas_object_image_filled_add(pEvas); - evas_object_resize(pImage, width, height); - evas_object_move(pImage, 0, 0); -// evas_object_show(pImage); - - return pImage; - -} - -extern "C" _OSP_EXPORT_ void -STO_FillSet(void* pVisualElement, int x, int y, int w, int h) -{ - VisualElement* pVE = (VisualElement*)pVisualElement; - - _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); - - _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); - Evas_Object* pEvasObject = pNode->GetNativeObject(); - if (pEvasObject) - { - evas_object_image_fill_set(pEvasObject, x, y, w, h); - } -} - -extern "C" _OSP_EXPORT_ void -STO_Destroy(void* pVisualElement, void* pEvasObject) -{ - VisualElement* pVE = (VisualElement* )pVisualElement; - - _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); - - _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); - pNode->AddNativeSmartObject(*pVE, null); - - evas_object_del((Evas_Object*)pEvasObject); -} - namespace Tizen { namespace Ui { diff --git a/src/ui/FUi_NativeObjectHandler.cpp b/src/ui/FUi_NativeObjectHandler.cpp new file mode 100644 index 0000000..91c4e07 --- /dev/null +++ b/src/ui/FUi_NativeObjectHandler.cpp @@ -0,0 +1,294 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 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 FUi_ModalLoopManager.cpp + * @brief This is the implementation file for the _ModalLoopManager class. + */ + +#include +#include "FUiAnimDisplayContext.h" +#include "FUiAnimVisualElement.h" + +#include "FUi_NativeObjectHandler.h" + +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_DisplayContextImpl.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_EflLayer.h" + +#include +#include "FUi_ControlImpl.h" + +#define STO_API + +#ifdef STO_API +// for sto +#include "FUiAnimVisualElementSurface.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" + +#endif + + + +using namespace Tizen::Ui::Animations; + +#ifdef STO_API +extern "C" _OSP_EXPORT_ void* +STO_GetNativeHandle(void* pControl) +{ + Handle nativeHandle = 0; + Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl; + + if (pControlPointer) + { + Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer); + + if (pControlImpl) + { + VisualElement *pVisualElement = pControlImpl->GetVisualElement(); + + if (pVisualElement) + { + VisualElementSurface* pSurface = pVisualElement->GetSurfaceN(); + + if (pSurface) + { + _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface); + if (pSurfaceImpl) + nativeHandle = pSurfaceImpl->GetNativeHandle(); + + delete pSurface; + } + } + } + } + + return (void*)nativeHandle; +} + +extern "C" _OSP_EXPORT_ void +STO_NativeHandleSetShowState(void* pNative, bool show) +{ + if(show) + evas_object_show((Evas_Object*)pNative); + else + evas_object_hide((Evas_Object*)pNative); +} + +extern "C" _OSP_EXPORT_ void* +STO_GetVisualElement(void* pControl) +{ + Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl; + Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer); + + return (void *)pControlImpl->GetVisualElement(); +} + +extern "C" _OSP_EXPORT_ +void STO_NativeHandleDataSet(void* pEvasObject, void* pData, int width, int height) +{ + evas_object_image_size_set((Evas_Object*)pEvasObject, width, height); + evas_object_image_data_set((Evas_Object*)pEvasObject, pData); +} + + + +extern "C" _OSP_EXPORT_ void +STO_SetVisualElementNativeObject(void* pVisualElement, void* pNativeObject) +{ + VisualElement* pVE = (VisualElement* )pVisualElement; + Evas_Object* pEO = (Evas_Object*)pNativeObject; + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + pNode->AddNativeSmartObject(*pVE, pEO); + + int imageWidth = 0; + int imageHeight = 0; + + evas_object_image_size_get(pEO, &imageWidth, &imageHeight); + evas_object_image_data_update_add(pEO, 0, 0, imageWidth, imageHeight); +} + +extern "C" _OSP_EXPORT_ +void* STO_CreateNativeImageObject(void* pDisplayContext, int width, int height) +{ + + if(!pDisplayContext) + { + return null; + } + + _DisplayContextImpl* pDispImpl = _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext); + + if(!pDispImpl->GetNativeLayer()) + { + return null; + } + Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas(); + + if(!pEvas) + { + return null; + } + + Evas_Object* pImage = evas_object_image_filled_add(pEvas); + evas_object_resize(pImage, width, height); + evas_object_move(pImage, 0, 0); +// evas_object_show(pImage); + + return pImage; + +} + +extern "C" _OSP_EXPORT_ void +STO_FillSet(void* pVisualElement, int x, int y, int w, int h) +{ + VisualElement* pVE = (VisualElement*)pVisualElement; + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + Evas_Object* pEvasObject = pNode->GetNativeObject(); + if (pEvasObject) + { + evas_object_image_fill_set(pEvasObject, x, y, w, h); + } +} + +extern "C" _OSP_EXPORT_ void +STO_Destroy(void* pVisualElement, void* pEvasObject) +{ + VisualElement* pVE = (VisualElement* )pVisualElement; + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + pNode->AddNativeSmartObject(*pVE, null); + + evas_object_del((Evas_Object*)pEvasObject); +} + +#endif //STO_API +namespace Tizen { namespace Ui { + +Handle +_NativeObjectHandler::CreateNativeImageObjectN(const DisplayContext* pDisplayContext, int width, int height) +{ +// * @exception E_SUCCESS The method is successful. +// * @exception E_INVALID_ARG The specified @c pDisplayContext is invalid. +// * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + if(!pDisplayContext) + { + return null; + } + + _DisplayContextImpl* pDispImpl = _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext); + + if(!pDispImpl->GetNativeLayer()) + { + return null; + } + Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas(); + + if(!pEvas) + { + return null; + } + + Evas_Object* pImage = evas_object_image_filled_add(pEvas); + evas_object_resize(pImage, width, height); + evas_object_move(pImage, 0, 0); +// evas_object_show(pImage); + + return reinterpret_cast(pImage); +} + +result +_NativeObjectHandler::SetNativeObjectToVisualElement(VisualElement* pVisualElement, Handle nativeObjectHandle) +{ +// * @exception E_SUCCESS The method is successful. +// * @exception E_INVALID_ARG The specified @c pNativeObject is @c null. +// * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + Evas_Object* pNative = reinterpret_cast(nativeObjectHandle); + + if(!pNative || !pVisualElement) + { + return E_INVALID_ARG; + } + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVisualElement); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + pNode->AddNativeSmartObject(*pVisualElement, pNative); + + int imageWidth = 0; + int imageHeight = 0; + + evas_object_image_size_get(pNative, &imageWidth, &imageHeight); + evas_object_image_data_update_add(pNative, 0, 0, imageWidth, imageHeight); + return E_SUCCESS; +} + +result +_NativeObjectHandler::SetNativeObjectShowState(Handle nativeObjectHandle, bool show) +{ +// * @exception E_SUCCESS The method is successful. +// * @exception E_INVALID_ARG The specified @c pVisualElement or @c pNativeObject is invalid. +// * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + Evas_Object* pNative = reinterpret_cast(nativeObjectHandle); + if(!pNative) + { + return E_INVALID_ARG; + } + if(show) + { + evas_object_show(pNative); + } + else + { + evas_object_hide(pNative); + } + + return E_SUCCESS; +} + +result +_NativeObjectHandler::DestroyNativeObject(VisualElement* pVisualElement, Handle nativeObjectHandle) +{ +// * @exception E_SUCCESS The method is successful. +// * @exception E_INVALID_ARG The specified @c pVisualElement or @c pNativeObject is invalid. +// * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + Evas_Object* pNative = reinterpret_cast(nativeObjectHandle); + if(!pNative || !pVisualElement) + { + return E_INVALID_ARG; + } + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVisualElement); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + pNode->AddNativeSmartObject(*pVisualElement, null); + + evas_object_del(pNative); + return E_SUCCESS; +} + +}} // namespace Tizen { namespace Ui { + diff --git a/src/ui/FUi_NativeObjectHandler.h b/src/ui/FUi_NativeObjectHandler.h new file mode 100755 index 0000000..926f289 --- /dev/null +++ b/src/ui/FUi_NativeObjectHandler.h @@ -0,0 +1,113 @@ +#ifndef _FUI_NATIVE_OBJECT_HANDLER_H_ +#define _FUI_NATIVE_OBJECT_HANDLER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations { + class DisplayContext; + class VisualElement; +}}} + +namespace Tizen { namespace Ui { + +/** +* @class _NativeObjectHandler +* @brief This class provides utility methods for helping to handle a native image object. +* +* @since 2.1 +* +* @final This class is not intended for extension. +* +* The %_NativeObjectHandler class provides utility methods for helping to handle a native image object. +*/ +class _OSP_EXPORT_ _NativeObjectHandler +{ +public: + /** + * Creates a native image object. + * + * @since 2.1 + * + * @return The native image object handle.@n + * else @c 0 if an error occurs. + * @param[in] pDisplayContext The display context of the window + * @param[in] width The width of the native image object + * @param[in] height The height of the native image object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c pDisplayContext is invalid. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static Handle CreateNativeImageObjectN(const Tizen::Ui::Animations::DisplayContext* pDisplayContext, int width, int height); + + /** + * Sets a native image object to the visual element. + * + * @since 2.1 + * + * @return An error code + * @param[in] pVisualElement The visual element to set the native image object + * @param[in] nativeObjectHandle The handle of native image object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c pVisualElement or @c pNativeObject is invalid. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + */ + static result SetNativeObjectToVisualElement(Tizen::Ui::Animations::VisualElement* pVisualElement, Handle nativeObjectHandle); + + /** + * Sets the show state of the native image object. + * + * @since 2.1 + * + * @return An error code + * @param[in] pNativeObject The native image object + * @param[in] show The new show state + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c pNativeObject is @c null. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + */ + static result SetNativeObjectShowState(Handle nativeObjectHandle, bool show); + + /** + * Deallocates the native image object. + * + * @since 2.1 + * + * @return An error code + * @param[in] pVisualElement The display context + * @param[in] pNativeObject The native image object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c pVisualElement or @c pNativeObject is invalid. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + */ + static result DestroyNativeObject(Tizen::Ui::Animations::VisualElement* pVisualElement, Handle nativeObjectHandle); + + +private: + // + // This default constructor is intentionally declared as private because this class cannot be constructed. + // + _NativeObjectHandler(void); + + // + // This destructor is intentionally declared as private because this class cannot be constructed. + // + virtual ~_NativeObjectHandler(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @param[in] rhs An instance of %_NativeObjectHandler + // + _NativeObjectHandler(const _NativeObjectHandler& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @param[in] rhs An instance of %_NativeObjectHandler + // + _NativeObjectHandler& operator =(const _NativeObjectHandler& rhs); +}; //_NativeObjectHandler +}} // namespace Tizen { namespace Ui { + +#endif //_FUI_NATIVE_OBJECT_HANDLER_H_ -- 2.7.4