Add unreleased controls logs for debugging
[platform/framework/native/uifw.git] / src / ui / FUi_Control.cpp
index 0830a1f..24a9a53 100644 (file)
@@ -693,6 +693,11 @@ _Control::OnMouseWheeled(const _Control& source, const _MouseInfo& mouseinfo)
 bool
 _Control::OnFocusGained(const _Control& source)
 {
+       bool isfocusMode = _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
+       if (isfocusMode)
+       {
+               DrawFocus();
+       }
        return false;
 }
 
@@ -936,7 +941,7 @@ void
 _Control::OnAncestorVisibleStateChanged(const _Control& control)
 {
        _TouchManager* pTouchManager = _TouchManager::GetInstance();
-       if (pTouchManager && IsVisible() == false)
+       if (pTouchManager && IsVisible() == false && IsAttachedToMainTree() == true)
        {
                if(pTouchManager->GetTouchControlSource() == this)
                {
@@ -1052,6 +1057,25 @@ _Control::Accept(Visitor& visitor) const
 }
 
 void
+_Control::InvalidateHierarchyRootWindow(void)
+{
+       struct _Visitor
+               : public Visitor
+       {
+               virtual VisitType Visit(_Control& control)
+               {
+                       control.__needRecalcRootWindow = true;
+                       control.__pRootWindow = null;
+
+                       return VISIT_DOWNWARD;
+               }
+       };
+
+       _Visitor visitor;
+       Accept(visitor);
+}
+
+void
 _Control::Draw(bool recursive)
 {
        ClearLastResult();
@@ -1593,6 +1617,11 @@ _Control::CallOnDetachingFromMainTree(_Control& control)
                {
                        pTop->SetFocusControl(&control, false);
                }
+               _Control* pFocusTraversalControl = pTop->GetFocusTraversalControl(this);
+               if ((&control) == pFocusTraversalControl)
+               {
+                       pTop->SetFocusTraversalControl(&control, false);
+               }
        }
 
        if (!__isPostOrderTraversal)
@@ -1772,6 +1801,7 @@ result
 _Control::EndAttaching(_Control& child)
 {
        child.SetParent(this);
+       child.InvalidateHierarchyRootWindow();
 
        FloatRectangle floatBounds(child.GetBoundsF().x, child.GetBoundsF().y, child.GetBoundsF().width, child.GetBoundsF().height);
 
@@ -1880,16 +1910,6 @@ _Control::IsFocusNavigateEnabled(void) const
        return __isNavigatable;
 }
 
-void
-_Control::SetFocusModeStateEnabled(bool enable)
-{
-       __isFocusMode = enable;
-       if (enable == false)
-       {
-               OnFocusModeStateChanged();
-       }
-}
-
 bool
 _Control::IsFocusModeStateEnabled(void) const
 {
@@ -2058,8 +2078,9 @@ _Control::DetachChild(_Control& child)
        ClearLastResult();
 
        SysAssert(GetLastResult() == E_SUCCESS);
-
        UpdateFocusList();
+       child.InvalidateHierarchyRootWindow();
+
        return E_SUCCESS;
 }
 
@@ -2523,6 +2544,11 @@ _Control::GetRootWindow(void) const
 {
        ClearLastResult();
 
+       if (!__needRecalcRootWindow && __pRootWindow != this)
+       {
+               return __pRootWindow;
+       }
+
        struct _Visitor
                : public Visitor
        {
@@ -2547,6 +2573,10 @@ _Control::GetRootWindow(void) const
        Accept(visitor);
 
        SysAssert(GetLastResult() == E_SUCCESS);
+
+       const_cast<_Control*>(this)->__pRootWindow = visitor.pRoot;
+       const_cast<_Control*>(this)->__needRecalcRootWindow = false;
+
        return visitor.pRoot;
 }
 
@@ -3821,17 +3851,6 @@ _Control::~_Control(void)
                __pFont = null;
        }
 
-       _Window* pWindow = GetRootWindow();
-
-       if (pWindow)
-       {
-               _Control* pFocusTraversalControl = pWindow->GetFocusTraversalControl(this);
-               if (pFocusTraversalControl == this)
-               {
-                       pWindow->SetFocusTraversalControl(null);
-               }
-       }
-
 //     Dangerous: it clears last result and log in catch block.
 //     ClearLastResult();
 }
@@ -3890,7 +3909,9 @@ _Control::DisposeControl(void)
 // E_OUT_OF_MEMORY
 // E_SYSTEM
 _Control::_Control(void)
-       : __name(L"")
+       : __needRecalcRootWindow(true)
+       , __pRootWindow(null)
+       , __name(L"")
        , __pParent(null)
        , __pChildren(null)
        , __pOwnees(null)
@@ -4332,7 +4353,11 @@ _Control::GetTopmostChildAt(const Point& point) const
        SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null.");
 
        _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf);
-       SysTryReturn(NID_UI, pHitTestElm, null, E_SYSTEM, "[E_SYSTEM] pHitTestElm is null.");
+       if (pHitTestElm == null)
+       {
+               SysSecureLog(NID_UI, "pHitTestElm is null, point(%f, %f)", ptf.x, ptf.y);
+               return null;
+       }
 
        pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData());
 
@@ -4787,10 +4812,15 @@ _Control::GetTouchInfoList(void)
        return __pDelayedTouchInfoList;
 }
 
+void
+_Control::SetVisualElement(_ControlVisualElement* pVisualElement)
+{
+       __pVisualElement = pVisualElement;
+}
+
 _VisualElement*
 _Control::GetVisualElement(void) const
 {
-       SysAssert(__pVisualElement);
        return __pVisualElement;
 }
 
@@ -4799,7 +4829,7 @@ _Control::PrintDescription(bool printChildren, int level)
 {
        int count = PrintDescription(printChildren, 0, level);
 
-       SysLog(NID_UI, "%d controls were printed.", count);
+       SysSecureLog(NID_UI, "%d controls were printed.", count);
 }
 
 int
@@ -4822,19 +4852,29 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
        indent.Append(format);
 
        String delimiter(L"-------------------------------------------------------------------------------------------");
-       SysLog(NID_UI, "%ls", delimiter.GetPointer());
+       SysSecureLog(NID_UI, "%ls", delimiter.GetPointer());
 
        // Public
        String publicDescription = GetControlDelegate().GetDescription();
        if (!publicDescription.IsEmpty())
        {
-               SysLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
+               SysSecureLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
+       }
+
+       _ControlManager* pControlManager = _ControlManager::GetInstance();
+       SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
+
+       bool focused = false;
+       _Control* pFocusedControl = pControlManager->GetFocusControl();
+       if (pFocusedControl && (pFocusedControl == this))
+       {
+               focused = true;
        }
 
        // Core
-       SysLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) focusable(%d) clip(%d) movable(%d) resizable(%d) inputEnableState(%d)",
+       SysSecureLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) focusable(%d) focused(%d) clip(%d) movable(%d) resizable(%d) inputEnableState(%d)",
                indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(),
-               IsFocusable(), IsClipToParent(), IsMovable(), IsResizable(), GetInputEnableState());
+               IsFocusable(), focused, IsClipToParent(), IsMovable(), IsResizable(), GetInputEnableState());
 
        Rectangle bounds = GetBounds();
        Dimension min = GetMinimumSize();
@@ -4842,14 +4882,14 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
        Rectangle clientBounds = GetClientBounds();
        Rectangle absoluteBounds = GetAbsoluteBounds();
 
-       SysLog(NID_UI, "%ls bounds(%d %d %d %d) min(%d %d) max(%d %d) scrollPos(%.2f %.2f) cbounds(%d %d %d %d) abounds(%d %d %d %d)",
+       SysSecureLog(NID_UI, "%ls bounds(%d %d %d %d) min(%d %d) max(%d %d) scrollPos(%.2f %.2f) cbounds(%d %d %d %d) abounds(%d %d %d %d)",
                indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height,
                min.width, min.height, max.width, max.height,
                GetVerticalScrollPosition(), GetHorizontalScrollPosition(),
                clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height,
                absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height);
 
-       SysLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
+       SysSecureLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
                indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer());
 
        Canvas* pCanvas = GetCanvasN();
@@ -4859,13 +4899,13 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
                Color canvasBackgroundColor = pCanvas->GetBackgroundColor();
                Color canvasForegroundColor = pCanvas->GetForegroundColor();
 
-               SysLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
+               SysSecureLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
                        indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32());
 
                delete pCanvas;
        }
 
-       SysLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
+       SysSecureLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
                indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying);
 
        // Ownees
@@ -4884,23 +4924,23 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
 
        if (!ownees.IsEmpty())
        {
-               SysLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
+               SysSecureLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
        }
 
        _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
 
-       SysLog(NID_UI, "%ls _VisualElement(0x%x) _VisualElementImpl(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
+       SysSecureLog(NID_UI, "%ls _VisualElement(0x%x) _VisualElementImpl(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
                indent.GetPointer(), __pVisualElement, pVisualElementImpl, __pVisualElementContentProvider, __pVisualElementEventListener);
 
        // Layout
-       SysLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
+       SysSecureLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
                indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer);
 
        // Derived class
        String description = GetDescription();
        if (!description.IsEmpty())
        {
-               SysLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
+               SysSecureLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
        }
 
        // Print Gesture List
@@ -4916,7 +4956,7 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
                pEnumerator->GetCurrent(pGestureDetector);
                if (pGestureDetector)
                {
-                       SysLog(NID_UI, "%ls AddedGesture : %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
+                       SysSecureLog(NID_UI, "%ls AddedGesture : %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
                }
        }
 
@@ -4932,7 +4972,7 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
                pStartedGestureEnumerator->GetKey(pStartedGestureDetector);
                if (pStartedGestureDetector)
                {
-                       SysLog(NID_UI, "%ls StartedGesture : %ls", indent.GetPointer(), pStartedGestureDetector->GetDescription().GetPointer());
+                       SysSecureLog(NID_UI, "%ls StartedGesture : %ls", indent.GetPointer(), pStartedGestureDetector->GetDescription().GetPointer());
                }
        }
 
@@ -5166,10 +5206,14 @@ _Control::OnDrawFocus(void)
                        pCanvas->SetBackgroundColor(0x55555555);
                        pCanvas->Clear();
                }
+               Color contentHighlightedColor;
+               GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
                Bitmap* pBitmap = null;
-               result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
+               Bitmap* pTempBitmap = null;
+               result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
+               pBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
 
-               if (r == E_SUCCESS)
+               if (pBitmap)
                {
                        if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
                        {
@@ -5195,6 +5239,11 @@ _Control::OnChildControlFocusMoved(const _Control& control)
 {
 }
 
+void
+_Control::OnDescendantControlFocusMoved(const _Control& control)
+{
+}
+
 bool
 _Control::IsChildControlFocusManage(void) const
 {
@@ -5306,9 +5355,8 @@ _Control::GetFocusListN(void) const
        {
                _Control* pEnumeratorControl = null;
                pEnum->GetCurrent(pEnumeratorControl);
-               _ContainerImpl* pTempContainerImpl = dynamic_cast<_ContainerImpl*>(static_cast <_ControlImpl* >(pEnumeratorControl->GetUserData()));
 
-               if (pTempContainerImpl != null && (nextContainerIndex < i))
+               if (nextContainerIndex < i)
                {
                        if (pEnumeratorControl->IsChildControlFocusManage() == false)
                        {