MyGUI: MyGUI_ResourceImageSetPointer.cpp Source File

MyGUI 3.2.2

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"
8 #include "MyGUI_ResourceImageSetPointer.h"
9 #include "MyGUI_ImageBox.h"
10 #include "MyGUI_ResourceManager.h"
11
12 namespace MyGUI
13 {
14
15 ResourceImageSetPointer::ResourceImageSetPointer() :
16 mImageSet(nullptr)
17 {
18 }
19
20 ResourceImageSetPointer::~ResourceImageSetPointer()
21 {
22 }
23
24 void ResourceImageSetPointer::deserialization(xml::ElementPtr _node, Version _version)
25 {
26 Base::deserialization(_node, _version);
27
28 // берем детей и крутимся, основной цикл
29 xml::ElementEnumerator info = _node->getElementEnumerator();
30 while (info.next("Property"))
31 {
32 const std::string& key = info->findAttribute("key");
33 const std::string& value = info->findAttribute("value");
34
35 if (key == "Point")
36 mPoint = IntPoint::parse(value);
37 else if (key == "Size")
38 mSize = IntSize::parse(value);
39 else if (key == "Resource")
40 mImageSet = ResourceManager::getInstance().getByName(value)->castType<ResourceImageSet>();
41 }
42 }
43
44 void ResourceImageSetPointer::setImage(ImageBox* _image)
45 {
46 if (mImageSet != nullptr)
47 _image->setItemResourceInfo(mImageSet->getIndexInfo(0, 0));
48 }
49
50 void ResourceImageSetPointer::setPosition(ImageBox* _image, const IntPoint& _point)
51 {
52 _image->setCoord(_point.left - mPoint.left, _point.top - mPoint.top, mSize.width, mSize.height);
53 }
54
55 } // namespace MyGUI
MyGUI::Singleton< ResourceManager >::getInstance
static ResourceManager & getInstance()
Definition: MyGUI_Singleton.h:38
MyGUI::ResourceImageSetPointer::~ResourceImageSetPointer
virtual ~ResourceImageSetPointer()
Definition: MyGUI_ResourceImageSetPointer.cpp:20
MyGUI::types::TSize::height
T height
Definition: MyGUI_TSize.h:21
MyGUI::ImageBox
ImageBox properties. Skin childs. ImageBox widget description should be here.
Definition: MyGUI_ImageBox.h:21
MyGUI::ResourceImageSet
Definition: MyGUI_ResourceImageSet.h:26
MyGUI::types::TPoint::top
T top
Definition: MyGUI_TPoint.h:21
MyGUI::ResourceImageSetPointer::setPosition
virtual void setPosition(ImageBox *_image, const IntPoint &_point)
Definition: MyGUI_ResourceImageSetPointer.cpp:50
MyGUI_ResourceManager.h
MyGUI::ResourceImageSetPointer::deserialization
virtual void deserialization(xml::ElementPtr _node, Version _version)
Definition: MyGUI_ResourceImageSetPointer.cpp:24
MyGUI::ImageBox::setItemResourceInfo
void setItemResourceInfo(const ImageIndexInfo &_info)
Definition: MyGUI_ImageBox.cpp:320
MyGUI::types::TPoint< int >
MyGUI::types::TSize::width
T width
Definition: MyGUI_TSize.h:20
MyGUI::xml::Element
Definition: MyGUI_XmlDocument.h:158
MyGUI::ResourceImageSetPointer::setImage
virtual void setImage(ImageBox *_image)
Definition: MyGUI_ResourceImageSetPointer.cpp:44
MyGUI::xml::Element::findAttribute
bool findAttribute(const std::string &_name, std::string &_value)
Definition: MyGUI_XmlDocument.cpp:246
MyGUI_Precompiled.h
MyGUI_ResourceImageSetPointer.h
MyGUI::Version
Definition: MyGUI_Version.h:17
MyGUI_ImageBox.h
MyGUI::types::TPoint< int >::parse
static TPoint< int > parse(const std::string &_value)
Definition: MyGUI_TPoint.h:120
MyGUI::types::TPoint::left
T left
Definition: MyGUI_TPoint.h:20
MyGUI::ResourceImageSet::getIndexInfo
ImageIndexInfo getIndexInfo(const std::string &_group, const std::string &_index)
Definition: MyGUI_ResourceImageSet.cpp:73
MyGUI::xml::ElementEnumerator
Definition: MyGUI_XmlDocument.h:114
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition: MyGUI_IObject.h:18
MyGUI::ResourceImageSetPointer::ResourceImageSetPointer
ResourceImageSetPointer()
Definition: MyGUI_ResourceImageSetPointer.cpp:15
MyGUI::ResourceManager::getByName
IResource * getByName(const std::string &_name, bool _throw=true) const
Definition: MyGUI_ResourceManager.cpp:235
nullptr
#define nullptr
Definition: MyGUI_Prerequest.h:29
MyGUI::Widget::setCoord
virtual void setCoord(const IntCoord &_value)
Definition: MyGUI_Widget.cpp:689
MyGUI::types::TSize< int >::parse
static TSize< int > parse(const std::string &_value)
Definition: MyGUI_TSize.h:120
MyGUI::xml::Element::getElementEnumerator
ElementEnumerator getElementEnumerator()
Definition: MyGUI_XmlDocument.cpp:352
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::xml::ElementEnumerator::next
bool next()
Definition: MyGUI_XmlDocument.cpp:100