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; }
void FrameEditor::InitAttributes() { mScale = 4.0f; mpAttributeScale = new nuiAttribute<float> (nglString(_T("Zoom")), nuiUnitPercent, nuiAttribute<float>::GetterDelegate(this, &FrameEditor::GetScale), nuiAttribute<float>::SetterDelegate(this, &FrameEditor::SetScale), nuiRange(4.0f, 1.0f, 8.0f, 1.0f, 0.0f, 0.0f)); mAttributeScale = nuiAttrib<float>(this, mpAttributeScale); }
//class nuiFontBrowser : public nuiSimpleContainer nuiFontBrowser::nuiFontBrowser() : mSink(this) { SetObjectClass(_T("nuiFontBrowser")); mFontSize = 14; mpFontDesc = NULL; SetPosition(nuiFill); nuiSplitter* pBox = new nuiSplitter(nuiHorizontal); AddChild(pBox); pBox->SetObjectName(_T("nuiFontBrowser_MainBox")); //pBox->SetExpand(nuiExpandShrinkAndGrow); nuiHBox* pPreview = new nuiHBox(); pBox->AddChild(pPreview); nuiScrollView* pScroll = new nuiScrollView(); pScroll->SetObjectName(_T("nuiFontBrowser_PreviewScroller")); mpPreviewLabel = new nuiLabel(_T("ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n01234567890!@#$%^&*(){}[]\\|/?<>,.:")); mpPreviewLabel->SetFont(nuiFont::GetFont(mFontSize)); mpPreviewLabel->SetPosition(nuiCenter); pScroll->AddChild(mpPreviewLabel); pPreview->AddCell(pScroll); pPreview->SetExpand(nuiExpandShrinkAndGrow); nuiVBox* pSizeBox = new nuiVBox(); pSizeBox->SetExpand(nuiExpandShrinkAndGrow); mpSizeSlider = new nuiSlider(nuiVertical, nuiRange(mFontSize, 1, 100)); pSizeBox->AddCell(mpSizeSlider); nglString str; str.SetCUInt(mFontSize); mpSizeLabel = new nuiLabel(str); pSizeBox->AddCell(mpSizeLabel); pSizeBox->SetCellExpand(0, nuiExpandShrinkAndGrow); pSizeBox->SetCellExpand(1, nuiExpandFixed); mpSizeLabel->SetPosition(nuiFillHorizontal); mpSizeSlider->SetPosition(nuiFill); pPreview->AddCell(pSizeBox); pPreview->SetCellExpand(0, nuiExpandShrinkAndGrow); pPreview->SetCellExpand(1, nuiExpandFixed); uint32 width = 25; pPreview->SetCellMinPixels(1, width); pPreview->SetCellMaxPixels(1, width); nuiFontManager& rManager = nuiFontManager::GetManager(); std::vector<nuiFontDesc*> FontList; rManager.GetFonts(FontList); { /// Build the font desc maps std::vector<nuiFontDesc*>::iterator it = FontList.begin(); std::vector<nuiFontDesc*>::iterator end = FontList.end(); while (it != end) { nuiFontDesc* pDesc = *it; mFonts[pDesc->GetName()][pDesc->GetStyle()] = pDesc;; ++it; } } nuiHBox* pHBox = new nuiHBox(); nuiScrollView* pLeftScroll = new nuiScrollView(); nuiScrollView* pRightScroll = new nuiScrollView(); pHBox->AddCell(pLeftScroll); pHBox->AddCell(pRightScroll); mpFontList = new nuiList(); mpStyleList = new nuiList(); pLeftScroll->AddChild(mpFontList); pRightScroll->AddChild(mpStyleList); pBox->AddChild(pHBox); pHBox->SetExpand(nuiExpandShrinkAndGrow); { FontMap::const_iterator it = mFonts.begin(); FontMap::const_iterator end = mFonts.end(); while (it != end) { nuiLabel* pLabel = new nuiLabel(it->first); pLabel->SetProperty(_T("FontName"), it->first); mpFontList->AddChild(pLabel); ++it; } } mSink.Connect(mpFontList->SelectionChanged, &nuiFontBrowser::OnFontChanged); mSink.Connect(mpStyleList->SelectionChanged, &nuiFontBrowser::OnStyleChanged); mSink.Connect(mpSizeSlider->ValueChanged, &nuiFontBrowser::OnStyleChanged); mSink.Connect(mpSizeSlider->InteractiveValueChanged, &nuiFontBrowser::OnStyleChanged); mpFontList->SelectItem((uint)0); }
nuiAttributeEditor* CreateEditor(void* pObj, nuiAttribute<float>* pAttrib) { return new nuiClampedValueAttributeEditor<float>(nuiAttrib<float>(pObj, pAttrib), nuiRange(pAttrib->Get(pObj), 0.0, 1.0, 0.05, 0.1)); }
nuiWidget* nuiColorSelector::Tab_RGB() { nuiSize red = mCurrentColor.Red(); nuiSize green = mCurrentColor.Green(); nuiSize blue = mCurrentColor.Blue(); nuiSize alpha = mCurrentColor.Alpha(); mpRgbGrid = new nuiGrid(3, 4); mpRgbGrid->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("RGB")); pLabel->SetBorder(2.f, 1.f); pPane->AddChild(pLabel); mpRgbGrid->SetCell(0, 0, new nuiLabel(_T("r:"))); mpRgbGrid->SetCell(0, 1, new nuiLabel(_T("g:"))); mpRgbGrid->SetCell(0, 2, new nuiLabel(_T("b:"))); mpRgbGrid->SetCell(0, 3, new nuiLabel(_T("a:"))); mpRedSlider = new nuiSlider(nuiHorizontal, nuiRange(red, 0.f, 1.f)); mpRgbGrid->SetCell(1, 0, mpRedSlider); mSink.Connect(mpRedSlider->InteractiveValueChanged, &nuiColorSelector::RGBSliderChanged); mSink.Connect(mpRedSlider->ValueChanged, &nuiColorSelector::RGBSliderChanged); mpGreenSlider = new nuiSlider(nuiHorizontal, nuiRange(green, 0.f, 1.f)); mpRgbGrid->SetCell(1, 1, mpGreenSlider); mSink.Connect(mpGreenSlider->InteractiveValueChanged, &nuiColorSelector::RGBSliderChanged); mSink.Connect(mpGreenSlider->ValueChanged, &nuiColorSelector::RGBSliderChanged); mpBlueSlider = new nuiSlider(nuiHorizontal, nuiRange(blue, 0.f, 1.f)); mpRgbGrid->SetCell(1, 2, mpBlueSlider); mSink.Connect(mpBlueSlider->InteractiveValueChanged, &nuiColorSelector::RGBSliderChanged); mSink.Connect(mpBlueSlider->ValueChanged, &nuiColorSelector::RGBSliderChanged); mpRGBAlphaSlider = new nuiSlider(nuiHorizontal, nuiRange(alpha, 0.f, 1.f)); mpRgbGrid->SetCell(1, 3, mpRGBAlphaSlider); mSink.Connect(mpRGBAlphaSlider->InteractiveValueChanged, &nuiColorSelector::RGBSliderChanged); mSink.Connect(mpRGBAlphaSlider->ValueChanged, &nuiColorSelector::RGBSliderChanged); mpRgbGrid->SetColumnPixels(2, 25); mpRedSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8)); FormatColor(red, mpRedSliderLabel); mpRgbGrid->SetCell(2, 0, mpRedSliderLabel, nuiRight); mpGreenSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8)); FormatColor(green, mpGreenSliderLabel); mpRgbGrid->SetCell(2, 1, mpGreenSliderLabel, nuiRight); mpBlueSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8)); FormatColor(blue, mpBlueSliderLabel); mpRgbGrid->SetCell(2, 2, mpBlueSliderLabel, nuiRight); mpRGBAlphaSliderLabel = new nuiLabel(_T(""), nuiFont::GetFont(8)); FormatColor(alpha, mpRGBAlphaSliderLabel); mpRgbGrid->SetCell(2, 3, mpRGBAlphaSliderLabel, nuiRight); return mpRgbGrid; }