Esempio n. 1
0
bool nuiContainer::DrawChildren(nuiDrawContext* pContext)
{
  CheckValid();
  IteratorPtr pIt;

  if (mReverseRender)
  {
    for (pIt = GetLastChild(); pIt && pIt->IsValid(); GetPreviousChild(pIt))
    {
      nuiWidgetPtr pItem = pIt->GetWidget();
      if (pItem)
        DrawChild(pContext, pItem);
    }
    delete pIt;
  }
  else
  {
    for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
    {
      nuiWidgetPtr pItem = pIt->GetWidget();
      if (pItem)
        DrawChild(pContext, pItem);
    }
    delete pIt;
  }
  return true;
}
Esempio n. 2
0
bool nuiSlider::Draw(nuiDrawContext* pContext)
{
  //pContext->PushState();
  pContext->ResetState();
  nuiTheme* pTheme = GetTheme();
  NGL_ASSERT(pTheme);
  
  if (mDrawBackground)
  {
    if (!mpBackground)
      pTheme->DrawSliderBackground(pContext,this);
    else
      DrawChild(pContext, mpBackground);
  }
  
  if (!mpHandle)
    pTheme->DrawSliderForeground(pContext,this);
  else
    DrawChild(pContext, mpHandle);
  
  //pContext->PopState();
  pTheme->Release();
  
  return true;
}
Esempio n. 3
0
bool nuiScrollView::Draw(nuiDrawContext* pContext)
{
  nuiSize scrollv = (mpVertical->IsVisible() && !mForceNoVertical && !mVerticalIsExternal)?mBarSize:0;
  nuiSize scrollh = (mpHorizontal->IsVisible() && !mForceNoHorizontal && !mHorizontalIsExternal)?mBarSize:0;
  nuiRect rect(0.0f,0.0f,mRect.GetWidth()-scrollv, mRect.GetHeight()-scrollh);

  IteratorPtr pIt;
  for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
  {
    nuiWidgetPtr pItem = pIt->GetWidget();
    nuiRect intersect;
    if (intersect.Intersect(rect, pItem->GetOverDrawRect(true, true)))
    {
      DrawChild(pContext, pItem);
    }
  }

  delete pIt;

  if (GetDebug())
  {
    pContext->SetStrokeColor(nuiColor("red"));
    pContext->DrawRect(GetRect().Size(), eStrokeShape);
    pContext->SetStrokeColor(nuiColor("blue"));
    pContext->DrawRect(GetIdealRect().Size(), eStrokeShape);
    pContext->SetStrokeColor("yellow");
    float h = GetRect().GetHeight() - scrollh - 1;
    pContext->DrawLine(0, h, GetRect().GetWidth(), h);
  }
  return true;
}
Esempio n. 4
0
void CTransformDecorator::Draw() const
{
    glPushMatrix();
    glMultMatrixf(glm::value_ptr(m_transform));
    DrawChild();
    glPopMatrix();
}
Esempio n. 5
0
void CAnimatedDecorator::Draw() const
{
    const glm::mat4 matrix = GetAnimationTransform();
    glPushMatrix();
    glMultMatrixf(glm::value_ptr(matrix));
    DrawChild();
    glPopMatrix();
}
Esempio n. 6
0
bool nuiStateDummy::Draw(nuiDrawContext* pContext)
{
  nuiWidgetPtr pWidget = mpState[(IsEnabled(mCombined)?1:0) + (IsSelected(mCombined)?2:0)];

  if (pWidget)
  {
    DrawChild(pContext, pWidget);
  }
  return true;
}
Esempio n. 7
0
bool nuiComboBox::Draw(nuiDrawContext* pContext)
{
  nuiWidget* pWidget = GetSelectedWidget();
  if (pWidget)
  {
    NGL_ASSERT(pWidget->GetParent() == this);
    DrawChild(pContext, pWidget);
  }
  
  return true;
}
Esempio n. 8
0
void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
                                       const CFX_RectF& rtClip,
                                       CFX_Graphics* pGraphics,
                                       const CFX_Matrix* pMatrix) {
  if (!parent)
    return;

  FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled();
  IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent);
  while (pNextChild) {
    IFWL_Widget* child = pNextChild;
    pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child);
    if (child->GetStates() & FWL_WGTSTATE_Invisible)
      continue;

    CFX_RectF rtWidget;
    child->GetWidgetRect(rtWidget);
    if (rtWidget.IsEmpty())
      continue;

    CFX_Matrix widgetMatrix;
    CFX_RectF clipBounds(rtWidget);
    if (!bFormDisable)
      child->GetMatrix(widgetMatrix, TRUE);
    if (pMatrix)
      widgetMatrix.Concat(*pMatrix);

    if (!bFormDisable) {
      widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
      clipBounds.Intersect(rtClip);
      if (clipBounds.IsEmpty())
        continue;

      pGraphics->SaveGraphState();
      pGraphics->SetClipRect(clipBounds);
    }
    widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE);
    IFWL_WidgetDelegate* pDelegate = child->SetDelegate(nullptr);
    if (pDelegate) {
      if (m_pWidgetMgr->IsFormDisabled() ||
          IsNeedRepaint(child, &widgetMatrix, rtClip)) {
        pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
      }
    }
    if (!bFormDisable)
      pGraphics->RestoreGraphState();

    DrawChild(child, clipBounds, pGraphics,
              bFormDisable ? &widgetMatrix : pMatrix);
    child = m_pWidgetMgr->GetNextSiblingWidget(child);
  }
}
Esempio n. 9
0
bool nuiContainer::DrawChildren(nuiDrawContext* pContext)
{
  CheckValid();
  IteratorPtr pIt;
  for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
  {
    nuiWidgetPtr pItem = pIt->GetWidget();
    if (pItem)
      DrawChild(pContext, pItem);
  }
  delete pIt;
  return true;
}
void CWindowManager::CoreDrawChilds()
{
    const TChildList &childs = GetChildList();
    
    for (TChildList::const_iterator it=childs.begin(); it!=childs.end(); it++)
    {
        if (!(*it)->Enabled())
            continue;
        
        if (std::find(m_ActiveWidgets.begin(), m_ActiveWidgets.end(), *it) != m_ActiveWidgets.end())
            continue; // We draw these as last, so it looks like they are on top
        DrawChild(*it);
    }
    
    for (TChildList::const_iterator it=m_ActiveWidgets.begin(); it!=m_ActiveWidgets.end(); it++)
    {
        if (!(*it)->Enabled())
            continue;

        DrawChild(*it);
    }
}
Esempio n. 11
0
bool nuiPopupMenu::Draw(nuiDrawContext* pContext)
{
  nuiRect r = GetRect();

  NGL_ASSERT(!mRects.empty());
  nuiMenuRect* pRect = mRects[0];

  nuiTheme* pTheme = GetTheme();
  NGL_ASSERT(pTheme);

  pTheme->DrawMenuWindow(pContext, pRect->mRect, this);
  if (pRect->mpSBar->IsVisible())
    DrawChild(pContext, pRect->mpSBar);
  //it++;

  if (mShowFirstNode)
  {
    nuiWidgetPtr pWidget = mpTree->GetElement();
    NGL_ASSERT(pWidget);
    nuiRect rect = pWidget->GetRect();
    //Draw the main menu item (tree root item)
    pContext->SetFillColor(GetColor(eMenuTitleBg));
    pContext->DrawRect(rect, eStrokeAndFillShape);

    pContext->EnableBlending(true);
    nuiReflection ref(1.0f, .4f);
    ref.Draw(pContext, rect);
    pContext->EnableBlending(false);

    DrawChild(pContext, pWidget);
  }

  DrawTree(pContext, mpTree, 0);
  pTheme->Release();
  return true;
}
Esempio n. 12
0
void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
                                          CFX_Graphics* pGraphics,
                                          const CFX_Matrix* pMatrix) {
  if (!pWidget || !pGraphics)
    return;

  CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
  CFX_RectF clipCopy;
  pWidget->GetWidgetRect(clipCopy);
  clipCopy.left = clipCopy.top = 0;
  if (bUseOffscreenDirect(pWidget)) {
    DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
    return;
  }
  CFX_RectF clipBounds;

#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \
    _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_
  IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(nullptr);
  pDelegate->OnDrawWidget(pTemp, pMatrix);
  pGraphics->GetClipRect(clipBounds);
  clipCopy = clipBounds;
#elif _FX_OS_ == _FX_MACOSX_
  if (m_pWidgetMgr->IsFormDisabled()) {
    IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(nullptr);
    pDelegate->OnDrawWidget(pTemp, pMatrix);
    pGraphics->GetClipRect(clipBounds);
    clipCopy = clipBounds;
  } else {
    clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
    const_cast<CFX_Matrix*>(pMatrix)->SetIdentity();  // FIXME: const cast.
    IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(nullptr);
    pDelegate->OnDrawWidget(pTemp, pMatrix);
  }
#endif  // _FX_OS_ == _FX_MACOSX_

  if (!m_pWidgetMgr->IsFormDisabled()) {
    CFX_RectF rtClient;
    pWidget->GetClientRect(rtClient);
    clipBounds.Intersect(rtClient);
  }
  if (!clipBounds.IsEmpty())
    DrawChild(pWidget, clipBounds, pTemp, pMatrix);

  DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
  m_pWidgetMgr->ResetRedrawCounts(pWidget);
}
Esempio n. 13
0
////////////////////////////////////////////////////////////////////////
///
/// @fn NodeTableControlPoint::renderReal() const
///
/// Fait le reel rendu de l'objet.
///
///
/// @return void
///
////////////////////////////////////////////////////////////////////////
void NodeTableControlPoint::renderReal() const
{
    glPushMatrix();
    glPushAttrib(GL_CURRENT_BIT | GL_POLYGON_BIT);

    // Assignation du mode d'affichage des polygones
    glPolygonMode( GL_FRONT_AND_BACK, mModePolygones );
    glTranslatef(0,0,25.f);
    // Affichage concret
    NoeudAbstrait::renderReal();

    // Restauration
    glPopAttrib();
    glPopMatrix();

    DrawChild();
}
Esempio n. 14
0
bool nuiPopupMenu::DrawTree(nuiDrawContext* pContext, nuiTreeNode* pTree, uint depth)
{
  nuiTreeNode*  pChildNode;
  nuiTreeNode*  pOpenedNode = NULL;
  nuiWidget*    pChildWidget;    
  nuiRect       WidgetRect;

  NGL_ASSERT(depth < mRects.size());
  nuiMenuRect* pRect= mRects[depth];

  NGL_ASSERT(pTree);
  nuiTheme* pTheme = GetTheme();
  NGL_ASSERT(pTheme);

  if (pTree != mpTree) // then Draw a new rect for this depth
  {
    pTheme->DrawMenuWindow(pContext, pRect->mRect, this);
    if (pRect->mpSBar->IsVisible(false))
      DrawChild(pContext, pRect->mpSBar);
  }

  uint32 count = pTree->GetChildrenCount();
  for (uint32 i = 0; i < count; i++)
  {
    pChildNode = dynamic_cast<nuiTreeNode*>(pTree->GetChild(i));
    pChildWidget = pChildNode->GetElement();
    WidgetRect = pChildWidget->GetRect();

    if (pChildNode->IsSelected() || pChildNode->IsOpened())
    {
      nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
      nuiRect r = WidgetRect;
      r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

      pTheme->DrawSelectionBackground(pContext, r, this);
    }

    if (!pChildNode->IsEmpty())
    {
      nuiRect r = WidgetRect;
      r.Move(WidgetRect.GetWidth(), 0);
      r.SetSize(NUI_POPUP_TREE_HANDLE_SIZE-4.f, r.GetHeight());
      pContext->SetFillColor(GetColor(eTreeViewHandle));
      pTheme->DrawTreeHandle(pContext, r, false, NUI_POPUP_TREE_HANDLE_SIZE-4.f);
    }

    DrawChild(pContext, pChildWidget);

    if (pChildNode->IsSelected() || pChildNode->IsOpened())
    {
      nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
      nuiRect r = WidgetRect;
      r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

      pTheme->DrawSelectionForeground(pContext, r, this);
    }



    if (pChildNode->IsOpened())
    {
      pOpenedNode = pChildNode;
    }
  }

  if (pRect->mpSBar->IsVisible(false))
  {
    SetFillColor(pContext, eMenuBg);
    SetStrokeColor(pContext, eNormalTextFg);
    pContext->EnableBlending(true);
  
    nuiGradient grad;
    nuiColor bg(GetColor(eMenuBg));
    grad.AddStop(bg, 1);
    bg.Multiply(0);
    grad.AddStop(bg, 0);

    if (pRect->mpSBar->GetRange().GetValue() + pRect->mpSBar->GetRange().GetPageSize() < pRect->mpSBar->GetRange().GetMaximum())
    {
      nuiRect r(pRect->mRect.Left() + 2, mRect.Bottom() - AUTOSCROLL_HEIGHT * 2, pRect->mRect.GetWidth() - SB_WIDTH - 2, AUTOSCROLL_HEIGHT * 2);
      pContext->DrawGradient(grad, r, 0, mRect.Bottom() - AUTOSCROLL_HEIGHT * 2, 0, mRect.Bottom());

      float w = pRect->mRect.GetWidth() - SB_WIDTH;
      float x = pRect->mRect.Left();
      float y = mRect.Bottom() - AUTOSCROLL_HEIGHT;
      float s = 8;
      pContext->DrawLine(x + w/2 - s, y + 4, x + w/2 + s, y + 4);
      pContext->DrawLine(x + w/2 + s, y + 4, x + w/2, y + 4 + s);
      pContext->DrawLine(x + w/2, y + 4 + s, x + w/2 - s, y + 4);
    }

    if (pRect->mpSBar->GetRange().GetValue() > pRect->mpSBar->GetRange().GetMinimum())
    {
      nuiRect r(pRect->mRect.Left() + 2, 0.0f, pRect->mRect.GetWidth() - SB_WIDTH - 2, AUTOSCROLL_HEIGHT * 2);
      pContext->DrawGradient(grad, r, 0, AUTOSCROLL_HEIGHT * 2, 0, 0);

      float w = pRect->mRect.GetWidth() - SB_WIDTH;
      float x = pRect->mRect.Left();
      float s = 8;
      pContext->DrawLine(x + w/2, 4, x + w/2 - s, 4 + s);
      pContext->DrawLine(x + w/2 - s, 4 + s, x + w/2 + s, 4 + s);
      pContext->DrawLine(x + w/2 + s, 4 + s, x + w/2, 4);
    }

    pContext->EnableBlending(false);
}

  if (pOpenedNode)
    DrawTree(pContext, pOpenedNode, depth+1);

  pTheme->Release();
  return true;
}