Пример #1
0
nuiWidget* nuiColorSelector::Tab_HSV()
{
  float h, s, v;
  mCurrentColor.GetHSV(h, s, v);
  nuiSize alpha = mCurrentColor.Alpha();
  
  mpHsvGrid = new nuiGrid(3, 4);
  mpHsvGrid->SetBorder(0,0,10,10);
  
  nuiPane* pPane = new nuiPane(nuiColor(1.f, 1.f, 1.f, 1.f), nuiColor(0.f, 0.f, 0.f, 1.f), eStrokeShape);
  nuiLabel* pLabel = new nuiLabel(_T("HSV"));
  pLabel->SetBorder(2.f, 1.f);
  pPane->AddChild(pLabel);
  
  mpHsvGrid->SetCell(0, 0, new nuiLabel(_T("h:")));
  mpHsvGrid->SetCell(0, 1, new nuiLabel(_T("s:")));
  mpHsvGrid->SetCell(0, 2, new nuiLabel(_T("v:")));
  mpHsvGrid->SetCell(0, 3, new nuiLabel(_T("a:")));
  
  mpHueSlider = new nuiSlider(nuiHorizontal, nuiRange(h, 0.f, 1.f));
  mpHsvGrid->SetCell(1, 0, mpHueSlider);
  mSink.Connect(mpHueSlider->InteractiveValueChanged, &nuiColorSelector::HSVSliderChanged);
  mSink.Connect(mpHueSlider->ValueChanged, &nuiColorSelector::HSVSliderChanged);
  
  mpSaturationSlider = new nuiSlider(nuiHorizontal, nuiRange(s, 0.f, 1.f));
  mpHsvGrid->SetCell(1, 1, mpSaturationSlider);
  mSink.Connect(mpSaturationSlider->InteractiveValueChanged, &nuiColorSelector::HSVSliderChanged);
  mSink.Connect(mpSaturationSlider->ValueChanged, &nuiColorSelector::HSVSliderChanged);
  
  mpValueSlider = new nuiSlider(nuiHorizontal, nuiRange(v, 0.f, 1.f));
  mpHsvGrid->SetCell(1, 2, mpValueSlider);
  mSink.Connect(mpValueSlider->InteractiveValueChanged, &nuiColorSelector::HSVSliderChanged);
  mSink.Connect(mpValueSlider->ValueChanged, &nuiColorSelector::HSVSliderChanged);
  //
  mpHSVAlphaSlider = new nuiSlider(nuiHorizontal, nuiRange(alpha, 0.f, 1.f));
  mpHsvGrid->SetCell(1, 3, mpHSVAlphaSlider);
  mSink.Connect(mpHSVAlphaSlider->InteractiveValueChanged, &nuiColorSelector::HSVSliderChanged);
  mSink.Connect(mpHSVAlphaSlider->ValueChanged, &nuiColorSelector::HSVSliderChanged);
  
  mpHsvGrid->SetColumnPixels(2, 25);
  
  mpHueSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8));
  FormatColor(h, mpHueSliderLabel, 100, false);
  mpHsvGrid->SetCell(2, 0, mpHueSliderLabel, nuiRight);
  
  mpSaturationSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8));
  FormatColor(s, mpSaturationSliderLabel, 100, false);
  mpHsvGrid->SetCell(2, 1, mpSaturationSliderLabel, nuiRight);
  
  mpValueSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8));
  FormatColor(v, mpValueSliderLabel, 100, false);
  mpHsvGrid->SetCell(2, 2, mpValueSliderLabel, nuiRight);
  
  mpHSVAlphaSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8));
  FormatColor(alpha, mpHSVAlphaSliderLabel, 100, false);
  mpHsvGrid->SetCell(2, 3, mpHSVAlphaSliderLabel, nuiRight);
  
  
  return mpHsvGrid;
}
Пример #2
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;
}
Пример #3
0
void nuiLabel::InitDefaultValues()
{
  //EnableSurface(true);
  //SetSurfaceBlendFunc(nuiBlendTop); // This is needed to handle text blending corectly for now.

  mUnderline = false;
  mStrikeThrough = false;
  
  mTextChanged = false;
  mFontChanged = true;
  mOrientation = nuiHorizontal;
  mTextLayoutMode = nuiTextLayoutLeft;

  mpLayout = NULL;
  mpIdealLayout = NULL;
  mpFont = NULL;
  
  mBackColor = nuiColor(255, 255, 255, 0);
  mTextColor = nuiColor(0, 0, 0, 255);

  mUseEllipsis = false;
  mClearBg = false;
  mTextPosition = nuiLeft;
  
  mVMargin = NUI_LABEL_VMARGIN;
  mHMargin = NUI_LABEL_HMARGIN;
  mWrapping = false;
}
Пример #4
0
///////////class nuiHTMLContext
nuiHTMLContext::nuiHTMLContext()
{
  mMaxWidth = 640;
  
  mVSpace = 0;
  
  mFont.SetName(_T("arial"), 0.8f);
  mFont.SetGenericName(_T("sans-serif"), 0.8f);
  mFont.SetStyle(_T("regular"), 0.5f);
  mFont.SetProportionnal(1.0f);
  
  mFont.SetScalable(1.0f);
  mFont.MustHaveSize(12.0f, 1.0f);
  mFont.SetItalic(false, 1.0f);
  mFont.SetBold(false, 1.0f);
  mpFont = NULL;
  mUnderline = false;
  mStrikeThrough = false;
  mTextFgColor = nuiColor(0,0,0,255);
  mTextBgColor = nuiColor(0,0,0,0);
  mLinkColor = nuiColor(64, 64, 200);

  mAlignHorizontal = eBegin;
  mAlignVertical = eBegin;
  
  UpdateFont();
}
Пример #5
0
void FrameEditor::UpdateFrameViews(bool CopyImageRect)
{
  nuiFixed* pFixed = new nuiFixed();
  mpFrameViewHolder->AddChild(pFixed);
  mpFrameView = new nuiFrameView(mpFrame);
  mpFrameView->AddChild(new nuiLabel(_T("This frame should\nlook nice at any size."), nuiFont::GetFont(20)));
  pFixed->AddChild(mpFrameView);
  
  nuiRectView* pFrameRectView = new nuiRectView(mpFrameView->GetIdealRect());
  mSlotSink.Connect(pFrameRectView->RectChanged, nuiMakeDelegate(this, &FrameEditor::OnFrameViewRectChanged));
	mEventSink.Connect(pFrameRectView->MovedMouse, &FrameEditor::OnFrameMouseMoved);
	pFrameRectView->EnableMouseEvent(true);

  pFrameRectView->SetColor(eShapeStroke, nuiColor(_T("blue")));
  mpFrameViewHolder->AddChild(pFrameRectView);
  
  nuiTexture* pTexture = mpFrame->GetTexture();
	mpImage = new nuiImage(pTexture);
  mpImage->SetPosition(nuiTopLeft);
  mpPictureHolder->AddChild(mpImage);

  if (CopyImageRect)
    mpFrame->SetSourceClientRect(nuiRect(0, 0, pTexture->GetImage()->GetWidth(), pTexture->GetImage()->GetHeight()));
  
  nuiRectView* pRectView = new nuiRectView(mpFrame->GetSourceClientRect());
  mSlotSink.Connect(pRectView->RectChanged, nuiMakeDelegate(this, &FrameEditor::OnFrameRectChanged));
	mEventSink.Connect(pRectView->MovedMouse, &FrameEditor::OnFrameMouseMoved);
	pRectView->EnableMouseEvent(true);
  pRectView->SetColor(eShapeStroke, nuiColor(_T("red")));
  mpPictureHolder->AddChild(pRectView);

  mAttributeScale.Set(mScale);
	
	
	// load attributes editors in inspector	
	mAttributeRect = nuiAttrib<const nuiRect&>(mpFrame->GetAttribute(_T("ClientRect")));
	mAttributeColor = nuiAttrib<const nuiColor&>(mpFrame->GetAttribute(_T("Color")));
	
	
	std::list<nuiAttribBase> attributes;

	attributes.push_back(GetMainWindow()->mAttributeMouseCoord);
	attributes.push_back(mAttributeScale);
	
	ToolPaneAttributes* pTPA = new ToolPaneAttributes(_T("Information"), attributes);
	mpInspector->AddToolpane(pTPA);

	attributes.clear();
	attributes.push_back(mAttributeRect);
	attributes.push_back(mAttributeColor);

	ToolPaneAttributes* pTPA2 = new ToolPaneAttributes(_T("Frame"), attributes);
	mpInspector->AddToolpane(pTPA2);
	
	
	// connect color change signal
	mSlotSink.Connect(mAttributeColor.GetChangedSignal(), nuiMakeDelegate(this, &FrameEditor::OnColorChanged));

}
Пример #6
0
nuiColorDecoration::nuiColorDecoration(const nglString& rName)
: nuiDecoration(rName)
{
  if (SetObjectClass(_T("nuiColorDecoration")))
    InitAttributes();

  mStrokeSize = 0;
  mFillColor = nuiColor(0,0,0);
  mStrokeColor = nuiColor(0,0,0);
  mShapeMode = eFillShape;
  mBlendFunc = nuiBlendTransp;
  mClientRect = nuiRect(0,0,0,0);
}
Пример #7
0
bool nuiSeparator::Draw(nuiDrawContext *pContext)
{
    nuiRect r(GetRect());

    // TODO : vertical draw

    pContext->SetStrokeColor(nuiColor(255, 255, 255));
    pContext->DrawLine(r.Left(), 0, r.Right(), 0);

    pContext->SetStrokeColor(nuiColor(0, 0, 0, 56));
    pContext->DrawLine(r.Left(), 1.5, r.Right(), 1.5);

    return true;
}
Пример #8
0
//**************************************************************************************************************
//
// 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));
  
}
Пример #9
0
void nuiColorSelector::MakeSwatchGrid()
{
  if (mpSwatchGrid)
    mpSwatchGrid->Trash();
  
  mpSwatchGrid = new nuiGrid(5, 0);
  mpSwatchGrid->SetBorder(0,0,10,10);
  
  std::vector<nuiColor>::const_iterator end = mColorList.end();
  uint i = 0;
  for (std::vector<nuiColor>::const_iterator it = mColorList.begin(); it != end; ++it, i++)
  {
    mpSwatchGrid->AddRows(i, 1);
    nuiPane* pSwatchPane;
    pSwatchPane = new nuiPane(*it, nuiColor(32,32,32));
    nuiButton* pButton = new nuiButton();
    pButton->SetUserSize(16,16);
    pButton->SetBorder(2,2);
    pButton->AddChild(pSwatchPane);
    
    pButton->EnableDecoration(false);
    
    
    mSink.Connect(pButton->Clicked, &nuiColorSelector::SwatchSelected, pSwatchPane);
    mpSwatchGrid->SetCell(i%5, i/5, pButton, nuiCenter);
  }
}
Пример #10
0
nuiColor nuiFileTree::GetHandleColor()
{
  if (!mpTreeView)
    return nuiColor(0,0,0);
  
  return mpTreeView->GetHandleColor();
}
Пример #11
0
bool nuiHugeImage::Draw(nuiDrawContext* pContext)
{
  pContext->Translate(mRect.GetWidth()/2, mRect.GetHeight()/2, 0.0f);
  pContext->Scale(mZoom, mZoom, 1.0f);
  pContext->Translate(-mX, -mY, 0.0f);
  pContext->EnableTexturing(true);
  pContext->SetFillColor(nuiColor(255, 255, 255));
  
  for (int32 i = 0; i < mTextures.size(); i++)
  {
    for (int32 j = 0; j < mTextures[i].size(); j++)
    {
      nuiTexture* pTexture = mTextures[i][j];
      if (pTexture)
      {
        int32 x = i * TEXTURE_SIZE;
        int32 y = j * TEXTURE_SIZE;
        int32 w = pTexture->GetWidth();
        int32 h = pTexture->GetHeight();
        nuiRect src(w, h);
        nuiRect dest(x, y, w, h);
        //NGL_OUT(_T("%d x %d - %s\n"), i, j, dest.GetValue().GetChars());
        pContext->SetTexture(pTexture);
        pContext->DrawImage(dest, src);
      }
    }
  }

  return true;
}
Пример #12
0
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();
}
Пример #13
0
FrameEditor::FrameEditor(ElementDesc* pDesc, ElementInspector* pInspector)
: mEventSink(this)
{
	InitAttributes();
	
  mpFrame = NULL;
  mpDesc = pDesc;
	mpInspector = pInspector;
  mpFrameView = NULL;

  
  mEventSink.Connect(mpDesc->CommitChanges, &FrameEditor::OnCommitChanges);

  nuiVBox* pBox = new nuiVBox();
  pBox->SetExpand(nuiExpandShrinkAndGrow);
  AddChild(pBox);
  pBox->AddCell(new nuiSeparator(nuiHorizontal));
  
  nglString str;
  str.Add(_T("nuiFrame editor (")).Add(pDesc->GetName()).Add(_T(")"));
  nuiLabel* pLabel = new nuiLabel(str, nuiFont::GetFont(24));
  pLabel->SetTextColor(nuiColor(_T("lightgray")));
  pBox->AddCell(pLabel, nuiCenter);
  pBox->AddCell(new nuiSeparator(nuiHorizontal));
  
  nuiSplitter* pSplitter = new nuiSplitter(nuiHorizontal, eModePixel);
  pSplitter->SetMasterChild(false);

  pBox->AddCell(pSplitter);
  pBox->SetCellExpand(pBox->GetNbCells()-1, nuiExpandShrinkAndGrow);

  pSplitter->SetHandlePos(200);

  // Frame view:
  mpPictureHolder = new nuiSimpleContainer();
  nuiScrollView* pScrollView = new nuiScrollView();
  pScrollView->AddChild(mpPictureHolder);
  pSplitter->AddChild(pScrollView);
  
  mpFrameViewHolder = new nuiScrollView();
  pSplitter->AddChild(mpFrameViewHolder);
  
  const nuiXMLNode* pNode = mpDesc->GetXML();
  if (pNode)
  {
    mpFrame = new nuiFrame(pDesc->GetName());
    if (mpFrame->Load(pNode))
    {
      UpdateFrameViews(false);
    } 
  }

  if (!mpFrame)
  {
    mpFrameViewHolder->AddChild(new nuiLabel(_T("Drop an image file here...")));
  }
  
  mDrawDndFrame = false;
}
Пример #14
0
ToolPane::ToolPane(nuiLabelAttribute* rLabel, nuiWidget* pWidget)
    : nuiFolderPane(rLabel, true/*opened*/)
{
    GetTitle()->SetObjectName(_T("Toolpane::Title"));
    GetTitle()->SetColor(eNormalTextFg, nuiColor(255,255,255));
    if (pWidget)
        SetContents(pWidget);
}
Пример #15
0
nuiReflection::nuiReflection(float Intensity, float Center)
{
  mColor = nuiColor(1.f,1.f,1.f, Intensity);
  mCenter = Center;
  mpSkyGradient = NULL;
  mpGroundGradient = NULL;
  mRecalc = true;
}
Пример #16
0
nuiWidget* MainWindow::Tutorial_Buttons()
{
  NGL_OUT("MainWindow::Tutorial_Buttons");
  nuiHBox* pBox = new nuiHBox(0);
  //pBox->EnableSurface(true);
  
  // a simple button
  nuiButton* pBtn = new nuiButton(_T("button"));
  pBtn->SetObjectName(_T("MyButton"));
  mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON1);
  pBox->AddCell(pBtn, nuiCenter);

  // a simple button filling the box's cell
  pBtn = new nuiButton(_T("button"));
  pBtn->SetObjectName(_T("MyButton"));
  pBox->AddCell(pBtn, nuiFill);
  mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON2);


  // a button with an image
  nglImage pImg(_T("rsrc:/decorations/button1.png"));
  pBtn = new nuiButton(pImg);
  pBtn->SetObjectName(_T("MyButton"));
  pBox->AddCell(pBtn);
  mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON3);


  // a roll-over button using decorations
  nuiGradientDecoration* pDecoUp = new nuiGradientDecoration(_T("DecoUp"), nuiColor(192,192,192), nuiColor(128,128,128), 1, nuiColor(0,0,0), eStrokeAndFillShape);
  nuiColorDecoration* pDecoUpHover = new nuiColorDecoration(_T("DecoUpHover"), nuiColor(255,0,0,128), 1, nuiColor(0,0,0));
  nuiFrame* pFrame = new nuiFrame(_T("DecoDown"), _T("rsrc:/decorations/button1.png"), nuiRect(0,0,57,54));

  // create a nuiStateDecoration using the three previous decorations for the rollover's three states : up, hover and done
  nuiStateDecoration* pStateDeco = new nuiStateDecoration(_T("Deco"), _T("DecoUp"), _T("DecoDown"), _T("DecoUpHover"));

  pBtn = new nuiButton(pStateDeco);
  pBtn->SetObjectName(_T("MyButton"));
  pBtn->SetUserSize(40,40);
  pBox->AddCell(pBtn, nuiCenter);
  mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON4);


  NGL_OUT("MainWindow::Tutorial_Buttons ok");
  return pBox;
}
Пример #17
0
nuiHyperLink::nuiHyperLink()
: nuiLabel(_T("")),
mURL(_T(""))
{
  if (SetObjectClass(_T("nuiHyperLink")))
    InitAttributes();

  SetTextColor(nuiColor(_T("nuiHyperLink")));
}
Пример #18
0
nuiHyperLink::nuiHyperLink(const nglString& rURL, const nglString& rLabel)
  : nuiLabel(rLabel.IsNull() ? rURL : rLabel),
    mURL(rURL)
{
  if (SetObjectClass(_T("nuiHyperLink")))
    InitAttributes();
    
  SetTextColor(nuiColor(_T("nuiHyperLink")));
}
Пример #19
0
void nuiDefaultDecoration::FileSelector_TreeView(nuiWidget* pWidget)
{
  nuiColorDecoration* pDeco = (nuiColorDecoration*)nuiDecoration::Get(_T("nuiDefaultDecorationFileSelectorWindow"));
  if (!pDeco)
  {
    pDeco = new nuiColorDecoration(_T("nuiDefaultDecorationFileSelectorWindow"), nuiColor(250,250,250), 1, nuiColor(175,175,175), eStrokeAndFillShape);
  }
  pWidget->SetDecoration(pDeco, eDecorationBorder);  
  
}
Пример #20
0
ToolPane::ToolPane(const nglString& rTitle, nuiWidget* pWidget)
    : nuiFolderPane(rTitle, true/*opened*/)
{
    nglString title = rTitle;
    nuiLabel* pLabel = new nuiLabel(title.ToUpper(), nuiFont::GetFont(11));
    pLabel->SetObjectName(_T("Toolpane::Title"));
    pLabel->SetColor(eNormalTextFg, nuiColor(255,255,255));
    SetTitle(pLabel);
    if (pWidget)
        SetContents(pWidget);
}
Пример #21
0
nuiFrame::nuiFrame(const nglString& rName)
: nuiDecoration(rName),
  mpTexture(NULL)
{
  if (SetObjectClass(_T("nuiFrame")))
    InitAttributes();
  mColor = nuiColor(255,255,255);
  mUseWidgetFrameColor = false;
  mDebug = false;
  mInterpolated = true;
}
Пример #22
0
const nuiColor nuiGradient::GetColorAt(nuiSize position) const
{
  if (mStops.size() == 0)
  {
    return nuiColor(0.f, 0.f, 0.f);
  }
  
  nuiGradientStopList::const_iterator stopIt = mStops.begin();
  nuiGradientStopList::const_iterator stopEnd = mStops.end();
  if (position <= (*stopIt).first)
  {
    return (*stopIt).second;
  }
  
  bool found = false;
  nuiGradientPair leftStop;
  for (; stopIt != stopEnd && !found; ++stopIt)
  {
    if (position > (*stopIt).first)
    {
      found = true;
      leftStop = *stopIt;
    }
  }
  
    if (stopIt == stopEnd)
    {
      return leftStop.second;
    }
    else
    {
      nuiGradientPair rightStop = *stopIt;
      float ratio = (position - leftStop.first) / (rightStop.first - leftStop.first);
      float red = ((rightStop.second.Red() - leftStop.second.Red()) * ratio) + leftStop.second.Red();
      float green = ((rightStop.second.Green() - leftStop.second.Green()) * ratio) + leftStop.second.Green();
      float blue = ((rightStop.second.Blue() - leftStop.second.Blue()) * ratio) + leftStop.second.Blue();
      float alpha = ((rightStop.second.Alpha() - leftStop.second.Alpha()) * ratio) + leftStop.second.Alpha();
      return nuiColor(red, green, blue, alpha);
    }
}
Пример #23
0
void  render_handler_nui::draw_bitmap(
                                      const gameswf::matrix& m,
                                      const gameswf::bitmap_info* bi,
                                      const gameswf::rect& coords,
                                      const gameswf::rect& uv_coords,
                                      gameswf::rgba color)
                                      // Draw a rectangle textured with the given bitmap, with the
                                      // given color.   Apply given transform; ignore any currently
                                      // set transforms.
                                      //
                                      // Intended for textured glyph rendering.
{
  assert(bi);
  const bitmap_info_nui* pbi = (bitmap_info_nui*)bi;

  apply_color(color);

  gameswf::point a, b, c, d;
  m.transform(&a, gameswf::point(coords.m_x_min, coords.m_y_min));
  m.transform(&b, gameswf::point(coords.m_x_max, coords.m_y_min));
  m.transform(&c, gameswf::point(coords.m_x_min, coords.m_y_max));
  d.m_x = b.m_x + c.m_x - a.m_x;
  d.m_y = b.m_y + c.m_y - a.m_y;

  mpContext->SetFillColor(nuiColor(color.m_r, color.m_g, color.m_b, color.m_a));
  mpContext->SetCurrentTexture(pbi->mpTexture);
  mpContext->EnableTexturing(true);
  nuiRect src(uv_coords.m_x_min, uv_coords.m_y_min, uv_coords.m_x_max, uv_coords.m_y_max, false);
  mpContext->DrawImageQuad(a.m_x, a.m_y, b.m_x, b.m_y, c.m_x, c.m_y, d.m_x, d.m_y, src);
/*
  glBindTexture(GL_TEXTURE_2D, bi->m_texture_id);
  glEnable(GL_TEXTURE_2D);
  glDisable(GL_TEXTURE_GEN_S);
  glDisable(GL_TEXTURE_GEN_T);

  glBegin(GL_TRIANGLE_STRIP);

  glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_min);
  glVertex2f(a.m_x, a.m_y);

  glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_min);
  glVertex2f(b.m_x, b.m_y);

  glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_max);
  glVertex2f(c.m_x, c.m_y);

  glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_max);
  glVertex2f(d.m_x, d.m_y);

  glEnd();
*/
}
Пример #24
0
void nuiColorSelector::RGBSliderChanged(const nuiEvent& rEvent)
{
  nuiSize red = (float)mpRedSlider->GetRange().GetValue();
  nuiSize green = (float)mpGreenSlider->GetRange().GetValue();
  nuiSize blue = (float)mpBlueSlider->GetRange().GetValue();
  nuiSize alpha = (float)mpRGBAlphaSlider->GetRange().GetValue();
  
  SetCurrentColor(nuiColor(red, green, blue, alpha));
  
  // send event
  RGBColorChanged();
  
  rEvent.Cancel();
}
Пример #25
0
void nuiHTMLImage::Draw(nuiDrawContext* pContext)
{
    if (!mVisible)
        return;
    if (!mpTexture || !mpTexture->IsValid())
        return;

    //NGL_OUT(_T("nuiHTMLImage::Draw %s\n"), mpTexture->GetObjectName().GetChars());
    pContext->PushState();
    pContext->SetTexture(mpTexture);
    pContext->SetFillColor(nuiColor(255, 255, 255));
    pContext->DrawImage(mIdealRect.Size(), nuiRect((float)mpTexture->GetWidth(), (float)mpTexture->GetHeight()));
    pContext->PopState();
}
Пример #26
0
void  render_handler_nui::begin_display(gameswf::rgba background_color, int viewport_x0, int viewport_y0, int viewport_width, int viewport_height, float x0, float x1, float y0, float y1)
// Set up to render a full frame from a movie and fills the
// background.  Sets up necessary transforms, to scale the
// movie to fit within the given dimensions.  Call
// end_display() when you're done.
//
// The rectangle (viewport_x0, viewport_y0, viewport_x0 +
// viewport_width, viewport_y0 + viewport_height) defines the
// window coordinates taken up by the movie.
//
// The rectangle (x0, y0, x1, y1) defines the pixel
// coordinates of the movie that correspond to the viewport
// bounds.
{
  // Thomas >> - viewport needs to be commented out to work nice with TGE and we manipulate the ortho too
  //glViewport(viewport_x0, viewport_y0, viewport_width, viewport_height);
  /*
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glOrtho(x0, x1, y1, y0, 0, 1);      
  */
  // << Thomas
  mpContext->PushState();
  mpContext->PushClipping();
  mpContext->EnableBlending(true);
  mpContext->SetBlendFunc(nuiBlendTransp);

//  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);  // GL_MODULATE

//  glDisable(GL_TEXTURE_2D);

  // Clear the background, if background color has alpha > 0.
  if (background_color.m_a > 0)
  {
    // Draw a big quad.
/*
    apply_color(background_color);
    glBegin(GL_QUADS);
    glVertex2f(x0, y0);
    glVertex2f(x1, y0);
    glVertex2f(x1, y1);
    glVertex2f(x0, y1);
    glEnd();
*/
    mpContext->SetFillColor(nuiColor(background_color.m_r, background_color.m_g, background_color.m_b, background_color.m_a));
    mpContext->DrawRect(nuiRect(0.0f, 0.0f, x1-x0, y1-y0), eFillShape);
  }
}
Пример #27
0
// virtual, overloaded from nuiWidget, to be able to draw the oscillo manually
bool guiOscillo::Draw(nuiDrawContext* pContext)
{
 if (mrData.empty())
    return false;
  
  const nuiRect& rect = GetRect();
  
  uint32 s1 = mrData[0].size();
  uint32 s2 = rect.GetWidth();
  uint32 count = MIN(s1, s2);
  nuiSize hi = rect.GetHeight();
  nuiSize mid = hi / 2;

  nuiColor color[2];
  color[0] = nuiColor(84,117,203);
  color[1] = nuiColor(200,0,0);
  
  for (uint32 c = 0; c < mrData.size(); c++)
  {
    
    nuiRenderArray* pArray = new nuiRenderArray(GL_LINE_STRIP);
    pArray->EnableArray(nuiRenderArray::eColor, true);
    
    pArray->SetColor(color[c]);
    for (uint32 s = 0; s < count; s++)
    {
      float value = mrData[c][s];
      pArray->SetVertex(s, mid + hi * value);
      pArray->PushVertex();
    }
    
    pContext->DrawArray(pArray);
  }
  
  return true;
}
Пример #28
0
bool FrameEditor::Draw(nuiDrawContext* pContext)
{
  if (mDrawDndFrame)
  {
    nuiRect r(GetRect().Size());
    r.Grow(-2, -2);
    nuiShape shp;
    shp.AddRect(r);
    pContext->SetLineWidth(4);
    pContext->SetStrokeColor(nuiColor(230, 230, 255));
    pContext->DrawShape(&shp, eStrokeShape);
  }

  nuiSimpleContainer::Draw(pContext);
  return true;
}
Пример #29
0
void nuiReflection::Recalc()
{
  float x = mRect.Left();
  float y = mRect.Top();
  float w = mRect.GetWidth();
  float h = mRect.GetHeight();
  float h_2 = h * mCenter;

  mRecalc = false;

  delete mpSkyGradient;
  delete mpGroundGradient;
  mpSkyGradient = new nuiGradient();

  nuiColor tmp;
  
  // Sky:
  tmp = mColor;
  float alpha = mColor.Alpha();
  tmp.SetOpacity(alpha * .2f);
  tmp.Crop();
  mpSkyGradient->AddStop(tmp, 0); 

  mpSkyGradient->AddStop(nuiColor(1.f,1.f,1.f, alpha), 0.1f); 

  tmp.SetOpacity(alpha * .6f);
  tmp.Crop();
  mpSkyGradient->AddStop(tmp, .4f); 

  tmp.SetOpacity(alpha * .4f);
  tmp.Crop();
  mpSkyGradient->AddStop(tmp, 1); 

  // Ground:
  mpGroundGradient = new nuiGradient();
  tmp.SetOpacity(alpha * .1f);
  tmp.Crop();
  mpGroundGradient->AddStop(tmp, 0); 

  tmp.SetOpacity(alpha * .4f);
  tmp.Crop();
  mpGroundGradient->AddStop(tmp, .8f); 

  tmp.SetOpacity(alpha *.6f);
  tmp.Crop();
  mpGroundGradient->AddStop(tmp, 1); 
}
Пример #30
0
void nuiTextureInspector::UpdateTextures()
{
  Clear();
  
  nuiSplitter* pSplitter = new nuiSplitter(nuiVertical);
  AddChild(pSplitter);
  nuiSplitter* pSplit = new nuiSplitter(nuiHorizontal);
  pSplitter->AddChild(pSplit);
  pSplit->SetMasterChild(false);
  
  nuiScrollView* pScrollView1 = new nuiScrollView(false, true);
  nuiScrollView* pScrollView2 = new nuiScrollView(false, true);
  pSplit->AddChild(pScrollView1);
  pSplit->AddChild(pScrollView2);
  
  nuiList* pList = new nuiList();
  pScrollView1->AddChild(pList);
  
  const nuiTextureMap& rMap(nuiTexture::Enum());
  nuiTextureMap::const_iterator it = rMap.begin();
  nuiTextureMap::const_iterator end = rMap.end();
  while (it != end)
  {
    nglString name(it->first);
    nuiLabel* pLabel = new nuiLabel(name);
    pLabel->SetProperty(_T("Texture"), name);
    pList->AddChild(pLabel);
    ++it;
  }
  
  /// Attribute list
  mpAttributeGrid = new nuiGrid(2, 0);
  mpAttributeGrid->DisplayGridBorder(true, 1.0f);
  mpAttributeGrid->SetColumnExpand(1, nuiExpandShrinkAndGrow);
  
  pScrollView2->AddChild(mpAttributeGrid);

  nuiSimpleContainer* pCont = new nuiSimpleContainer();
  nuiColorDecoration* pColDec = new nuiColorDecoration(_T("TextureInspectorBg"), nuiColor(128, 128, 128), 0, nuiColor(0, 0, 0), eFillShape, nuiBlendTransp, nuiRect(0,0,0,0));
  pCont->SetDecoration(pColDec);
  pSplitter->AddChild(pCont);
  mpImage = new nuiImage();
  mpImage->SetPosition(nuiCenter);
  pCont->AddChild(mpImage);
  
  mSink.Connect(pList->SelectionChanged, &nuiTextureInspector::OnTextureSelection, (void*)pList);
}