projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge changes I88ded17f,I3960a370 into devel/master
[platform/core/uifw/dali-toolkit.git]
/
automated-tests
/
src
/
dali-toolkit
/
dali-toolkit-test-utils
/
toolkit-orientation.cpp
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
e7e2568
..
b1b5660
100644
(file)
--- 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
@@
-15,130
+15,145
@@
*
*/
*
*/
-#include
"toolkit-orientation.h"
+#include
<dali/devel-api/adaptor-framework/orientation.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/signals/dali-signal
-v2
.h>
+#include <dali/public-api/signals/dali-signal.h>
-namespace Dali
-{
+using namespace Dali;
-namespace
+namespace
Dali
{
{
-ToolkitOrientation* gToolkitOrientation(NULL);
-} // unnamed namespace
+class Adaptor;
namespace Internal
{
namespace Internal
{
-
namespace Adaptor
{
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
+ {
+ return 0.0f;
+ }
+ OrientationSignalType& ChangedSignal()
{
{
-
mChangedSignal.Emit(Dali::Orientation(this))
;
+
return mChangedSignal
;
}
}
+ virtual void OnRotationPrepare( const RotationEvent& rotation )
+ {
+ };
+ virtual void OnRotationRequest( )
+ {
+ };
private:
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<Internal::Adaptor::Orientation&>(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<const Internal::Adaptor::Orientation&>(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