1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#ifndef _d90c3428_278f_44c7_9400_f8b7e1bff0bd_
#define _d90c3428_278f_44c7_9400_f8b7e1bff0bd_
#include <MyGUI.h>
namespace tools::utility
{
// это можно в методы гуи занести
inline MyGUI::IntCoord convertCoordToParentCoord(const MyGUI::IntCoord& _coord, MyGUI::Widget* _widget)
{
MyGUI::IntCoord coord = _coord;
MyGUI::Widget* parent = _widget->getParent();
while (nullptr != parent)
{
coord = coord - parent->getPosition();
// а может у нас и дедушка есть? а может и прадед...
parent = parent->getParent();
}
return coord;
}
inline void mapSet(MyGUI::VectorStringPairs& _map, std::string_view _key, std::string_view _value)
{
for (auto& iter : _map)
{
if (iter.first == _key)
{
iter.second = _value;
return;
}
}
_map.emplace_back(_key, _value);
}
inline MyGUI::VectorStringPairs::iterator mapFind(MyGUI::VectorStringPairs& _map, std::string_view _key)
{
for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter)
{
if (iter->first == _key)
return iter;
}
return _map.end();
}
inline void mapErase(MyGUI::VectorStringPairs& _map, std::string_view _key)
{
for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter)
{
if (iter->first == _key)
{
_map.erase(iter);
return;
}
}
}
}
#endif
|