25 mCategoryName(
"Layer"),
26 mSingletonHolder(this)
60 mIsInitialise =
false;
63 void LayerManager::clear()
65 for (VectorLayer::iterator iter = mLayerNodes.begin(); iter != mLayerNodes.end(); ++iter)
72 void LayerManager::_load(
xml::ElementPtr _node,
const std::string& _file, Version _version)
76 xml::ElementEnumerator layer = _node->getElementEnumerator();
77 while (layer.next(mCategoryName))
82 if ( !layer->findAttribute(
"name", name))
84 MYGUI_LOG(Warning,
"Attribute 'name' not found (file : " << _file <<
")");
88 for (VectorLayer::iterator iter = layers.begin(); iter != layers.end(); ++iter)
90 MYGUI_ASSERT((*iter)->getName() != name,
"Layer '" << name <<
"' already exist (file : " << _file <<
")");
93 std::string type = layer->findAttribute(
"type");
94 if (type.empty() && _version <= Version(1, 0))
97 type = overlapped ?
"OverlappedLayer" :
"SharedLayer";
100 ILayer* item = _createLayerObject(type);
101 item->deserialization(layer.current(), _version);
103 layers.push_back(item);
110 ILayer* LayerManager::_createLayerObject(
const std::string& _type)
113 MYGUI_ASSERT(
object !=
nullptr,
"factory '" << _type <<
"' is not found");
115 return object->castType<ILayer>();
118 void LayerManager::_unlinkWidget(Widget* _widget)
126 MYGUI_ASSERT(
nullptr != _item,
"pointer must be valid");
133 for (VectorLayer::iterator iter = mLayerNodes.begin(); iter != mLayerNodes.end(); ++iter)
135 if (_name == (*iter)->getName())
143 MYGUI_LOG(Error,
"Layer '" << _name <<
"' is not found");
149 MYGUI_ASSERT(
nullptr != _item,
"pointer must be valid");
155 MYGUI_ASSERT(
nullptr != _item,
"pointer must be valid");
161 return getByName(_name,
false) !=
nullptr;
164 void LayerManager::merge(VectorLayer& _layers)
166 for (VectorLayer::iterator iter = mLayerNodes.begin(); iter != mLayerNodes.end(); ++iter)
168 if ((*iter) ==
nullptr)
continue;
170 std::string name = (*iter)->
getName();
171 for (VectorLayer::iterator iter2 = _layers.begin(); iter2 != _layers.end(); ++iter2)
173 if (name == (*iter2)->getName())
191 mLayerNodes = _layers;
198 ILayer* item = _createLayerObject(_type);
201 mLayerNodes.insert(mLayerNodes.begin() + _index, item);
206 void LayerManager::destroy(
ILayer* _layer)
214 VectorLayer::const_reverse_iterator iter = mLayerNodes.rbegin();
215 while (iter != mLayerNodes.rend())
218 if (item !=
nullptr)
return static_cast<Widget*
>(item);
226 for (VectorLayer::iterator iter = mLayerNodes.begin(); iter != mLayerNodes.end(); ++iter)
228 (*iter)->renderToTarget(_target, _update);
234 for (VectorLayer::const_iterator iter = mLayerNodes.begin(); iter != mLayerNodes.end(); ++iter)
236 if (_name == (*iter)->getName())
239 MYGUI_ASSERT(!_throw,
"Layer '" << _name <<
"' not found");
250 for (VectorLayer::const_iterator iter = mLayerNodes.begin(); iter != mLayerNodes.end(); ++iter)
251 (*iter)->resizeView(_viewSize);
256 return mLayerNodes.size();
262 return mLayerNodes[_index];
267 return mCategoryName;
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_ASSERT_RANGE(index, size, owner)
#define MYGUI_LOG(level, text)
void unregisterFactory(const std::string &_category, const std::string &_type)
static FactoryManager & getInstance()
void registerFactory(const std::string &_category, const std::string &_type, Delegate::IDelegate *_delegate)
IObject * createObject(const std::string &_category, const std::string &_type)
const std::string & getName() const
void setName(const std::string &_name)
virtual ILayerItem * getLayerItemByPoint(int _left, int _top) const =0
virtual void attachLayerItem(ILayerItem *_item)=0
virtual ILayerNode * createChildItemNode()=0
void detachFromLayer() override
void upLayerItem() override
void detachFromLayer(Widget *_item)
void upLayerItem(Widget *_item)
ILayer * getLayer(size_t _index) const
bool isExist(const std::string &_name) const
const std::string & getCategoryName() const
EnumeratorLayer getEnumerator() const
size_t getLayerCount() const
void renderToTarget(IRenderTarget *_target, bool _update)
Enumerator< VectorLayer > EnumeratorLayer
static const char * getClassTypeName()
void resizeView(const IntSize &_viewSize)
ILayer * getByName(const std::string &_name, bool _throw=true) const
Widget * getWidgetFromPoint(int _left, int _top) const
std::vector< ILayer * > VectorLayer
void attachToLayerNode(const std::string &_name, Widget *_item)
ILayer * createLayerAt(const std::string &_name, const std::string &_type, size_t _index)
void unregisterLoadXmlDelegate(const std::string &_key)
static ResourceManager & getInstance()
LoadXmlDelegate & registerLoadXmlDelegate(const std::string &_key)
bool parseBool(const std::string &_value)
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
MYGUI_SINGLETON_DEFINITION(ClipboardManager)