From 3508a45060015829a7f2d316de10746334d6fbbf Mon Sep 17 00:00:00 2001 From: HeeJu Kang Date: Wed, 26 Dec 2012 16:20:15 +0900 Subject: [PATCH] Fixed popup bounds Change-Id: Ic1052b4e4457081e8d55dd0565cace7326952023 Signed-off-by: HeeJu Kang --- src/FShell_LiveboxPopupView.cpp | 35 ++++++++++++++++++++++++++++++++++- src/FShell_LiveboxPopupView.h | 1 + src/FShell_LiveboxView.cpp | 30 +++++++++++++++++++++++------- src/FShell_LiveboxViewManager.cpp | 15 ++++++--------- src/FShell_LiveboxViewPresenter.cpp | 2 +- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/FShell_LiveboxPopupView.cpp b/src/FShell_LiveboxPopupView.cpp index f15bb80..413e4f6 100644 --- a/src/FShell_LiveboxPopupView.cpp +++ b/src/FShell_LiveboxPopupView.cpp @@ -125,6 +125,36 @@ _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 popupBounds(0, 0, size.width, size.height); + + int remainingSpace = parentClientBounds.height - bounds.y - bounds.height; + + if (size.height > remainingSpace) + { + popupBounds.y = absoluteBounds.y - size.height; + } + else + { + popupBounds.y = absoluteBounds.y + absoluteBounds.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::FireLiveboxPopupEvent(bool open) { if (__pLiveboxPopupViewEvent) @@ -306,7 +336,10 @@ _LiveboxPopupView::OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const SysLog(NID_UI_CTRL, "(%d %d) %lld", size.width, size.height, ticks); - SetSize(size); + if (size != GetSize()) + { + SetPopupBounds(size); + } __pBitmap.reset(const_cast(&bitmap)); diff --git a/src/FShell_LiveboxPopupView.h b/src/FShell_LiveboxPopupView.h index 75f038c..e51a9e5 100644 --- a/src/FShell_LiveboxPopupView.h +++ b/src/FShell_LiveboxPopupView.h @@ -78,6 +78,7 @@ private: _LiveboxPopupView(const _LiveboxPopupView& rhs); _LiveboxPopupView& operator =(const _LiveboxPopupView& rhs); + void SetPopupBounds(const Tizen::Graphics::Dimension& size); void FireLiveboxPopupEvent(bool open); void GetTouchPostion(const Tizen::Graphics::Point& point, double& x, double& y); void PlayAnimation(bool open); diff --git a/src/FShell_LiveboxView.cpp b/src/FShell_LiveboxView.cpp index 5069dfb..d546f00 100644 --- a/src/FShell_LiveboxView.cpp +++ b/src/FShell_LiveboxView.cpp @@ -172,9 +172,6 @@ result _LiveboxView::OpenLiveboxPopup(void) { result r = E_SUCCESS; - Dimension size = __pLiveboxViewManager->GetLiveboxPopupSize(__pLivebox); - Rectangle trayBounds(0, 0, size.width, size.height); - Rectangle absoluteBounds = GetAbsoluteBounds(); if (!__pLiveboxPopupView) { @@ -191,9 +188,29 @@ _LiveboxView::OpenLiveboxPopup(void) __pLiveboxPopupView = move(pLiveboxPopupView); } - trayBounds.y = absoluteBounds.y + absoluteBounds.height; + const _Control* pParent = GetParent(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pParent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Dimension size = __pLiveboxViewManager->GetLiveboxPopupSize(__pLivebox); + Rectangle popupBounds(0, 0, size.width, size.height); + Rectangle bounds = GetBounds(); + Rectangle absoluteBounds = GetAbsoluteBounds(); - r = __pLiveboxPopupView->SetBounds(trayBounds); + Rectangle parentClientBounds = pParent->GetClientBounds(); + int remainingSpace = parentClientBounds.height - bounds.y - bounds.height; + if (size.height > remainingSpace) + { + popupBounds.y = absoluteBounds.y - size.height; + } + else + { + popupBounds.y = absoluteBounds.y + absoluteBounds.height; + } + + 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)); __pLiveboxPopupView->SetOwner(this); @@ -271,11 +288,10 @@ _LiveboxView::OnDetachingFromMainTree(void) bool _LiveboxView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) { - PlayFlickAnimation(); - _FlickDirection direction = gesture.GetDirection(); if (direction == _FLICK_DIRECTION_DOWN) { + PlayFlickAnimation(); OpenLiveboxPopup(); } diff --git a/src/FShell_LiveboxViewManager.cpp b/src/FShell_LiveboxViewManager.cpp index 190beb0..3185bda 100644 --- a/src/FShell_LiveboxViewManager.cpp +++ b/src/FShell_LiveboxViewManager.cpp @@ -101,10 +101,7 @@ _LiveboxViewManager::AddLiveboxView(_LiveboxView* pLiveboxView, const String& us livebox* pLivebox = livebox_add_with_size(pAppId.get(), pContent.get(), pCluster, pCategory, GetLiveboxSizeType(pLiveboxView->GetSize()), 1, OnLiveboxAdded, this); SysTryReturn(NID_UI_CTRL, pLivebox, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); -/* - livebox* pLivebox = livebox_add(pAppId.get(), pContent.get(), pCluster, pCategory, 1, OnLiveboxAdded, this); - SysTryReturn(NID_UI_CTRL, pLivebox, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); -*/ + __pViewMap->Add(pLivebox, pLiveboxView); return pLivebox; @@ -225,27 +222,27 @@ _LiveboxViewManager::GetLiveboxSizeType(const Tizen::Graphics::Dimension& size) MediaPixelFormat _LiveboxViewManager::GetPixelFormat(BitmapPixelFormat format) const { - MediaPixelFormat out = MEDIA_PIXEL_FORMAT_NONE; + MediaPixelFormat mediaPixelFormat = MEDIA_PIXEL_FORMAT_NONE; switch(format) { case BITMAP_PIXEL_FORMAT_RGB565: - out = MEDIA_PIXEL_FORMAT_RGB565LE; + mediaPixelFormat = MEDIA_PIXEL_FORMAT_RGB565LE; break; case BITMAP_PIXEL_FORMAT_ARGB8888: - out = MEDIA_PIXEL_FORMAT_BGRA8888; + mediaPixelFormat = MEDIA_PIXEL_FORMAT_BGRA8888; break; case BITMAP_PIXEL_FORMAT_R8G8B8A8: - out = MEDIA_PIXEL_FORMAT_RGBA8888; + mediaPixelFormat = MEDIA_PIXEL_FORMAT_RGBA8888; break; default: break; } - return out; + return mediaPixelFormat; } Bitmap* diff --git a/src/FShell_LiveboxViewPresenter.cpp b/src/FShell_LiveboxViewPresenter.cpp index b062a19..98f9e7d 100644 --- a/src/FShell_LiveboxViewPresenter.cpp +++ b/src/FShell_LiveboxViewPresenter.cpp @@ -112,7 +112,7 @@ _LiveboxViewPresenter::Draw(void) pBitmap = __pLiveboxView->GetAppIconBitmap(); } - SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_SYSTEM, "Bitmap is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_SYSTEM, "Bitmap is invalid (%d).", updated); Dimension liveboxSize = __pLiveboxView->GetSize(); int bitmapWidth = pBitmap->GetWidth(); -- 2.7.4