Ejemplo n.º 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;
}
Ejemplo n.º 2
0
void nuiColorSelector::SetCurrentColor(const nuiColor& rColor)
{
  mCurrentColor = rColor;
  mpColorPaneDeco->SetFillColor(rColor);
  
  nuiSize red = rColor.Red();
  nuiSize green = rColor.Green();
  nuiSize blue = rColor.Blue();
  nuiSize alpha = rColor.Alpha();
  FormatColor(red, mpRedSliderLabel);
  FormatColor(green, mpGreenSliderLabel);
  FormatColor(blue, mpBlueSliderLabel);
  FormatColor(alpha, mpRGBAlphaSliderLabel);
  
  float h, s, v;
  h = mpHueSlider->GetRange().GetValue();
  s = mpSaturationSlider->GetRange().GetValue();
  v = mpValueSlider->GetRange().GetValue();
  FormatColor(h, mpHueSliderLabel, 100, false);
  FormatColor(s, mpSaturationSliderLabel, 100, false);
  FormatColor(v, mpValueSliderLabel, 100, false);
  FormatColor(alpha, mpHSVAlphaSliderLabel, 100, false);
  
  mpColorPane->Invalidate();
  
  uint tabIndex = mpTabView->GetSelectedTab();
  if (tabIndex != 0)
    Tab_RGB_Update();
  if (tabIndex != 1)
    Tab_HSV_Update();
  
  // send event
  ColorChanged(); 
}
Ejemplo n.º 3
0
String HighlightSetup::StoreHlStyles()
{
	String r;
	for(int i = 0; i < HL_COUNT; i++) {
		const HlStyle& s = GetHlStyle(i);
		r << Format("%-25s", s_hl_color[i]) << ' ' << FormatColor(s.color);
		if(s.bold)
			r << " bold";
		if(s.italic)
			r << " italic";
		if(s.underline)
			r << " underline";
		r << ";\r\n";
	}
	return r;
}
Ejemplo n.º 4
0
void ColorPusher::Paint(Draw& w)
{
	Size sz = GetSize();
	w.DrawRect(sz, push ? SColorHighlight : SColorPaper);
	int ty = (sz.cy - StdFont().Info().GetHeight()) / 2;
	if(withtext) {
		w.DrawRect(2, 2, sz.cy - 4, sz.cy - 4, color);
		DrawFrame(w, 1, 1, sz.cy - 2, sz.cy - 2, SColorText);
		w.DrawText(sz.cy + 2, ty, FormatColor(color), StdFont(), SColorText());
	}
	else {
		if(!IsNull(color)) {
			w.DrawRect(2, 2, sz.cx - 4, sz.cy - 4, color);
			DrawFrame(w, 1, 1, sz.cx - 2, sz.cy - 2, SColorText);
		}
		else
		if(!withtext)
			w.DrawText(max(2, (sz.cx - GetTextSize(nulltext, StdFont()).cx) / 2), ty,
			           nulltext, StdFont(), SColorText());
	}
	if(HasFocus())
		DrawFocus(w, GetSize());
}
Ejemplo n.º 5
0
	virtual String   Save() const           { return FormatColor(~editor); }
Ejemplo n.º 6
0
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;
}