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;
}
Exemplo n.º 3
0
//----------------------------------------------------------------------------------------------------
CView* UIGridController::verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description)
{
	CTextEdit* control = dynamic_cast<CTextEdit*>(view);
	if (control)
	{
		switch (control->getTag ())
		{
			case kGridXTag:
			{
				gridControls[0] = control;
			#if VSTGUI_HAS_FUNCTIONAL
				gridControls[0]->setStringToValueFunction (stringToValue);
				gridControls[0]->setValueToStringFunction (valueToString);
			#else
				gridControls[0]->setStringToValueProc (stringToValue);
				gridControls[0]->setValueToStringProc (valueToString);
			#endif
				gridControls[0]->setValue ((float)size.x);
				break;
			}
			case kGridYTag:
			{
				gridControls[1] = control;
			#if VSTGUI_HAS_FUNCTIONAL
				gridControls[1]->setStringToValueFunction (stringToValue);
				gridControls[1]->setValueToStringFunction (valueToString);
			#else
				gridControls[1]->setStringToValueProc (stringToValue);
				gridControls[1]->setValueToStringProc (valueToString);
			#endif
				gridControls[1]->setValue ((float)size.y);
				break;
			}
		}
	}
	return DelegationController::verifyView (view, attributes, description);
}
Exemplo n.º 4
0
//----------------------------------------------------------------------------------------------------
void UITemplateSettingsController::valueChanged (CControl* control)
{
	switch (control->getTag ())
	{
		case kNameTag:
		{
			CTextEdit* edit = dynamic_cast<CTextEdit*>(control);
			if (edit)
			{
				if (edit->getText ())
					newTemplateName = edit->getText ();
				else
					edit->setText (newTemplateName.c_str ());
			}
			break;
		}
		case kMinWidthTag:
		{
			minSize.x = control->getValue ();
			break;
		}
		case kMinHeightTag:
		{
			minSize.y = control->getValue ();
			break;
		}
		case kMaxWidthTag:
		{
			maxSize.x = control->getValue ();
			break;
		}
		case kMaxHeightTag:
		{
			maxSize.y = control->getValue ();
			break;
		}
		case kMinUseCurrentTag:
		case kMaxUseCurrentTag:
		{
			if (control->getValue() == control->getMax())
			{
				const UIAttributes* attr = description->getViewAttributes (templateName.c_str());
				if (attr)
				{
					CPoint currentSize;
					if (attr->getPointAttribute ("size", currentSize))
					{
						if (control->getTag () == kMinUseCurrentTag)
						{
							minSize = currentSize;
							if (controls[kMinWidthTag])
							{
								controls[kMinWidthTag]->setValue ((float)minSize.x);
								controls[kMinWidthTag]->invalid ();
							}
							if (controls[kMinHeightTag])
							{
								controls[kMinHeightTag]->setValue ((float)minSize.y);
								controls[kMinHeightTag]->invalid ();
							}
						}
						else
						{
							maxSize = currentSize;
							if (controls[kMaxWidthTag])
							{
								controls[kMaxWidthTag]->setValue ((float)maxSize.x);
								controls[kMaxWidthTag]->invalid ();
							}
							if (controls[kMaxHeightTag])
							{
								controls[kMaxHeightTag]->setValue ((float)maxSize.y);
								controls[kMaxHeightTag]->invalid ();
							}
						}
					}
				}
			}
			break;
		}
	}
}
Exemplo n.º 5
0
//----------------------------------------------------------------------------------------------------
CView* UITemplateSettingsController::verifyView (CView* view, const UIAttributes& attributes, IUIDescription* description)
{
	CTextEdit* control = dynamic_cast<CTextEdit*>(view);
	if (control)
	{
		switch (control->getTag ())
		{
			case kNameTag:
			{
				controls[kNameTag] = control;
				control->setText (templateName.c_str ());
				break;
			}
			case kMinWidthTag:
			{
				controls[kMinWidthTag] = control;
				control->setStringToValueProc (stringToValue);
				control->setValueToStringProc (valueToString);
				control->setValue ((float)minSize.x);
				break;
			}
			case kMinHeightTag:
			{
				controls[kMinHeightTag] = control;
				control->setStringToValueProc (stringToValue);
				control->setValueToStringProc (valueToString);
				control->setValue ((float)minSize.y);
				break;
			}
			case kMaxWidthTag:
			{
				controls[kMaxWidthTag] = control;
				control->setStringToValueProc (stringToValue);
				control->setValueToStringProc (valueToString);
				control->setValue ((float)maxSize.x);
				break;
			}
			case kMaxHeightTag:
			{
				controls[kMaxHeightTag] = control;
				control->setStringToValueProc (stringToValue);
				control->setValueToStringProc (valueToString);
				control->setValue ((float)maxSize.y);
				break;
			}
		}
	}
	return view;
}