X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-orientation.cpp;h=b1b566067642f3f138cc73a9fd45887c2f115c24;hp=62598d3fe50f1e820b11395d4421b05c6c143e33;hb=d07dc4c4a6067ba3080184d862bca40a90d1789c;hpb=30f6ca1e541089b19f2b349a8a12d8a5bcaf2f9e diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp index 62598d3..b1b5660 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp @@ -1,143 +1,159 @@ -// -// Copyright (c) 2014 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. -// - -#include "toolkit-orientation.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. + * + */ + +#include #include #include -#include +#include -namespace Dali -{ +using namespace Dali; -namespace +namespace Dali { -ToolkitOrientation* gToolkitOrientation(NULL); -} // unnamed namespace +class Adaptor; namespace Internal { - namespace Adaptor { +class Window; + + +struct RotationEvent +{ + int angle; ///< one of 0, 90, 180, 270 + int winResize; ///< true if the window should be resized + int width; ///< new window width + int height; ///< new window height +}; /** - * Stub for the Orientation + * The RotationObserver can be overridden in order to listen to rotation events. */ -class Orientation : public BaseObject +class RotationObserver { -public: // Creation & Destruction +public: + virtual void OnRotationPrepare( const RotationEvent& rotation ) = 0; + virtual void OnRotationRequest( ) = 0; - Orientation(); - Orientation(ToolkitOrientation *orientation); - ~Orientation(); +protected: + RotationObserver(){} + virtual ~RotationObserver(){} +}; -public: // Setters & Getters +class Orientation : public BaseObject, public RotationObserver +{ +public: + typedef Dali::Orientation::OrientationSignalType OrientationSignalType; - void SetDegrees( int degrees ) + static Orientation* New(Window* window) + { + Orientation* orientation = new Orientation(window); + return orientation; + } + Orientation(Window* window) { - mOrientation = degrees; } - int GetDegrees() const; - float GetRadians() const; - -public: // Signals - - Dali::Orientation::OrientationSignalV2& ChangedSignal(); - - void EmitChangedSignal() +protected: + virtual ~Orientation() + { + } +public: + void SetAdaptor(Dali::Adaptor& adaptor) + { + } + int GetDegrees() const + { + return 0; + } + float GetRadians() const { - mChangedSignal.Emit(Dali::Orientation(this)); + return 0.0f; } + OrientationSignalType& ChangedSignal() + { + return mChangedSignal; + } + virtual void OnRotationPrepare( const RotationEvent& rotation ) + { + }; + virtual void OnRotationRequest( ) + { + }; private: - - Dali::Orientation::OrientationSignalV2 mChangedSignal; - - ToolkitOrientation* mToolkitOrientation; - - int mOrientation; + Orientation(const Orientation&); + Orientation& operator=(Orientation&); + OrientationSignalType mChangedSignal; }; -Orientation::Orientation() -: mToolkitOrientation(NULL), - mOrientation(0) -{ -} +} // Adaptor namespace +} // Internal namespace -Orientation::Orientation(ToolkitOrientation *orientation) -: mToolkitOrientation(orientation), - mOrientation(0) +inline Internal::Adaptor::Orientation& GetImplementation (Dali::Orientation& orientation) { + DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty"); + BaseObject& handle = orientation.GetBaseObject(); + return static_cast(handle); } - -Orientation::~Orientation() +inline const Internal::Adaptor::Orientation& GetImplementation(const Dali::Orientation& orientation) { + DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty"); + const BaseObject& handle = orientation.GetBaseObject(); + return static_cast(handle); } -int Orientation::GetDegrees() const +Orientation::Orientation() { - mToolkitOrientation->mFunctionsCalled.GetDegrees = true; - return mOrientation; } - -float Orientation::GetRadians() const +Orientation::~Orientation() { - mToolkitOrientation->mFunctionsCalled.GetRadians = true; - return Math::PI * (float)mOrientation / 180.0f; } - -Dali::Orientation::OrientationSignalV2& Orientation::ChangedSignal() +Orientation::Orientation(const Orientation& handle) +: BaseHandle(handle) { - mToolkitOrientation->mFunctionsCalled.ChangedSignal = true; - return mChangedSignal; } -} // namespace Adaptor - -} // namespace Internal - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -ToolkitOrientation::ToolkitOrientation() -: mOrientationStub(new Internal::Adaptor::Orientation(this)), - mOrientation( mOrientationStub ) +Orientation& Orientation::operator=(const Orientation& rhs) { - gToolkitOrientation = this; + BaseHandle::operator=(rhs); + return *this; } -ToolkitOrientation::~ToolkitOrientation() +int Orientation::GetDegrees() const { - gToolkitOrientation = NULL; + return GetImplementation(*this).GetDegrees(); } -Orientation ToolkitOrientation::GetHandle() +float Orientation::GetRadians() const { - return mOrientation; + return GetImplementation(*this).GetRadians(); } -void ToolkitOrientation::SetDegrees( int degrees ) +Orientation::OrientationSignalType& Orientation::ChangedSignal() { - mOrientationStub->SetDegrees( degrees ); + return GetImplementation(*this).ChangedSignal(); } -void ToolkitOrientation::EmitChangedSignal() +Orientation::Orientation( Internal::Adaptor::Orientation* orientation ) +: BaseHandle(orientation) { - mOrientationStub->EmitChangedSignal(); } -} // namespace Dali +} // Dali