39 mCurrentTextureName = _texture;
44 mRectImage.
top = _coord.
top;
49 updateSelectIndex(mIndexSelect);
59 if (mIndexSelect ==
ITEM_NONE) mIndexSelect = 0;
62 updateSelectIndex(mIndexSelect);
68 mRectImage.
top = _coord.
top;
82 if (mIndexSelect ==
ITEM_NONE) mIndexSelect = 0;
85 updateSelectIndex(mIndexSelect);
90 mCurrentTextureName = _texture;
102 updateSelectIndex(mIndexSelect);
106 void ImageBox::recalcIndexes()
112 if ((mSizeTile.
width <= 0) || (mSizeTile.
height <= 0))
115 size_t count_h = (size_t)(mRectImage.
width() / mSizeTile.
width);
116 size_t count_v = (size_t)(mRectImage.
height() / mSizeTile.
height);
124 int pos_h = mRectImage.
left;
125 int pos_v = mRectImage.
top;
127 for (
size_t v = 0; v < count_v; ++v)
129 for (
size_t h = 0; h < count_h; ++h)
132 pos_h += mSizeTile.
width;
134 pos_v += mSizeTile.
height;
135 pos_h = mRectImage.
left;
139 void ImageBox::updateSelectIndex(
size_t _index)
141 mIndexSelect = _index;
143 if ((_index ==
ITEM_NONE) || (_index >= mItems.size()))
153 VectorImages::iterator iter = mItems.begin() + _index;
155 if (iter->images.size() < 2)
169 if ( ! iter->images.empty())
171 _setUVSet(iter->images.front());
179 mItems.erase(mItems.begin() + _index);
183 if (mItems.empty()) updateSelectIndex(
ITEM_NONE);
184 else if ((_index < mIndexSelect) || (mIndexSelect == mItems.size())) updateSelectIndex(mIndexSelect--);
197 if (_index ==
ITEM_NONE) _index = mItems.size();
199 VectorImages::iterator iter = mItems.insert(mItems.begin() + _index,
ImageItem());
203 if ((mIndexSelect !=
ITEM_NONE) && (_index <= mIndexSelect)) updateSelectIndex(mIndexSelect++);
210 VectorImages::iterator iter = mItems.begin() + _index;
211 iter->images.clear();
214 if (_index == mIndexSelect) updateSelectIndex(mIndexSelect);
217 void ImageBox::frameEntered(
float _frame)
221 if (mItems.empty())
return;
222 VectorImages::iterator iter = mItems.begin() + mIndexSelect;
223 if ((iter->images.size() < 2) || (iter->frame_rate == 0))
return;
225 mCurrentTime += _frame;
227 while (mCurrentTime >= iter->frame_rate)
229 mCurrentTime -= iter->frame_rate;
231 if (mCurrentFrame >= (iter->images.size())) mCurrentFrame = 0;
234 _setUVSet(iter->images[mCurrentFrame]);
240 VectorImages::iterator iter = mItems.begin() + _index;
241 iter->images.clear();
247 VectorImages::iterator iter = mItems.begin() + _index;
254 VectorImages::iterator iter = mItems.begin() + _index;
255 iter->frame_rate = _rate;
261 VectorImages::iterator iter = mItems.begin() + _index;
262 return iter->frame_rate;
269 VectorImages::iterator iter = mItems.begin() + _index;
270 MYGUI_ASSERT_RANGE(_indexSourceFrame, iter->images.size(),
"ImageBox::addItemFrameDublicate");
271 iter->images.push_back(iter->images[_indexSourceFrame]);
278 VectorImages::iterator iter = mItems.begin() + _index;
280 if (_indexFrame ==
ITEM_NONE) _indexFrame = iter->images.size() - 1;
282 iter->images.insert(iter->images.begin() + _indexFrame,
290 VectorImages::iterator iter = mItems.begin() + _index;
292 if (_indexFrame ==
ITEM_NONE) _indexFrame = iter->images.size() - 1;
294 MYGUI_ASSERT_RANGE(_indexSourceFrame, iter->images.size(),
"ImageBox::insertItemFrameDublicate");
296 iter->images.insert(iter->images.begin() + _indexFrame, iter->images[_indexSourceFrame]);
303 VectorImages::iterator iter = mItems.begin() + _index;
313 VectorImages::iterator iter = mItems.begin() + _index;
315 if (_indexFrame ==
ITEM_NONE) _indexFrame = iter->images.size() - 1;
317 iter->images.erase(iter->images.begin() + _indexFrame);
322 mCurrentTextureName = _info.
texture;
327 if (_info.
frames.size() != 0)
329 std::vector<IntPoint>::const_iterator iter = _info.
frames.begin();
334 for (++iter; iter != _info.
frames.end(); ++iter)
342 updateSelectIndex(mIndexSelect);
349 return resource !=
nullptr;
354 if (mResource == _resource)
358 if (mResource ==
nullptr && _resource !=
nullptr)
360 if (mItemGroup.empty())
363 while (iter_group.
next())
365 mItemGroup = iter_group.
current().name;
366 if (mItemName.empty() && !iter_group.
current().indexes.empty())
368 mItemName = iter_group.
current().indexes[0].name;
373 else if (mItemName.empty())
376 while (iter_group.
next())
378 if (mItemGroup == iter_group.
current().name)
380 if (!iter_group.
current().indexes.empty())
382 mItemName = iter_group.
current().indexes[0].name;
390 mResource = _resource;
391 if (!mResource || mItemGroup.empty() || mItemName.empty()) updateSelectIndex(
ITEM_NONE);
397 if (mItemGroup == _group)
401 if (!mResource || mItemGroup.empty() || mItemName.empty()) updateSelectIndex(
ITEM_NONE);
407 if (mItemName == _name)
411 if (!mResource || mItemGroup.empty() || mItemName.empty()) updateSelectIndex(
ITEM_NONE);
417 mResource = _resource;
420 if (!mResource || mItemGroup.empty() || mItemName.empty()) updateSelectIndex(
ITEM_NONE);
424 void ImageBox::frameAdvise(
bool _advise)
428 if ( ! mFrameAdvise )
439 mFrameAdvise =
false;
461 if (mIndexSelect != _index) updateSelectIndex(_index);
464 void ImageBox::_setUVSet(
const FloatRect& _rect)
473 if (_key ==
"ImageTexture")
477 else if (_key ==
"ImageCoord")
481 else if (_key ==
"ImageTile")
485 else if (_key ==
"ImageIndex")
489 else if (_key ==
"ImageResource")
493 else if (_key ==
"ImageGroup")
497 else if (_key ==
"ImageName")
511 return mItems.size();