当前位置: 首页>>代码示例>>C++>>正文


C++ nuiRect类代码示例

本文整理汇总了C++中nuiRect的典型用法代码示例。如果您正苦于以下问题:C++ nuiRect类的具体用法?C++ nuiRect怎么用?C++ nuiRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了nuiRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetIdealClientRect

void nuiDecoration::GlobalToClientRect(nuiRect& rRect, const nuiWidget* pWidget) const
{
    nuiRect clientRect = GetIdealClientRect(pWidget);
//  nuiSize bordertop = GetBorder(nuiTop, pWidget);
//  nuiSize borderleft = GetBorder(nuiLeft, pWidget);
    nuiSize borderright = GetBorder(nuiRight, pWidget);
    nuiSize borderbottom = GetBorder(nuiBottom, pWidget);


    float X1 = (float)clientRect.Left();
    float X2 = (float)clientRect.Right();
    float X3 = (float)clientRect.Right()+borderright;

    float Y1 = (float)clientRect.Top();
    float Y2 = (float)clientRect.Bottom();
    float Y3 = (float)clientRect.Bottom()+borderbottom;

    const float x0 = (float)rRect.Left();
    const float x1 = x0 + X1;
    const float x3 = (float)rRect.Right();
    const float x2 = x3 - (X3 - X2);

    const float y0 = (float)rRect.Top();
    const float y1 = y0 + Y1;
    const float y3 = (float)rRect.Bottom();
    const float y2 = y3 - (Y3 - Y2);

    rRect.Set(x1, y1, x2, y2, false);
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: ValidateWindowRect

bool nuiWindowManager::ValidateWindowRect(nuiRect& rRect) const
{
  bool res = true;
  
  if (rRect.mTop > (mRect.GetHeight() - 10))
  {
    rRect.Move(0, mRect.GetHeight() - 10 - rRect.mTop);
    res = false;
  }
  if (rRect.mTop < 0)
  {
    rRect.Move(0, - rRect.mTop);
    res = false;
  }
  
  if (rRect.mLeft > (mRect.GetWidth() - 10))
  {
    rRect.Move(mRect.GetWidth() - 10 - rRect.mLeft, 0);
    res = false;
  }
  if (rRect.mRight < 10)
  {
    rRect.Move(10 - rRect.mRight, 0);
    res = false;
  }
  return res;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:27,代码来源:nuiWindowManager.cpp

示例3: GetScratchPad

void nuiGLDrawContext::BlurRect(const nuiRect& rRect, uint Strength)
{
  nuiRect Rect = rRect;
  if (mClippingRect.mEnabled)
    Rect.Intersect(mClippingRect,rRect);
  nuiRect size = Rect.Size();

  nuiTexture* pScratchPad = GetScratchPad(ToZero(size.GetWidth()), ToZero(size.GetHeight()));

  if (!pScratchPad)
    return;

  SetTexture(pScratchPad);

  glPushMatrix();
  glLoadIdentity();

  EnableBlending(true);
  EnableTexture2D(true);
  SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  do
  {
    glCopyTexSubImage2D(
      GL_TEXTURE_2D, 0, 
      0, 0, 
      ToZero(rRect.mLeft), ToZero(mHeight) - 1 - ToZero(rRect.mTop) - ToZero(rRect.GetHeight()), 
      ToZero(rRect.GetWidth()), ToZero(rRect.GetHeight())
      );

    SetFillColor(nuiColor(1,1,1,.15f));
    nuiRect rect = Rect;

    rect.Move(-1,-1);
    DrawImage(rect,size);
    rect.Move(1,0);
    DrawImage(rect,size);
    rect.Move(1,0);
    DrawImage(rect,size);

    rect.Move(-2,1);
    DrawImage(rect,size);
    rect.Move(1,0);
    DrawImage(rect,size);
    rect.Move(1,0);
    DrawImage(rect,size);

    rect.Move(-2,1);
    DrawImage(rect,size);
    rect.Move(0,1);
    DrawImage(rect,size);
    rect.Move(0,1);
    DrawImage(rect,size);
  } while ((long)(Strength--) > 0);

  EnableBlending(false);
  EnableTexture2D(false);

  glPopMatrix();
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:60,代码来源:nuiGLDrawContext.cpp

示例4: nuiPainter

nuiSoftwarePainter::nuiSoftwarePainter(const nuiRect& rRect, nglContext* pContext)
: nuiPainter(rRect, pContext)
{
  mWidth = ToNearest(rRect.GetWidth());
  mHeight = ToNearest(rRect.GetHeight());
  mpRasterizer = new nuiRasterizer(mWidth, mHeight);
  AddNeedTextureBackingStore();
}
开发者ID:jbl2024,项目名称:nui3,代码行数:8,代码来源:nuiSoftwarePainter.cpp

示例5: LoadProjectionMatrix

void nuiDrawContext::Set2DProjectionMatrix(const nuiRect& rRect)
{
  //printf("Set2DProjectionMatrix: %s\n", rRect.GetValue().GetChars());
  nuiMatrix m;
  m.Translate(-1.0f, 1.0f, 0.0f);
  m.Scale(2.0f/rRect.GetWidth(), -2.0f/rRect.GetHeight(), 1.0f);
  LoadProjectionMatrix(rRect, m);
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:8,代码来源:nuiDrawContext.cpp

示例6: GetTopLevel

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);
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例7: NGL_ASSERT

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());
}
开发者ID:,项目名称:,代码行数:54,代码来源:

示例8: LoadProjectionMatrix

void nuiMetaPainter::LoadProjectionMatrix(const nuiRect& rViewport, const nuiMatrix& rMatrix)
{
  StoreOpCode(eLoadProjectionMatrix);
  StoreFloat(rViewport.Left());
  StoreFloat(rViewport.Top());
  StoreFloat(rViewport.GetWidth());
  StoreFloat(rViewport.GetHeight());
  StoreBuffer(rMatrix.Array, sizeof(nuiSize), 16);  
  
  nuiPainter::LoadProjectionMatrix(rViewport, rMatrix);
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:11,代码来源:nuiMetaPainter.cpp

示例9: LoadProjectionMatrix

void nuiPainter::LoadProjectionMatrix(const nuiRect& rViewport, const nuiMatrix& rMatrix)
{
  NGL_ASSERT(!mProjectionMatrixStack.empty());
  mProjectionMatrixStack.top() = rMatrix;

  nuiMatrix LocalMatrix(mMatrixStack.top());
  nuiVector vec1(rViewport.Left(), rViewport.Top(), 0.0f);
  nuiVector vec2(rViewport.Right(), rViewport.Bottom(), 0.0f);
  vec1 = LocalMatrix * vec1;
  vec2 = LocalMatrix * vec2;
  mProjectionViewportStack.top().Set(vec1[0], vec1[1], vec2[0], vec2[1], false);
}
开发者ID:YetToCome,项目名称:nui3,代码行数:12,代码来源:nuiPainter.cpp

示例10: TextureToImageCoord

void nuiTexture::TextureToImageCoord(nuiRect& rRect) const
{
  nuiSize x, y, xx, yy;
  x = rRect.Left();
  y = rRect.Top();
  xx = rRect.Right();
  yy = rRect.Bottom();
  TextureToImageCoord(x, y);
  TextureToImageCoord(xx, yy);
  
  rRect.Set(x, y, xx, yy, false);
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:12,代码来源:nuiTexture.cpp

示例11: ClientToGlobalRect

void nuiDecoration::ClientToGlobalRect(nuiRect& rRect, const nuiWidget* pWidget) const
{
    nuiSize bordertop = GetBorder(nuiTop, pWidget);
    nuiSize borderleft = GetBorder(nuiLeft, pWidget);
    nuiSize borderright = GetBorder(nuiRight, pWidget);
    nuiSize borderbottom = GetBorder(nuiBottom, pWidget);

    rRect.Set(rRect.Left() - borderleft,
              rRect.Top() - bordertop,
              rRect.Right() + borderright,
              rRect.Bottom() + borderbottom,
              false);


}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例12: ResetStats

///////////////////////////////////
// nuiPainter implementation:
nuiPainter::nuiPainter(const nuiRect& rRect, nglContext* pContext) 
{
  ResetStats();
  mWidth = ToNearest(rRect.GetWidth());
  mHeight = ToNearest(rRect.GetHeight());
  mMatrixStack.push(nuiMatrix());
  mProjectionMatrixStack.push(nuiMatrix());
  mProjectionViewportStack.push(nuiRect());
  
  mDummyMode = false;
  mpSurface = NULL;

  mAngle=0;

  mEnableDrawArray = true;
}
开发者ID:YetToCome,项目名称:nui3,代码行数:18,代码来源:nuiPainter.cpp

示例13:

/****************************************************************************
 *
 * Constructor / Destructor
 *
 ****************************************************************************/
nuiDrawContext::nuiDrawContext(const nuiRect& rRect)
{
  mWidth = rRect.GetWidth();
  mHeight = rRect.GetHeight();

  mClipOffsetX = mClipOffsetY = 0;

  mPermitAntialising = true;

  mpPainter = NULL;
  mpMainPainter = NULL;
  mpSavedPainter = NULL;
  mpAATexture = nuiTexture::GetAATexture();
  
  mStateChanges = 1;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:21,代码来源:nuiDrawContext.cpp

示例14: SetRect

bool nuiStateDummy::SetRect(const nuiRect& rRect)
{
  nuiWidget::SetRect(rRect);
  nuiWidgetPtr pWidget = mpState[(IsEnabled(mCombined)?1:0) + (IsSelected(mCombined)?2:0)];
  if (pWidget)
    pWidget->SetLayout(rRect.Size());
  return true;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:8,代码来源:nuiStateDummy.cpp

示例15: ideal

bool nuiLabel::SetRect(const nuiRect& rRect)
{
  bool needRecalcLayout = false;

  if (mUseEllipsis || mWrapping)
    needRecalcLayout = (rRect.GetWidth() != mRect.GetWidth());
    
  nuiWidget::SetRect(rRect);

  nuiRect ideal(mIdealLayoutRect);


  if (needRecalcLayout || ideal.GetWidth() > mRect.GetWidth())
  {
    if (mUseEllipsis)
    {
      CalcLayout();
      nuiSize diff = ideal.GetWidth() - mRect.GetWidth();
      int NbLetterToRemove = ToNearest(diff / (ideal.GetWidth() / mText.GetLength())) + 3;
      nglString text = mText;
      if (NbLetterToRemove > 0)
      {
        int len = text.GetLength();
        text.DeleteRight(MIN(NbLetterToRemove, len));
        text.Append(_T("..."));
      }
      delete mpLayout;
      mpLayout = new nuiTextLayout(mpFont);
      mpLayout->SetWrapX(0);
      mpLayout->Layout(text);
      GetLayoutRect();
    }
    else if (mWrapping)
    {
      CalcLayout();
      delete mpLayout;
      mpLayout = new nuiTextLayout(mpFont);
      delete mpIdealLayout;
      mpIdealLayout = new nuiTextLayout(mpFont);
      mpLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight);
      mpIdealLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight);
      mpLayout->Layout(mText);
      mpIdealLayout->Layout(mText);
      GetLayoutRect();
    }

    SetToolTip(mText);
  }
  else
  {
    if (GetToolTip() == mText)
      SetToolTip(nglString::Empty);
  }

  return true;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:56,代码来源:nuiLabel.cpp


注:本文中的nuiRect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。