MyGUI  3.2.0
MyGUI_ImageBox.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_IMAGE_BOX_H__
23 #define __MYGUI_IMAGE_BOX_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Widget.h"
27 #include "MyGUI_ResourceImageSet.h"
28 #include "MyGUI_ImageInfo.h"
29 
30 namespace MyGUI
31 {
32 
34  public Widget
35  {
37 
38  public:
39  ImageBox();
40 
41  //------------------------------------------------------------------------------//
42  // The simple interface
43  //------------------------------------------------------------------------------//
44 
45  /* Set texture and size of image _tile
46  @param _texture file name or texture name
47  @param _coord - part of texture where we take tiles
48  @param _tile size
49  */
50  void setImageInfo(const std::string& _texture, const IntCoord& _coord, const IntSize& _tile);
51 
52  /* Set texture
53  @param _texture file name or texture name
54  */
55  void setImageTexture(const std::string& _value);
56 
58  void setImageRect(const IntRect& _value);
59 
61  void setImageCoord(const IntCoord& _value);
62 
64  void setImageTile(const IntSize& _value);
65 
78  void setImageIndex(size_t _index);
80  size_t getImageIndex() const;
81 
82  //------------------------------------------------------------------------------//
83  // The expanded interface
84  //------------------------------------------------------------------------------//
85 
87  size_t getItemCount() const;
88 
90  void setItemSelect(size_t _index);
92  size_t getItemSelect() const;
94  void resetItemSelect();
95 
97  void insertItem(size_t _index, const IntCoord& _item);
99  void addItem(const IntCoord& _item);
101  void setItem(size_t _index, const IntCoord& _item);
102 
104  void deleteItem(size_t _index);
106  void deleteAllItems();
107 
108  // работа с фреймами анимированных индексов
113  void addItemFrame(size_t _index, const IntCoord& _item);
114 
120  void insertItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item);
121 
126  void addItemFrameDublicate(size_t _index, size_t _indexSourceFrame);
127 
133  void insertItemFrameDublicate(size_t _index, size_t _indexFrame, size_t _indexSourceFrame);
134 
140  void setItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item);
141 
146  void deleteItemFrame(size_t _index, size_t _indexFrame);
147 
151  void deleteAllItemFrames(size_t _index);
152 
157  void setItemFrameRate(size_t _index, float _rate);
158 
162  float getItemFrameRate(size_t _index);
163 
164  //------------------------------------------------------------------------------//
165  // The interface with support of resources
166  //------------------------------------------------------------------------------//
167 
172  bool setItemResource(const std::string& _name);
173 
175  void setItemGroup(const std::string& _value);
177  void setItemName(const std::string& _value);
178 
182  void setItemResourcePtr(ResourceImageSetPtr _resource);
184  void setItemResourceInfo(const ImageIndexInfo& _info);
185 
187  ResourceImageSetPtr getItemResource() const;
189  void setItemResourceInfo(ResourceImageSetPtr _resource, const std::string& _group, const std::string& _name);
190 
191  protected:
192  virtual void shutdownOverride();
193 
194  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
195 
196  private:
197  void frameEntered(float _frame);
198 
199  void recalcIndexes();
200  void updateSelectIndex(size_t _index);
201 
202  void frameAdvise(bool _advise);
203 
204  void _setUVSet(const FloatRect& _rect);
205 
206  private:
207  // кусок в текстуре наших картинок
208  IntRect mRectImage;
209  // размер одной картинки
210  IntSize mSizeTile;
211  // размер текстуры
212  IntSize mSizeTexture;
213  // текущая картинка
214  size_t mIndexSelect;
215 
216  VectorImages mItems;
217 
218  bool mFrameAdvise;
219  float mCurrentTime;
220  size_t mCurrentFrame;
221 
222  ResourceImageSetPtr mResource;
223  std::string mItemName;
224  std::string mItemGroup;
225  std::string mCurrentTextureName;
226  };
227 
228 } // namespace MyGUI
229 
230 #endif // __MYGUI_IMAGE_BOX_H__
std::vector< ImageItem > VectorImages
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:88
#define MYGUI_EXPORT