*/
#include <unique_ptr.h>
+#include <app.h>
#include <FBaseSysLog.h>
#include <FBaseColArrayList.h>
#include "FUi_OrientationAgent.h"
, __pPublicEvent(null)
, __mode(ORIENTATION_PORTRAIT)
, __status(ORIENTATION_STATUS_PORTRAIT)
+ , __tempStatus(ORIENTATION_STATUS_PORTRAIT)
, __firePublicEvent(false)
, __statusChanged(false)
, __updateStatus(true)
+#if defined(WINDOW_BASE_ROTATE)
+ , __draw(false)
+#endif
{
_PublicOrientationEvent* pPublicEvent = _PublicOrientationEvent::CreateInstanceN(publicControl);
void
_OrientationAgent::Update(bool draw)
{
+#if defined(WINDOW_BASE_ROTATE)
+ // Update orientation status(Not Auto-mode)
+ // Request rotation to window manager -> async -> Update VEs
+ // Window(not rotation) -> sync -> UpdateVEs
+
+ _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
+ SysAssert(pImplManager);
+
+ _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
+ if (!pImpl)
+ {
+ return;
+ }
+
+ _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+ if (!pEcoreEvas)
+ {
+ return;
+ }
+
+ bool autoMode = false;
+
+ if ((__mode == ORIENTATION_AUTOMATIC) || (__mode == ORIENTATION_AUTOMATIC_FOUR_DIRECTION))
+ {
+ autoMode = true;
+ }
+
+// if (autoMode == false)
+// {
+ // [Sync]
+ // Update orientation status
+ // Update VEs
+ // Fire orientation event
+ // Rotate screen
+ // Set preffered rotation
+
+ OrientationStatus status = pImplManager->GetOrientationStatus(__mode);
+ SysLog(NID_UI, "[Window Manager Rotation] Update : __mode(%d) -> status(%d)", __mode, status);
+
+ if (__updateStatus == true)
+ {
+ __statusChanged = false;
+ if (__status != status)
+ {
+ __statusChanged = true;
+ __updateStatus = false;
+ }
+ }
+
+ __status = status;
+
+ pEcoreEvas->AllowSetWindowBounds(false);
+ FireEvent(status);
+ pEcoreEvas->AllowSetWindowBounds(true);
+
+ // For the form to be made by Ui-Builder
+ if ((draw == true) && (__statusChanged == true))
+ {
+ _ControlOrientation coreOrientation =
+ (status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ?
+ _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE;
+
+ Rectangle temp;
+ bool exist = pImpl->GetBuilderBounds(coreOrientation, temp);
+ if (exist)
+ {
+ pImpl->Invalidate(true);
+ }
+ }
+
+ // Despite not changing status, it needs to rotate screen.
+ _ControlImpl* pControlImpl = _ControlImpl::GetInstance(__publicControl);
+ pImplManager->RotateScreen(pControlImpl, status);
+
+ _Window* pRootWindow = pImpl->GetCore().GetRootWindow();
+ if (pRootWindow)
+ {
+ SetRotation(*pRootWindow, __mode);
+ }
+// }
+// else
+// {
+ // [Async]
+ // Set preffered rotation
+
+// _Window* pRootWindow = pImpl->GetCore().GetRootWindow();
+// if (pRootWindow)
+// {
+// SetRotation(*pRootWindow, __mode);
+// }
+
+ __draw = draw;
+// }
+#else
_ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
SysAssert(pImplManager);
return;
}
-#if defined(ROTATION_SYNC)
_EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
if (!pEcoreEvas)
{
{
if ((__mode == ORIENTATION_AUTOMATIC) || (__mode == ORIENTATION_AUTOMATIC_FOUR_DIRECTION))
{
- SysLog(NID_UI, "ROTATE SYNC: Form(0x%x) <- Parent(0x%x), X(0x%x) ON", pForm, pWindow, pWindow->GetNativeHandle());
pEcoreEvas->SetWindowOrientationEnabled(*pWindow, true);
pWindow->SetOrientationEnabled(true);
}
else
{
- SysLog(NID_UI, "ROTATE SYNC: Form(0x%x) <- Parent(0x%x), X(0x%x) OFF", pForm, pWindow, pWindow->GetNativeHandle());
pEcoreEvas->SetWindowOrientationEnabled(*pWindow, false);
pWindow->SetOrientationEnabled(false);
}
{
if ((__mode == ORIENTATION_AUTOMATIC) || (__mode == ORIENTATION_AUTOMATIC_FOUR_DIRECTION))
{
- SysLog(NID_UI, "ROTATE SYNC: Frame(0x%x) <- X(0x%x) ON", pFrame, pFrame->GetNativeHandle());
pEcoreEvas->SetWindowOrientationEnabled(*pFrame, true);
pFrame->SetOrientationEnabled(true);
}
else
{
- SysLog(NID_UI, "ROTATE SYNC: Frame(0x%x) <- X(0x%x) OFF", pFrame, pFrame->GetNativeHandle());
pEcoreEvas->SetWindowOrientationEnabled(*pFrame, false);
pFrame->SetOrientationEnabled(false);
}
}
}
}
-#endif
OrientationStatus status = pImplManager->GetOrientationStatus(__mode);
__status = status;
-#if !defined(ROTATION_SYNC)
+ pEcoreEvas->AllowSetWindowBounds(false);
+ FireEvent(status);
+ pEcoreEvas->AllowSetWindowBounds(true);
+
+ // For the form to be made by Ui-Builder
+ if ((draw == true) && (__statusChanged == true))
+ {
+ _ControlOrientation coreOrientation =
+ (status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ?
+ _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE;
+
+ Rectangle temp;
+ bool exist = pImpl->GetBuilderBounds(coreOrientation, temp);
+ if (exist)
+ {
+ pImpl->Invalidate(true);
+ }
+ }
+
+ // Despite not changing status, it needs to rotate screen.
+ _ControlImpl* pControlImpl = _ControlImpl::GetInstance(__publicControl);
+ pImplManager->RotateScreen(pControlImpl, status);
+#endif
+}
+
+#if defined(WINDOW_BASE_ROTATE)
+void
+_OrientationAgent::UpdateOrientation(void)
+{
+ // Get window rotation
+ // Update VEs
+ // Fire orientation event
+ // Update window bounds
+ // Invalidate
+
_EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
if (!pEcoreEvas)
{
return;
}
-#endif
+
+ _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
+ if (!pImpl)
+ {
+ return;
+ }
+
+ _Window* pRootWindow = pImpl->GetCore().GetRootWindow();
+ if (!pRootWindow)
+ {
+ return;
+ }
+
+ int rotation = pEcoreEvas->GetWindowRotation(*pRootWindow);
+ OrientationStatus status = ORIENTATION_STATUS_NONE;
+ switch (rotation)
+ {
+ case 0:
+ status = ORIENTATION_STATUS_PORTRAIT;
+ break;
+ case 270:
+ status = ORIENTATION_STATUS_LANDSCAPE;
+ break;
+ case 180:
+ status = ORIENTATION_STATUS_PORTRAIT_REVERSE;
+ break;
+ case 90:
+ status = ORIENTATION_STATUS_LANDSCAPE_REVERSE;
+ break;
+ default:
+ break;
+ }
+
+ if (__updateStatus == true)
+ {
+ __statusChanged = false;
+ if (__status != status)
+ {
+ __statusChanged = true;
+ __updateStatus = false;
+ }
+ }
+
+ __status = status;
pEcoreEvas->AllowSetWindowBounds(false);
FireEvent(status);
pEcoreEvas->AllowSetWindowBounds(true);
// For the form to be made by Ui-Builder
- if ((draw == true) && (__statusChanged == true))
+ if ((__draw == true) && (__statusChanged == true))
{
_ControlOrientation coreOrientation =
(status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ?
}
}
- // Despite not changing status, it needs to rotate screen.
- _ControlImpl* pControlImpl = _ControlImpl::GetInstance(__publicControl);
- pImplManager->RotateScreen(pControlImpl, status);
+ pEcoreEvas->RotateWindow(*pRootWindow, rotation);
+
+ pImpl->Invalidate(true);
+
+ Rectangle bounds = pRootWindow->GetBounds();
+ SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, rot = %d, %d, %d, %d, %d] Update Orientation.", pRootWindow->GetNativeHandle(), rotation, bounds.x, bounds.y, bounds.width, bounds.height);
}
+#endif
void
_OrientationAgent::RequestOrientationEvent(void)
pImplManager->SetOrientationStatus(status);
pImpl->GetCore().ChangeLayout(coreOrientation);
+#if !defined(WINDOW_BASE_ROTATE)
// Ownee
int owneeCount = pImpl->GetCore().GetOwneeCount();
for (int i = 0; i < owneeCount; i++)
pOwnee->ChangeLayout(coreOrientation);
}
}
+#endif
// Public
if (__firePublicEvent && __statusChanged)
}
}
+#if defined(WINDOW_BASE_ROTATE)
+void
+_OrientationAgent::SetRotation(const _Window& window, Orientation orientation)
+{
+ _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+ if (!pEcoreEvas)
+ {
+ return;
+ }
+
+ switch (orientation)
+ {
+ case ORIENTATION_PORTRAIT:
+ pEcoreEvas->SetWindowPreferredRotation(window, 0);
+ break;
+ case ORIENTATION_LANDSCAPE:
+ pEcoreEvas->SetWindowPreferredRotation(window, 270);
+ break;
+ case ORIENTATION_PORTRAIT_REVERSE:
+ pEcoreEvas->SetWindowPreferredRotation(window, 180);
+ break;
+ case ORIENTATION_LANDSCAPE_REVERSE:
+ pEcoreEvas->SetWindowPreferredRotation(window, 90);
+ break;
+ case ORIENTATION_AUTOMATIC:
+ {
+ pEcoreEvas->SetWindowPreferredRotation(window, -1);
+ int autoRotation[3] = {0, 90, 270};
+ pEcoreEvas->SetWindowAvailabledRotation(window, autoRotation, 3);
+ }
+
+ break;
+ case ORIENTATION_AUTOMATIC_FOUR_DIRECTION:
+ {
+ pEcoreEvas->SetWindowPreferredRotation(window, -1);
+ int autoFourRotation[4] = {0, 90, 180, 270};
+ pEcoreEvas->SetWindowAvailabledRotation(window, autoFourRotation, 4);
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ // [Ownee]
+ // 1. ActivateWindow
+ // 2. SetOwner
+ // 3. SetRotation
+
+ _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
+ if (!pImpl)
+ {
+ return;
+ }
+
+ int owneeCount = pImpl->GetCore().GetOwneeCount();
+ for (int i = 0; i < owneeCount; i++)
+ {
+ _Window* pOwnee = pImpl->GetCore().GetOwnee(i);
+ if (pOwnee)
+ {
+ pEcoreEvas->SetOwner(*pOwnee, pImpl->GetCore());
+ }
+ }
+
+ _Control* pParent = pImpl->GetCore().GetParent();
+ if (pParent)
+ {
+ int owneeCount = pParent->GetOwneeCount();
+ for (int i = 0; i < owneeCount; i++)
+ {
+ _Window* pOwnee = pParent->GetOwnee(i);
+ if (pOwnee)
+ {
+ pEcoreEvas->SetOwner(*pOwnee, *pParent);
+ }
+ }
+ }
+}
+#endif
+
}} // Tizen::Ui