示例#1
0
	void SkinExportSerializer::fillSeparatorData(DataPtr _data, pugi::xml_node _node)
	{
		pugi::xpath_node_set regions = _node.select_nodes("BasisSkin[@type=\"SubSkin\"or@type=\"TileRect\"]");
		for (pugi::xpath_node_set::const_iterator region = regions.begin(); region != regions.end(); region ++)
		{
			MyGUI::IntCoord offset = MyGUI::IntCoord::parse((*region).node().attribute("offset").value());

			MyGUI::Align align = MyGUI::Align::parse((*region).node().attribute("align").value());
			if (align.isLeft())
			{
				DataPtr data = getChildData(_data, "Separator", "Left");
				data->setPropertyValue("Visible", "True");
				data->setPropertyValue("Offset", MyGUI::utility::toString(offset.width));
			}
			else if (align.isRight())
			{
				DataPtr data = getChildData(_data, "Separator", "Right");
				data->setPropertyValue("Visible", "True");
				data->setPropertyValue("Offset", MyGUI::utility::toString(offset.width));
			}
			if (align.isTop())
			{
				DataPtr data = getChildData(_data, "Separator", "Top");
				data->setPropertyValue("Visible", "True");
				data->setPropertyValue("Offset", MyGUI::utility::toString(offset.height));
			}
			else if (align.isBottom())
			{
				DataPtr data = getChildData(_data, "Separator", "Bottom");
				data->setPropertyValue("Visible", "True");
				data->setPropertyValue("Offset", MyGUI::utility::toString(offset.height));
			}
		}
	}
示例#2
0
	void TextView::update(const MyGUI::UString& _text, const Sandbox::FontPtr& _font , MyGUI::Align _align, int _maxWidth)
	{
		
        m_font = _font;
		mViewSize.clear();
        mTextData.Clear();
        
        FontAlign align = ALIGN_LEFT;
        if (_align.isHCenter())
            align = ALIGN_CENTER;
        if (_align.isRight())
            align = ALIGN_RIGHT;
        
        mTextData.Fill(_text.c_str(), _font, _maxWidth, align);

		mViewSize = MyGUI::IntSize(mTextData.size.w,mTextData.size.h);
	}
	void SeparatorTextureControl::addCoord(std::vector<int>& _coordsHor, std::vector<int>& _coordsVert, MyGUI::Align _corner, const MyGUI::UString& _position)
	{
		int offset = 0;
		if (MyGUI::utility::parseComplex(_position, offset))
		{
			if (_corner.isTop())
			{
				for (std::vector<int>::iterator item = _coordsHor.begin(); item != _coordsHor.end(); ++item)
				{
					if ((*item) == offset)
						return;
				}
				_coordsHor.push_back(offset);
			}
			else if (_corner.isLeft())
			{
				for (std::vector<int>::iterator item = _coordsVert.begin(); item != _coordsVert.end(); ++item)
				{
					if ((*item) == offset)
						return;
				}
				_coordsVert.push_back(offset);
			}
			else if (_corner.isBottom())
			{
				for (std::vector<int>::iterator item = _coordsHor.begin(); item != _coordsHor.end(); ++item)
				{
					if ((*item) == (mTextureRegion.height - offset))
						return;
				}
				_coordsHor.push_back(mTextureRegion.height - offset);
			}
			else if (_corner.isRight())
			{
				for (std::vector<int>::iterator item = _coordsVert.begin(); item != _coordsVert.end(); ++item)
				{
					if ((*item) == (mTextureRegion.width - offset))
						return;
				}
				_coordsVert.push_back(mTextureRegion.width - offset);
			}
		}
	}
	void BaseLayout::snapToParent(MyGUI::Widget* _child)
	{
		if (_child->isUserString("SnapTo"))
		{
			MyGUI::Align align = MyGUI::Align::parse(_child->getUserString("SnapTo"));

			MyGUI::IntCoord coord = _child->getCoord();
			MyGUI::IntSize size = _child->getParentSize();

			if (align.isHStretch())
			{
				coord.left = 0;
				coord.width = size.width;
			} else if (align.isLeft())
			{
				coord.left = 0;
			} else if (align.isRight())
			{
				coord.left = size.width - coord.width;
			} else
			{
				coord.left = (size.width - coord.width) / 2;
			}

			if (align.isVStretch())
			{
				coord.top = 0;
				coord.height = size.height;
			} else if (align.isTop())
			{
				coord.top = 0;
			} else if (align.isBottom())
			{
				coord.top = size.height - coord.height;
			} else
			{
				coord.top = (size.height - coord.height) / 2;
			}

			_child->setCoord(coord);
		}
	}
	void SeparatorTextureControl::notifyChangePosition()
	{
		if (getCurrentSeparator() != nullptr)
		{
			MyGUI::Align corner = getCurrentSeparator()->getCorner();

			if (corner.isTop())
				getCurrentSeparator()->getPropertySet()->setPropertyValue("Offset",
					MyGUI::utility::toString(mHorizontalSelectorControl->getPosition().top), mTypeName);
			else if (corner.isLeft())
				getCurrentSeparator()->getPropertySet()->setPropertyValue("Offset",
					MyGUI::utility::toString(mVerticalSelectorControl->getPosition().left), mTypeName);
			else if (corner.isBottom())
				getCurrentSeparator()->getPropertySet()->setPropertyValue("Offset",
					MyGUI::utility::toString(mTextureRegion.height - mHorizontalSelectorControl->getPosition().top), mTypeName);
			else if (corner.isRight())
				getCurrentSeparator()->getPropertySet()->setPropertyValue("Offset",
					MyGUI::utility::toString(mTextureRegion.width -  mVerticalSelectorControl->getPosition().left), mTypeName);
		}
	}
	void SeparatorTextureControl::updatePosition()
	{
		if (getCurrentSeparator() != nullptr)
		{
			MyGUI::UString value = getCurrentSeparator()->getPropertySet()->getPropertyValue("Offset");
			MyGUI::Align corner = getCurrentSeparator()->getCorner();

			int offset = 0;
			if (MyGUI::utility::parseComplex(value, offset))
			{
				if (corner.isTop())
					mHorizontalSelectorControl->setCoord(MyGUI::IntCoord(0, offset, mTextureRegion.width, 1));
				else if (corner.isLeft())
					mVerticalSelectorControl->setCoord(MyGUI::IntCoord(offset, 0, 1, mTextureRegion.height));
				else if (corner.isBottom())
					mHorizontalSelectorControl->setCoord(MyGUI::IntCoord(0, mTextureRegion.height - offset, mTextureRegion.width, 1));
				else if (corner.isRight())
					mVerticalSelectorControl->setCoord(MyGUI::IntCoord(mTextureRegion.width - offset, 0, 1, mTextureRegion.height));
			}
		}
	}
示例#7
0
	void SkinExportSerializer::fillRegionData(DataPtr _data, pugi::xml_node _node)
	{
		pugi::xpath_node_set regions = _node.select_nodes("BasisSkin[@type=\"SubSkin\"or@type=\"TileRect\"]");
		for (pugi::xpath_node_set::const_iterator region = regions.begin(); region != regions.end(); region ++)
		{
			DataPtr regionData = NULL;

			MyGUI::Align align = MyGUI::Align::parse((*region).node().attribute("align").value());

			if (align.isLeft() && align.isTop())
				regionData = getChildData(_data, "Region", "Left Top");
			else if (align.isLeft() && align.isVStretch())
				regionData = getChildData(_data, "Region", "Left");
			else if (align.isLeft() && align.isBottom())
				regionData = getChildData(_data, "Region", "Left Bottom");

			else if (align.isHStretch() && align.isTop())
				regionData = getChildData(_data, "Region", "Top");
			else if (align.isHStretch() && align.isVStretch())
				regionData = getChildData(_data, "Region", "Center");
			else if (align.isHStretch() && align.isBottom())
				regionData = getChildData(_data, "Region", "Bottom");

			else if (align.isRight() && align.isTop())
				regionData = getChildData(_data, "Region", "Right Top");
			else if (align.isRight() && align.isVStretch())
				regionData = getChildData(_data, "Region", "Right");
			else if (align.isRight() && align.isBottom())
				regionData = getChildData(_data, "Region", "Right Bottom");

			if (regionData == nullptr)
				continue;

			regionData->setPropertyValue("Visible", "True");

			std::string type = (*region).node().attribute("type").value();
			if (type == "TileRect")
			{
				bool vert = MyGUI::utility::parseValue<bool>((*region).node().select_single_node("State/Property[@key=\"TileV\"]/@value").attribute().value());
				bool horz = MyGUI::utility::parseValue<bool>((*region).node().select_single_node("State/Property[@key=\"TileH\"]/@value").attribute().value());

				if (vert && !horz)
					type = "TileRect Vert";
				else if (!vert && horz)
					type = "TileRect Horz";
			}

			regionData->setPropertyValue("Type", type);
		}

		pugi::xpath_node regionText = _node.select_single_node("BasisSkin[@type=\"SimpleText\"or@type=\"EditText\"]");
		if (!regionText.node().empty())
		{
			DataPtr regionData = getChildData(_data, "RegionText", "Text");

			if (regionData != nullptr)
			{
				regionData->setPropertyValue("Visible", "True");

				std::string type = regionText.node().attribute("type").value();
				regionData->setPropertyValue("Type", type);

				MyGUI::IntCoord offset = MyGUI::IntCoord::parse(regionText.node().attribute("offset").value());
				regionData->setPropertyValue("Coord", offset);

				MyGUI::Align align = MyGUI::Align::parse(regionText.node().attribute("align").value());
				regionData->setPropertyValue("Align", align);
			}
		}
	}