Fixed popup position
authorHeeJu Kang <mobum.kang@samsung.com>
Tue, 26 Feb 2013 06:33:00 +0000 (15:33 +0900)
committerHeeJu Kang <mobum.kang@samsung.com>
Tue, 26 Feb 2013 06:33:00 +0000 (15:33 +0900)
Change-Id: Ibac1f49e4e87e3dd11fa0dd1c04a4b98a6693d82
Signed-off-by: HeeJu Kang <mobum.kang@samsung.com>
src/FShell_LiveboxPopupView.cpp
src/FShell_LiveboxPopupView.h
src/FShell_LiveboxView.cpp
src/FShell_LiveboxView.h

index 9fa0109..4aa3f7d 100644 (file)
@@ -115,7 +115,7 @@ _LiveboxPopupView::Initialize(const Rectangle& bounds)
 
        int lower = 0;
        int upper = 0;
-       GetRemainingSpace(lower, upper);
+       __pLiveboxView->GetRemainingSpace(lower, upper);
 
        if (lower > upper)
        {
@@ -168,15 +168,16 @@ _LiveboxPopupView::SetPopupBounds(const Dimension& size)
        int lower = 0;
        int upper = 0;
 
-       GetRemainingSpace(lower, upper);
+       Dimension anchorSize = __pLiveboxView->GetAnchorSize();
+       __pLiveboxView->GetRemainingSpace(lower, upper);
 
        if (lower > upper)
        {
-               popupBounds.y = absoluteViewBounds.y - size.height;
+               popupBounds.y = absoluteViewBounds.y - size.height + anchorSize.height;
        }
        else
        {
-               popupBounds.y = absoluteViewBounds.y + absoluteViewBounds.height;
+               popupBounds.y = absoluteViewBounds.y + absoluteViewBounds.height - anchorSize.height;
        }
 
        SetBounds(popupBounds);
@@ -185,22 +186,6 @@ _LiveboxPopupView::SetPopupBounds(const Dimension& size)
 }
 
 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 931b207..6ccaba2 100644 (file)
@@ -82,7 +82,6 @@ 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) const;
        void PlayAnimation(bool open);
index 40389f0..2c0c84b 100644 (file)
@@ -138,6 +138,19 @@ _LiveboxView::Initialize(const AppId& appId, const Tizen::Base::String& provider
        r = GetLastResult();
        SysTryReturn(NID_UI_CTRL, __pLivebox, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       Bitmap* pResourceBitmap = null;
+
+       r = GET_BITMAP_CONFIG_N(LIVEBOX::POPUP_BG_ARROW_UP, BITMAP_PIXEL_FORMAT_ARGB8888, pResourceBitmap);
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<Bitmap> pArrowUpBitmap(pResourceBitmap);
+
+       r = GET_BITMAP_CONFIG_N(LIVEBOX::POPUP_BG_ARROW_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888, pResourceBitmap);
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pArrowUpBitmap = move(pArrowUpBitmap);
+       __pArrowDownBitmap.reset(pResourceBitmap);
+
        return r;
 }
 
@@ -177,6 +190,27 @@ _LiveboxView::IsUpdated(void) const
        return __updated;
 }
 
+Dimension
+_LiveboxView::GetAnchorSize(void) const
+{
+       Bitmap* pArrowBitmap = null;
+       int lower = 0;
+       int upper = 0;
+
+       GetRemainingSpace(lower, upper);
+
+       if (lower > upper)
+       {
+               pArrowBitmap = __pArrowDownBitmap.get();
+       }
+       else
+       {
+               pArrowBitmap = __pArrowUpBitmap.get();
+       }
+
+       return Dimension(pArrowBitmap->GetWidth(), pArrowBitmap->GetHeight());
+}
+
 livebox*
 _LiveboxView::GetNativeLivebox(void) const
 {
@@ -197,27 +231,22 @@ _LiveboxView::OpenLiveboxPopup(void)
        Rectangle bounds = GetBounds();
        Rectangle absoluteBounds = GetAbsoluteBounds();
 
-       int leftMargin = 0;
-       int rightMargin = 0;
-       int topMargin = 0;
-       int bottomMargin = 0;
-       _ControlOrientation orientation = GetOrientation();
+       int lower = 0;
+       int upper = 0;
 
-       GET_SHAPE_CONFIG(LIVEBOX::POPUP_TOP_MARGIN, orientation, topMargin);
-       GET_SHAPE_CONFIG(LIVEBOX::POPUP_BOTTOM_MARGIN, orientation, bottomMargin);
+       Dimension anchorSize = GetAnchorSize();
+       GetRemainingSpace(lower, upper);
 
-       Rectangle parentClientBounds = pParent->GetClientBounds();
-       int remainingSpace = parentClientBounds.height - bounds.y - bounds.height;
-       if (size.height > remainingSpace)
+       if (lower > upper)
        {
-               popupBounds.y = absoluteBounds.y - size.height + bottomMargin;
+               popupBounds.y = absoluteBounds.y - size.height + anchorSize.height;
        }
        else
        {
-               popupBounds.y = absoluteBounds.y + absoluteBounds.height - topMargin;
+               popupBounds.y = absoluteBounds.y + absoluteBounds.height - anchorSize.height;
        }
 
-       SysLog(NID_UI_CTRL, "[%d %d %d %d]", parentClientBounds.height, remainingSpace, popupBounds.y, size.height);
+       SysLog(NID_UI_CTRL, "[%d %d]", popupBounds.y, size.height);
 
        if (!__pLiveboxPopupView)
        {
@@ -290,6 +319,22 @@ _LiveboxView::PlayFlickAnimation(void)
        pVisualElement->AddAnimation(L"Scale", animation);
 }
 
+void
+_LiveboxView::GetRemainingSpace(int& lower, int& upper) const
+{
+       const _Control* pParent = GetParent();
+       result r = GetLastResult();
+       SysTryReturnVoidResult(NID_UI_CTRL, pParent, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       Rectangle parentClientBounds = pParent->GetClientBounds();
+       Rectangle viewBounds = GetBounds();
+
+       lower = viewBounds.y;
+       upper = parentClientBounds.height - viewBounds.y - viewBounds.height;
+
+       SysLog(NID_UI_CTRL, "[%d %d]", lower, upper);
+}
+
 result
 _LiveboxView::OnAttachedToMainTree(void)
 {
index 31682cb..0ba02e7 100644 (file)
@@ -77,6 +77,7 @@ public:
        Tizen::Graphics::Bitmap* GetAppIconBitmap(void) const;
        Tizen::Graphics::Bitmap* GetBitmap(void) const;
        bool IsUpdated(void) const;
+       Tizen::Graphics::Dimension GetAnchorSize(void) const;
 
 protected:
        _LiveboxView(void);
@@ -90,6 +91,7 @@ private:
        void GetTouchPostion(const Tizen::Graphics::Point& point, double& x, double& y) const;
        void PlayClickAnimation(void);
        void PlayFlickAnimation(void);
+       void GetRemainingSpace(int& lower, int& upper) const;
 
        virtual result OnAttachedToMainTree(void);
        virtual result OnDetachingFromMainTree(void);
@@ -112,6 +114,8 @@ private:
        std::unique_ptr<_LiveboxViewPresenter> __pLiveboxViewPresenter;
        std::unique_ptr<Tizen::Graphics::Bitmap> __pBitmap;
        std::unique_ptr<Tizen::Graphics::Bitmap> __pAppIconBitmap;
+       std::unique_ptr<Tizen::Graphics::Bitmap> __pArrowUpBitmap;
+       std::unique_ptr<Tizen::Graphics::Bitmap> __pArrowDownBitmap;
        struct livebox* __pLivebox;
        friend class _LiveboxViewManager;
        class _LiveboxViewManager* __pLiveboxViewManager;