#include "FShell_LiveboxPopupViewEvent.h"
#include "FShell_LiveboxView.h"
#include "FShell_ILiveboxPopupViewEventListener.h"
+#include "FUi_ControlManager.h"
#include "FUiAnim_VisualElement.h"
using namespace std;
, __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)
}
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
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)
{
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));
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);