MyGUI_ResourceImageSetPointer.cpp
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#include "MyGUI_Precompiled.h"
#include "MyGUI_ResourceImageSetPointer.h"
#include "MyGUI_ImageBox.h"
#include "MyGUI_ResourceManager.h"
namespace MyGUI
{
void ResourceImageSetPointer::deserialization(xml::ElementPtr _node, Version _version)
{
Base::deserialization(_node, _version);
// берем детей и крутимся, основной цикл
xml::ElementEnumerator info = _node->getElementEnumerator();
while (info.next("Property"))
{
std::string_view key = info->findAttribute("key");
std::string_view value = info->findAttribute("value");
if (key == "Point")
mPoint = IntPoint::parse(value);
else if (key == "Size")
mSize = IntSize::parse(value);
else if (key == "Resource")
mImageSet = ResourceManager::getInstance().getByName(value)->castType<ResourceImageSet>();
}
}
void ResourceImageSetPointer::setImage(ImageBox* _image)
{
if (mImageSet != nullptr)
_image->setItemResourceInfo(mImageSet->getIndexInfo(0, 0));
}
void ResourceImageSetPointer::setPosition(ImageBox* _image, const IntPoint& _point)
{
_image->setCoord(_point.left - mPoint.left, _point.top - mPoint.top, mSize.width, mSize.height);
}
} // namespace MyGUI
MyGUI_ImageBox.h
MyGUI_Precompiled.h
MyGUI_ResourceImageSetPointer.h
MyGUI_ResourceManager.h
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition MyGUI_IObject.h:18
MyGUI::ImageBox
widget description should be here.
Definition MyGUI_ImageBox.h:22
MyGUI::ImageBox::setItemResourceInfo
void setItemResourceInfo(const ImageIndexInfo &_info)
Definition MyGUI_ImageBox.cpp:331
MyGUI::ResourceImageSet
Definition MyGUI_ResourceImageSet.h:27
MyGUI::ResourceImageSetPointer::setPosition
void setPosition(ImageBox *_image, const IntPoint &_point) override
Definition MyGUI_ResourceImageSetPointer.cpp:41
MyGUI::ResourceImageSetPointer::deserialization
void deserialization(xml::ElementPtr _node, Version _version) override
Definition MyGUI_ResourceImageSetPointer.cpp:15
MyGUI::ResourceImageSetPointer::setImage
void setImage(ImageBox *_image) override
Definition MyGUI_ResourceImageSetPointer.cpp:35
MyGUI::ResourceManager::getByName
IResource * getByName(std::string_view _name, bool _throw=true) const
Definition MyGUI_ResourceManager.cpp:243
MyGUI::ResourceManager::getInstance
static ResourceManager & getInstance()
MyGUI::Version
Definition MyGUI_Version.h:18
MyGUI::Widget::setCoord
void setCoord(const IntCoord &_coord) override
Definition MyGUI_Widget.cpp:730
MyGUI::xml::ElementEnumerator
Definition MyGUI_XmlDocument.h:121
MyGUI::xml::ElementEnumerator::next
bool next()
Definition MyGUI_XmlDocument.cpp:107
MyGUI::xml::Element::findAttribute
bool findAttribute(std::string_view _name, std::string &_value)
Definition MyGUI_XmlDocument.cpp:242
MyGUI::xml::Element::getElementEnumerator
ElementEnumerator getElementEnumerator()
Definition MyGUI_XmlDocument.cpp:348
MyGUI::xml::ElementPtr
Element * ElementPtr
Definition MyGUI_XmlDocument.h:112
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::IntPoint
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
MyGUI::types::TPoint< int >::parse
static TPoint< int > parse(std::string_view _value)
Definition MyGUI_TPoint.h:102
MyGUI::types::TPoint::left
T left
Definition MyGUI_TPoint.h:19
MyGUI::types::TPoint::top
T top
Definition MyGUI_TPoint.h:20
MyGUI::types::TSize< int >::parse
static TSize< int > parse(std::string_view _value)
Definition MyGUI_TSize.h:102