Exemplo n.º 1
0
//----------------------------------------------------------------------------------------------------
CView* UIFocusSettingsController::verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description)
{
	CControl* control = dynamic_cast<CControl*>(view);
	if (control)
	{
		switch (control->getTag ())
		{
			case kEnabledTag:
			{
				bool value = false;
				settings->getBooleanAttribute ("enabled", value);
				control->setValue (value ? control->getMax () : control->getMin ());
				controls[kEnabledTag] = control;
				break;
			}
			case kColorTag:
			{
				COptionMenu* menu = dynamic_cast<COptionMenu*>(control);
				if (menu)
				{
					controls[kColorTag] = control;
					const std::string* current = settings->getAttributeValue ("color");
					std::list<const std::string*> names;
					editDescription->collectColorNames (names);
					names.sort (UIEditController::std__stringCompare);
					int32_t index = 0;
					for (std::list<const std::string*>::const_iterator it = names.begin (); it != names.end (); it++, index++)
					{
						menu->addEntry (new CMenuItem ((*it)->c_str ()));
						if (current && *current == *(*it))
						{
							menu->setValue ((float)index);
						}
					}
				}
				break;
			}
			case kWidthTag:
			{
				controls[kWidthTag] = control;
				CTextEdit* edit = dynamic_cast<CTextEdit*>(control);
				if (edit)
				{
				#if VSTGUI_HAS_FUNCTIONAL
					edit->setStringToValueFunction (stringToValue);
					edit->setValueToStringFunction (valueToString);
				#else
					edit->setStringToValueProc (stringToValue);
					edit->setValueToStringProc (valueToString);
				#endif
				}
				double current = 1.;
				settings->getDoubleAttribute ("width", current);
				control->setValue ((float)current);
				break;
			}
		}
	}
	return view;
}
Exemplo n.º 2
0
//----------------------------------------------------------------------------------------------------
CView* UIColorChooserController::verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description)
{
	CControl* control = dynamic_cast<CControl*>(view);
	if (control && control->getTag () >= 0)
	{
		controls.push_back (control);
		CTextEdit* textEdit = dynamic_cast<CTextEdit*> (control);
		if (textEdit)
		{
		#if VSTGUI_HAS_FUNCTIONAL
			textEdit->setValueToStringFunction (valueToString);
			textEdit->setStringToValueFunction (stringToValue);
		#else
			textEdit->setValueToStringProc (valueToString, textEdit);
			textEdit->setStringToValueProc (stringToValue, textEdit);
		#endif
		}
		updateColorSlider (control);
	}
	return view;
}