MyGUI: MyGUI_ResourceImageSetPointer.cpp Source File

MyGUI 3.4.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"
8#include "MyGUI_ResourceImageSetPointer.h"
9#include "MyGUI_ImageBox.h"
10#include "MyGUI_ResourceManager.h"
11
12namespace MyGUI
13{
14
15 void ResourceImageSetPointer::deserialization(xml::ElementPtr _node, Version _version)
16 {
17 Base::deserialization(_node, _version);
18
19 // берем детей и крутимся, основной цикл
20 xml::ElementEnumerator info = _node->getElementEnumerator();
21 while (info.next("Property"))
22 {
23 std::string_view key = info->findAttribute("key");
24 std::string_view value = info->findAttribute("value");
25
26 if (key == "Point")
27 mPoint = IntPoint::parse(value);
28 else if (key == "Size")
29 mSize = IntSize::parse(value);
30 else if (key == "Resource")
31 mImageSet = ResourceManager::getInstance().getByName(value)->castType<ResourceImageSet>();
32 }
33 }
34
35 void ResourceImageSetPointer::setImage(ImageBox* _image)
36 {
37 if (mImageSet != nullptr)
38 _image->setItemResourceInfo(mImageSet->getIndexInfo(0, 0));
39 }
40
41 void ResourceImageSetPointer::setPosition(ImageBox* _image, const IntPoint& _point)
42 {
43 _image->setCoord(_point.left - mPoint.left, _point.top - mPoint.top, mSize.width, mSize.height);
44 }
45
46} // 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