std::string BaseLayout::FindParentPrefix(MyGUI::Widget* _parent)
	{
		std::string prefix = _parent->getUserString("BaseLayoutPrefix");
		if (!prefix.empty())
			return prefix;
		if (_parent->getParent() != nullptr)
			return FindParentPrefix(_parent->getParent());

		return "";
	}
	void BaseLayout::initialise(const std::string& _layout, MyGUI::Widget* _parent, bool _throw, bool _createFakeWidgets)
	{
		const std::string MAIN_WINDOW1 = "_Main";
		const std::string MAIN_WINDOW2 = "Root";
		mLayoutName = _layout;

		// оборачиваем
		if (mLayoutName.empty())
		{
			mMainWidget = _parent;
			if (mMainWidget != nullptr)
			{
				mListWindowRoot.push_back(mMainWidget);
				mPrefix = FindParentPrefix(mMainWidget);
			}
		}
		// загружаем лейаут на виджет
		else
		{
			mPrefix = MyGUI::utility::toString(this, "_");
			mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);

			const std::string mainName1 = mPrefix + MAIN_WINDOW1;
			const std::string mainName2 = mPrefix + MAIN_WINDOW2;
			for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter)
			{
				if ((*iter)->getName() == mainName1 || (*iter)->getName() == mainName2)
				{
					mMainWidget = (*iter);

					snapToParent(mMainWidget);

					break;
				}
			}

			if (mMainWidget == nullptr)
			{
				MYGUI_LOG(Warning, "Root widget with name '" << MAIN_WINDOW1 << "' or '" << MAIN_WINDOW2 << "'  not found. [" << mLayoutName << "]");
				MYGUI_ASSERT(!_throw, "No root widget. ['" << mLayoutName << "]");
				if (_createFakeWidgets)
					mMainWidget = _createFakeWidget<MyGUI::Widget>(_parent);
			}

			mMainWidget->setUserString("BaseLayoutPrefix", mPrefix);
		}
	}
Beispiel #3
0
	void SeparatorV::assignLeftRightPanel()
	{
		std::string prefix = FindParentPrefix(getParent());

		mLeftPanel = getParent()->findWidget(prefix + "Left");
		mRightPanel = getParent()->findWidget(prefix + "Right");

		if (mLeftPanel == NULL || mRightPanel == NULL)
		{
			return;
		}

		mMinSizeLeft = MyGUI::utility::parseValue<int>(mLeftPanel->getUserString("MinSize"));
		mMinSizeRight = MyGUI::utility::parseValue<int>(mRightPanel->getUserString("MinSize"));

		eventMouseButtonPressed += MyGUI::newDelegate(this, &SeparatorV::notifyMouseButtonPressed);
		eventMouseDrag += MyGUI::newDelegate(this, &SeparatorV::notifyMouseDrag);
	}