void nuiSimpleContainer::LowerChild(nuiWidgetPtr pChild) { CheckValid(); nuiWidgetList::iterator it = mpChildren.begin(); nuiWidgetList::iterator end = mpChildren.end(); nuiWidgetList::iterator previous = it; for ( ; it != end; ++it) { nuiWidgetPtr pItem = *it; if (pChild == pItem) { if (previous != mpChildren.begin()) { nuiWidgetPtr pPrevious = *previous; mpChildren.erase(previous); mpChildren.insert(it, pPrevious); Invalidate(); } DebugRefreshInfo(); return; } previous = it; } DebugRefreshInfo(); }
void nuiContainer::SetAlpha(float Alpha) { CheckValid(); nuiWidget::SetAlpha(Alpha); SilentInvalidateChildren(true); DebugRefreshInfo(); }
void nuiContainer::SetSelected(bool set) { CheckValid(); nuiWidget::SetSelected(set); SilentInvalidateChildren(true); Invalidate(); DebugRefreshInfo(); }
void nuiContainer::SetEnabled(bool set) { CheckValid(); if (set == mEnabled) return; nuiWidget::SetEnabled(set); SilentInvalidateChildren(true); Invalidate(); DebugRefreshInfo(); }
void nuiSimpleContainer::LowerChildToBack(nuiWidgetPtr pChild) { CheckValid(); nuiWidgetList::iterator it = mpChildren.begin(); nuiWidgetList::iterator end = mpChildren.end(); for ( ; it != end; ++it) { nuiWidgetPtr pItem = *it; if (pChild == pItem) { mpChildren.erase(it); mpChildren.insert(mpChildren.begin(), pItem); Invalidate(); DebugRefreshInfo(); return; } } DebugRefreshInfo(); }
void nuiSprite::DelMatrixNode(uint32 index) { if (!mpMatrixNodes) return; CheckValid(); mpMatrixNodes->at(index)->Release(); mpMatrixNodes->erase(mpMatrixNodes->begin() + index); DebugRefreshInfo(); }
bool nuiSimpleContainer::DelChild(nuiWidgetPtr pChild) { CheckValid(); NGL_ASSERT(pChild->GetParent() == this) if (GetDebug()) { NGL_OUT(_T("[%s] Del Child 0x%x <--- 0x%x (%s)\n"), GetObjectClass().GetChars(), this, pChild); } nuiWidgetList::iterator it = mpChildren.begin(); nuiWidgetList::iterator end = mpChildren.end(); for ( ; it != end; ++it) { if (*it == pChild) { mpChildren.erase(it); if (!pChild->IsTrashed()) { nuiTopLevel* pRoot = GetTopLevel(); Trashed(); Invalidate(); if (pRoot) pRoot->AdviseObjectDeath(pChild); pChild->SetParent(NULL); } ChildDeleted(this, pChild); Invalidate(); InvalidateLayout(); DebugRefreshInfo(); pChild->Release(); return true; } } DebugRefreshInfo(); return false; }
void nuiSprite::LoadIdentityMatrix() { CheckValid(); if (mpMatrixNodes) { for (size_t i = 0; i < mpMatrixNodes->size(); i++) mpMatrixNodes->at(i)->Release(); delete mpMatrixNodes; mpMatrixNodes = NULL; } DebugRefreshInfo(); }
nuiRect nuiContainer::CalcIdealSize() { CheckValid(); nuiRect temp; IteratorPtr pIt; for (pIt = GetFirstChild(false); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (mCanRespectConstraint) pItem->SetLayoutConstraint(mConstraint); nuiRect r(pItem->GetIdealRect()); // Dummy call. Only the side effect is important: the object recalculates its layout. temp.Union(temp, r.Size()); } delete pIt; DebugRefreshInfo(); return temp.Size(); }
bool nuiScrollView::Clear() { int childCount = GetChildrenCount(); for (childCount--; childCount >= 0; childCount--) { nuiWidget* pWidget = GetChild(childCount); if (pWidget && pWidget != mpHorizontal && pWidget != mpVertical) { DelChild(pWidget); } } mpChildren.clear(); if (!mVerticalIsExternal) mpChildren.push_back(mpVertical); if (!mHorizontalIsExternal) mpChildren.push_back(mpHorizontal); InvalidateLayout(); DebugRefreshInfo(); return true; }
bool nuiContainer::SetRect(const nuiRect& rRect) { CheckValid(); nuiWidget::SetRect(rRect); nuiRect rect(rRect.Size()); IteratorPtr pIt; for (pIt = GetFirstChild(false); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (mCanRespectConstraint) pItem->SetLayoutConstraint(mConstraint); pItem->GetIdealRect(); pItem->SetLayout(rect); } delete pIt; DebugRefreshInfo(); return true; }
bool nuiSimpleContainer::Clear() { CheckValid(); // start by trashing everybody nuiContainer::ChildrenCallOnTrash(); // then, clear the container int childCount = GetChildrenCount(); for (childCount--; childCount >= 0; childCount--) { nuiWidget* pWidget = GetChild(childCount); if (pWidget) { DelChild(pWidget); } } mpChildren.clear(); InvalidateLayout(); DebugRefreshInfo(); return true; }
bool nuiFrameView::SetRect(const nuiRect& rRect) { nuiRect r(rRect.Size()); if (mpFrame) mpFrame->GlobalToClientRect(r, this); nuiWidget::SetRect(rRect); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (mCanRespectConstraint) pItem->SetLayoutConstraint(mConstraint); pItem->GetIdealRect(); r.RoundToSmallest(); pItem->SetLayout(r); } delete pIt; DebugRefreshInfo(); return true; }
bool nuiSimpleContainer::AddChild(nuiWidgetPtr pChild) { CheckValid(); if (GetDebug()) { NGL_OUT(_T("[%s] Add Child 0x%x <--- 0x%x\n"), GetObjectClass().GetChars(), this, pChild); } pChild->Acquire(); nuiContainer* pParent = pChild->GetParent(); NGL_ASSERT(pParent != this); uint32 capacity = mpChildren.capacity(); uint32 size = mpChildren.size(); if (size == capacity) { if (size < 128) { mpChildren.reserve(size * 2); } else { mpChildren.reserve(size + 128); } } mpChildren.push_back(pChild); if (pParent) pParent->DelChild(pChild); // Remove from previous parent... pChild->SetParent(this); ChildAdded(this, pChild); Invalidate(); InvalidateLayout(); DebugRefreshInfo(); return true; }
void nuiPositioner::Invalidate() { // Get the rect of all the children: nuiRect rect; IteratorPtr pIt; //NGL_OUT(_T("nuiPositioner CalcIdealSize\n")); for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); nuiRect wrect(pItem->GetIdealRect()); //NGL_OUT(_T(" WRect %ls\n"), wrect.GetValue().GetChars()); rect.Union(rect,wrect.Size()); } delete pIt; rect.SetPosition(mPPosition, GetRect().Size()); nuiWidget::InvalidateRect(rect); SilentInvalidate(); if (mpParent) ((nuiPositioner*)mpParent)->BroadcastInvalidate(this); //#HACK! DebugRefreshInfo(); }