Beispiel #1
1
nuiUniformDesc::nuiUniformDesc(const nglString& rName, GLenum Type, int count, GLuint Location, nuiShaderProgram* pProgram)
: mName(rName), mType(Type), mCount(count), mLocation(Location), mChanged(false)
{
  switch (mType)
  {
    case GL_FLOAT:              mValues.mpFloats  = new float[1 * count];  break;
    case GL_FLOAT_VEC2:         mValues.mpFloats  = new float[2 * count];  break;
    case GL_FLOAT_VEC3:         mValues.mpFloats  = new float[3 * count];  break;
    case GL_FLOAT_VEC4:         mValues.mpFloats  = new float[4 * count];  break;

    case GL_INT:                mValues.mpInts    = new int32[1 * count];  break;
    case GL_INT_VEC2:           mValues.mpInts    = new int32[2 * count];  break;
    case GL_INT_VEC3:           mValues.mpInts    = new int32[3 * count];  break;
    case GL_INT_VEC4:           mValues.mpInts    = new int32[4 * count];  break;
    case GL_UNSIGNED_INT:       mValues.mpInts    = new int32[1 * count];  break;

    case GL_FLOAT_MAT2:         mValues.mpFloats  = new float[2 * 2 * count];  break;
    case GL_FLOAT_MAT3:         mValues.mpFloats  = new float[3 * 3 * count];  break;
    case GL_FLOAT_MAT4:         mValues.mpFloats  = new float[4 * 4 * count];  break;

    case GL_SAMPLER_2D:         mValues.mpInts    = new int32[1 * count];  break;
    case GL_SAMPLER_CUBE:       mValues.mpInts    = new int32[1 * count];  break;

    default:
      NGL_ASSERT(0);
  }

  if (pProgram)
  {
    switch (mType)
    {
      case GL_FLOAT:
      case GL_FLOAT_VEC2:
      case GL_FLOAT_VEC3:
      case GL_FLOAT_VEC4:
      case GL_FLOAT_MAT2:
      case GL_FLOAT_MAT3:
      case GL_FLOAT_MAT4:
        glGetUniformfv(pProgram->GetProgram(), mLocation, mValues.mpFloats);
        break;

      case GL_INT:
      case GL_INT_VEC2:
      case GL_INT_VEC3:
      case GL_INT_VEC4:
      case GL_UNSIGNED_INT:
      case GL_SAMPLER_2D:
      case GL_SAMPLER_CUBE:
        glGetUniformiv(pProgram->GetProgram(), mLocation, mValues.mpInts);
        break;

      default:
        NGL_ASSERT(0);
    }
  }
}
Beispiel #2
0
void nuiComboBox::ReparentTree(nuiTreeNode* pTree)
{
  NGL_ASSERT(pTree);
  nuiWidgetPtr pWidget = pTree->GetElement();
  NGL_ASSERT(pWidget);

  pWidget->SetLayout(nuiRect(0.f,0.f, GetRect().GetWidth()-mHandleWidth, GetRect().GetHeight()));

  if (pWidget->GetParent() != this)
  {
    AddChild(pWidget);
    pWidget->InvalidateLayout();
  }

  if (GetSelectedWidget() == pWidget)
  {
    if (!pWidget->IsVisible())
      pWidget->SetVisible(true);
  }
  else 
  {
    if (pWidget->IsVisible())
      pWidget->SetVisible(false);
  }

  uint32 count = pTree->GetChildrenCount();
  for (uint32 i = 0; i < count; i++)
  {
    nuiTreeNode* pNode = dynamic_cast<nuiTreeNode*>(pTree->GetChild(i));
    NGL_ASSERT(pNode);
    ReparentTree(pNode);
  }
}
Beispiel #3
0
void nuiSpriteDef::Uninit()
{
  std::map<nglString, nuiSpriteDef*>::iterator it = mSpriteMap.begin();
  std::map<nglString, nuiSpriteDef*>::iterator end = mSpriteMap.end();

  std::vector<nuiSpriteDef*> temp;
  
  while (it != end)
  {
    nuiSpriteDef* pDef = it->second;
    pDef->CheckValid();
    //pDef->Release();
    temp.push_back(pDef);
    ++it;
  }
  
  for (int32 i = 0; i < temp.size(); i++)
  {
    nuiSpriteDef* pDef = temp[i];
    pDef->Release();
  }

  NGL_ASSERT(mSpriteMap.empty());
  NGL_ASSERT(!nuiSprite::mSpriteCounter);

}
//**************************************************************************************************************
//
// nuiComboBox
//
void nuiDefaultDecoration::ComboBox(nuiWidget* pWidget)
{
 
  nuiStateDecoration* pDeco = (nuiStateDecoration*)nuiDecoration::Get(_T("nuiDefaultDecorationComboBox"));
  if (pDeco)
  {
    pWidget->SetDecoration(pDeco, eDecorationBorder);
    return;
  }
  
  nuiTexture* pTex = nuiTexture::GetTexture("ComboUp");
  NGL_ASSERT(pTex);
  nuiFrame* pFrame = new nuiFrame(_T("nuiDefaultDecorationComboBoxUp"), pTex, nuiRect(12,4,2,10));
  pFrame->EnableBorder(false);
      
  pTex = nuiTexture::GetTexture("ComboDown");
  NGL_ASSERT(pTex);
  pFrame = new nuiFrame(_T("nuiDefaultDecorationComboBoxDown"), pTex, nuiRect(12,4,2,10));
  pFrame->EnableBorder(false);
    
  
  
  nuiStateDecoration* pState = new nuiStateDecoration(_T("nuiDefaultDecorationComboBox"));
  pState->SetState(nuiStateEnabled  | nuiStateReleased, nuiDecoration::Get(_T("nuiDefaultDecorationComboBoxUp")));
  pState->SetState(nuiStateEnabled  | nuiStateSelected, nuiDecoration::Get(_T("nuiDefaultDecorationComboBoxDown")));
  pWidget->SetDecoration(pState, eDecorationBorder);
  pWidget->SetUserHeight(18);
  
  pWidget->SetColor(eSelectedTextFg, nuiColor(32,32,32));
  
}
Beispiel #5
0
void nuiLayout::SetProperty(const nglString& rName, const nglString& rValue)
{
  nuiAttribBase attr(GetAttribute(rName));
  if (attr.IsValid())
  {
    attr.FromString(rValue);
    return;
  }

  if (rName.CompareLeft("VAnchors_", true) == 0 || rName.CompareLeft("HAnchors_", true) == 0)
  {
    // Create an attribute for this anchor, unless it exists already
    AddAttribute(new LayoutAnchorValue(rName, this));
    {
      nuiAttribBase attr(GetAttribute(rName));
      NGL_ASSERT(attr.IsValid());
      attr.FromString(rValue);
    }
  }
  else if (rName.CompareLeft("VAnchorsType_", true) == 0 || rName.CompareLeft("HAnchorsType_", true) == 0)
  {
    // Create an attribute for this anchor, unless it exists already
    AddAttribute(new nuiAttribute<nuiAnchorType>(rName, this));
    {
      nuiAttribBase attr(GetAttribute(rName));
      NGL_ASSERT(attr.IsValid());
      attr.FromString(rValue);
    }
  }
  else
  {
    nuiObject::SetProperty(rName, rValue);
  }

}
//**************************************************************************************************************
//
// nuiCloseButton (for windows)
//
void nuiDefaultDecoration::CloseButton(nuiWidget* pWidget)
{
  
  nuiStateDecoration* pDeco = (nuiStateDecoration*)nuiDecoration::Get(_T("nuiDefaultDecorationCloseButton"));
  if (pDeco)
  {
    pWidget->SetDecoration(pDeco, eDecorationBorder);
    return;
  }
  
  nuiTexture* pTexUp = nuiTexture::GetTexture("CloseButtonUp");
  NGL_ASSERT(pTexUp);
  nuiFrame* pFrameUp = new nuiFrame(_T("nuiDefaultDecorationCloseButtonUp"), pTexUp, nuiRect(0,0,12,15));
  
  
  nuiTexture* pTexHover = nuiTexture::GetTexture("CloseButtonHover");
  NGL_ASSERT(pTexHover);
  nuiFrame* pFrameHover = new nuiFrame(_T("nuiDefaultDecorationCloseButtonHover"), pTexHover, nuiRect(0,0,12,15));
  
  
  nuiTexture* pTexDown = nuiTexture::GetTexture("CloseButtonDown");
  NGL_ASSERT(pTexDown);
  nuiFrame* pFrameDown = new nuiFrame(_T("nuiDefaultDecorationCloseButtonDown"), pTexDown, nuiRect(0,0,12,15));
  
  
  
  nuiStateDecoration* pState = new nuiStateDecoration(_T("nuiDefaultDecorationCloseButton"), 
                                                      _T("nuiDefaultDecorationCloseButtonUp"),
                                                      _T("nuiDefaultDecorationCloseButtonDown"),
                                                      _T("nuiDefaultDecorationCloseButtonHover"));
  pState->SetSourceClientRect(nuiRect(0,0,12,15));
  
  pWidget->SetDecoration(pState, eDecorationBorder);
  
}
void nuiDefaultDecoration::InitIcons()
{
  // volume icon
  nuiTexture* pTex = nuiTexture::GetTexture("IconVolume");
  NGL_ASSERT(pTex);
  pTex->SetSource(_T("nuiDefaultDecorationIconVolume"));
  mIcons.push_back(pTex);
  
  // folder icon
  pTex = nuiTexture::GetTexture("IconFolder");
    NGL_ASSERT(pTex);
  pTex->SetSource(_T("nuiDefaultDecorationIconFolder"));
  mIcons.push_back(pTex);

  // open folder icon
  pTex = nuiTexture::GetTexture("IconOpenFolder");
    NGL_ASSERT(pTex);
  pTex->SetSource(_T("nuiDefaultDecorationIconOpenFolder"));
  mIcons.push_back(pTex);

  // parent folder icon
  pTex = nuiTexture::GetTexture("IconParentFolder");
    NGL_ASSERT(pTex);
  pTex->SetSource(_T("nuiDefaultDecorationIconParentFolder"));
  mIcons.push_back(pTex);
  
  // file icon
  pTex = nuiTexture::GetTexture("IconFile");
    NGL_ASSERT(pTex);
  pTex->SetSource(_T("nuiDefaultDecorationIconFile"));
  mIcons.push_back(pTex);
}
Beispiel #8
0
nuiWidgetPtr nuiSimpleContainer::GetChild(int index)
{
  CheckValid();
  NGL_ASSERT(index >= 0);
  NGL_ASSERT(index < mpChildren.size());
  return mpChildren[index];
}
Beispiel #9
0
double nuiRange::GetUnitValue() const
{
  NGL_ASSERT(IsValid());
  const double v = ConvertToUnit(GetValue());
  NGL_ASSERT(finite(v));
  return v;
}
Beispiel #10
0
void nuiDrawContext::DrawArray(nuiRenderArray* pArray)
{
  uint32 size = pArray->GetSize();
  if (!size)
  {
    pArray->Release();
    return;
  }

#ifdef _DEBUG_
  {
    // Error checking:
    if (!pArray->GetIndexArrayCount())
    {
      switch (pArray->GetMode())
      {
        case GL_POINTS:
          NGL_ASSERT(size);
          break;
        case GL_LINES:
          NGL_ASSERT(!(size & 1));
          break;
        case GL_LINE_LOOP:
          NGL_ASSERT(size > 1);
          break;
        case GL_LINE_STRIP:
          NGL_ASSERT(size > 1);
          break;
        case GL_TRIANGLES:
          NGL_ASSERT(size > 2 && !(size % 3));
          break;
        case GL_TRIANGLE_STRIP:
          NGL_ASSERT(size > 2);
          break;
        case GL_TRIANGLE_FAN:
          NGL_ASSERT(size > 2);
          break;
#ifndef _OPENGL_ES_
        case GL_QUADS:
          NGL_ASSERT(size > 3 && !(size % 4));
          break;
        case GL_QUAD_STRIP:
          NGL_ASSERT(size > 3);
          break;
        case GL_POLYGON:
          NGL_ASSERT(size > 3);
          break;
#endif
      }
    }
  }
#endif

  if (mStateChanges)
    mpPainter->SetState(mCurrentState);
  mStateChanges = 0;

  mpPainter->DrawArray(pArray);
}
Beispiel #11
0
double nuiRange::ConvertFromUnit(double UnitValue) const
{
  NGL_ASSERT(IsValid());
  NGL_ASSERT(finite(UnitValue));
  double r = mMaximum - mMinimum;
  double v = pow(UnitValue, 1.0 / mUnitCurve);
  return v * r + mMinimum;
}
Beispiel #12
0
void nuiComboBox::SetValue(uint32 childIndex)
{
  NGL_ASSERT(mpChoicesTree);
  NGL_ASSERT(mpChoicesTree->GetChildrenCount() > childIndex);

  SetSelected((nuiTreeNode*)(mpChoicesTree->GetChild(childIndex)));
  InvalidateLayout();
}
Beispiel #13
0
bool PreferencesBase::GetBool(const nglString& rKey, const nglString& rName, PreferencesTarget target) const
{
  nuiXMLNode* pNode = mXml[target]->GetChild(rKey);
  
  NGL_ASSERT(pNode);
  NGL_ASSERT(pNode->HasAttribute(rName));
  
  return pNode->GetAttribute(rName).Compare(_T("false"));
}
Beispiel #14
0
double PreferencesBase::GetDouble(const nglString& rKey, const nglString& rName, PreferencesTarget target) const
{
  nuiXMLNode* pNode = mXml[target]->GetChild(rKey);
  
  NGL_ASSERT(pNode);
  NGL_ASSERT(pNode->HasAttribute(rName));
  
  return pNode->GetAttribute(rName).GetCDouble();
}
Beispiel #15
0
double nuiRange::ConvertToUnit(double RangeValue) const
{
  NGL_ASSERT(IsValid());
  NGL_ASSERT(finite(RangeValue));
  double t = RangeValue - mMinimum;
  double r = mMaximum - mMinimum;
  double v = t / r;
  return pow(v, mUnitCurve);
}
Beispiel #16
0
nuiSize nuiPopupMenu::AdjustRectsPos(nuiSize& rX, nuiSize& rY, uint depth, nuiRect CurRect)
{
  nuiTopLevel* pRoot = GetTopLevel();
  NGL_ASSERT(pRoot);
  NGL_ASSERT(depth+1 < mRects.size());
  nuiRect MainRect = pRoot->GetRect();
  nuiRect& prevRect(mRects[depth]->mRect); // prevRect is the previous rect in the hierarchy (NOT the previous rect of this sub menu)
  depth++;

  nuiMenuRect* pMenuRect = mRects[depth];
  nuiRect& rRect(pMenuRect->mRect);

  nuiSize x, y;
  x = rX + (mXdir * rRect.GetWidth()) - (mXdir < 0 ? prevRect.GetWidth() : 0); // Compute X so that the rect doesn't get out of the main container
  y = rY + (mYdir * rRect.GetHeight()) + (mYdir < 0 ? CurRect.GetHeight() : 0); // Compute Y so that the rect doesn't get out of the main container
  if (x > MainRect.GetWidth() || x < 0) // Should we change the current x direction?
    mXdir *= -1;
  if (y > MainRect.GetHeight() || y < 0)  // Should we change the current y direction?
    mYdir *= -1;

  rX = rX - ((mXdir < 0) ? rRect.GetWidth()  + prevRect.GetWidth() : 0);
  rY = rY - ((mYdir < 0) ? rRect.GetHeight() - CurRect.GetHeight() : 0);

  if (rY < 0)
    rY = 0;
  if ( 
    ( (mYdir > 0) && (MainRect.GetHeight() < (rY + rRect.GetHeight()) ) ) ||
    ( (mYdir < 0) && (0 > (rY - rRect.GetHeight()) ) )
    )
  {
    nuiSize heightDiff = MainRect.GetHeight() - rRect.GetHeight();
    if (heightDiff > 0)
    {
      rY = heightDiff;
    }
    else
    {
      nuiRect r( ToNearest(rX + rRect.GetWidth() - SB_WIDTH), 0, ToNearest(SB_WIDTH), ToNearest(MainRect.GetHeight()));
      pMenuRect->mpSBar->GetRange().SetRange(0.f, rRect.GetHeight());
      pMenuRect->mpSBar->GetRange().SetPageSize(MainRect.GetHeight());
      pMenuRect->mpSBar->GetRange().SetIncrement(10.f);

      pMenuRect->mpSBar->SetLayout(r);
      pMenuRect->mpSBar->SetVisible(true);
      pMenuRect->mpSBar->SetSelected(false);
      pMenuRect->mpSBar->SetEnabled(true);
      rY = -pMenuRect->mpSBar->GetRange().GetValue();
      return (SB_WIDTH);
    }
  }
  if (pMenuRect->mpSBar)
  {
    pMenuRect->mpSBar->SetVisible(false);
    pMenuRect->mpSBar->SetEnabled(false);
  }
  return (0.f);
}
Beispiel #17
0
nglString PreferencesBase::GetString(const nglString& rGroup, const nglString& rName, PreferencesTarget target) const
{
  nuiXMLNode* pNode = mXml[target]->GetChild(rGroup);
  
  NGL_ASSERT(pNode);
  NGL_ASSERT(pNode->HasAttribute(rName));
  
  return pNode->GetAttribute(rName);
}
void nuiDefaultDecoration::FileTree_ParentFolderIcon(nuiWidget* pWidget)
{
  nuiTexture* pTex = nuiTexture::GetTexture(nglString(_T("nuiDefaultDecorationIconParentFolder")));
  NGL_ASSERT(pTex);
  
  NGL_ASSERT(dynamic_cast<nuiImage*>(pWidget));
  nuiImage* pImg = (nuiImage*)pWidget;
  pImg->SetTexture(pTex);
  pWidget->InvalidateLayout();
}
void nuiAudioDevice_DS_ProcessingTh::Process(uint pos)
{
  NGL_LOG(_T("nuiAudioDevice_DS_ProcessingTh"), NGL_LOG_DEBUG, _T("Process Thread received Event %d\n"), pos);

  int16* pBuf1=NULL;
  int16* pBuf2=NULL;
  DWORD size1=0;
  DWORD size2=0;
  DWORD bufferBytes = mBufferSize * mInputNbChannels * sizeof(int16);

  if (!mpRingBuffer->GetWritable())
    return;

  //
  // lock the input buffer if any,
  // and read data from it to the local buffer
  //
  if (  mpDSInputBuffer 
    && mpDSInputBuffer->Lock(pos * bufferBytes /* offset */, bufferBytes /*size*/, (LPVOID*)&pBuf1, &size1, (LPVOID*)&pBuf2, &size2, 0)
    )
  {
    if (!pBuf1 || !size1)
    {
      //NGL_LOG(_T("nuiAudioDevice_DS_ProcessingTh"), NGL_LOG_ERROR, _T("Process error : could not lock any part of the input buffer\n"));
      NGL_ASSERT(0);
      return;
    }

    // check that we got the right size
    NGL_ASSERT((size1+size2) == bufferBytes);


    // copy input data into local buffer
    memcpy(mpLocalBuf, pBuf1, size1);
    if (pBuf2)
      memcpy(mpLocalBuf+size1, pBuf2, size2);

    // convert int16 buffer to float buffer
    for (uint32 ch=0; ch < mInputNbChannels; ch++)
    {
      nuiAudioConvert_INint16ToDEfloat(mpLocalBuf, const_cast<float*>(mFloatInputBuf[ch]), ch, mInputNbChannels, mBufferSize); 
    }
  }


  // call user audio process function
  mpProcessFunction(mFloatInputBuf, mFloatOutputBuf, mBufferSize);

  // copy output buffer contents to ringbuffer
  uint32 nbWrite = WriteToRingBuf(mFloatOutputBuf, mBufferSize, mOutputNbChannels);

  // release DS input buffer
  if (mpDSInputBuffer)
    mpDSInputBuffer->Unlock(pBuf1, size1, pBuf2, size2);
}
Beispiel #20
0
void nuiPopupMenu::CalcTreeSize(nuiRect& rRect, nuiTreeNode* pTree, uint32& cpt)
{
  NGL_ASSERT(pTree); // no chance to happen
  cpt++;
  nuiRect rect(0,0,0,0);
  nuiWidgetPtr pWidget;
  nuiRect WidgetRect;

  uint32 depth = cpt;

  uint32 count = pTree->GetChildrenCount();
  if (count <= 0)
    return;

  bool HasNonEmpty = false;

  for (uint32 i = 0; i < count; i++)
  {
    nuiTreeNode* pNode = dynamic_cast<nuiTreeNode*>(pTree->GetChild(i));
    NGL_ASSERT(pNode);
    pWidget = pNode->GetElement();
    NGL_ASSERT(pWidget);
    WidgetRect = pWidget->GetIdealRect();
    rect.SetSize(MAX(rect.GetWidth(), WidgetRect.GetWidth()), rect.GetHeight() + WidgetRect.GetHeight());
    if (!pNode->IsEmpty())
    {
      HasNonEmpty = true;
    }
    if (pNode->IsOpened())
    {
      if (mRects.size() <= depth + 1) // ensure that there is a rect for the next node
      {
        nuiMenuRect* pMenuRect = new nuiMenuRect(this, cpt+1);
        mRects.push_back(pMenuRect);
        mPopupTreeSink.Connect(pMenuRect->mpSBar->ValueChanged, &nuiPopupMenu::OnScrollBarChange, pMenuRect);
      }
      mRects[depth+1]->mpFromNode = pNode;
      CalcTreeSize(rRect, pNode, cpt);
    }
  }
  if (HasNonEmpty)
  {
    mRects[depth]->mHasNonEmpty = true;
    rect.SetSize(rect.GetWidth() + NUI_POPUP_TREE_HANDLE_SIZE * 2, rect.GetHeight());
  }
  else
  {
    mRects[depth]->mHasNonEmpty = false;
  }

  mRects[depth]->mRect = rect;
  NGL_ASSERT(mRects.size() >= depth+1);
  rRect.SetSize(rect.GetWidth()+rRect.GetWidth(), rect.GetHeight()+rRect.GetHeight());
}
void nuiDefaultDecoration::FileSelector_VolumeIcon(nuiWidget* pWidget)
{
  nuiTexture* pTex = nuiTexture::GetTexture(nglString(_T("nuiDefaultDecorationIconVolume")));
  NGL_ASSERT(pTex);

  NGL_ASSERT(dynamic_cast<nuiImage*>(pWidget));
  nuiImage* pImg = (nuiImage*)pWidget;
  pImg->SetTexture(pTex);
  pWidget->InvalidateLayout();
  
}
void nuiDefaultDecoration::TabView_Contents(nuiTabView* pView, nuiWidget* pContents)
{
  nglString decoName = _T("nuiDefaultDecorationTabTopContents");
  
  nuiRect frameRect;
  
  const char* deco = "TabTopContents";
  
  switch (pView->GetTabPosition())
  {
    case nuiTop:
      decoName = _T("nuiDefaultDecorationTabTopContents");
      deco = "TabTopContents";
      frameRect = nuiRect(4,5,2,4);
      break;
      
    case nuiLeft:
      decoName = _T("nuiDefaultDecorationTabLeftContents");
      deco = "TabLeftContents";
      frameRect = nuiRect(5,4,4,2);
      break;
      
    case nuiRight:
      decoName = _T("nuiDefaultDecorationTabRightContents");
      deco = "TabRightContents";
      frameRect = nuiRect(5,4,4,2);
      break;
      
    case nuiBottom:
      decoName = _T("nuiDefaultDecorationTabBottomContents");
      deco = "TabBottomContents";
      frameRect = nuiRect(4,5,2,4);
      break;

    default:
      NGL_ASSERT(0);
      break;
  }
  
  nuiFrame* pDeco = (nuiFrame*)nuiDecoration::Get(decoName);
  if (pDeco)
  {
    pContents->SetDecoration(pDeco, eDecorationBorder);
    return;
  }
  
  nuiTexture* pTex = nuiTexture::GetTexture(deco);
  NGL_ASSERT(pTex);
  pDeco = new nuiFrame(decoName, pTex, frameRect);
    
  pContents->SetDecoration(pDeco, eDecorationBorder);
  
}
//**************************************************************************************************************
//
// nuiToggleButton
//
void nuiDefaultDecoration::ToggleButton(nuiWidget* pWidget)
{
  nuiToggleButton* pBtn = (nuiToggleButton*)pWidget;
  if (!pBtn->GetDisplayAsCheckBox() && !pBtn->GetDisplayAsFrameBox())
  {
    nuiDefaultDecoration::Button(pWidget);
    return;
  }
  
  if (pBtn->GetDisplayAsCheckBox())
  {
    nuiStateDecoration* pDeco = (nuiStateDecoration*)nuiDecoration::Get(_T("nuiDefaultDecorationToggleButtonCheckBox"));
    if (pDeco)
    {
      pWidget->SetDecoration(pDeco, eDecorationBorder);
      return;
    }
    
    nuiTexture* pTex = nuiTexture::GetTexture("ToggleButtonUp");
    NGL_ASSERT(pTex);
    nuiImageDecoration* pFrame = new nuiImageDecoration(_T("nuiDefaultDecorationToggleButtonCheckBoxUp"), pTex, nuiRect(0,0,13,13));
    pFrame->SetPosition(nuiLeft);
        
    
    pTex = nuiTexture::GetTexture("ToggleButtonDown");
    NGL_ASSERT(pTex);
    pFrame = new nuiImageDecoration(_T("nuiDefaultDecorationToggleButtonCheckBoxDown"), pTex, nuiRect(0,0,13,13));
    pFrame->SetPosition(nuiLeft);
        
    pTex = nuiTexture::GetTexture("ToggleButtonUpDisabled");
    NGL_ASSERT(pTex);
    pFrame = new nuiImageDecoration(_T("nuiDefaultDecorationToggleButtonCheckBoxUpDisabled"), pTex, nuiRect(0,0,13,13));
    pFrame->SetPosition(nuiLeft);
        
    pTex = nuiTexture::GetTexture("ToggleButtonDownDisabled");
    NGL_ASSERT(pTex);
    pFrame = new nuiImageDecoration(_T("nuiDefaultDecorationToggleButtonCheckBoxDownDisabled"), pTex, nuiRect(0,0,13,13));
    pFrame->SetPosition(nuiLeft);
        
    
    nuiStateDecoration* pState = new nuiStateDecoration(_T("nuiDefaultDecorationToggleButtonCheckBox"), 
                                                        _T("nuiDefaultDecorationToggleButtonCheckBoxUp"),
                                                        _T("nuiDefaultDecorationToggleButtonCheckBoxDown"),
                                                        _T("nuiDefaultDecorationToggleButtonCheckBoxUp"),/* hover up */
                                                        _T("nuiDefaultDecorationToggleButtonCheckBoxDown"), /* hover down*/
                                                        _T("nuiDefaultDecorationToggleButtonCheckBoxUpDisabled"),
                                                        _T("nuiDefaultDecorationToggleButtonCheckBoxDownDisabled"));
    pState->SetSourceClientRect(nuiRect(0,0,13,13));
    pWidget->SetDecoration(pState, eDecorationBorder);
  }
  
}
//**************************************************************************************************************
//
// nuiDialog
//
void nuiDefaultDecoration::Dialog(nuiSimpleContainer* pCont)
{
  nuiFrame* pFrame = (nuiFrame*)nuiDecoration::Get(_T("nuiDefaultDecorationOutterPane"));
  if (!pFrame)
  {
    nuiTexture* pTex = nuiTexture::GetTexture("PaneOutter");
    NGL_ASSERT(pTex);
    pFrame = new nuiFrame(_T("nuiDefaultDecorationOutterPane"), pTex, nuiRect(12,12,0,1));
    pFrame->UseWidgetAlpha(true);
  }
  NGL_ASSERT(pFrame);
  pCont->SetDecoration(pFrame);  
}
//**************************************************************************************************************
//
// nuiDialog::EditLine
//
void nuiDefaultDecoration::Dialog_EditLine(nuiWidget* pWidget)
{
  nuiFrame* pFrame = (nuiFrame*)nuiDecoration::Get(_T("nuiDefaultDecorationInnerPane"));
  if (!pFrame)
  {
    nuiTexture* pTex = nuiTexture::GetTexture("PaneInner");
    NGL_ASSERT(pTex);
    pFrame = new nuiFrame(_T("nuiDefaultDecorationInnerPane"), pTex, nuiRect(6,6,0,0));
    pFrame->UseWidgetAlpha(true);
  }
  NGL_ASSERT(pFrame);
  pWidget->SetDecoration(pFrame, eDecorationBorder);    
}
//**************************************************************************************************************
//
// nuiMessageBox
//
void nuiDefaultDecoration::MessageBox(nuiMessageBox* pBox)
{
  nuiFrame* pFrame = (nuiFrame*)nuiDecoration::Get(_T("nuiDefaultDecorationOutterPane"));
  if (!pFrame)
  {
    nuiTexture* pTex = nuiTexture::GetTexture("PaneOutter");
    NGL_ASSERT(pTex);
    pFrame = new nuiFrame(_T("nuiDefaultDecorationOutterPane"), pTex, nuiRect(12,12,0,1));
    pFrame->UseWidgetAlpha(true);
  }
  NGL_ASSERT(pFrame);
  pBox->SetDecoration(pFrame);
}
Beispiel #27
0
nglCriticalSectionPrivate::nglCriticalSectionPrivate ()
{
    int res = 0;
    pthread_mutexattr_t mta;
    res = pthread_mutexattr_init(&mta);
    NGL_ASSERT(res == 0);
    res = pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE);
    NGL_ASSERT(res == 0);
    res = pthread_mutex_init(&cmutex, &mta);
    NGL_ASSERT(res == 0);
    res = pthread_mutexattr_destroy(&mta);
    NGL_ASSERT(res == 0);
}
Beispiel #28
0
void nuiUniformDesc::Set(const int32* pV, int32 count, bool apply)
{
  switch (mType)
  {
    case GL_INT:            NGL_ASSERT(count <= (int32)mCount * 1); break;
    case GL_INT_VEC2:       NGL_ASSERT(count <= (int32)mCount * 2); break;
    case GL_INT_VEC3:       NGL_ASSERT(count <= (int32)mCount * 3); break;
    case GL_INT_VEC4:       NGL_ASSERT(count <= (int32)mCount * 4); break;

    case GL_UNSIGNED_INT:   NGL_ASSERT(count <= (int32)mCount * 4); break;
    case GL_SAMPLER_2D:     NGL_ASSERT(count <= (int32)mCount * 4); break;
    case GL_SAMPLER_CUBE:   NGL_ASSERT(count <= (int32)mCount * 4); break;

    default:
      NGL_ASSERT(0);
  }

  bool same = true;
  for (int32 i = 0; i < count; i++)
  {
    const GLint v1 = mValues.mpInts[i];
    const GLint v2 = pV[i];

    mValues.mpInts[i] = v2;
    same = same && (v1 == v2);
  }

  mChanged = mChanged || !same;


  if (apply)
    Apply();
}
Beispiel #29
0
void nuiUniformDesc::Set(const float* pV, int32 count, bool apply)
{
  switch (mType)
  {
    case GL_FLOAT:        NGL_ASSERT(count <= (int32)mCount * 1); break;
    case GL_FLOAT_VEC2:   NGL_ASSERT(count <= (int32)mCount * 2); break;
    case GL_FLOAT_VEC3:   NGL_ASSERT(count <= (int32)mCount * 3); break;
    case GL_FLOAT_VEC4:   NGL_ASSERT(count <= (int32)mCount * 4); break;

    case GL_FLOAT_MAT2:   NGL_ASSERT(count <= (int32)mCount * 2 * 2); break;
    case GL_FLOAT_MAT3:   NGL_ASSERT(count <= (int32)mCount * 3 * 3); break;
    case GL_FLOAT_MAT4:   NGL_ASSERT(count <= (int32)mCount * 4 * 4); break;

    default:
      NGL_ASSERT(0);
  }

  bool same = true;
  for (int32 i = 0; i < count; i++)
  {
    const float v1 = mValues.mpFloats[i];
    const float v2 = pV[i];

    mValues.mpFloats[i] = v2;
    same = same && (v1 == v2);
  }

  mChanged = mChanged || !same;

  if (apply)
    Apply();
}
void nglTimer::Stop()
{
  if (mRunning)
  {
    NGL_ASSERT(mpCFRunLoopTimer);
    CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
    NGL_ASSERT(mpCFRunLoop == currentRunLoop);
    CFRunLoopRemoveTimer(currentRunLoop, mpCFRunLoopTimer, kCFRunLoopCommonModes);
    if (mpCFRunLoopTimer)
      CFRelease(mpCFRunLoopTimer);
    mpCFRunLoopTimer = NULL;
  }
  mRunning = false;
}