From: Kimmo Hoikka Date: Wed, 24 Sep 2014 13:45:46 +0000 (-0700) Subject: Merge "Completely remove use of Adaptor class" into tizen X-Git-Tag: accepted/tizen/common/20140925.172059~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d75e2f3c09d1667c853a5683f0d98b4f8d47e457;hp=120c462b74858ad2316c748b8656f23ed32779ea Merge "Completely remove use of Adaptor class" into tizen --- diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index ff683d5..78b995d 100644 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -18,7 +18,6 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-manager.cpp - ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp diff --git a/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt b/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt index 13c2d32..a4ad16f 100644 --- a/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt @@ -55,7 +55,6 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-manager.cpp - ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 52f8353..afe9242 100644 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -37,7 +37,6 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES dali-toolkit-test-utils/toolkit-accessibility-manager.cpp - dali-toolkit-test-utils/toolkit-adaptor.cpp dali-toolkit-test-utils/toolkit-application.cpp dali-toolkit-test-utils/toolkit-clipboard.cpp dali-toolkit-test-utils/toolkit-imf-manager.cpp diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp deleted file mode 100644 index 17bd210..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * - */ - -#define __DALI_ADAPTOR_H__ -#define __DALI_ACCESSIBILITY_MANAGER_H__ -#define __DALI_TIMER_H__ -#define __DALI_CLIPBOARD_H__ -#define __DALI_IMF_MANAGER_H__ - -#include "toolkit-adaptor.h" -#include -#include -#include - -namespace Dali -{ - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -class TestRenderSurface : public RenderSurface -{ -public: - TestRenderSurface(){} - virtual ~TestRenderSurface(){} - virtual SurfaceType GetType() { return RenderSurface::WINDOW; } - virtual Dali::Any GetSurface() { return Dali::Any(); } - virtual Dali::Any GetDisplay() { return Dali::Any(); } - virtual PositionSize GetPositionSize() const { return PositionSize(0, 0, 640, 480);} -}; - -typedef Dali::Rect PositionSize; - -/** - * Stub for the Adaptor - */ -class Adaptor -{ -public: - - typedef SignalV2< void ( Adaptor& ) > AdaptorSignalV2; - -public: - - Adaptor(ToolkitAdaptor& toolkitAdaptor); - ~Adaptor(); - -public: - - void Start(); - void Pause(); - void Resume(); - void Stop(); - bool AddIdle(boost::function callBack); - void FeedEvent(TouchPoint& point, int timeStamp); - bool MoveResize(const PositionSize& positionSize); - void SurfaceResized(const PositionSize& positionSize); - void ReplaceSurface(RenderSurface& surface); - void RenderSync(); - RenderSurface& GetSurface(); - -public: // static methods - static Adaptor& Get(); - static bool IsAvailable(); - -public: // Signals - - AdaptorSignalV2& SignalResize(); - - void EmitSignalResize() - { - mResizeSignal.Emit( *this ); - } - -private: - - // Undefined - Adaptor(const Adaptor&); - Adaptor& operator=(Adaptor&); - - AdaptorSignalV2 mResizeSignal; - TestRenderSurface mRenderSurface; - ToolkitAdaptor& mToolkitAdaptor; -}; - -namespace -{ -Adaptor* gAdaptor = NULL; - -} - -Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor) -: mToolkitAdaptor(toolkitAdaptor) -{ -} - -Adaptor::~Adaptor() -{ - -} - -void Adaptor::Start() -{ - mToolkitAdaptor.mFunctionsCalled.Start = true; -} - -void Adaptor::Pause() -{ - mToolkitAdaptor.mFunctionsCalled.Pause = true; -} - -void Adaptor::Resume() -{ - mToolkitAdaptor.mFunctionsCalled.Resume = true; -} - -void Adaptor::Stop() -{ - mToolkitAdaptor.mFunctionsCalled.Stop = true; -} - -bool Adaptor::AddIdle(boost::function callBack) -{ - mToolkitAdaptor.mFunctionsCalled.AddIdle = true; - mToolkitAdaptor.mLastIdleAdded = callBack; - return true; -} - -void Adaptor::FeedEvent(TouchPoint& point, int timeStamp) -{ - mToolkitAdaptor.mFunctionsCalled.FeedEvent = true; - mToolkitAdaptor.mLastTouchPointFed = point; - mToolkitAdaptor.mLastTimeStampFed = timeStamp; -} - -bool Adaptor::MoveResize(const PositionSize& positionSize) -{ - mToolkitAdaptor.mFunctionsCalled.MoveResize = true; - mToolkitAdaptor.mLastSizeSet = positionSize; - return true; -} - -void Adaptor::SurfaceResized(const PositionSize& positionSize) -{ - mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true; - mToolkitAdaptor.mLastSizeSet = positionSize; -} - -void Adaptor::ReplaceSurface(RenderSurface& surface) -{ - mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true; -} - -void Adaptor::RenderSync() -{ - mToolkitAdaptor.mFunctionsCalled.RenderSync = true; -} - -RenderSurface& Adaptor::GetSurface() -{ - mToolkitAdaptor.mFunctionsCalled.GetSurface = true; - return mRenderSurface; -} - -Adaptor& Adaptor::Get() -{ - DALI_ASSERT_ALWAYS(gAdaptor); - gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true; - return *gAdaptor; -} - -bool Adaptor::IsAvailable() -{ - bool available(false); - - if (gAdaptor) - { - gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true; - available = true; - } - - return available; -} - -Adaptor::AdaptorSignalV2& Adaptor::SignalResize() -{ - mToolkitAdaptor.mFunctionsCalled.SignalResize = true; - return mResizeSignal; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -ToolkitAdaptor::ToolkitAdaptor() -: mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f), - mLastTimeStampFed(0), - mStyleMonitor(StyleMonitor::Get()), - mAccessibilityManager(AccessibilityManager::Get()), - mImfManager(ImfManager::Get()), - mAdaptorStub(new Adaptor(*this)) -{ - gAdaptor = mAdaptorStub; -} - -ToolkitAdaptor::~ToolkitAdaptor() -{ - delete mAdaptorStub; - gAdaptor = NULL; -} - -void ToolkitAdaptor::EmitSignalResize() -{ - mAdaptorStub->EmitSignalResize(); -} - -} // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.h deleted file mode 100644 index 5d8473c..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.h +++ /dev/null @@ -1,256 +0,0 @@ -#ifndef __DALI_TOOLKIT_TOOLKIT_ADAPTOR_H__ -#define __DALI_TOOLKIT_TOOLKIT_ADAPTOR_H__ - -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include "toolkit-style-monitor.h" -#include "toolkit-accessibility-manager.h" -#include "toolkit-timer.h" -#include "toolkit-imf-manager.h" -#include "toolkit-clipboard-event-notifier.h" - -#include -#include - -namespace Dali -{ - -class Adaptor; - -typedef Dali::Rect PositionSize; - -/** - * This creates a stubbed Adaptor so that internal Toolkit Adaptor calls work. - * Furthermore, it provides an interface to see if certain methods were invoked. - */ -class ToolkitAdaptor -{ -public: // Construction & Destruction - - ToolkitAdaptor(); - ~ToolkitAdaptor(); - -public: // Getters - - boost::function GetLastIdleAdded() const - { - return mLastIdleAdded; - } - - TouchPoint GetLastTouchPointFed() const - { - return mLastTouchPointFed; - } - - int GetLastTimeStampFed() const - { - return mLastTimeStampFed; - } - - PositionSize GetLastSizeSet() const - { - return mLastSizeSet; - } - - StyleMonitor& GetToolkitStyleMonitor() - { - return mStyleMonitor; - } - - AccessibilityManager& GetAccessibilityManager() - { - return mAccessibilityManager; - } - - ToolkitClipboardEventNotifier& GetClipboardEventNotifier() - { - return mClipboardEventNotifier; - } - -public: // Signal Emissions - - void EmitSignalResize(); - -public: // TEST FUNCTIONS - - // Enumeration of Adaptor methods - enum TestFuncEnum - { - StartType, - PauseType, - ResumeType, - StopType, - AddIdleType, - FeedEventType, - MoveResizeType, - SurfaceResizedType, - ReplaceSurfaceType, - RenderSyncType, - GetSurfaceType, - GetType, - IsAvailableType, - RegisterSingletonType, - GetSingletonType, - SignalResizeType, - }; - - void Reset() - { - mFunctionsCalled.Reset(); - } - - bool WasCalled(TestFuncEnum func) - { - switch(func) - { - case StartType: return mFunctionsCalled.Start; - case PauseType: return mFunctionsCalled.Pause; - case ResumeType: return mFunctionsCalled.Resume; - case StopType: return mFunctionsCalled.Stop; - case AddIdleType: return mFunctionsCalled.AddIdle; - case FeedEventType: return mFunctionsCalled.FeedEvent; - case MoveResizeType: return mFunctionsCalled.MoveResize; - case SurfaceResizedType: return mFunctionsCalled.SurfaceResized; - case ReplaceSurfaceType: return mFunctionsCalled.ReplaceSurface; - case RenderSyncType: return mFunctionsCalled.RenderSync; - case GetSurfaceType: return mFunctionsCalled.GetSurface; - case GetType: return mFunctionsCalled.Get; - case IsAvailableType: return mFunctionsCalled.IsAvailable; - case RegisterSingletonType: return mFunctionsCalled.RegisterSingleton; - case GetSingletonType: return mFunctionsCalled.GetSingleton; - case SignalResizeType: return mFunctionsCalled.SignalResize; - } - return false; - } - - void ResetCallStatistics(TestFuncEnum func) - { - switch(func) - { - case StartType: mFunctionsCalled.Start = false; break; - case PauseType: mFunctionsCalled.Pause = false; break; - case ResumeType: mFunctionsCalled.Resume = false; break; - case StopType: mFunctionsCalled.Stop = false; break; - case AddIdleType: mFunctionsCalled.AddIdle = false; break; - case FeedEventType: mFunctionsCalled.FeedEvent = false; break; - case MoveResizeType: mFunctionsCalled.MoveResize = false; break; - case SurfaceResizedType: mFunctionsCalled.SurfaceResized = false; break; - case ReplaceSurfaceType: mFunctionsCalled.ReplaceSurface = false; break; - case RenderSyncType: mFunctionsCalled.RenderSync = false; break; - case GetSurfaceType: mFunctionsCalled.GetSurface = false; break; - case GetType: mFunctionsCalled.Get = false; break; - case IsAvailableType: mFunctionsCalled.IsAvailable = false; break; - case RegisterSingletonType: mFunctionsCalled.RegisterSingleton = false; break; - case GetSingletonType: mFunctionsCalled.GetSingleton = false; break; - case SignalResizeType: mFunctionsCalled.SignalResize = false; break; - } - } - -private: - - struct TestFunctions - { - TestFunctions() - : Start(false), - Pause(false), - Resume(false), - Stop(false), - AddIdle(false), - FeedEvent(false), - MoveResize(false), - SurfaceResized(false), - ReplaceSurface(false), - RenderSync(false), - GetSurface(false), - Get(false), - IsAvailable(false), - RegisterSingleton(false), - GetSingleton(false), - SignalResize(false) - { - } - - void Reset() - { - Start = false; - Pause = false; - Resume = false; - Stop = false; - AddIdle = false; - FeedEvent = false; - MoveResize = false; - SurfaceResized = false; - ReplaceSurface = false; - RenderSync = false; - GetSurface = false; - Get = false; - IsAvailable = false; - RegisterSingleton = false; - GetSingleton = false; - SignalResize = false; - } - - bool Start; - bool Pause; - bool Resume; - bool Stop; - bool AddIdle; - bool FeedEvent; - bool MoveResize; - bool SurfaceResized; - bool ReplaceSurface; - bool RenderSync; - bool GetSurface; - bool Get; - bool IsAvailable; - bool RegisterSingleton; - bool GetSingleton; - bool SignalResize; - }; - - TestFunctions mFunctionsCalled; - - // Last set information - boost::function mLastIdleAdded; - TouchPoint mLastTouchPointFed; - int mLastTimeStampFed; - PositionSize mLastSizeSet; - - // Contains Test functions for the Style Monitor - StyleMonitor mStyleMonitor; - - // Stub for AccessibilityManager - AccessibilityManager mAccessibilityManager; - - // Stub for ClipboardEventNotifier - ToolkitClipboardEventNotifier mClipboardEventNotifier; - - ImfManager mImfManager; - - // The Adaptor Stub - Adaptor* mAdaptorStub; - friend class Adaptor; -}; - -} // namespace Dali - -#endif // __DALI_TOOLKIT_TOOLKIT_ADAPTOR_H__ diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp index e4dc0cc..cf00a92 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp @@ -24,56 +24,116 @@ namespace Dali { -namespace -{ -ToolkitClipboardEventNotifier* gToolkitClipboardEventNotifier(NULL); -} // unnamed namespace - namespace Internal { namespace Adaptor { -/** - * Stub for the ClipboardEventNotifier - */ -class ClipboardEventNotifier : public BaseObject +class ClipboardEventNotifier : public Dali::BaseObject { -public: // Creation & Destruction +public: + + typedef Dali::ClipboardEventNotifier::ClipboardEventSignalV2 ClipboardEventSignalV2; + // Creation + static Dali::ClipboardEventNotifier New(); static Dali::ClipboardEventNotifier Get(); + // Public API + const std::string& GetContent() const; + void SetContent( const std::string& content ); + void ClearContent(); + void EmitContentSelectedSignal(); + + // Signals + ClipboardEventSignalV2& ContentSelectedSignal() + { + return mContentSelectedSignalV2; + } + +private: + // Construction & Destruction ClipboardEventNotifier(); - ClipboardEventNotifier(ToolkitClipboardEventNotifier *clipboardEventNotifier); - ~ClipboardEventNotifier(); + virtual ~ClipboardEventNotifier(); + + // Undefined + ClipboardEventNotifier( const ClipboardEventNotifier& ); + ClipboardEventNotifier& operator=( ClipboardEventNotifier& ); + +private: -public: // Signals + std::string mContent; ///< The current selected content. + ClipboardEventSignalV2 mContentSelectedSignalV2; - Dali::ClipboardEventNotifier::ClipboardEventSignalV2& SignalContentSelected() + static Dali::ClipboardEventNotifier mToolkitClipboardEventNotifier; + +public: + + // Helpers for public-api forwarding methods + + inline static Internal::Adaptor::ClipboardEventNotifier& GetImplementation(Dali::ClipboardEventNotifier& detector) { - return mClipboardSignal; + DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" ); + + BaseObject& handle = detector.GetBaseObject(); + + return static_cast(handle); } -private: + inline static const Internal::Adaptor::ClipboardEventNotifier& GetImplementation(const Dali::ClipboardEventNotifier& detector) + { + DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" ); + + const BaseObject& handle = detector.GetBaseObject(); - ToolkitClipboardEventNotifier* mToolkitClipboardEventNotifier; - Dali::ClipboardEventNotifier::ClipboardEventSignalV2 mClipboardSignal; + return static_cast(handle); + } }; +Dali::ClipboardEventNotifier ClipboardEventNotifier::mToolkitClipboardEventNotifier; + +Dali::ClipboardEventNotifier ClipboardEventNotifier::New() +{ + return Get(); +} + Dali::ClipboardEventNotifier ClipboardEventNotifier::Get() { - return gToolkitClipboardEventNotifier->GetClipboardEventNotifier(); + if ( !mToolkitClipboardEventNotifier ) + { + mToolkitClipboardEventNotifier = Dali::ClipboardEventNotifier( new ClipboardEventNotifier ); + } + return mToolkitClipboardEventNotifier; } -ClipboardEventNotifier::ClipboardEventNotifier() -: mToolkitClipboardEventNotifier(NULL) +const std::string& ClipboardEventNotifier::GetContent() const +{ + return mContent; +} + +void ClipboardEventNotifier::SetContent( const std::string& content ) { + mContent = content; } -ClipboardEventNotifier::ClipboardEventNotifier(ToolkitClipboardEventNotifier *clipboardEventNotifier) -: mToolkitClipboardEventNotifier(clipboardEventNotifier) +void ClipboardEventNotifier::ClearContent() +{ + mContent.clear(); +} + +void ClipboardEventNotifier::EmitContentSelectedSignal() +{ + if ( !mContentSelectedSignalV2.Empty() ) + { + Dali::ClipboardEventNotifier handle( this ); + mContentSelectedSignalV2.Emit( handle ); + } +} + +ClipboardEventNotifier::ClipboardEventNotifier() +: mContent() { } @@ -82,26 +142,53 @@ ClipboardEventNotifier::~ClipboardEventNotifier() } } // namespace Adaptor - } // namespace Internal //////////////////////////////////////////////////////////////////////////////////////////////////// -ToolkitClipboardEventNotifier::ToolkitClipboardEventNotifier() -: mClipboardEventNotifierStub(new Internal::Adaptor::ClipboardEventNotifier(this)), - mClipboardEventNotifier( mClipboardEventNotifierStub ) +const char* const ClipboardEventNotifier::SIGNAL_CONTENT_SELECTED( "content-selected" ); + +ClipboardEventNotifier::ClipboardEventNotifier() +{ +} + +ClipboardEventNotifier ClipboardEventNotifier::Get() +{ + return Internal::Adaptor::ClipboardEventNotifier::Get(); +} + +ClipboardEventNotifier::~ClipboardEventNotifier() +{ +} + +const std::string& ClipboardEventNotifier::GetContent() const +{ + return Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).GetContent(); +} + +void ClipboardEventNotifier::SetContent( const std::string& content ) +{ + Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).SetContent(content); +} + +void ClipboardEventNotifier::ClearContent() +{ + Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).ClearContent(); +} + +void ClipboardEventNotifier::EmitContentSelectedSignal() { - gToolkitClipboardEventNotifier = this; + Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).EmitContentSelectedSignal(); } -ToolkitClipboardEventNotifier::~ToolkitClipboardEventNotifier() +ClipboardEventNotifier::ClipboardEventSignalV2& ClipboardEventNotifier::ContentSelectedSignal() { - gToolkitClipboardEventNotifier = NULL; + return Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).ContentSelectedSignal(); } -ClipboardEventNotifier ToolkitClipboardEventNotifier::GetClipboardEventNotifier() +ClipboardEventNotifier::ClipboardEventNotifier( Internal::Adaptor::ClipboardEventNotifier* notifier ) +: BaseHandle( notifier ) { - return mClipboardEventNotifier; } } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.h index c7dcc08..adc4abc 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.h @@ -22,7 +22,10 @@ #include // PUBLIC INCLUDES -#include +#define __DALI_CLIPBOARD_EVENT_NOTIFIER_H__ +#include +#include + namespace Dali { @@ -35,33 +38,24 @@ class ClipboardEventNotifier; } } -/** - * This creates a stubbed ClipboardEventNotifier so that internal Toolkit Adaptor calls work. - */ -class ToolkitClipboardEventNotifier +class ClipboardEventNotifier : public BaseHandle { -public: // Constants - -public: // Construction & Destruction - - ToolkitClipboardEventNotifier(); - ~ToolkitClipboardEventNotifier(); - -public: // Getters - - ClipboardEventNotifier GetClipboardEventNotifier(); - -public: // Signal Emissions +public: + typedef SignalV2< void ( ClipboardEventNotifier& ) > ClipboardEventSignalV2; + static const char* const SIGNAL_CONTENT_SELECTED; ///< name "content-selected" - ClipboardEventNotifier::ClipboardEventSignalV2& SignalContentSelected(); + ClipboardEventNotifier(); + static ClipboardEventNotifier Get(); + ~ClipboardEventNotifier(); -public: // TEST FUNCTIONS + const std::string& GetContent() const; + void SetContent( const std::string& content ); + void ClearContent(); -private: + void EmitContentSelectedSignal(); + ClipboardEventSignalV2& ContentSelectedSignal(); - Internal::Adaptor::ClipboardEventNotifier* mClipboardEventNotifierStub; - friend class Internal::Adaptor::ClipboardEventNotifier; - ClipboardEventNotifier mClipboardEventNotifier; // Hold a handle ourselves. + ClipboardEventNotifier( Internal::Adaptor::ClipboardEventNotifier* notifier ); }; } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h index 7a090f5..e8e4466 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h @@ -21,7 +21,6 @@ // INTERNAL INCLUDES #include -#include "toolkit-adaptor.h" #include "toolkit-orientation.h" namespace Dali @@ -50,18 +49,12 @@ public: mCore = NULL; } - inline ToolkitAdaptor& GetAdaptor() - { - return mAdaptor; - } - //ToolkitOrientation& GetOrientation() //{ //return mOrientation; //} private: - ToolkitAdaptor mAdaptor; //ToolkitOrientation mOrientation; }; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 5d0e4ab..869f9a6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -21,6 +21,7 @@ // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include +#include "toolkit-style-monitor.h" #include #include @@ -656,7 +657,7 @@ int UtcDaliControlImplStyleChange(void) DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION ); StyleChange styleChange; styleChange.defaultFontChange = true; - Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor(); + Dali::StyleMonitor styleMonitor = StyleMonitor::Get(); styleMonitor.EmitStyleChangeSignal(styleChange); DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION ); diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp index d82cb4f..69e02a8 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp @@ -1042,13 +1042,10 @@ void TextInput::OnKeyInputFocusGained() mClipboard = Clipboard::Get(); // Store handle to clipboard // Now in edit mode we can accept string to paste from clipboard - if( Adaptor::IsAvailable() ) + ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); + if ( notifier ) { - ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); - if ( notifier ) - { - notifier.ContentSelectedSignal().Connect( this, &TextInput::OnClipboardTextSelected ); - } + notifier.ContentSelectedSignal().Connect( this, &TextInput::OnClipboardTextSelected ); } } @@ -1092,19 +1089,16 @@ void TextInput::OnKeyInputFocusLost() mClipboard.Reset(); // No longer in edit mode so do not want to receive string from clipboard - if( Adaptor::IsAvailable() ) + ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); + if ( notifier ) { - ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); - if ( notifier ) - { - notifier.ContentSelectedSignal().Disconnect( this, &TextInput::OnClipboardTextSelected ); - } - Clipboard clipboard = Clipboard::Get(); + notifier.ContentSelectedSignal().Disconnect( this, &TextInput::OnClipboardTextSelected ); + } - if ( clipboard ) - { - clipboard.HideClipboard(); - } + Clipboard clipboard = Clipboard::Get(); + if ( clipboard ) + { + clipboard.HideClipboard(); } } diff --git a/base/dali-toolkit/internal/factory/localized-control-factory-impl.cpp b/base/dali-toolkit/internal/factory/localized-control-factory-impl.cpp deleted file mode 100644 index da07f2f..0000000 --- a/base/dali-toolkit/internal/factory/localized-control-factory-impl.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * - */ - -// CLASS HEADER -#include "localized-control-factory-impl.h" - -// INTERNAL INCLUDES -#include -#include - -// EXTERNAL INCLUDES -#include - -using std::string; -using namespace Dali; - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace // unnamed namespace -{ - - -} - -LocalizedControlFactory::LocalizedControlFactory() -: mObjectEntries(), - mSignalsConnected( false ) -{ -} - -LocalizedControlFactory::~LocalizedControlFactory() -{ -} - -Dali::Toolkit::TextView LocalizedControlFactory::CreateLocalizedTextView( const std::string& textID, const std::string& textDomain, const std::string& textViewTheme ) -{ - if( !mSignalsConnected ) - { - Stage::GetCurrent().GetObjectRegistry().ObjectDestroyedSignal().Connect( this, &LocalizedControlFactory::OnObjectDestruction ); - Adaptor::Get().LanguageChangedSignal().Connect( this, &LocalizedControlFactory::OnLanguageChanged ); - mSignalsConnected = true; - } - - const string& localizedText = dgettext(textDomain.c_str(), textID.c_str()); - Dali::Toolkit::TextView textView = Dali::Toolkit::TextView::New(); - textView.SetText(localizedText); - - LocalisedStringInfo info(textID, textDomain, textViewTheme); - - mObjectEntries[textView.GetObjectPtr()] = info; - - return textView; -} - -void LocalizedControlFactory::OnObjectDestruction( const Dali::RefObject* objectPointer ) -{ - if(!mObjectEntries.empty()) - { - //Needs optimization. All the destructed objects are currently checked for existence in entries. - mObjectEntries.erase(objectPointer); - } -} - -void LocalizedControlFactory::OnLanguageChanged( Dali::Adaptor& adaptor) -{ - if(!mObjectEntries.empty()) - { - ObjectEntriesIterator iter = mObjectEntries.begin(); - ObjectEntriesIterator iterEnd = mObjectEntries.end(); - while(iter != iterEnd) - { - RefObject* refObjectPtr = const_cast (iter->first); - BaseHandle handle(static_cast(refObjectPtr)); - LocalisedStringInfo info = iter->second; - - const string& localizedText = dgettext(info.textDomain.c_str(), info.textID.c_str()); - - Toolkit::TextView textView = Dali::Toolkit::TextView::DownCast( handle ); - - if(textView) - { - textView.SetText( localizedText ); - } - else - { - DALI_ASSERT_ALWAYS(false && "Corrupt TextView internal pointer in entries!"); - } - - ++iter; - } - } -} - - - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/base/dali-toolkit/internal/factory/localized-control-factory-impl.h b/base/dali-toolkit/internal/factory/localized-control-factory-impl.h deleted file mode 100644 index ac49226..0000000 --- a/base/dali-toolkit/internal/factory/localized-control-factory-impl.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_LOCALIZED_CONTROL_FACTORY_H__ -#define __DALI_TOOLKIT_INTERNAL_LOCALIZED_CONTROL_FACTORY_H__ - -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -/** - * @copydoc Toolkit::LocalizedControlFactory - */ -class LocalizedControlFactory : public Dali::BaseObject, public ConnectionTracker -{ -public: - - /** - * Structure used to store/retrieve localisation info. - */ - struct LocalisedStringInfo - { - LocalisedStringInfo() - { - } - - LocalisedStringInfo(std::string id, std::string domain, std::string theme) - : textID(id), - textDomain(domain), - textViewTheme(theme) - { - - } - - std::string textID; - std::string textDomain; - std::string textViewTheme; - }; - - typedef std::map< const Dali::RefObject*, LocalisedStringInfo > ObjectEntriesContainer; - typedef ObjectEntriesContainer::iterator ObjectEntriesIterator; - typedef ObjectEntriesContainer::const_iterator ObjectEntriesConstIterator; - - /** - * Construct a new LocalizedControlFactory. - */ - LocalizedControlFactory(); - - /** - * @copydoc Toolkit::LocalizedControlFactory::CreateLocalizedTextView - */ - Dali::Toolkit::TextView CreateLocalizedTextView( const std::string& textID, const std::string& textDomain, const std::string& textViewTheme ); - -protected: - - /** - * Destructor - */ - virtual ~LocalizedControlFactory(); - -private: - - /** - * Callback for Object destructed signal. - * @param objectPointer Pointer to a RefObject - */ - void OnObjectDestruction( const Dali::RefObject* objectPointer ); - - /** - * Callback for language changed signal. - * @param adaptor Reference to a Dali::Adaptor instance - */ - void OnLanguageChanged( Dali::Adaptor& adaptor); - -private: - - // Undefined - LocalizedControlFactory(const LocalizedControlFactory&); - LocalizedControlFactory& operator=(const LocalizedControlFactory& rhs); - -private: - - ObjectEntriesContainer mObjectEntries; - bool mSignalsConnected:1; - -}; - -} // namespace Internal - -inline Internal::LocalizedControlFactory& GetImpl(Dali::Toolkit::LocalizedControlFactory& obj) -{ - DALI_ASSERT_ALWAYS(obj); - - Dali::BaseObject& handle = obj.GetBaseObject(); - - return static_cast(handle); -} - -inline const Internal::LocalizedControlFactory& GetImpl(const Dali::Toolkit::LocalizedControlFactory& obj) -{ - DALI_ASSERT_ALWAYS(obj); - - const Dali::BaseObject& handle = obj.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_INTERNAL_LOCALIZED_CONTROL_FACTORY_H__ diff --git a/base/dali-toolkit/internal/file.list b/base/dali-toolkit/internal/file.list index f2331cc..5e8af9c 100644 --- a/base/dali-toolkit/internal/file.list +++ b/base/dali-toolkit/internal/file.list @@ -55,7 +55,6 @@ toolkit_base_src_files = \ $(toolkit_base_src_dir)/controls/text-view/text-view-processor-dbg.cpp \ $(toolkit_base_src_dir)/controls/text-view/text-view-processor-helper-functions.cpp \ $(toolkit_base_src_dir)/controls/text-view/text-view-word-processor.cpp \ - $(toolkit_base_src_dir)/factory/localized-control-factory-impl.cpp \ $(toolkit_base_src_dir)/focus-manager/focus-manager-impl.cpp \ $(toolkit_base_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \ $(toolkit_base_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \ diff --git a/base/dali-toolkit/internal/styling/style-manager-impl.cpp b/base/dali-toolkit/internal/styling/style-manager-impl.cpp index 57be231..acf1ced 100644 --- a/base/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/base/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -116,9 +116,10 @@ StyleManager::StyleManager() RequestDefaultTheme(); - if( Adaptor::IsAvailable() ) + StyleMonitor styleMonitor( StyleMonitor::Get() ); + if( styleMonitor ) { - StyleMonitor::Get().StyleChangeSignal().Connect( this, &StyleManager::StyleMonitorChange ); + styleMonitor.StyleChangeSignal().Connect( this, &StyleManager::StyleMonitorChange ); } } diff --git a/base/dali-toolkit/public-api/factory/localized-control-factory.cpp b/base/dali-toolkit/public-api/factory/localized-control-factory.cpp deleted file mode 100644 index d8999c1..0000000 --- a/base/dali-toolkit/public-api/factory/localized-control-factory.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * - */ - -// CLASS HEADER - -#include - -// EXTERNAL INCLUDES - -// INTERNAL INCLUDES - -#include - -namespace Dali -{ - -namespace Toolkit -{ - -Dali::Toolkit::TextView LocalizedControlFactory::CreateLocalizedTextView( const std::string& textID, const std::string& textDomain, const std::string& textViewTheme ) -{ - LocalizedControlFactory factory = Get(); - return GetImpl(factory).CreateLocalizedTextView(textID, textDomain, textViewTheme); -} - -LocalizedControlFactory::LocalizedControlFactory() -{ -} - -LocalizedControlFactory::~LocalizedControlFactory() -{ -} - -LocalizedControlFactory LocalizedControlFactory::Get() -{ - LocalizedControlFactory factory; - - // Check whether the focus factory is already created - SingletonService singletonService( SingletonService::Get() ); - if ( singletonService ) - { - Dali::BaseHandle handle = singletonService.GetSingleton(typeid(LocalizedControlFactory)); - if(handle) - { - // If so, downcast the handle of singleton to focus factory - factory = LocalizedControlFactory(dynamic_cast(handle.GetObjectPtr())); - } - - if(!factory) - { - // If not, create the focus factory and register it as a singleton - factory = LocalizedControlFactory(new Internal::LocalizedControlFactory()); - singletonService.Register(typeid(factory), factory); - } - } - - return factory; -} - -LocalizedControlFactory::LocalizedControlFactory(Internal::LocalizedControlFactory *impl) - : BaseHandle(impl) -{ -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/base/dali-toolkit/public-api/factory/localized-control-factory.h b/base/dali-toolkit/public-api/factory/localized-control-factory.h deleted file mode 100644 index 6276550..0000000 --- a/base/dali-toolkit/public-api/factory/localized-control-factory.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __DALI_TOOLKIT_LOCALIZED_CONTROL_FACTORY_H__ -#define __DALI_TOOLKIT_LOCALIZED_CONTROL_FACTORY_H__ - -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * - */ - -// INTERNAL INCLUDES -#include - -namespace Dali DALI_IMPORT_API -{ - -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class LocalizedControlFactory; -} - -/** - * @brief This class provides functionality for creating controls which have localized text. - * - * This class keeps track of objects created using its factory methods, and updates them - * when the system language changes. - * - * Warning: If the developer calls SetText on the object to overwrite the managed TextView, - * then it leads to an inconsistent state where the object will be overwritten with the - * localized text when language/locale changes. - */ - -class LocalizedControlFactory : public BaseHandle -{ -public: - - /** - * @brief Creates a localized TextView, which is automatically updated when the locale or language changes. - * - * @pre The LocalizedControlFactory has been initialized. - * - * @param textID The id of the localized text with which a platform request (gettext) for localized text can be made. - * @param textDomain The text domain for the localized text. Eg "sys_string" - * @param textViewTheme A string containing style info about various properties of TextView for different - * locale/language. - * @return handle to a new localized TextView - */ - static Dali::Toolkit::TextView CreateLocalizedTextView( const std::string& textID, const std::string& textDomain = "sys_string", const std::string& textViewTheme = "{}" ); - - -private: - - /** - * @brief Create a LocalizedControlFactory handle; this can be initialised with LocalizedControlFactory::New(). - * - * Calling member functions with an uninitialised handle is not allowed. - */ - LocalizedControlFactory(); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~LocalizedControlFactory(); - - /** - * @brief Get the singleton of LocalizedControlFactory object. - * - * @return A handle to the LocalizedControlFactory control. - */ - static LocalizedControlFactory Get(); - - /** - * @brief Allows the creation of this Control from an Internal::LocalizedControlFactory pointer. - * - * @param[in] impl A pointer to the internal LocalizedControlFactory. - */ - LocalizedControlFactory(Internal::LocalizedControlFactory *impl); -}; // class LocalizedControlFactory - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_LOCALIZED_CONTROL_FACTORY_H__ diff --git a/base/dali-toolkit/public-api/file.list b/base/dali-toolkit/public-api/file.list index e46991d..d497cea 100755 --- a/base/dali-toolkit/public-api/file.list +++ b/base/dali-toolkit/public-api/file.list @@ -43,7 +43,6 @@ public_api_base_src_files = \ $(public_api_base_src_dir)/controls/table-view/table-view.cpp \ $(public_api_base_src_dir)/controls/text-input/text-input.cpp \ $(public_api_base_src_dir)/controls/text-view/text-view.cpp \ - $(public_api_base_src_dir)/factory/localized-control-factory.cpp \ $(public_api_base_src_dir)/focus-manager/focus-manager.cpp \ $(public_api_base_src_dir)/focus-manager/keyboard-focus-manager.cpp \ $(public_api_base_src_dir)/focus-manager/keyinput-focus-manager.cpp \ @@ -126,9 +125,6 @@ public_api_base_text_input_header_files = \ public_api_base_text_view_header_files = \ $(public_api_base_src_dir)/controls/text-view/text-view.h -public_api_base_factory_header_files = \ - $(public_api_base_src_dir)/factory/localized-control-factory.h - public_api_base_focus_manager_header_files = \ $(public_api_base_src_dir)/focus-manager/keyinput-focus-manager.h \ $(public_api_base_src_dir)/focus-manager/focus-manager.h \ diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am index 3168719..86111b2 100644 --- a/build/tizen/dali-toolkit/Makefile.am +++ b/build/tizen/dali-toolkit/Makefile.am @@ -137,7 +137,6 @@ publicapibasescrollview_HEADERS = $(public_api_base_scroll_view_header_files) publicapibasetableview_HEADERS = $(public_api_base_table_view_header_files) publicapibasetextview_HEADERS = $(public_api_base_text_view_header_files) publicapibasetextinput_HEADERS = $(public_api_base_text_input_header_files) -publicapibasefactory_HEADERS = $(public_api_base_factory_header_files) publicapibasefocusmanager_HEADERS = $(public_api_base_focus_manager_header_files) publicapibasemarkupprocessor_HEADERS = $(public_api_base_markup_processor_header_files) publicapibaseshadereffects_HEADERS = $(public_api_base_shader_effects_header_files) diff --git a/optional/dali-toolkit/dali-toolkit.h b/optional/dali-toolkit/dali-toolkit.h index 2c838cd..45d1566 100644 --- a/optional/dali-toolkit/dali-toolkit.h +++ b/optional/dali-toolkit/dali-toolkit.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include