Fixed popup position
authorHeeJu Kang <mobum.kang@samsung.com>
Thu, 27 Dec 2012 05:49:46 +0000 (14:49 +0900)
committerHeeJu Kang <mobum.kang@samsung.com>
Thu, 27 Dec 2012 05:49:46 +0000 (14:49 +0900)
Change-Id: Ib4608dec9ee7c35304d885f6c7454dbddda58228
Signed-off-by: HeeJu Kang <mobum.kang@samsung.com>
src/FShell_LiveboxPopupView.cpp
src/FShell_LiveboxPopupView.h
src/FShell_LiveboxView.cpp

index 413e4f6..b0bcfe7 100644 (file)
@@ -39,6 +39,7 @@
 #include "FShell_LiveboxPopupViewEvent.h"
 #include "FShell_LiveboxView.h"
 #include "FShell_ILiveboxPopupViewEventListener.h"
+#include "FUi_ControlManager.h"
 #include "FUiAnim_VisualElement.h"
 
 using namespace std;
@@ -62,8 +63,6 @@ _LiveboxPopupView::_LiveboxPopupView(_LiveboxView& liveBoxView)
        , __pLiveboxPopupViewEvent(_LiveboxPopupViewEvent::CreateInstanceN(*this))
        , __firstUpdated(false)
 {
-       int ret = livebox_create_pd(__pLiveboxView->__pLivebox, OnLiveboxPopupCreated, this);
-       SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
 }
 
 _LiveboxPopupView::~_LiveboxPopupView(void)
@@ -95,9 +94,34 @@ _LiveboxPopupView::CreateLiveboxPopupN(_LiveboxView& liveBoxView)
 }
 
 result
-_LiveboxPopupView::Initialize(void)
+_LiveboxPopupView::Initialize(const Rectangle& bounds)
 {
-       return E_SUCCESS;
+       Dimension screenSize = _ControlManager::GetInstance()->GetScreenSize();
+
+       Rectangle viewAbsoluteBounds = __pLiveboxView->GetAbsoluteBounds();
+       double x = (static_cast<double>(viewAbsoluteBounds.x) + static_cast<double>((viewAbsoluteBounds.width) / 2)) / static_cast<double>(screenSize.width);
+       double y = 0.0f;
+
+       int lower = 0;
+       int upper = 0;
+       GetRemainingSpace(lower, upper);
+
+       if (lower > upper)
+       {
+               y = 1.0f;
+       }
+
+       SysLog(NID_UI_CTRL, "[%d %d %d %d]", bounds.x, bounds.y, bounds.width, bounds.height);
+       SysLog(NID_UI_CTRL, "[%d %d %d %d]", viewAbsoluteBounds.x, viewAbsoluteBounds.y, viewAbsoluteBounds.width, viewAbsoluteBounds.height);
+       SysLog(NID_UI_CTRL, "[%f %f]", x, y);
+
+       int ret = livebox_create_pd_with_position(__pLiveboxView->__pLivebox, x, y, OnLiveboxPopupCreated, this);
+       SysTryReturn(NID_UI_CTRL, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+
+       result r = SetBounds(bounds);
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
 }
 
 result
@@ -127,34 +151,45 @@ _LiveboxPopupView::GetBitmap(void) const
 void
 _LiveboxPopupView::SetPopupBounds(const Dimension& size)
 {
-       const _Control* pParent = __pLiveboxView->GetParent();
-       result r = GetLastResult();
-       SysTryReturnVoidResult(NID_UI_CTRL, pParent, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       Rectangle bounds = __pLiveboxView->GetBounds();
-       Rectangle parentClientBounds = pParent->GetClientBounds();
-       Rectangle absoluteBounds = __pLiveboxView->GetAbsoluteBounds();
+       Rectangle absoluteViewBounds = __pLiveboxView->GetAbsoluteBounds();
        Rectangle popupBounds(0, 0, size.width, size.height);
 
-       int remainingSpace = parentClientBounds.height - bounds.y - bounds.height;
+       int lower = 0;
+       int upper = 0;
 
-       if (size.height > remainingSpace)
+       GetRemainingSpace(lower, upper);
+
+       if (lower > upper)
        {
-               popupBounds.y = absoluteBounds.y - size.height;
+               popupBounds.y = absoluteViewBounds.y - size.height;
        }
        else
        {
-               popupBounds.y = absoluteBounds.y + absoluteBounds.height;
+               popupBounds.y = absoluteViewBounds.y + absoluteViewBounds.height;
        }
 
-       SysLog(NID_UI_CTRL, "[%d %d %d %d]", parentClientBounds.height, remainingSpace, popupBounds.y, size.height);
-
        SetBounds(popupBounds);
 
        SysLog(NID_UI_CTRL, "[%d %d %d %d]", popupBounds.x, popupBounds.y, popupBounds.width, popupBounds.height);
 }
 
 void
+_LiveboxPopupView::GetRemainingSpace(int& lower, int& upper) const
+{
+       const _Control* pParent = __pLiveboxView->GetParent();
+       result r = GetLastResult();
+       SysTryReturnVoidResult(NID_UI_CTRL, pParent, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       Rectangle parentClientBounds = pParent->GetClientBounds();
+       Rectangle viewBounds = __pLiveboxView->GetBounds();
+
+       lower = viewBounds.y;
+       upper = parentClientBounds.height - viewBounds.y - viewBounds.height;
+
+       SysLog(NID_UI_CTRL, "[%d %d]", lower, upper);
+}
+
+void
 _LiveboxPopupView::FireLiveboxPopupEvent(bool open)
 {
        if (__pLiveboxPopupViewEvent)
index e51a9e5..ebff7d4 100644 (file)
@@ -66,7 +66,7 @@ public:
        static _LiveboxPopupView* CreateLiveboxPopupN(_LiveboxView& liveBoxView);
        virtual ~_LiveboxPopupView(void);
 
-       result Initialize(void);
+       result Initialize(const Tizen::Graphics::Rectangle& bounds);
        result AddLiveboxPopupEventListener(const _ILiveboxPopupViewEventListener& listener);
        result RemoveLiveboxPopupEventListener(const _ILiveboxPopupViewEventListener& listener);
        Tizen::Graphics::Bitmap* GetBitmap(void) const;
@@ -79,6 +79,7 @@ private:
        _LiveboxPopupView& operator =(const _LiveboxPopupView&  rhs);
 
        void SetPopupBounds(const Tizen::Graphics::Dimension& size);
+       void GetRemainingSpace(int& lower, int& upper) const;
        void FireLiveboxPopupEvent(bool open);
        void GetTouchPostion(const Tizen::Graphics::Point& point, double& x, double& y);
        void PlayAnimation(bool open);
index 5ec2f49..1b9e9fc 100644 (file)
@@ -174,21 +174,6 @@ _LiveboxView::OpenLiveboxPopup(void)
 {
        result r = E_SUCCESS;
 
-       if (!__pLiveboxPopupView)
-       {
-               unique_ptr<_LiveboxPopupView> pLiveboxPopupView(_LiveboxPopupView::CreateLiveboxPopupN(*this));
-               r = GetLastResult();
-               SysTryReturn(NID_UI_CTRL, pLiveboxPopupView, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               r = pLiveboxPopupView->Initialize();
-               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               r = pLiveboxPopupView->AddLiveboxPopupEventListener(*this);
-               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               __pLiveboxPopupView = move(pLiveboxPopupView);
-       }
-
        const _Control* pParent = GetParent();
        r = GetLastResult();
        SysTryReturn(NID_UI_CTRL, pParent, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -211,8 +196,20 @@ _LiveboxView::OpenLiveboxPopup(void)
 
        SysLog(NID_UI_CTRL, "[%d %d %d %d]", parentClientBounds.height, remainingSpace, popupBounds.y, size.height);
 
-       r = __pLiveboxPopupView->SetBounds(popupBounds);
-       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       if (!__pLiveboxPopupView)
+       {
+               unique_ptr<_LiveboxPopupView> pLiveboxPopupView(_LiveboxPopupView::CreateLiveboxPopupN(*this));
+               r = GetLastResult();
+               SysTryReturn(NID_UI_CTRL, pLiveboxPopupView, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = pLiveboxPopupView->Initialize(popupBounds);
+               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = pLiveboxPopupView->AddLiveboxPopupEventListener(*this);
+               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pLiveboxPopupView = move(pLiveboxPopupView);
+       }
 
        __pLiveboxPopupView->SetOwner(this);