40 const std::string
XML_TYPE(
"Pointer");
45 template <> PointerManager* Singleton<PointerManager>::msInstance =
nullptr;
72 mMousePointer =
nullptr;
73 mWidgetOwner =
nullptr;
76 mSkinName =
"ImageBox";
94 _destroyAllChildWidget();
96 mWidgetOwner =
nullptr;
102 mIsInitialise =
false;
123 while (info.
next(
"Info"))
126 if (name.empty())
continue;
130 std::string type = (shared_text.empty() && texture.empty()) ?
"ResourceImageSetPointer" :
"ResourceManualPointer";
150 prop->addAttribute(
"value", tmp);
157 prop->addAttribute(
"value", tmp);
164 prop->addAttribute(
"value", tmp);
167 if (!shared_text.empty() || !texture.empty())
171 prop->addAttribute(
"value", shared_text.empty() ? texture : shared_text);
182 if (key ==
"Default")
184 else if (key ==
"Layer")
186 else if (key ==
"Skin")
194 if (!pointer.empty())
199 void PointerManager::notifyFrameStart(
float _time)
202 if (
nullptr != mMousePointer && mPointer !=
nullptr)
208 if (
nullptr != mMousePointer) mMousePointer->
setVisible(_visible);
214 if (
nullptr == mMousePointer)
218 if (result ==
nullptr)
226 mPointer = result->
castType<IPointer>();
230 mWidgetOwner = _owner;
233 void PointerManager::_unlinkWidget(Widget* _widget)
235 if (_widget == mWidgetOwner)
setPointer(mDefaultName,
nullptr);
236 else if (_widget == mMousePointer) mMousePointer =
nullptr;
245 Widget* PointerManager::baseCreateWidget(
WidgetStyle _style,
const std::string& _type,
const std::string& _skin,
const IntCoord& _coord,
Align _align,
const std::string& _layer,
const std::string& _name)
248 mWidgetChild.push_back(widget);
259 void PointerManager::_destroyChildWidget(Widget* _widget)
261 MYGUI_ASSERT(
nullptr != _widget,
"invalid widget pointer");
263 VectorWidgetPtr::iterator iter = std::find(mWidgetChild.begin(), mWidgetChild.end(), _widget);
264 if (iter != mWidgetChild.end())
270 mWidgetChild.erase(iter);
280 MYGUI_EXCEPT(
"Widget '" << _widget->getName() <<
"' not found");
285 void PointerManager::_destroyAllChildWidget()
288 while (!mWidgetChild.empty())
291 Widget* widget = mWidgetChild.back();
292 mWidgetChild.pop_back();
295 manager.unlinkFromUnlinkers(widget);
306 mDefaultName = _value;
319 void PointerManager::Update()
321 if (mMousePointer ==
nullptr)
331 if (result ==
nullptr)
337 void PointerManager::notifyChangeMouseFocus(
Widget* _widget)
339 std::string pointer = (_widget ==
nullptr || !_widget->
getEnabled()) ?
"" : _widget->
getPointer();
340 if (pointer != mCurrentMousePointer)
342 mCurrentMousePointer = pointer;
343 if (mCurrentMousePointer.empty())
const std::string RESOURCE_DEFAULT_NAME("Default")
ElementPtr createRoot(const std::string &_name)
EventHandle_FrameEventDelegate eventFrameStart
void resetToDefaultPointer()
static const std::string & getClassTypeName()
void unregisterLoadXmlDelegate(const std::string &_key)
LoadXmlDelegate & registerLoadXmlDelegate(const std::string &_key)
delegates::IDelegate0 * newDelegate(void(*_func)())
static Gui & getInstance()
void loadFromXmlNode(xml::ElementPtr _node, const std::string &_file, Version _version)
bool findAttribute(const std::string &_name, std::string &_value)
void setVisible(bool _visible)
static const char * getClassTypeName()
delegates::CMultiDelegate1< const std::string & > eventChangeMousePointer
const std::string & getLayerName() const
const std::string XML_TYPE("Font")
types::TCoord< int > IntCoord
IResource * getByName(const std::string &_name, bool _throw=true) const
#define MYGUI_LOG(level, text)
#define MYGUI_EXCEPT(dest)
void setDefaultPointer(const std::string &_value)
virtual void setImage(ImageBox *_image)=0
const std::string & getDefaultPointer() const
#define MYGUI_ASSERT(exp, dest)
const std::string XML_TYPE_PROPERTY("Property")
void attachToLayerNode(const std::string &_name, Widget *_item)
Type * castType(bool _throw=true)
void setPointer(const std::string &_name)
void unregisterFactory(const std::string &_category, const std::string &_type)
void registerFactory(const std::string &_category, const std::string &_type, Delegate::IDelegate *_delegate)
ElementEnumerator getElementEnumerator()
virtual void setPosition(ImageBox *_image, const IntPoint &_point)=0
const std::string & getName() const
static const char * mClassTypeName
void addAttribute(const std::string &_key, const T &_value)
IPointer * getByName(const std::string &_name) const
const std::string XML_TYPE_RESOURCE("Resource")
void setLayerName(const std::string &_value)
ElementPtr createChild(const std::string &_name, const std::string &_content="", ElementType _type=ElementType::Normal)