37 std::string_view
_name)
57#if MYGUI_DEBUG_MODE == 1
121 shutdownWidgetSkinBase();
157 shutdownWidgetSkinBase();
187 for (
const auto& item : data)
189 if (item.name ==
"Root")
218#ifndef MYGUI_DONT_USE_OBSOLETE
220 for (
const auto& property : properties)
227 <<
" skin property is deprecated, move it to UserString in a widget in ResourceLayout"
236 for (
const auto& iter : child)
248 for (
const auto& prop : iter.params)
258 for (
const auto& userString : root->userStrings)
263 for (
const auto& iter : root->childWidgetsInfo)
275 void Widget::shutdownWidgetSkinBase()
282 for (
auto& iter : mWidgetChildSkin)
285 mWidgetChild.push_back(iter);
288 mWidgetChildSkin.clear();
290 mWidgetClient =
nullptr;
295 std::string_view
_type,
296 std::string_view
_skin,
300 std::string_view
_name,
315 mWidgetChildSkin.push_back(
widget);
319 if (mWidgetClient !=
nullptr)
350 std::string_view
_type,
351 std::string_view
_skin,
354 std::string_view
_name)
376 for (
auto&
widget : mWidgetChild)
378 for (
auto&
widget : mWidgetChildSkin)
398 for (
auto&
widget : mWidgetChild)
400 for (
auto&
widget : mWidgetChildSkin)
420 VectorWidgetPtr::iterator
iter = std::find(mWidgetChild.begin(), mWidgetChild.end(),
_widget);
421 if (
iter != mWidgetChild.end())
427 mWidgetChild.erase(
iter);
445 while (!mWidgetChild.empty())
449 mWidgetChild.pop_back();
461 if (mWidgetClient !=
nullptr)
475 void Widget::_updateAlpha()
477 if (
nullptr != mParent)
478 mRealAlpha = mAlpha * (mInheritsAlpha ? mParent->_getRealAlpha() :
ALPHA_MAX);
482 for (
auto&
widget : mWidgetChild)
484 for (
auto&
widget : mWidgetChildSkin)
506 for (VectorWidgetPtr::const_reverse_iterator
widget = mWidgetChild.rbegin();
widget != mWidgetChild.rend();
518 for (VectorWidgetPtr::const_reverse_iterator
widget = mWidgetChildSkin.rbegin();
519 widget != mWidgetChildSkin.rend();
531 void Widget::_updateAbsolutePoint()
539 for (
auto&
widget : mWidgetChild)
540 widget->_updateAbsolutePoint();
541 for (
auto&
widget : mWidgetChildSkin)
542 widget->_updateAbsolutePoint();
549 if (mWidgetClient !=
nullptr)
555 auto iter = std::find(mWidgetChild.begin(), mWidgetChild.end(),
_widget);
556 if (
iter == mWidgetChild.end())
559 for (
auto&
widget : mWidgetChild)
563 else if (
widget->getDepth() == -1)
569 mWidgetChild.begin(),
579 if (mWidgetClient !=
nullptr)
582 for (
const auto&
widget : mWidgetChild)
681 for (
auto&
widget : mWidgetChild)
682 widget->_updateAbsolutePoint();
683 for (
auto&
widget : mWidgetChildSkin)
684 widget->_updateAbsolutePoint();
717 for (
auto&
widget : mWidgetChild)
719 for (
auto&
widget : mWidgetChildSkin)
735 for (
auto&
widget : mWidgetChild)
736 widget->_updateAbsolutePoint();
737 for (
auto&
widget : mWidgetChildSkin)
738 widget->_updateAbsolutePoint();
762 for (
auto&
widget : mWidgetChild)
764 for (
auto&
widget : mWidgetChildSkin)
810 for (
auto&
widget : mWidgetChild)
811 widget->_updateAbsolutePoint();
812 for (
auto&
widget : mWidgetChildSkin)
813 widget->_updateAbsolutePoint();
822 while (
parent->getParent())
826 mParent->_unlinkChildWidget(
this);
848 if (
_parent->getClientWidget())
852 while (
parent->getParent())
864 if (mParent ==
nullptr)
867 mParent->_unlinkChildWidget(
this);
870 mParent->_linkChildWidget(
this);
883 if (mParent ==
nullptr)
886 mParent->_unlinkChildWidget(
this);
890 mParent->_linkChildWidget(
this);
895 for (
auto&
widget : mWidgetChild)
896 widget->_updateAbsolutePoint();
897 for (
auto&
widget : mWidgetChildSkin)
898 widget->_updateAbsolutePoint();
906 if (mParent ==
nullptr)
909 mParent->_unlinkChildWidget(
this);
912 mParent->_linkChildWidget(
this);
917 for (
auto&
widget : mWidgetChild)
918 widget->_updateAbsolutePoint();
919 for (
auto&
widget : mWidgetChildSkin)
920 widget->_updateAbsolutePoint();
932 if (
_style == mWidgetStyle)
945 std::string_view
_type,
946 std::string_view
_skin,
949 std::string_view
_name)
955 std::string_view
_type,
956 std::string_view
_skin,
962 std::string_view
_name)
968 std::string_view
_type,
969 std::string_view
_skin,
975 std::string_view
_name)
982 std::string_view
_type,
983 std::string_view
_skin,
987 std::string_view
_name)
994 if (mWidgetClient !=
nullptr)
996 return {mWidgetChild.begin(), mWidgetChild.end()};
1001 if (mWidgetClient !=
nullptr)
1003 return mWidgetChild.size();
1008 if (mWidgetClient !=
nullptr)
1011 return mWidgetChild[
_index];
1031 void Widget::_updateVisible()
1034 mInheritedVisible = mVisible && mInheritedVisible;
1038 for (
auto&
widget : mWidgetChild)
1039 widget->_updateVisible();
1040 for (
auto&
widget : mWidgetChildSkin)
1041 widget->_updateVisible();
1058 void Widget::_updateEnabled()
1061 mInheritedEnabled = mInheritedEnabled && mEnabled;
1063 for (
auto&
iter : mWidgetChild)
1064 iter->_updateEnabled();
1065 for (
auto&
iter : mWidgetChildSkin)
1066 iter->_updateEnabled();
1070 if (!mInheritedEnabled)
1078 for (
auto&
widget : mWidgetChildSkin)
1106 VectorWidgetPtr::iterator
iter = std::find(mWidgetChild.begin(), mWidgetChild.end(),
_widget);
1111 void Widget::_unlinkChildWidget(Widget* _widget)
1113 VectorWidgetPtr::iterator iter = std::remove(mWidgetChild.begin(), mWidgetChild.end(), _widget);
1114 MYGUI_ASSERT(iter != mWidgetChild.end(),
"widget not found");
1115 mWidgetChild.erase(iter);
1131 for (
const auto&
property : properties)
1137 std::string key{
_key};
1138 std::string value{
_value};
1142 size_t index = key.find(
'_');
1143 if (index != std::string::npos)
1147 "Widget property '" << key <<
"' have type prefix - use '" << key.substr(index + 1) <<
"' instead ["
1149 key = key.substr(index + 1);
1160 for (
const auto&
childSkin : mWidgetChildSkin)
1171 if (mWidgetClient !=
nullptr)
1177 for (
const auto&
widget : mWidgetChild)
1192 MYGUI_ASSERT(mWidgetClient !=
this,
"mWidgetClient can not be this widget");
1208 std::string_view
_type,
1209 std::string_view
_skin,
1213 std::string_view
_name)
1221 if (
_key ==
"Position")
1225 else if (
_key ==
"Size")
1229 else if (
_key ==
"Coord")
1233 else if (
_key ==
"Visible")
1237 else if (
_key ==
"Depth")
1241 else if (
_key ==
"Alpha")
1245 else if (
_key ==
"Colour")
1249 else if (
_key ==
"InheritsAlpha")
1253 else if (
_key ==
"InheritsPick")
1257 else if (
_key ==
"MaskPick")
1261 else if (
_key ==
"NeedKey")
1265 else if (
_key ==
"NeedMouse")
1269 else if (
_key ==
"Enabled")
1273 else if (
_key ==
"NeedToolTip")
1277 else if (
_key ==
"Pointer")
1344 return mInheritsAlpha;
1369 return mWidgetClient;
1374 return mWidgetClient;
1379 return mWidgetStyle;
1407 float Widget::_getRealAlpha()
const
1414 return mInheritedEnabled;
1419 return mInheritedVisible;
1434 if (mParent !=
nullptr)
1436 mParent->_unlinkChildWidget(
this);
1437 mParent->_linkChildWidget(
this);
1453 for (
size_t index = 0; index < mWidgetChild.size(); ++index)
1458 mWidgetChild.insert(mWidgetChild.begin() + index,
_widget);
1464 mWidgetChild.push_back(_widget);
1469 for (
auto&
widget : mWidgetChild)
1473 widget->detachFromLayerItemNode(
false);
1478 for (
auto&
widget : mWidgetChild)
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_EXCEPT(dest)
#define MYGUI_ASSERT_RANGE(index, size, owner)
#define MYGUI_LOG(level, text)
static bool isIgnoreProperty(std::string_view _key)
static bool checkProperty(Widget *_owner, std::string &_key, std::string &_value)
static IntCoord convertFromRelative(const FloatCoord &_coord, const IntSize &_view)
static Gui & getInstance()
const IntPoint & getAbsolutePosition() const
bool _checkOutside() const
ICroppedRectangle * mCroppedParent
IntPoint mAbsolutePosition
const IntCoord & getCoord() const
int _getViewRight() const
int _getViewBottom() const
const std::string & getName() const
virtual const IntSize & getSize() const =0
virtual ILayerItem * getLayerItemByPoint(int _left, int _top) const =0
void removeChildNode(LayerItem *_item)
void detachFromLayerItemNode(bool _deep)
void addChildItem(LayerItem *_item)
void addChildNode(LayerItem *_item)
void removeChildItem(LayerItem *_item)
ILayer * getLayer() const
static LayerManager & getInstance()
static LayoutManager & getInstance()
static RenderManager & getInstance()
Widget * createWidget(const WidgetInfo &_widgetInfo, std::string_view _prefix={}, Widget *_parent=nullptr, bool _template=false)
const MapString & getProperties() const
const VectorChildSkinInfo & getChild() const
void _correctSkinItemView()
void _setSkinItemAlpha(float _value)
void _createSkinItem(ResourceSkin *_info)
void _setSkinItemColour(const Colour &_value)
bool _setSkinItemState(std::string_view _state)
void _updateSkinItemView()
void _setSubSkinVisible(bool _visible)
void _setSkinItemAlign(const IntSize &_size)
void _setSkinItemVisible(bool _value)
static SkinManager & getInstance()
void setUserString(std::string_view _key, std::string_view _value)
void setUserData(Any _data)
constexpr float ALPHA_MAX
types::TPoint< int > IntPoint
types::TCoord< float > FloatCoord
std::map< std::string, std::string, std::less<> > MapString
std::vector< WidgetInfo > VectorWidgetInfo
types::TPoint< float > FloatPoint
constexpr size_t ITEM_NONE
types::TSize< float > FloatSize
types::TCoord< int > IntCoord
types::TSize< int > IntSize
std::vector< Widget * > VectorWidgetPtr
std::vector< ChildSkinInfo > VectorChildSkinInfo
TPoint< T > point() const