//----------------------------------------------------------------------------------------------------
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;
}
Exemple #2
0
//------------------------------------------------------------------------
COptionMenu* UIDescriptionTestController::createContextMenu (const CPoint& pos, VST3Editor* editor)
{
	Parameter* tabParameter = getParameterObject (20000);
	if (tabParameter)
	{
		UIDescriptionTestControllerMenuHandler* menuHandler = new UIDescriptionTestControllerMenuHandler (tabParameter);
		COptionMenu* menu = new COptionMenu ();
		menu->setStyle (kMultipleCheckStyle);
		for (int32 i = 0; i <= tabParameter->getInfo ().stepCount; i++)
		{
			String128 valueString;
			tabParameter->toString (tabParameter->toNormalized (i), valueString);
			String str (valueString);
			str.toMultiByte (kCP_Utf8);
			CMenuItem* item = menu->addEntry (new CCommandMenuItem (str.text8 (), i, menuHandler));
			if (tabParameter->getNormalized () == tabParameter->toNormalized (i))
				item->setChecked (true);
		}
		COptionMenu* mainMenu = new COptionMenu ();
		mainMenu->addEntry (new CMenuItem ("Show Tab"))->setSubmenu (menu);
		menuHandler->forget ();
		return mainMenu;
	}
	return 0;
}
Exemple #3
0
	virtual CMouseEventResult onMouseDown (CPoint &where, const long &buttons)
	{
		if (buttons == kRButton)
		{
			CView* view = getViewAt (where);
			if (!view || view->isTypeOf ("CTabButton"))
			{
				CRect r;
				localToFrame (where);
				r.offset (where.x, where.y);
				r.offset (-size.left, -size.top);
				COptionMenu* menu = new COptionMenu (r, NULL, 0);
				menu->addEntry ("Tabs Left");
				menu->addEntry ("Tabs Right");
				menu->addEntry ("Tabs Top");
				menu->addEntry ("Tabs Bottom");
				menu->addEntry ("-");
				menu->addEntry ("Align Tabs Centered");
				menu->addEntry ("Align Tabs Left/Top");
				menu->addEntry ("Align Tabs Right/Bottom");
				getFrame ()->addView (menu);
				menu->takeFocus ();
				long res = menu->getLastResult ();
				getFrame ()->removeView (menu);
				if (res != -1)
				{
					if (res < 4)
					{
						r = size;
						editor->setTabView (getFrame (), r, res);
					}
					else
					{
						alignTabs (kAlignCenter + res - 5);
					}
				}
				return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
			}
		}
		return CTabView::onMouseDown (where, buttons);
	}
//----------------------------------------------------------------------------------------------------
CMouseEventResult UIViewCreatorDataSource::dbOnMouseDown (const CPoint& where, const CButtonState& buttons, int32_t row, int32_t column, CDataBrowser* browser)
{
	mouseDownRow = row;
	if (buttons.isLeftButton ())
	{
		if (!buttons.isDoubleClick ())
			return kMouseEventHandled;
		addViewToCurrentEditView ();
	}
	else if (buttons.isRightButton ())
	{
		const std::string& viewName = getStringList ()->at (static_cast<uint32_t> (mouseDownRow));
		std::string menuEntryName = "Add a new '" + viewName + "'";
		COptionMenu menu;
		menu.setStyle (kPopupStyle);
		menu.addEntry (menuEntryName.c_str ());
		CPoint menuLocation (where);
		browser->localToFrame (menuLocation);
		if (menu.popup (browser->getFrame (), menuLocation))
		{
			if (menu.getEntry (menu.getLastResult ()))
				addViewToCurrentEditView ();
		}
	}
	mouseDownRow = -1;
	return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
}
//----------------------------------------------------------------------------------------------------
CMessageResult UIFocusSettingsController::notify (CBaseObject* sender, IdStringPtr message)
{
	if (message == UIDialogController::kMsgDialogButton1Clicked)
	{
		if (controls[kEnabledTag])
		{
			settings->setBooleanAttribute ("enabled", controls[kEnabledTag]->getValue () == controls[kEnabledTag]->getMax () ? true : false);
		}
		if (controls[kColorTag])
		{
			COptionMenu* menu = dynamic_cast<COptionMenu*>(controls[kColorTag]);
			CMenuItem* item = menu->getCurrent ();
			if (item)
				settings->setAttribute ("color", item->getTitle ());
		}
		if (controls[kWidthTag])
		{
			settings->setDoubleAttribute ("width", controls[kWidthTag]->getValue ());
		}
		return kMessageNotified;
	}
	return kMessageUnknown;
}