MyGUI 3.5.3
MyGUI_ResourceImageSetPointer.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
9#include "MyGUI_ImageBox.h"
11
12#include <pugixml.hpp>
13
14namespace MyGUI
15{
16
17 void ResourceImageSetPointer::deserialization(xml::ElementPtr _node, Version _version)
18 {
19 Base::deserialization(_node, _version);
20
21 // iterate children, main loop
22 for (auto info : _node.node().children("Property"))
23 {
24 std::string_view key = info.attribute("key").value();
25 std::string_view value = info.attribute("value").value();
26
27 if (key == "Point")
28 mPoint = IntPoint::parse(value);
29 else if (key == "Size")
30 mSize = IntSize::parse(value);
31 else if (key == "Resource")
32 mImageSet = ResourceManager::getInstance().getByName(value)->castType<ResourceImageSet>();
33 }
34 }
35
36 void ResourceImageSetPointer::setImage(ImageBox* _image)
37 {
38 if (mImageSet != nullptr)
39 _image->setItemResourceInfo(mImageSet->getIndexInfo(0, 0));
40 }
41
42 void ResourceImageSetPointer::setPosition(ImageBox* _image, const IntPoint& _point)
43 {
44 _image->setCoord(_point.left - mPoint.left, _point.top - mPoint.top, mSize.width, mSize.height);
45 }
46
47} // namespace MyGUI
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:26
static TPoint< int > parse(std::string_view _value)
static TSize< int > parse(std::string_view _value)