Exemplo n.º 1
0
	void ColourPanel::notifyEditTextChange(MyGUI::EditBox* _sender)
	{
		MyGUI::EditBox* edit = static_cast<MyGUI::EditBox*>(_sender);
		size_t cursor = edit->getTextCursor();
		size_t num = MyGUI::utility::parseSizeT(edit->getOnlyText());
		if (num > 255) num = 255;
		edit->setCaption(MyGUI::utility::toString(num));
		if (cursor < edit->getTextLength()) edit->setTextCursor(cursor);

		MyGUI::Colour colour(
			MyGUI::utility::parseFloat(mEditRed->getOnlyText()) / 255.0f,
			MyGUI::utility::parseFloat(mEditGreen->getOnlyText()) / 255.0f,
			MyGUI::utility::parseFloat(mEditBlue->getOnlyText()) / 255.0f);

		updateFromColour(colour);
	}
Exemplo n.º 2
0
void MYGUIManager::setIntersectionPoint(const osg::Vec3d& point, bool update)
{
	_intersectionPoint = point;

	if (!update)
	{
		_intersectionPointUpdated = true;
		return;
	}

	if (_root && _intersectionPointUpdated)
	{
		try
		{
			MyGUI::ListBox* list = MyGUI::Gui::getInstance().findWidget<MyGUI::ListBox>("CommandListBox");
			MyGUI::EditBox* edit = MyGUI::Gui::getInstance().findWidget<MyGUI::EditBox>("Arguments");

			if (edit && list)
			{
				if (list->getIndexSelected() == MyGUI::ITEM_NONE) return;

				Base::Commands::CommandPtr command = *list->getItemDataAt<Base::Commands::CommandPtr>(
					list->getItemIndexSelected(), false
					);
				if (command.valid())
				{
					const std::string format = command->getArgumentsFormat();
					const std::string cmd = edit->getOnlyText();

					Base::StringUtils::Tokens cmdTokens = Base::StringUtils::instance()->tokenize(cmd);
					Base::StringUtils::Tokens formatTokens = Base::StringUtils::instance()->tokenize(format, ":");

					std::ostringstream oss;
					for (size_t i = 0; i < cmdTokens.size(); ++i)
					{
						if (i < formatTokens.size())
						{
							std::string token = formatTokens.at(i);
							if (token.at(0) == 'P')
							{
								oss << std::setprecision(10) << " " << _intersectionPoint.x() << " " << _intersectionPoint.y() << " " << _intersectionPoint.z();
								i += 2;
								continue;
							}
							if (token.at(0) == 'F')
							{
								oss << " \"" << cmdTokens.at(i) << "\"";
								continue;
							}
						}
						oss << " " << cmdTokens.at(i);
					}
					if (cmdTokens.size() < formatTokens.size() && formatTokens.at(cmdTokens.size()).at(0) == 'P')
					{
						oss << std::setprecision(10) << " " << _intersectionPoint.x() << " " << _intersectionPoint.y() << " " << _intersectionPoint.z();
					}
					edit->setOnlyText(oss.str().c_str());

				}
			}
		}
		catch (const std::exception& e)
		{
			osg::notify(osg::NOTICE) << "UI: exception: " << e.what() << std::endl;
		}
	}

	_intersectionPointUpdated = false;
}