}
void
-_Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
+_Control::ChangeLayout(_Control& control, _ControlOrientation orientation)
{
- ClearLastResult();
-
- struct _Visitor
- : public Visitor
+ if (control.__orientation != orientation)
{
- _Visitor(_ControlOrientation orientation)
- : __orientation(orientation){}
+ control.__orientation = orientation;
+ control.GetControlDelegate().OnChangeLayout(orientation);
+ }
- virtual VisitType Visit(_Control& control)
+ for (int i = 0; i < control.GetChildCount(); ++i)
+ {
+ _Control* pChild = control.GetChild(i);
+ if (pChild)
{
- if (control.__orientation != __orientation)
- {
- control.__orientation = __orientation;
- control.GetControlDelegate().OnChangeLayout(__orientation);
- ClearLastResult();
- }
-
- return VISIT_DOWNWARD;
+ ChangeLayout(*pChild, orientation);
}
+ }
+}
-private:
- _ControlOrientation __orientation;
- };
-
- _Visitor visitor(orientation);
- Accept(visitor);
-
- SysAssert(GetLastResult() == E_SUCCESS);
+void
+_Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
+{
+ ClearLastResult();
+ ChangeLayout(*this, orientation);
if (callRotation == true)
{
}
void
-_Control::ChangeLayout(_ControlRotation rotation)
+_Control::ChangeLayout(_Control& control, _ControlRotation rotation)
{
- ClearLastResult();
-
- struct _Visitor
- : public Visitor
+ if (control.__rotation != rotation)
{
- _Visitor(_ControlRotation rotation)
- : __rotation(rotation){}
+ control.__rotation = rotation;
+ control.GetControlDelegate().OnChangeLayout(rotation);
+ ClearLastResult();
+ }
- virtual VisitType Visit(_Control& control)
+ for (int i = 0; i < control.GetChildCount(); ++i)
+ {
+ _Control* pChild = control.GetChild(i);
+ if (pChild)
{
- if (control.__rotation != __rotation)
- {
- control.__rotation = __rotation;
- control.GetControlDelegate().OnChangeLayout(__rotation);
- ClearLastResult();
- }
-
- return VISIT_DOWNWARD;
+ ChangeLayout(*pChild, rotation);
}
+ }
+}
-private:
- _ControlRotation __rotation;
- };
-
- _Visitor visitor(rotation);
- Accept(visitor);
-
- SysAssert(GetLastResult() == E_SUCCESS);
+void
+_Control::ChangeLayout(_ControlRotation rotation)
+{
+ ClearLastResult();
+ ChangeLayout(*this, rotation);
}
bool
}
void
-_Control::CallOnAncestorVisibleStateChanged(void)
+_Control::CallOnAncestorVisibleStateChanged(_Control& control)
{
- struct _Visitor
- : public Visitor
- {
- _Visitor(_Control& parent)
- : __parent(parent){}
+ control.GetControlDelegate().OnAncestorVisibleStateChanged(*this);
- virtual VisitType Visit(_Control& control)
+ for (int i = 0; i < control.GetChildCount(); ++i)
+ {
+ _Control* pChild = control.GetChild(i);
+ if (pChild)
{
- control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent);
- return VISIT_DOWNWARD;
+ CallOnAncestorVisibleStateChanged(*pChild);
}
-
- _Control& __parent;
- };
-
- _Visitor visitor(*this);
- Accept(visitor);
+ }
}
void
-_Control::CallOnAncestorEnableStateChanged(void)
+_Control::CallOnAncestorEnableStateChanged(_Control& control)
{
- struct _Visitor
- : public Visitor
- {
- _Visitor(_Control& parent)
- : __parent(parent){}
+ control.GetControlDelegate().OnAncestorEnableStateChanged(*this);
- virtual VisitType Visit(_Control& control)
+ for (int i = 0; i < control.GetChildCount(); ++i)
+ {
+ _Control* pChild = control.GetChild(i);
+ if (pChild)
{
- control.GetControlDelegate().OnAncestorEnableStateChanged(__parent);
- return VISIT_DOWNWARD;
+ CallOnAncestorEnableStateChanged(*pChild);
}
-
- _Control& __parent;
- };
-
- _Visitor visitor(*this);
- Accept(visitor);
+ }
}
void
-_Control::CallOnAncestorInputEnableStateChanged(void)
+_Control::CallOnAncestorInputEnableStateChanged(_Control& control)
{
- struct _Visitor
- : public Visitor
- {
- _Visitor(_Control& parent)
- : __parent(parent){}
+ control.GetControlDelegate().OnAncestorInputEnableStateChanged(*this);
- virtual VisitType Visit(_Control& control)
+ for (int i = 0; i < control.GetChildCount(); ++i)
+ {
+ _Control* pChild = control.GetChild(i);
+ if (pChild)
{
- control.GetControlDelegate().OnAncestorInputEnableStateChanged(__parent);
- return VISIT_DOWNWARD;
+ CallOnAncestorInputEnableStateChanged(*pChild);
}
-
- _Control& __parent;
- };
-
- _Visitor visitor(*this);
- Accept(visitor);
+ }
}
// E_INVALID_ARG
_Control::IsAncestorOf(const _Control& control) const
{
ClearLastResult();
+ return IsAncestorOf(control, *this);
+}
+bool
+_Control::IsAncestorOf(const _Control& control, const _Control& ancestor) const
+{
const _Control* pParent = control.GetParent();
- if (!pParent)
+ if (pParent)
{
- return false;
- }
-
- struct _Visitor
- : public Visitor
- {
-private:
- const _Control& __ancestor;
-
-public:
- bool yes;
-
- _Visitor(const _Control& ancestor)
- : __ancestor(ancestor)
- , yes(false){}
-
- virtual VisitType Visit(_Control& control)
+ if (pParent == &ancestor)
{
- if (&__ancestor == &control)
- {
- yes = true;
- return VISIT_STOP;
- }
- else
- {
- return VISIT_UPWARD;
- }
+ return true;
}
- };
-
- _Visitor visitor(*this);
- pParent->Accept(visitor);
+ return IsAncestorOf(*pParent, ancestor);
+ }
- SysAssert(GetLastResult() == E_SUCCESS);
- return visitor.yes;
+ return false;
}
_Window*
return __pRootWindow;
}
- struct _Visitor
- : public Visitor
- {
- _Window* pRoot;
+ _Window* pRoot = null;
+ _Control* pControl = const_cast<_Control*>(this);
- _Visitor(void)
- : pRoot(null){}
-
- virtual VisitType Visit(_Control& control)
+ while (pControl)
+ {
+ pRoot = dynamic_cast <_Window*>(pControl);
+ if (pRoot)
{
- pRoot = dynamic_cast <_Window*>(&control);
- if (pRoot != null)
- {
- return VISIT_STOP;
- }
-
- return VISIT_UPWARD;
+ break;
}
- };
-
- _Visitor visitor;
- Accept(visitor);
-
- SysAssert(GetLastResult() == E_SUCCESS);
+ pControl = pControl->GetParent();
+ }
- const_cast<_Control*>(this)->__pRootWindow = visitor.pRoot;
+ const_cast<_Control*>(this)->__pRootWindow = pRoot;
const_cast<_Control*>(this)->__needRecalcRootWindow = false;
- return visitor.pRoot;
+ return pRoot;
}
bool
{
ClearLastResult();
- struct _Visitor
- : public Visitor
- {
- bool enabled;
-
- _Visitor(void)
- : enabled(true){}
+ bool enabled = true;
+ const _Control* pControl = this;
- virtual VisitType Visit(_Control& control)
+ while (pControl)
+ {
+ if (!pControl->GetEnableState())
{
- if (!control.GetEnableState())
- {
- enabled = false;
- return VISIT_STOP;
- }
-
- return VISIT_UPWARD;
+ enabled = false;
+ break;
}
- };
+ pControl = pControl->GetParent();
+ }
- _Visitor visitor;
- Accept(visitor);
- return visitor.enabled;
+ return enabled;
}
bool
if (changed)
{
__enabledState = enabledState;
- CallOnAncestorEnableStateChanged();
+ CallOnAncestorEnableStateChanged(*this);
}
__pAccessibilityContainer->SetEnableState(enabledState);
}
{
ClearLastResult();
- struct _Visitor
- : public Visitor
- {
- bool inputEnabled;
-
- _Visitor(void)
- : inputEnabled(true){}
+ bool inputEnabled = true;
+ const _Control* pControl = this;
- virtual VisitType Visit(_Control& control)
+ while (pControl)
+ {
+ if (!pControl->GetInputEnableState())
{
- if (!control.GetInputEnableState())
- {
- inputEnabled = false;
- return VISIT_STOP;
- }
-
- return VISIT_UPWARD;
+ inputEnabled = false;
+ break;
}
- };
+ pControl = pControl->GetParent();
+ }
- _Visitor visitor;
- Accept(visitor);
- return visitor.inputEnabled;
+ return inputEnabled;
}
bool
_Control::LockInputEvent(void)
{
__inputLockRefCount++;
- CallOnAncestorInputEnableStateChanged();
+ CallOnAncestorInputEnableStateChanged(*this);
}
void
return false;
}
- struct _Visitor
- : public Visitor
- {
- bool visible;
-
- _Visitor(void)
- : visible(true){}
+ bool visible = true;
+ const _Control* pControl = this;
- virtual VisitType Visit(_Control& control)
+ while (pControl)
+ {
+ if (!pControl->GetVisibleState())
{
- if (!control.GetVisibleState())
- {
- visible = false;
- return VISIT_STOP;
- }
-
- return VISIT_UPWARD;
+ visible = false;
+ break;
}
- };
-
- _Visitor visitor;
- Accept(visitor);
+ pControl = pControl->GetParent();
+ }
- SysAssert(GetLastResult() == E_SUCCESS);
- return visitor.visible;
+ return visible;
}
bool
if (changed)
{
GetControlDelegate().OnVisibleStateChanged();
- CallOnAncestorVisibleStateChanged();
+ CallOnAncestorVisibleStateChanged(*this);
_Control* pParent = GetParent();
if (pParent)
{
}
result
-_Control::AdjustAbsoluteBounds(void)
+_Control::AdjustAbsoluteBounds(_Control& control)
{
- struct _Visitor
- : public Visitor
+ if (&control == this)
{
- _Visitor(_Control* pControl)
- : __pControl(pControl){}
-
- virtual VisitType Visit(_Control& control)
- {
- result r = E_SUCCESS;
+ return E_SUCCESS;
+ }
- if (__pControl == &control)
- {
- return VISIT_DOWNWARD;
- }
- FloatRectangle fbounds = control.GetBoundsF();
- if (control.IsLayoutChangable() == false)
- {
- r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
- }
- else
- {
- r = control.UpdateBoundsOfVisualElement(fbounds);
- }
+ result r = E_SUCCESS;
+ FloatRectangle fbounds = control.GetBoundsF();
- ControlList& children = control.GetChildList();
+ if (control.IsLayoutChangable() == false)
+ {
+ r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
+ }
+ else
+ {
+ r = control.UpdateBoundsOfVisualElement(fbounds);
+ }
- int childrenCount = children.GetCount();
- if (childrenCount <= 0)
- {
- return VISIT_STOP;
- }
- else
+ for (int i = 0; i < control.GetChildCount(); ++i)
+ {
+ _Control* pChild = control.GetChild(i);
+ if (pChild)
+ {
+ r = AdjustAbsoluteBounds(*pChild);
+ if (IsFailed(r))
{
- return VISIT_DOWNWARD;
+ SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
}
}
- private :
- _Control* __pControl;
- };
-
- _Visitor visitor(this);
- Accept(visitor);
+ }
- return E_SUCCESS;
+ return r;
}
bool
if (moved || resized)
{
- result r = AdjustAbsoluteBounds();
+ result r = AdjustAbsoluteBounds(*this);
SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
SetUpdateLayoutState(true);
if (moved || resized)
{
- result r = AdjustAbsoluteBounds();
+ result r = AdjustAbsoluteBounds(*this);
SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
SetUpdateLayoutState(true);
for(int i = 0; i < childCount; i++)
{
_Control* pChildControl = pControl->GetChild(i);
- Rectangle rect = pChildControl->GetAbsoluteBounds(true);
+ Rectangle rect = pChildControl->GetAbsoluteBounds();
unique_ptr<IEnumeratorT<_Control*> > pEnum (pFocusControlList->GetEnumeratorN());
int index = 0;
while (pEnum->MoveNext() == E_SUCCESS)
}
}} // Tizen::Ui
-